Skip to contentSkip to conversation

mt76: use rcu_read_lock_bh in mt76_dma_rx_poll

PATCH In review Felix Fietkau 2 participants 4 messages Nov 20, 2019

Subsystems (2)
lore
Share & tools
lore

Felix Fietkau

author maintainer
#0 lore raw

PATCH 1/1 mt76: use rcu_read_lock_bh in mt76_dma_rx_poll

Fixes potential RCU issues and avoids calling ieee80211_rx_napi with softirq enabled.

---
 drivers/net/wireless/mediatek/mt76/dma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/dma.c +2 -2
index 6173c80189ba..ed0ee2d4a452 100644
@@ -528,7 +528,7 @@ mt76_dma_rx_poll(struct napi_struct *napi, int budget)
 	dev = container_of(napi->dev, struct mt76_dev, napi_dev);
 	qid = napi - dev->napi;
 
-	rcu_read_lock();
+	rcu_read_lock_bh();
 
 	do {
 		cur = mt76_dma_rx_process(dev, &dev->q_rx[qid], budget - done);
@@ -536,7 +536,7 @@ mt76_dma_rx_poll(struct napi_struct *napi, int budget)
 		done += cur;
 	} while (cur && done < budget);
 
-	rcu_read_unlock();
+	rcu_read_unlock_bh();
 
 	if (done < budget && napi_complete(napi))
 		dev->drv->rx_poll_complete(dev, qid);
Signature · 1 line
2.24.0
#1 lore raw
Quoted 23 lines · Felix Fietkau

Fixes potential RCU issues and avoids calling ieee80211_rx_napi with softirq enabled.

---
 drivers/net/wireless/mediatek/mt76/dma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/dma.c +1 -1
index 6173c80189ba..ed0ee2d4a452 100644
@@ -528,7 +528,7 @@ mt76_dma_rx_poll(struct napi_struct *napi, int budget)
 	dev = container_of(napi->dev, struct mt76_dev, napi_dev);
 	qid = napi - dev->napi;
 
-	rcu_read_lock();
+	rcu_read_lock_bh();
 
 	do {
 		cur = mt76_dma_rx_process(dev, &dev->q_rx[qid], budget - done);

drivers/net/wireless/mediatek/mt76/dma.c mt76_dma_rx_poll(struct napi_struct *napi, int budget) · line 542

Quoted 8 lines
drivers/net/wireless/mediatek/mt76/dma.c +1 -1
@@ -536,7 +536,7 @@ mt76_dma_rx_poll(struct napi_struct *napi, int budget)
 		done += cur;
 	} while (cur && done < budget);
 
-	rcu_read_unlock();
+	rcu_read_unlock_bh();
 
 	if (done < budget && napi_complete(napi))
 		dev->drv->rx_poll_complete(dev, qid);

This patch is incomplete. The same problem exists for usb. I'll send a fix for that.

Regards,
Markus

author maintainer
#2 lore raw
Quoted 27 lines · Markus Theil
Quoted 26 lines · Felix Fietkau

Fixes potential RCU issues and avoids calling ieee80211_rx_napi with softirq enabled.

---
 drivers/net/wireless/mediatek/mt76/dma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/dma.c +1 -1
index 6173c80189ba..ed0ee2d4a452 100644
@@ -528,7 +528,7 @@ mt76_dma_rx_poll(struct napi_struct *napi, int budget)
 	dev = container_of(napi->dev, struct mt76_dev, napi_dev);
 	qid = napi - dev->napi;
 
-	rcu_read_lock();
+	rcu_read_lock_bh();
 
 	do {
 		cur = mt76_dma_rx_process(dev, &dev->q_rx[qid], budget - done);
@@ -536,7 +536,7 @@ mt76_dma_rx_poll(struct napi_struct *napi, int budget)
 		done += cur;
 	} while (cur && done < budget);
 
Quoted 7 lines

drivers/net/wireless/mediatek/mt76/dma.c mt76_dma_rx_poll(struct napi_struct *napi, int budget) · line 542

Quoted 5 lines
drivers/net/wireless/mediatek/mt76/dma.c +1 -1
-	rcu_read_unlock();
+	rcu_read_unlock_bh();
 
 	if (done < budget && napi_complete(napi))
 		dev->drv->rx_poll_complete(dev, qid);

This patch is incomplete. The same problem exists for usb. I'll send a fix for that.

How so? On usb, it is called from a tasklet already.

- Felix

#3 lore raw
Quoted 31 lines · Felix Fietkau
Quoted 30 lines · Markus Theil
Quoted 29 lines · Felix Fietkau

Fixes potential RCU issues and avoids calling ieee80211_rx_napi with softirq enabled.

---
 drivers/net/wireless/mediatek/mt76/dma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/dma.c +2 -2
index 6173c80189ba..ed0ee2d4a452 100644
@@ -528,7 +528,7 @@ mt76_dma_rx_poll(struct napi_struct *napi, int budget)
 	dev = container_of(napi->dev, struct mt76_dev, napi_dev);
 	qid = napi - dev->napi;
 
-	rcu_read_lock();
+	rcu_read_lock_bh();
 
 	do {
 		cur = mt76_dma_rx_process(dev, &dev->q_rx[qid], budget - done);
@@ -536,7 +536,7 @@ mt76_dma_rx_poll(struct napi_struct *napi, int budget)
 		done += cur;
 	} while (cur && done < budget);
 
-	rcu_read_unlock();
+	rcu_read_unlock_bh();
 
Quoted 6 lines
Quoted 3 lines

drivers/net/wireless/mediatek/mt76/dma.c mt76_dma_rx_poll(struct napi_struct *napi, int budget) · line 542

Quoted 2 lines
drivers/net/wireless/mediatek/mt76/dma.c +0 -0
 	if (done < budget && napi_complete(napi))
 		dev->drv->rx_poll_complete(dev, qid);

This patch is incomplete. The same problem exists for usb. I'll send a fix for that.

How so? On usb, it is called from a tasklet already.

- Felix

I've noticed the bug I reported on USB devices. I've only seen that mt76_rx_aggr_reorder_work also accesses mt76_rx_complete. Maybe it only worked for me by accident. Of course, the tasklet should not run in parallel with multiple instances.

Markus