Linux wireless drivers development
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Felix Fietkau <nbd@nbd.name>
Cc: linux-wireless@vger.kernel.org
Subject: Re: [PATCH mt76-next 04/20] wifi: mt76: mt7996: clean up the DMA when the NPU RX queue init fails
Date: Sun, 29 Nov 2026 21:36:49 +0100	[thread overview]
Message-ID: <awyM4QLEEvwo7wkg@lore-desk> (raw)
In-Reply-To: <20261129193131.3367661-4-nbd@nbd.name>

[-- Attachment #1: Type: text/plain, Size: 3796 bytes --]

> mt7996_dma_init() returns an error of mt7996_npu_rx_queues_init() after
> mt76_init_queues() enabled the RX NAPIs, and the probe then frees the
> device. The RX NAPIs stay in the global NAPI hash inside the freed
> memory, and their threads, page pools and dummy netdevs leak.
> 
> On this error, disable the RX NAPIs and clean up the DMA, as the stop of
> the hardware does. Set up the TX NAPI before the NPU RX queues, since
> mt76_dma_cleanup() needs it.
> 
> Fixes: 377aa17d2aed ("wifi: mt76: mt7996: Add NPU offload support to MT7996 driver")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>

Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>

> ---
>  .../net/wireless/mediatek/mt76/mt7996/dma.c   | 21 +++++++++++++++----
>  .../net/wireless/mediatek/mt76/mt7996/init.c  |  7 +------
>  .../wireless/mediatek/mt76/mt7996/mt7996.h    |  1 +
>  3 files changed, 19 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/dma.c b/drivers/net/wireless/mediatek/mt76/mt7996/dma.c
> index 4450d35e9439..46d213c196a5 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7996/dma.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7996/dma.c
> @@ -945,14 +945,17 @@ int mt7996_dma_init(struct mt7996_dev *dev)
>  	if (ret < 0)
>  		return ret;
>  
> -	ret = mt7996_npu_rx_queues_init(dev);
> -	if (ret)
> -		return ret;
> -
>  	netif_napi_add_tx(dev->mt76.tx_napi_dev, &dev->mt76.tx_napi,
>  			  mt7996_poll_tx);
>  	napi_enable(&dev->mt76.tx_napi);
>  
> +	ret = mt7996_npu_rx_queues_init(dev);
> +	if (ret) {
> +		mt7996_dma_rx_napi_disable(dev);
> +		mt7996_dma_cleanup(dev);
> +		return ret;
> +	}
> +
>  	mt7996_dma_enable(dev, false);
>  
>  	return 0;
> @@ -1072,6 +1075,16 @@ void mt7996_dma_reset(struct mt7996_dev *dev, bool force)
>  	mt7996_dma_enable(dev, !force);
>  }
>  
> +void mt7996_dma_rx_napi_disable(struct mt7996_dev *dev)
> +{
> +	int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(dev->mt76.napi); i++) {
> +		if (dev->mt76.napi[i].dev)
> +			napi_disable(&dev->mt76.napi[i]);
> +	}
> +}
> +
>  void mt7996_dma_cleanup(struct mt7996_dev *dev)
>  {
>  	mt7996_dma_disable(dev, true);
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/init.c b/drivers/net/wireless/mediatek/mt76/mt7996/init.c
> index 0363476ea708..8962d4dab678 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7996/init.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7996/init.c
> @@ -1272,14 +1272,9 @@ int mt7996_global_wcid_init(struct mt7996_dev *dev)
>  
>  static void mt7996_stop_hardware(struct mt7996_dev *dev)
>  {
> -	int i;
> -
>  	cancel_work_sync(&dev->dump_work);
>  	cancel_work_sync(&dev->reset_work);
> -	for (i = 0; i < ARRAY_SIZE(dev->mt76.napi); i++) {
> -		if (dev->mt76.napi[i].dev)
> -			napi_disable(&dev->mt76.napi[i]);
> -	}
> +	mt7996_dma_rx_napi_disable(dev);
>  	mt7996_mcu_exit(dev);
>  	mt7996_tx_token_put(dev);
>  	mt7996_dma_cleanup(dev);
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
> index 86c718d6ec82..fda43d2ae620 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
> @@ -732,6 +732,7 @@ bool mt7996_eeprom_has_background_radar(struct mt7996_dev *dev);
>  int mt7996_dma_init(struct mt7996_dev *dev);
>  void mt7996_dma_reset(struct mt7996_dev *dev, bool force);
>  void mt7996_dma_prefetch(struct mt7996_dev *dev);
> +void mt7996_dma_rx_napi_disable(struct mt7996_dev *dev);
>  void mt7996_dma_cleanup(struct mt7996_dev *dev);
>  void mt7996_dma_start(struct mt7996_dev *dev, bool reset, bool wed_reset);
>  int mt7996_init_tx_queues(struct mt7996_phy *phy, int idx,
> -- 
> 2.47.3
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2026-11-29 20:36 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 19:31 [PATCH mt76-next 01/20] wifi: mt76: mt7996: hold the wiphy lock in the L1 SER reset work Felix Fietkau
2026-11-29 19:31 ` [PATCH mt76-next 02/20] wifi: mt76: mt7996: report the TX statistics of each link of a station Felix Fietkau
2026-11-29 20:51   ` Lorenzo Bianconi
2026-11-29 19:31 ` [PATCH mt76-next 03/20] wifi: mt76: mt7996: stop the hardware when the probe fails Felix Fietkau
2026-11-29 20:45   ` Lorenzo Bianconi
2026-11-29 19:31 ` [PATCH mt76-next 04/20] wifi: mt76: mt7996: clean up the DMA when the NPU RX queue init fails Felix Fietkau
2026-11-29 20:36   ` Lorenzo Bianconi [this message]
2026-11-29 19:31 ` [PATCH mt76-next 05/20] wifi: mt76: mt7996: name the link and the error of a failed key install Felix Fietkau
2026-11-29 20:42   ` Lorenzo Bianconi
2026-11-29 19:31 ` [PATCH mt76-next 06/20] wifi: mt76: mt7925: send the HE capabilities of each link of a peer Felix Fietkau
2026-11-29 19:31 ` [PATCH mt76-next 07/20] wifi: mt76: connac: mask the LDPC capabilities of an AP peer Felix Fietkau
2026-11-29 19:31 ` [PATCH mt76-next 08/20] wifi: mt76: mt7925: " Felix Fietkau
2026-11-29 19:31 ` [PATCH mt76-next 09/20] wifi: mt76: mt7996: read the EHT capabilities of a station as LE Felix Fietkau
2026-11-29 19:31 ` [PATCH mt76-next 10/20] wifi: mt76: mt7925: " Felix Fietkau
2026-11-29 20:47   ` Lorenzo Bianconi
2026-11-29 19:31 ` [PATCH mt76-next 11/20] wifi: mt76: mt7615: drop RX frame with a header gap past its end Felix Fietkau
2026-11-29 20:43   ` Lorenzo Bianconi
2026-11-29 19:31 ` [PATCH mt76-next 12/20] wifi: mt76: connac: drop a first fragment without an Ethernet header Felix Fietkau
2026-11-29 20:43   ` Lorenzo Bianconi
2026-11-29 19:31 ` [PATCH mt76-next 13/20] wifi: mt76: mt7915: drop RX frame with a header gap past its end Felix Fietkau
2026-11-29 20:47   ` Lorenzo Bianconi
2026-11-29 19:31 ` [PATCH mt76-next 14/20] wifi: mt76: mt7921: " Felix Fietkau
2026-11-29 20:47   ` Lorenzo Bianconi
2026-11-29 19:31 ` [PATCH mt76-next 15/20] wifi: mt76: mt7996: " Felix Fietkau
2026-11-29 20:51   ` Lorenzo Bianconi
2026-11-29 19:31 ` [PATCH mt76-next 16/20] wifi: mt76: mt7925: bound the header gap by the linear data of a frame Felix Fietkau
2026-11-29 20:45   ` Lorenzo Bianconi
2026-11-29 19:31 ` [PATCH mt76-next 17/20] wifi: mt76: mt7921: fix out-of-bounds read in mt7921_mac_add_txs Felix Fietkau
2026-11-29 20:42   ` Lorenzo Bianconi
2026-11-29 19:31 ` [PATCH mt76-next 18/20] wifi: mt76: mt7925: fix out-of-bounds read in mt7925_mac_add_txs Felix Fietkau
2026-11-29 20:41   ` Lorenzo Bianconi
2026-11-29 19:31 ` [PATCH mt76-next 19/20] wifi: mt76: mt7925: apply the dwell time of a scan request Felix Fietkau
2026-11-29 19:31 ` [PATCH mt76-next 20/20] wifi: mt76: connac: apply the dwell time of a scan request on mt7663 Felix Fietkau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=awyM4QLEEvwo7wkg@lore-desk \
    --to=lorenzo@kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=nbd@nbd.name \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox