πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24969

Re: [PATCH net 1/2] net: airoha: fix NPU mailbox notification ordering

#24969
From: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 04:37
109 lines
12266 bytes
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
Technical Details
Message-ID: <179609982804.3146.10880112368695516095@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374701-linux-kernel-netdev=dewy.ru
References: <20261130034106.869059-2-faliang.wang@airoha.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374701-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 1/2] net: airoha: fix NPU mailbox notification ordering
Date: Tue, 01 Dec 2026 04:37:08 +0000
Organization: Usenet Network
Message-ID: <179609982804.3146.10880112368695516095@kernel.org>
References: <20261130034106.869059-2-faliang.wang@airoha.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1614742"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:GV6D7nRrH0R+iKuQ+EQYAIw72Hc= sha256:9BAb7wcOWNaowsc2e6tz80izPgBjLunra94LPCP6R64=
	sha1:o+doeWkkG7YCuXnlXt+Bk7RbVRs= sha256:mfD/TQRWp1SJaFYroTAMsNgmSVZJps1D+sPozvuEExc=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 20A3E117233; Tue,  1 Dec 2026 07:37:30 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id woukNzxTm14L;
	Tue,  1 Dec 2026 07:37:22 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374701-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 36F0E117238; Tue,  1 Dec 2026 07:37:13 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id CA1F52AE87; Tue,  1 Dec 2026 04:37:10 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796099830;
	b=nf9Ez+1wpnI72xyZTBp6h6t9bCETv/jc3F08BMrAvepGtr6TNEkSI6Nevwb+boIF/hig
	 qrko9RGr65cD16sv69FasI8DBfqDiskQ7N9rOmyME5S+ThWVtcZmvg4E3cNDjKhv7+iVA
	 9tyswUv6yBP7AgqumtTIV1gN4cVay4fKddQbyBz+sZGqr95EOLv/Dw3UO+8Bh8R14WIWk
	 JJycH3mWviA2Izh6/f172A1Xx/YsbY/AGGtJLseC7F0vxz7yqcSOGCEq7LVjDZC5mYzBu
	 8r5EGL7aftL9ITe16+zcX07EfovhxfHDC6wbSQszERDxpo6aM5PrZnG2DAszZqAcLWg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796099830;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=xRNFrqvGnz/l8X4U3VNaq2y3kjRE03UdEtIOqk/0tgg=;
	b=AtIcSqdJHB7xSUHO0jBLd3QJAvFLk2HSCeougdUf2m5XgirO+ovE+CLgugRXpjSvkYvy
	 0+4Q5AZlVaRh5MuYExIoCnHoGtq8V9VTqWmbD6crZr3sMbpkK9P+HXXvB/8I+8uqavWzp
	 azN9M3PzeY+N1JbYmfOYvePDiFoxF5YCQhtDeuqoVxZTvK4H2l6M8eIa5gCspeGDKzhtD
	 /zWnICQKc2tAPsJuf/Mp8UDaJwmzanxXKv6fnJuY3boFqlzYeR7/ZTKQk1s/CKx3Epsq4
	 rLt9vZaKRfjc/tCmdNpVbBh3h+eUmp9HjyV9YtkSB6sfU3yejQhOEFlQZXk+FNL/MnQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="F04MA/cb";
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C3CE606A334;
	Tue,  1 Dec 2026 04:37:10 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=F04MA/cb
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796099829;
	b=hZN5U1VpBoOOwkp1mLFILTRwUJeQHCpcP9xCWYbf+fkUizAqJixzecllM8o7ZHUVOtvO
	 gh9jtj2SndUI1xezcURIlZQRgA7Ea0tLDn4PQ6eOo3/JOQaJSg5yM4rRWsUcSmnJbP49i
	 NoH3GvDT4P5R1WI2zeUFpjJIJQwJmZxGheJhE/egD50KgwuMsXyNRIt4fJhUkE2ZW+6Qi
	 xn6qcptEJ1VnHnIk+/yDihZGIFGhZHCh9UGucXNhF/rPPt/9IRA67AJFT4O4NzjW9XlqG
	 ccy+8LSh6R1RDyAMxhZQ+8ZbKi5rqO2H2zVjQOVfq3UjFWQ09VKgHUSoJG5Z3e6ajSQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796099829;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=xRNFrqvGnz/l8X4U3VNaq2y3kjRE03UdEtIOqk/0tgg=;
	b=SYfsmg9Ynpdlwkjcd+xxEPMfIFbz3u9Du8FDjMRyr817I2FuyCq3de3JPUptNAtoPenR
	 PnQ1Yfqj1ckCZikhlFqIwpvNVJUULJbpKPWiwjd9IQGgbhuu4R9TvRDMBeluWm8Q5HPMC
	 iKkJ9i/q2K2wF3NkBRcqeA5yhtuW7sBRHUiqvod9v0PT4306YgL1+ZwgQdXP/hKHK9coW
	 Tx5cT+IAOhmwmCSqOTOg05U8xkKU5fNsfPKKe1hxXTWlWIXdhoH5Ao05oV59mhA9s+e2Q
	 X4H2m52mIR0LyXPgKk+cbNa+jFhA2qX7c3/CyKO04TjwOytmif8X25DIKU7Gmr9lMKA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="F04MA/cb";
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BAEF606A320
	for <netdev@vger.kernel.org>; Tue,  1 Dec 2026 04:37:09 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9384D1F00893;
	Tue,  1 Dec 2026 04:37:08 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796099829;
	bh=xRNFrqvGnz/l8X4U3VNaq2y3kjRE03UdEtIOqk/0tgg=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=F04MA/cbwauZjo90f3rGrzD81ZNdoAlwRBH3t2gLAOipR1DfcpNf1FvDL8ZyJmupZ
	 P4W47X3vxjPZevOiVbj+Cvz/Xwkyy2OdOeJCCfx+sWp8WyKel9r/7EnwIWRoeN8P3u
	 YcuJWgcafqt9jUDlJIslmegJAWB0sYNUgxJ2XvjgDDbxobhU2ctShUlbQ+xAlfSQZ2
	 KiXt9jj2+iyetvmbBK0IaJGU82pSP1hhGxcy+KSgOg8q3VCXl+Wtx6SqmcLoosziDC
	 qWVibZovkK+4o2hNM04WnTwO3KY/SCs0amgXNbBZAAgz7kwYVW9s0Ab0F35Ge2D93y
	 z4jJCz5vEvAQw==
X-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
X-In-Reply-To: <20261130034106.869059-2-faliang.wang@airoha.com>
X-sashiko-severity: Low
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list