Skip to contentSkip to conversation

rt2x00usb: fix rx queue hang

PATCH In review Soeren Moch 3 participants 8 messages Jul 1, 2019 – Jul 24, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 rt2x00usb: fix rx queue hang

Since commit ed194d136769 ("usb: core: remove local_irq_save() around
->complete() handler") the handler rt2x00usb_interrupt_rxdone() is
not running with interrupts disabled anymore. So this completion handler is not guaranteed to run completely before workqueue processing starts for the same queue entry.
Be sure to set all other flags in the entry correctly before marking this entry ready for workqueue processing. This way we cannot miss error conditions that need to be signalled from the completion handler to the worker thread.
Note that rt2x00usb_work_rxdone() processes all available entries, not only such for which queue_work() was called.

This patch is similar to what commit df71c9cfceea ("rt2x00: fix order of entry flags modification") did for TX processing.

This fixes a regression on a RT5370 based wifi stick in AP mode, which suddenly stopped data transmission after some period of heavy load. Also stopping the hanging hostapd resulted in the error message "ieee80211
phy0: rt2x00queue_flush_queue: Warning - Queue 14 failed to flush". Other operation modes are probably affected as well, this just was the used testcase.

Fixes ed194d136769 ("usb: core: remove local_irq_save() around ->complete() handler")

---
Changes in v2:
complete rework

Cc Stanislaw Gruszka <[email protected]>
Cc Helmut Schaa <[email protected]>
Cc Kalle Valo <[email protected]>
Cc "David S. Miller" <[email protected]>
---
 drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/wireless/ralink/rt2x00/rt2x00usb.c +6 -6
index 67b81c7221c4..7e3a621b9c0d 100644
@@ -372,14 +372,9 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb)
 	struct queue_entry *entry = (struct queue_entry *)urb->context;
 	struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
 
-	if (!test_and_clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags))
+	if (!test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags))
 		return;
 
-	/*
-	 * Report the frame as DMA done
-	 */
-	rt2x00lib_dmadone(entry);
-
 	/*
 	 * Check if the received data is simply too small
 	 * to be actually valid, or if the urb is signaling
@@ -388,6 +383,11 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb)
 	if (urb->actual_length < entry->queue->desc_size || urb->status)
 		set_bit(ENTRY_DATA_IO_FAILED, &entry->flags);
 
+	/*
+	 * Report the frame as DMA done
+	 */
+	rt2x00lib_dmadone(entry);
+
 	/*
 	 * Schedule the delayed work for reading the RX status
 	 * from the device.

--
2.17.1

#1 lore raw

PATCH v2 2/2 rt2x00usb: remove unnecessary rx flag checks

In contrast to the TX path, there is no need to separately read the transfer status from the device after receiving RX data. Consequently, there is no real STATUS_PENDING RX processing queue entry state.
Remove the unnecessary ENTRY_DATA_STATUS_PENDING flag checks from the RX path. Also remove the misleading comment about reading RX status from device.

---
Changes in v2:
new patch

Cc Stanislaw Gruszka <[email protected]>
Cc Helmut Schaa <[email protected]>
Cc Kalle Valo <[email protected]>
Cc "David S. Miller" <[email protected]>
---
 drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/wireless/ralink/rt2x00/rt2x00usb.c +3 -6
index 7e3a621b9c0d..bc2dfef0de22 100644
@@ -349,8 +349,7 @@ static void rt2x00usb_work_rxdone(struct work_struct *work)
 	while (!rt2x00queue_empty(rt2x00dev->rx)) {
 		entry = rt2x00queue_get_entry(rt2x00dev->rx, Q_INDEX_DONE);
 
-		if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) ||
-		    !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))
+		if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags))
 			break;
 
 		/*
@@ -389,8 +388,7 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb)
 	rt2x00lib_dmadone(entry);
 
 	/*
-	 * Schedule the delayed work for reading the RX status
-	 * from the device.
+	 * Schedule the delayed work for processing RX data
 	 */
 	queue_work(rt2x00dev->workqueue, &rt2x00dev->rxdone_work);
 }
@@ -402,8 +400,7 @@ static bool rt2x00usb_kick_rx_entry(struct queue_entry *entry, void *data)
 	struct queue_entry_priv_usb *entry_priv = entry->priv_data;
 	int status;
 
-	if (test_and_set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) ||
-	    test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))
+	if (test_and_set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags))
 		return false;
 
 	rt2x00lib_dmastart(entry);

--
2.17.1

Acked-by on v2 2/2
#2 lore raw

Re: [PATCH v2 2/2] rt2x00usb: remove unnecessary rx flag checks

Quoted 8 lines · Soeren Moch

In contrast to the TX path, there is no need to separately read the transfer status from the device after receiving RX data. Consequently, there is no real STATUS_PENDING RX processing queue entry state.
Remove the unnecessary ENTRY_DATA_STATUS_PENDING flag checks from the RX path. Also remove the misleading comment about reading RX status from device.

#3 lore raw

Re: [PATCH v2 2/2] rt2x00usb: remove unnecessary rx flag checks

In reply to Soeren Moch
Quoted 9 lines · Soeren Moch

In contrast to the TX path, there is no need to separately read the transfer status from the device after receiving RX data. Consequently, there is no real STATUS_PENDING RX processing queue entry state.
Remove the unnecessary ENTRY_DATA_STATUS_PENDING flag checks from the RX path. Also remove the misleading comment about reading RX status from device.

Patch applied to wireless-drivers-next.git, thanks.

3b902fa811cf rt2x00usb: remove unnecessary rx flag checks

Signature · 3 lines
https://patchwork.kernel.org/patch/11025559/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Acked-by on v2 1/2
#4 lore raw
In reply to Soeren Moch
Quoted 22 lines · Soeren Moch

Since commit ed194d136769 ("usb: core: remove local_irq_save() around
->complete() handler") the handler rt2x00usb_interrupt_rxdone() is
not running with interrupts disabled anymore. So this completion handler is not guaranteed to run completely before workqueue processing starts for the same queue entry.
Be sure to set all other flags in the entry correctly before marking this entry ready for workqueue processing. This way we cannot miss error conditions that need to be signalled from the completion handler to the worker thread.
Note that rt2x00usb_work_rxdone() processes all available entries, not only such for which queue_work() was called.

This patch is similar to what commit df71c9cfceea ("rt2x00: fix order of entry flags modification") did for TX processing.

This fixes a regression on a RT5370 based wifi stick in AP mode, which suddenly stopped data transmission after some period of heavy load. Also stopping the hanging hostapd resulted in the error message "ieee80211
phy0: rt2x00queue_flush_queue: Warning - Queue 14 failed to flush". Other operation modes are probably affected as well, this just was the used testcase.

Quoted 3 lines
Fixes ed194d136769 ("usb: core: remove local_irq_save() around ->complete() handler")
#5 lore raw
In reply to Soeren Moch
Quoted 22 lines · Soeren Moch

Since commit ed194d136769 ("usb: core: remove local_irq_save() around
->complete() handler") the handler rt2x00usb_interrupt_rxdone() is
not running with interrupts disabled anymore. So this completion handler is not guaranteed to run completely before workqueue processing starts for the same queue entry.
Be sure to set all other flags in the entry correctly before marking this entry ready for workqueue processing. This way we cannot miss error conditions that need to be signalled from the completion handler to the worker thread.
Note that rt2x00usb_work_rxdone() processes all available entries, not only such for which queue_work() was called.

This patch is similar to what commit df71c9cfceea ("rt2x00: fix order of entry flags modification") did for TX processing.

This fixes a regression on a RT5370 based wifi stick in AP mode, which suddenly stopped data transmission after some period of heavy load. Also stopping the hanging hostapd resulted in the error message "ieee80211
phy0: rt2x00queue_flush_queue: Warning - Queue 14 failed to flush". Other operation modes are probably affected as well, this just was the used testcase.

Quoted 3 lines
Fixes ed194d136769 ("usb: core: remove local_irq_save() around ->complete() handler")

I'll queue this for v5.3.

Signature · 1 line
Kalle Valo
#6 lore raw
Quoted 24 lines · Kalle Valo
Quoted 22 lines · Soeren Moch

Since commit ed194d136769 ("usb: core: remove local_irq_save() around
->complete() handler") the handler rt2x00usb_interrupt_rxdone() is
not running with interrupts disabled anymore. So this completion handler is not guaranteed to run completely before workqueue processing starts for the same queue entry.
Be sure to set all other flags in the entry correctly before marking this entry ready for workqueue processing. This way we cannot miss error conditions that need to be signalled from the completion handler to the worker thread.
Note that rt2x00usb_work_rxdone() processes all available entries, not only such for which queue_work() was called.

This patch is similar to what commit df71c9cfceea ("rt2x00: fix order of entry flags modification") did for TX processing.

This fixes a regression on a RT5370 based wifi stick in AP mode, which suddenly stopped data transmission after some period of heavy load. Also stopping the hanging hostapd resulted in the error message "ieee80211
phy0: rt2x00queue_flush_queue: Warning - Queue 14 failed to flush". Other operation modes are probably affected as well, this just was the used testcase.

Quoted 5 lines
Quoted 3 lines
Fixes ed194d136769 ("usb: core: remove local_irq_save() around ->complete() handler")

I'll queue this for v5.3.

OK, thanks,
Soeren

#7 lore raw
In reply to Soeren Moch
Quoted 22 lines · Soeren Moch

Since commit ed194d136769 ("usb: core: remove local_irq_save() around
->complete() handler") the handler rt2x00usb_interrupt_rxdone() is
not running with interrupts disabled anymore. So this completion handler is not guaranteed to run completely before workqueue processing starts for the same queue entry.
Be sure to set all other flags in the entry correctly before marking this entry ready for workqueue processing. This way we cannot miss error conditions that need to be signalled from the completion handler to the worker thread.
Note that rt2x00usb_work_rxdone() processes all available entries, not only such for which queue_work() was called.

This patch is similar to what commit df71c9cfceea ("rt2x00: fix order of entry flags modification") did for TX processing.

This fixes a regression on a RT5370 based wifi stick in AP mode, which suddenly stopped data transmission after some period of heavy load. Also stopping the hanging hostapd resulted in the error message "ieee80211
phy0: rt2x00queue_flush_queue: Warning - Queue 14 failed to flush". Other operation modes are probably affected as well, this just was the used testcase.

Quoted 4 lines
Fixes ed194d136769 ("usb: core: remove local_irq_save() around ->complete() handler")

Patch applied to wireless-drivers.git, thanks.

41a531ffa4c5 rt2x00usb: fix rx queue hang

Signature · 3 lines
https://patchwork.kernel.org/patch/11025561/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches