2022-01-11 07:51:18

by Bo Jiao

[permalink] [raw]
Subject: [PATCH 2/5] mt76: rework dma.c to adapt mt7986 changes

From: Bo Jiao <[email protected]>

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 <[email protected]>
Signed-off-by: Bo Jiao <[email protected]>
Reviewed-by: Ryder Lee <[email protected]>
---
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) {
+ 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;
--
2.18.0



2022-01-11 08:21:22

by Felix Fietkau

[permalink] [raw]
Subject: Re: [PATCH 2/5] mt76: rework dma.c to adapt mt7986 changes

On 2022-01-11 08:51, Bo Jiao wrote:
> From: Bo Jiao <[email protected]>
>
> 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 <[email protected]>
> Signed-off-by: Bo Jiao <[email protected]>
> Reviewed-by: Ryder Lee <[email protected]>
> ---
> 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