Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: faliang.wang@airoha.com
Cc: netdev@vger.kernel.org, lorenzo@kernel.org,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH net 1/2] net: airoha: fix NPU mailbox notification ordering
Date: Tue, 01 Dec 2026 04:37:08 +0000	[thread overview]
Message-ID: <179609982804.3146.10880112368695516095@kernel.org> (raw)
In-Reply-To: <20261130034106.869059-2-faliang.wang@airoha.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] net: airoha: malformed placeholder Fixes trailer in commit
  message

Pre-existing issues:
- [Medium] airoha_npu_send_msg() maps the caller's buffer with
  dma_map_single(..., DMA_BIDIRECTIONAL) and writes its bus address to…

--

net: airoha: fix NPU mailbox notification ordering

This patch changes the write order in airoha_npu_send_msg(). The function
information is now written to CTRL(3) before the CTRL(2) message counter
is incremented. Incrementing that counter is what tells the NPU a new
message is ready, so the NPU now sees the function information before the
notification.

> diff --git a/drivers/net/ethernet/airoha/airoha_npu.c b/drivers/net/ethernet/airoha/airoha_npu.c
> index edec6b1118956..7f7cdc2553ad4 100644
> --- a/drivers/net/ethernet/airoha/airoha_npu.c
> +++ b/drivers/net/ethernet/airoha/airoha_npu.c
> @@ -178,10 +178,10 @@ static int airoha_npu_send_msg(struct airoha_npu *npu, int func_id,
>
>  	regmap_write(npu->regmap, REG_CR_MBQ0_CTRL(0) + offset, dma_addr);
>  	regmap_write(npu->regmap, REG_CR_MBQ0_CTRL(1) + offset, size);
> -	regmap_read(npu->regmap, REG_CR_MBQ0_CTRL(2) + offset, &val);
> -	regmap_write(npu->regmap, REG_CR_MBQ0_CTRL(2) + offset, val + 1);
>  	val = FIELD_PREP(MBOX_MSG_FUNC_ID, func_id) | MBOX_MSG_WAIT_RSP;
>  	regmap_write(npu->regmap, REG_CR_MBQ0_CTRL(3) + offset, val);
> +	regmap_read(npu->regmap, REG_CR_MBQ0_CTRL(2) + offset, &val);
> +	regmap_write(npu->regmap, REG_CR_MBQ0_CTRL(2) + offset, val + 1);
>
>  	ret = regmap_read_poll_timeout_atomic(npu->regmap,
>  					      REG_CR_MBQ0_CTRL(3) + offset,

[Severity: Low]
The Fixes tag in the commit message still contains the template
placeholder:

  Fixes: REAL_LINUX_SHA ("EXACT_ORIGINAL_COMMIT_SUBJECT")

That is not a valid trailer. checkpatch will flag it. The stable
tooling also has no commit to match against, so this fix may not be
picked up for the kernels that carry the original ordering.

The history suggests that airoha_npu_send_msg() and the original
CTRL(2)-then-CTRL(3) write sequence came in with the initial NPU
support. If so, the tag should read:

  Fixes: 23290c7bc190 ("net: airoha: Introduce Airoha NPU support")

Could you confirm that this is the commit that introduced the problem
and update the trailer in v2?

[Severity: Medium]
This is a pre-existing issue, not one introduced by this patch. What
happens to the DMA buffer when this poll times out?

After the CTRL(2) increment, the poll waits for MBOX_MSG_DONE with a
timeout of 100 * MSEC_PER_SEC us, which is 100 ms. On -ETIMEDOUT the rest
of airoha_npu_send_msg() runs as normal:

	spin_unlock_bh(&npu->cores[core].lock);

	dma_unmap_single(npu->dev, dma_addr, size, DMA_BIDIRECTIONAL);

	return ret;

On this path nothing tells the NPU to drop the message. CTRL(0) and
CTRL(1) still hold the buffer address and size, and the counter is not
rolled back.

Every caller then frees the buffer, whatever the return value. For
example, in airoha_npu_wlan_msg_send():

	err = airoha_npu_send_msg(npu, NPU_FUNC_WIFI, wlan_data, len);
	kfree(wlan_data);

The same holds for airoha_npu_wlan_msg_get(), airoha_npu_ppe_init(),
airoha_npu_ppe_deinit(), airoha_npu_ppe_flush_sram_entries(),
airoha_npu_foe_commit_entry() and airoha_npu_ppe_stats_setup().

The NPU writes responses back into this buffer. Could it then DMA into
memory that is already unmapped and freed, if the firmware finishes a
timed-out request late?

A later airoha_npu_send_msg() call would also overwrite CTRL(0), CTRL(1)
and CTRL(3) while the earlier request might still be in progress.

Whether the firmware actually completes a request after the host gives up
cannot be confirmed from the kernel source alone.

The follow-up patch in this series, "net: airoha: retry WLAN initialization
commands", resends WLAN init commands after a failure, including
-ETIMEDOUT, without any abort step. Does that make the timeout-then-reuse
sequence more likely?

Would it help to have an abort or ownership handshake with the NPU before
unmapping and freeing the buffer on timeout?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130034106.869059-1-faliang.wang%40airoha.com

  parent reply	other threads:[~2026-12-01  4:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  3:41 [PATCH net 0/2] net: airoha: fix NPU mailbox and WLAN initialization Faliang Wang
2026-11-30  3:41 ` [PATCH net 1/2] net: airoha: fix NPU mailbox notification ordering Faliang Wang
2026-11-30  8:27   ` Lorenzo Bianconi
2026-11-30  8:31     ` Faliang Wang (王法亮)
2026-12-01  4:37   ` netdev-bot+sashiko [this message]
2026-11-30  3:41 ` [PATCH net 2/2] net: airoha: retry WLAN initialization commands Faliang Wang
2026-11-30  8:31   ` Lorenzo Bianconi
2026-12-01  4:37   ` netdev-bot+sashiko
2026-11-30  3:45 ` [PATCH net 0/2] net: airoha: fix NPU mailbox and WLAN initialization netdev-bot+sinfo

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=179609982804.3146.10880112368695516095@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=faliang.wang@airoha.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=lorenzo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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