diff mbox series

[1/1] wifi: rt2x00: Fix "Error - Attempt to send packet over invalid queue 2"

Message ID 20220908173618.155291-2-hdegoede@redhat.com
State New
Headers show
Series rt2x00 WA for mac80211 core (BUG?) submitting skb-s with queue-ids >= hw.queues | expand

Commit Message

Hans de Goede Sept. 8, 2022, 5:36 p.m. UTC
Even though ieee80211_hw.queues is set to 2, the ralink rt2x00 driver
is seeing tx skbs submitted to it with the queue-id set to 2 / set to
IEEE80211_AC_BE on a rt2500 card when associating with an access-point.

This causes rt2x00queue_get_tx_queue() to return NULL and the following
error to be logged: "ieee80211 phy0: rt2x00mac_tx: Error - Attempt to
send packet over invalid queue 2", after which association with the AP
fails.

This patch works around this by mapping QID_AC_BE and QID_AC_BK
to QID_AC_VI when there are only 2 tx_queues.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
The net/mac80211 code has checks for local->hw.queues < IEEE80211_NUM_ACS
in various places and returns queue-id 0 when this condition is true.

So it looks like the rt2x00 driver receiving a queue-id of 2 /
IEEE80211_AC_BE might actually be a bug in the mac80211 core code,
I will send out a separate email about this.
---
 drivers/net/wireless/ralink/rt2x00/rt2x00.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Stanislaw Gruszka Sept. 15, 2022, 6:56 p.m. UTC | #1
On Thu, Sep 08, 2022 at 07:36:18PM +0200, Hans de Goede wrote:
> Even though ieee80211_hw.queues is set to 2, the ralink rt2x00 driver
> is seeing tx skbs submitted to it with the queue-id set to 2 / set to
> IEEE80211_AC_BE on a rt2500 card when associating with an access-point.

I'm impressed you have still working rt2500 card :-)
 
> This causes rt2x00queue_get_tx_queue() to return NULL and the following
> error to be logged: "ieee80211 phy0: rt2x00mac_tx: Error - Attempt to
> send packet over invalid queue 2", after which association with the AP
> fails.
> 
> This patch works around this by mapping QID_AC_BE and QID_AC_BK
> to QID_AC_VI when there are only 2 tx_queues.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Hans de Goede Sept. 16, 2022, 11:32 a.m. UTC | #2
Hi,

On 9/15/22 20:56, Stanislaw Gruszka wrote:
> On Thu, Sep 08, 2022 at 07:36:18PM +0200, Hans de Goede wrote:
>> Even though ieee80211_hw.queues is set to 2, the ralink rt2x00 driver
>> is seeing tx skbs submitted to it with the queue-id set to 2 / set to
>> IEEE80211_AC_BE on a rt2500 card when associating with an access-point.
> 
> I'm impressed you have still working rt2500 card :-)

I recently become the owner of a Turion64 based MSI S270 laptop to test
some kernel code I was refactoring on. This has a mini-pci rt2500 card,
which indeed still works after this fix.

The thing has 2G RAM and even runs a Fedora 37 beta but the CPU is
quite slow and gets pretty toasty.

>> This causes rt2x00queue_get_tx_queue() to return NULL and the following
>> error to be logged: "ieee80211 phy0: rt2x00mac_tx: Error - Attempt to
>> send packet over invalid queue 2", after which association with the AP
>> fails.
>>
>> This patch works around this by mapping QID_AC_BE and QID_AC_BK
>> to QID_AC_VI when there are only 2 tx_queues.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> 
> Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>

Thanks.

Regards,

Hans
diff mbox series

Patch

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00.h b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
index 8f5772b98f58..07a6a5a9ce13 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
@@ -1309,8 +1309,11 @@  void rt2x00queue_unmap_skb(struct queue_entry *entry);
  */
 static inline struct data_queue *
 rt2x00queue_get_tx_queue(struct rt2x00_dev *rt2x00dev,
-			 const enum data_queue_qid queue)
+			 enum data_queue_qid queue)
 {
+	if (queue >= rt2x00dev->ops->tx_queues && queue < IEEE80211_NUM_ACS)
+		queue = rt2x00dev->ops->tx_queues - 1;
+
 	if (queue < rt2x00dev->ops->tx_queues && rt2x00dev->tx)
 		return &rt2x00dev->tx[queue];