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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. From adf26a356f132e35093585521ea3e36cd185af83 Mon Sep 17 00:00:00 2001
  2. From: Stanislaw Gruszka <sgruszka@redhat.com>
  3. Date: Wed, 26 Sep 2018 12:24:56 +0200
  4. Subject: [PATCH 05/28] 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 <sgruszka@redhat.com>
  11. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  12. ---
  13. .../net/wireless/ralink/rt2x00/rt2800lib.c | 31 +++++++++++++------
  14. drivers/net/wireless/ralink/rt2x00/rt2x00.h | 1 +
  15. .../net/wireless/ralink/rt2x00/rt2x00mac.c | 4 +++
  16. 3 files changed, 26 insertions(+), 10 deletions(-)
  17. --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  18. +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  19. @@ -1137,36 +1137,47 @@ void rt2800_txdone(struct rt2x00_dev *rt
  20. }
  21. EXPORT_SYMBOL_GPL(rt2800_txdone);
  22. -static inline bool rt2800_entry_txstatus_timeout(struct queue_entry *entry)
  23. +static inline bool rt2800_entry_txstatus_timeout(struct rt2x00_dev *rt2x00dev,
  24. + struct queue_entry *entry)
  25. {
  26. - bool tout;
  27. + bool ret;
  28. + unsigned long tout;
  29. if (!test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))
  30. return false;
  31. - tout = time_after(jiffies, entry->last_action + msecs_to_jiffies(500));
  32. - if (unlikely(tout))
  33. + if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags))
  34. + tout = msecs_to_jiffies(100);
  35. + else
  36. + tout = msecs_to_jiffies(2000);
  37. +
  38. + ret = time_after(jiffies, entry->last_action + tout);
  39. + if (unlikely(ret))
  40. rt2x00_dbg(entry->queue->rt2x00dev,
  41. "TX status timeout for entry %d in queue %d\n",
  42. entry->entry_idx, entry->queue->qid);
  43. - return tout;
  44. -
  45. + return ret;
  46. }
  47. bool rt2800_txstatus_timeout(struct rt2x00_dev *rt2x00dev)
  48. {
  49. struct data_queue *queue;
  50. struct queue_entry *entry;
  51. + unsigned long tout;
  52. +
  53. + if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags))
  54. + tout = msecs_to_jiffies(50);
  55. + else
  56. + tout = msecs_to_jiffies(1000);
  57. - if (time_before(jiffies,
  58. - rt2x00dev->last_nostatus_check + msecs_to_jiffies(500)))
  59. + if (time_before(jiffies, rt2x00dev->last_nostatus_check + tout))
  60. return false;
  61. rt2x00dev->last_nostatus_check = jiffies;
  62. tx_queue_for_each(rt2x00dev, queue) {
  63. entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
  64. - if (rt2800_entry_txstatus_timeout(entry))
  65. + if (rt2800_entry_txstatus_timeout(rt2x00dev, entry))
  66. return true;
  67. }
  68. @@ -1195,7 +1206,7 @@ void rt2800_txdone_nostatus(struct rt2x0
  69. break;
  70. if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags) ||
  71. - rt2800_entry_txstatus_timeout(entry))
  72. + rt2800_entry_txstatus_timeout(rt2x00dev, entry))
  73. rt2x00lib_txdone_noinfo(entry, TXDONE_FAILURE);
  74. else
  75. break;
  76. --- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
  77. +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
  78. @@ -665,6 +665,7 @@ enum rt2x00_state_flags {
  79. DEVICE_STATE_STARTED,
  80. DEVICE_STATE_ENABLED_RADIO,
  81. DEVICE_STATE_SCANNING,
  82. + DEVICE_STATE_FLUSHING,
  83. /*
  84. * Driver configuration
  85. --- a/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c
  86. +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c
  87. @@ -710,8 +710,12 @@ void rt2x00mac_flush(struct ieee80211_hw
  88. if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
  89. return;
  90. + set_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags);
  91. +
  92. tx_queue_for_each(rt2x00dev, queue)
  93. rt2x00queue_flush_queue(queue, drop);
  94. +
  95. + clear_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags);
  96. }
  97. EXPORT_SYMBOL_GPL(rt2x00mac_flush);