ce733c949ac688319e604ba3e2c54e645ac87f7c
[openwrt/staging/jow.git] /
1 From feb87977b6d251fb01a329905719e45908f6c939 Mon Sep 17 00:00:00 2001
2 From: Stanislaw Gruszka <sgruszka@redhat.com>
3 Date: Fri, 10 Aug 2018 12:31:55 +0200
4 Subject: [PATCH 4/5] rt2x00: use different txstatus timeouts when flushing
5
6 Use different tx status timeouts for normal operation and when flushing.
7 This increase timeout to 2s for normal operation as when there are bad
8 radio conditions and frames are reposted many times device can not provide
9 the status for quite long. With new timeout we can still get valid status
10 on such bad conditions.
11
12 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
13 ---
14 .../net/wireless/ralink/rt2x00/rt2800lib.c | 31 +++++++++++++------
15 drivers/net/wireless/ralink/rt2x00/rt2x00.h | 1 +
16 .../net/wireless/ralink/rt2x00/rt2x00mac.c | 4 +++
17 3 files changed, 26 insertions(+), 10 deletions(-)
18
19 diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
20 index 0c56c7dca55f..595cb9c90b81 100644
21 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
22 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
23 @@ -1137,36 +1137,47 @@ void rt2800_txdone(struct rt2x00_dev *rt2x00dev)
24 }
25 EXPORT_SYMBOL_GPL(rt2800_txdone);
26
27 -static inline bool rt2800_entry_txstatus_timeout(struct queue_entry *entry)
28 +static inline bool rt2800_entry_txstatus_timeout(struct rt2x00_dev *rt2x00dev,
29 + struct queue_entry *entry)
30 {
31 - bool tout;
32 + bool ret;
33 + unsigned long tout;
34
35 if (!test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))
36 return false;
37
38 - tout = time_after(jiffies, entry->last_action + msecs_to_jiffies(500));
39 - if (unlikely(tout))
40 + if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags))
41 + tout = msecs_to_jiffies(100);
42 + else
43 + tout = msecs_to_jiffies(2000);
44 +
45 + ret = time_after(jiffies, entry->last_action + tout);
46 + if (unlikely(ret))
47 rt2x00_dbg(entry->queue->rt2x00dev,
48 "TX status timeout for entry %d in queue %d\n",
49 entry->entry_idx, entry->queue->qid);
50 - return tout;
51 -
52 + return ret;
53 }
54
55 bool rt2800_txstatus_timeout(struct rt2x00_dev *rt2x00dev)
56 {
57 struct data_queue *queue;
58 struct queue_entry *entry;
59 + unsigned long tout;
60 +
61 + if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags))
62 + tout = msecs_to_jiffies(50);
63 + else
64 + tout = msecs_to_jiffies(1000);
65
66 - if (time_before(jiffies,
67 - rt2x00dev->last_nostatus_check + msecs_to_jiffies(500)))
68 + if (time_before(jiffies, rt2x00dev->last_nostatus_check + tout))
69 return false;
70
71 rt2x00dev->last_nostatus_check = jiffies;
72
73 tx_queue_for_each(rt2x00dev, queue) {
74 entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
75 - if (rt2800_entry_txstatus_timeout(entry))
76 + if (rt2800_entry_txstatus_timeout(rt2x00dev, entry))
77 return true;
78 }
79
80 @@ -1195,7 +1206,7 @@ void rt2800_txdone_nostatus(struct rt2x00_dev *rt2x00dev)
81 break;
82
83 if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags) ||
84 - rt2800_entry_txstatus_timeout(entry))
85 + rt2800_entry_txstatus_timeout(rt2x00dev, entry))
86 rt2x00lib_txdone_noinfo(entry, TXDONE_FAILURE);
87 else
88 break;
89 diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00.h b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
90 index af062cda4a23..4b1744e9fb78 100644
91 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
92 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
93 @@ -665,6 +665,7 @@ enum rt2x00_state_flags {
94 DEVICE_STATE_STARTED,
95 DEVICE_STATE_ENABLED_RADIO,
96 DEVICE_STATE_SCANNING,
97 + DEVICE_STATE_FLUSHING,
98
99 /*
100 * Driver configuration
101 diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c b/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c
102 index fa2fd64084ac..2825560e2424 100644
103 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c
104 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c
105 @@ -720,8 +720,12 @@ void rt2x00mac_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
106 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
107 return;
108
109 + set_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags);
110 +
111 tx_queue_for_each(rt2x00dev, queue)
112 rt2x00queue_flush_queue(queue, drop);
113 +
114 + clear_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags);
115 }
116 EXPORT_SYMBOL_GPL(rt2x00mac_flush);
117
118 --
119 2.18.0
120