53325bdb5d9085df223532da9c0dfc36cd40e194
[oweals/openwrt.git] /
1 From b5d6e37ea15949a126907050d8cfa4408153a0cd Mon Sep 17 00:00:00 2001
2 From: Stanislaw Gruszka <sgruszka@redhat.com>
3 Date: Fri, 18 May 2018 12:25:10 +0200
4 Subject: [PATCH 3/5] rt2x00: do not check for txstatus timeout every time on
5  tasklet
6
7 Do not check for tx status timeout everytime we perform txstatus tasklet.
8 Perform check once per half a second.
9
10 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
11 ---
12  drivers/net/wireless/ralink/rt2x00/rt2800lib.c   | 7 +++++++
13  drivers/net/wireless/ralink/rt2x00/rt2800mmio.c  | 3 ++-
14  drivers/net/wireless/ralink/rt2x00/rt2x00.h      | 2 ++
15  drivers/net/wireless/ralink/rt2x00/rt2x00queue.c | 1 +
16  4 files changed, 12 insertions(+), 1 deletion(-)
17
18 diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
19 index 9f2835729016..0c56c7dca55f 100644
20 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
21 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
22 @@ -1158,11 +1158,18 @@ bool rt2800_txstatus_timeout(struct rt2x00_dev *rt2x00dev)
23         struct data_queue *queue;
24         struct queue_entry *entry;
25  
26 +       if (time_before(jiffies,
27 +                       rt2x00dev->last_nostatus_check + msecs_to_jiffies(500)))
28 +               return false;
29 +
30 +       rt2x00dev->last_nostatus_check = jiffies;
31 +
32         tx_queue_for_each(rt2x00dev, queue) {
33                 entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
34                 if (rt2800_entry_txstatus_timeout(entry))
35                         return true;
36         }
37 +
38         return false;
39  }
40  EXPORT_SYMBOL_GPL(rt2800_txstatus_timeout);
41 diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c
42 index aa8449a5e8fe..d0426314c2df 100644
43 --- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c
44 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c
45 @@ -197,7 +197,8 @@ void rt2800mmio_txstatus_tasklet(unsigned long data)
46  
47         rt2800_txdone(rt2x00dev);
48  
49 -       rt2800_txdone_nostatus(rt2x00dev);
50 +       if (rt2800_txstatus_timeout(rt2x00dev))
51 +               rt2800_txdone_nostatus(rt2x00dev);
52  
53         if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
54                 rt2800mmio_enable_interrupt(rt2x00dev,
55 diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00.h b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
56 index a279a4363bc1..af062cda4a23 100644
57 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
58 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
59 @@ -980,6 +980,8 @@ struct rt2x00_dev {
60          */
61         DECLARE_KFIFO_PTR(txstatus_fifo, u32);
62  
63 +       unsigned long last_nostatus_check;
64 +
65         /*
66          * Timer to ensure tx status reports are read (rt2800usb).
67          */
68 diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
69 index 6e8beb7ea350..92ddc19e7bf7 100644
70 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
71 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
72 @@ -1039,6 +1039,7 @@ void rt2x00queue_start_queues(struct rt2x00_dev *rt2x00dev)
73          */
74         tx_queue_for_each(rt2x00dev, queue)
75                 rt2x00queue_start_queue(queue);
76 +       rt2x00dev->last_nostatus_check = jiffies;
77  
78         rt2x00queue_start_queue(rt2x00dev->rx);
79  }
80 -- 
81 2.18.0
82