mt76: use rcu_read_lock_bh in mt76_dma_rx_poll
Subsystems (2)
Felix Fietkau
maintainerPATCH 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
@@ -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
Quoted 23 lines · Felix Fietkau
Fixes potential RCU issues and avoids calling
ieee80211_rx_napiwith softirq enabled.Reported-by Markus Theil <[email protected]>Signed-off-by Felix Fietkau <[email protected]>--- drivers/net/wireless/mediatek/mt76/dma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/wireless/mediatek/mt76/dma.c +1
-1@@ -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
Felix Fietkau
maintainerQuoted 27 lines · Markus Theil
Quoted 26 lines · Felix Fietkau
Fixes potential RCU issues and avoids calling
ieee80211_rx_napiwith softirq enabled.Reported-by Markus Theil <[email protected]>Signed-off-by Felix Fietkau <[email protected]>--- drivers/net/wireless/mediatek/mt76/dma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/wireless/mediatek/mt76/dma.c +1
-1@@ -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
Quoted 31 lines · Felix Fietkau
Quoted 30 lines · Markus Theil
Quoted 29 lines · Felix Fietkau
Fixes potential RCU issues and avoids calling
ieee80211_rx_napiwith softirq enabled.Reported-by Markus Theil <[email protected]>Signed-off-by Felix Fietkau <[email protected]>--- drivers/net/wireless/mediatek/mt76/dma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/wireless/mediatek/mt76/dma.c +2
-2@@ -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
-0if (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