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
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.
12 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
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(-)
19 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
20 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
21 @@ -1140,36 +1140,47 @@ void rt2800_txdone(struct rt2x00_dev *rt
23 EXPORT_SYMBOL_GPL(rt2800_txdone);
25 -static inline bool rt2800_entry_txstatus_timeout(struct queue_entry *entry)
26 +static inline bool rt2800_entry_txstatus_timeout(struct rt2x00_dev *rt2x00dev,
27 + struct queue_entry *entry)
33 if (!test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))
36 - tout = time_after(jiffies, entry->last_action + msecs_to_jiffies(500));
38 + if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags))
39 + tout = msecs_to_jiffies(100);
41 + tout = msecs_to_jiffies(2000);
43 + ret = time_after(jiffies, entry->last_action + tout);
45 rt2x00_dbg(entry->queue->rt2x00dev,
46 "TX status timeout for entry %d in queue %d\n",
47 entry->entry_idx, entry->queue->qid);
53 bool rt2800_txstatus_timeout(struct rt2x00_dev *rt2x00dev)
55 struct data_queue *queue;
56 struct queue_entry *entry;
59 + if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags))
60 + tout = msecs_to_jiffies(50);
62 + tout = msecs_to_jiffies(1000);
64 - if (time_before(jiffies,
65 - rt2x00dev->last_nostatus_check + msecs_to_jiffies(500)))
66 + if (time_before(jiffies, rt2x00dev->last_nostatus_check + tout))
69 rt2x00dev->last_nostatus_check = jiffies;
71 tx_queue_for_each(rt2x00dev, queue) {
72 entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
73 - if (rt2800_entry_txstatus_timeout(entry))
74 + if (rt2800_entry_txstatus_timeout(rt2x00dev, entry))
78 @@ -1198,7 +1209,7 @@ void rt2800_txdone_nostatus(struct rt2x0
81 if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags) ||
82 - rt2800_entry_txstatus_timeout(entry))
83 + rt2800_entry_txstatus_timeout(rt2x00dev, entry))
84 rt2x00lib_txdone_noinfo(entry, TXDONE_FAILURE);
87 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
88 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
89 @@ -667,6 +667,7 @@ enum rt2x00_state_flags {
91 DEVICE_STATE_ENABLED_RADIO,
92 DEVICE_STATE_SCANNING,
93 + DEVICE_STATE_FLUSHING,
96 * Driver configuration
97 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c
98 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c
99 @@ -720,8 +720,12 @@ void rt2x00mac_flush(struct ieee80211_hw
100 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
103 + set_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags);
105 tx_queue_for_each(rt2x00dev, queue)
106 rt2x00queue_flush_queue(queue, drop);
108 + clear_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags);
110 EXPORT_SYMBOL_GPL(rt2x00mac_flush);