2
0

704-rt2x00-use-different-txstatus-timeouts-when-flushing.patch 3.6 KB

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