diff mbox series

[2/5] mt76: rework dma.c to adapt mt7986 changes

Message ID 73fb8a688cfa53e030492f344f72ef64b4167a36.1641886298.git.Bo.Jiao@mediatek.com (mailing list archive)
State Superseded
Delegated to: Felix Fietkau
Headers show
Series [1/5] dt-bindings: net: wireless: mt76: document bindings for MT7986 | expand

Commit Message

Bo Jiao Jan. 11, 2022, 7:51 a.m. UTC
From: Bo Jiao <Bo.Jiao@mediatek.com>

Check ndesc of q_rx to avoid potential hole in iteration.
This is an intermediate patch to add mt7986 support.

Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
---
 drivers/net/wireless/mediatek/mt76/dma.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Felix Fietkau Jan. 11, 2022, 8:21 a.m. UTC | #1
On 2022-01-11 08:51, Bo Jiao wrote:
> From: Bo Jiao <Bo.Jiao@mediatek.com>
> 
> Check ndesc of q_rx to avoid potential hole in iteration.
> This is an intermediate patch to add mt7986 support.
> 
> Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
> Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
> Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
> ---
>   drivers/net/wireless/mediatek/mt76/dma.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
> index fd4c51b..83f045a 100644
> --- a/drivers/net/wireless/mediatek/mt76/dma.c
> +++ b/drivers/net/wireless/mediatek/mt76/dma.c
> @@ -660,10 +660,12 @@ mt76_dma_init(struct mt76_dev *dev,
>   		 wiphy_name(dev->hw->wiphy));
>   	dev->napi_dev.threaded = 1;
>   
> -	mt76_for_each_q_rx(dev, i) {
> -		netif_napi_add(&dev->napi_dev, &dev->napi[i], poll, 64);
> -		mt76_dma_rx_fill(dev, &dev->q_rx[i]);
> -		napi_enable(&dev->napi[i]);
> +	for (i = 0; i < ARRAY_SIZE(dev->q_rx); i++) {
> +		if (dev->q_rx[i].ndesc) {
Please fix mt76_for_each_q_rx instead. You can simply define it to

for (i = 0; i < ARRAY_SIZE((dev)->q_rx); i++)		\
	if ((dev)->q_rx[i].ndesc)

Thanks,

- Felix
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
index fd4c51b..83f045a 100644
--- a/drivers/net/wireless/mediatek/mt76/dma.c
+++ b/drivers/net/wireless/mediatek/mt76/dma.c
@@ -660,10 +660,12 @@  mt76_dma_init(struct mt76_dev *dev,
 		 wiphy_name(dev->hw->wiphy));
 	dev->napi_dev.threaded = 1;
 
-	mt76_for_each_q_rx(dev, i) {
-		netif_napi_add(&dev->napi_dev, &dev->napi[i], poll, 64);
-		mt76_dma_rx_fill(dev, &dev->q_rx[i]);
-		napi_enable(&dev->napi[i]);
+	for (i = 0; i < ARRAY_SIZE(dev->q_rx); i++) {
+		if (dev->q_rx[i].ndesc) {
+			netif_napi_add(&dev->napi_dev, &dev->napi[i], poll, 64);
+			mt76_dma_rx_fill(dev, &dev->q_rx[i]);
+			napi_enable(&dev->napi[i]);
+		}
 	}
 
 	return 0;