* [PATCH net 0/2] net: airoha: fix NPU mailbox and WLAN initialization
@ 2026-11-30 3:41 Faliang Wang
2026-11-30 3:41 ` [PATCH net 1/2] net: airoha: fix NPU mailbox notification ordering Faliang Wang
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Faliang Wang @ 2026-11-30 3:41 UTC (permalink / raw)
To: netdev
Cc: lorenzo, andrew+netdev, davem, edumazet, kuba, pabeni,
linux-arm-kernel, linux-mediatek, Faliang Wang
During automated reboot testing, NPU mailbox communication can fail
intermittently and prevent Wi-Fi from coming up.
This series contains two changes:
Write the function information to CTRL(3) before updating the message
counter in CTRL(2). This ensures that the function information is
written before the NPU is notified of a new message.
Retry WLAN initialization commands up to three total attempts, with
a 10-11 ms sleep between failed attempts. Apply the same retry handling
to the optional BA memory-region initialization command.
Faliang Wang (2):
net: airoha: fix NPU mailbox notification ordering
net: airoha: retry WLAN initialization commands
drivers/net/ethernet/airoha/airoha_npu.c | 45 +++++++++++++++++-------
1 file changed, 33 insertions(+), 12 deletions(-)
base-commit: e6474ead54b8acecb8b0462dde2d77f46d2b7dc1
--
2.43.0
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH net 1/2] net: airoha: fix NPU mailbox notification ordering 2026-11-30 3:41 [PATCH net 0/2] net: airoha: fix NPU mailbox and WLAN initialization Faliang Wang @ 2026-11-30 3:41 ` Faliang Wang 2026-11-30 8:27 ` Lorenzo Bianconi 2026-12-01 4:37 ` netdev-bot+sashiko 2026-11-30 3:41 ` [PATCH net 2/2] net: airoha: retry WLAN initialization commands Faliang Wang 2026-11-30 3:45 ` [PATCH net 0/2] net: airoha: fix NPU mailbox and WLAN initialization netdev-bot+sinfo 2 siblings, 2 replies; 9+ messages in thread From: Faliang Wang @ 2026-11-30 3:41 UTC (permalink / raw) To: netdev Cc: lorenzo, andrew+netdev, davem, edumazet, kuba, pabeni, linux-arm-kernel, linux-mediatek, Faliang Wang During automated reboot testing, NPU mailbox communication can fail intermittently and prevent Wi-Fi from coming up. The message counter in CTRL(2) notifies the NPU that a new message is ready. Write the function information to CTRL(3) before updating that counter, so the NPU receives the function information before the notification. Fixes: REAL_LINUX_SHA ("EXACT_ORIGINAL_COMMIT_SUBJECT") Signed-off-by: Faliang Wang <faliang.wang@airoha.com> --- drivers/net/ethernet/airoha/airoha_npu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/airoha/airoha_npu.c b/drivers/net/ethernet/airoha/airoha_npu.c index edec6b111895..7f7cdc2553ad 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, -- 2.43.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net 1/2] net: airoha: fix NPU mailbox notification ordering 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 1 sibling, 1 reply; 9+ messages in thread From: Lorenzo Bianconi @ 2026-11-30 8:27 UTC (permalink / raw) To: Faliang Wang Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, linux-arm-kernel, linux-mediatek [-- Attachment #1: Type: text/plain, Size: 1680 bytes --] > During automated reboot testing, NPU mailbox communication can fail > intermittently and prevent Wi-Fi from coming up. > > The message counter in CTRL(2) notifies the NPU that a new message is > ready. Write the function information to CTRL(3) before updating that > counter, so the NPU receives the function information before the > notification. > > Fixes: REAL_LINUX_SHA ("EXACT_ORIGINAL_COMMIT_SUBJECT") This does not seem a valid Fixes tag. Regards, Lorenzo > Signed-off-by: Faliang Wang <faliang.wang@airoha.com> > --- > drivers/net/ethernet/airoha/airoha_npu.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/airoha/airoha_npu.c b/drivers/net/ethernet/airoha/airoha_npu.c > index edec6b111895..7f7cdc2553ad 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, > -- > 2.43.0 > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH net 1/2] net: airoha: fix NPU mailbox notification ordering 2026-11-30 8:27 ` Lorenzo Bianconi @ 2026-11-30 8:31 ` Faliang Wang (王法亮) 0 siblings, 0 replies; 9+ messages in thread From: Faliang Wang (王法亮) @ 2026-11-30 8:31 UTC (permalink / raw) To: Lorenzo Bianconi Cc: netdev@vger.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 Hi Lorenzon, Thanks for your review, Patch information has been updated, and it will be re-sent tomorrow. Best regards Faliang Wang -----Original Message----- From: Lorenzo Bianconi <lorenzo@kernel.org> Sent: Monday, November 30, 2026 4:28 PM To: Faliang Wang (王法亮) <Faliang.Wang@airoha.com> Cc: netdev@vger.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 > During automated reboot testing, NPU mailbox communication can fail > intermittently and prevent Wi-Fi from coming up. > > The message counter in CTRL(2) notifies the NPU that a new message is > ready. Write the function information to CTRL(3) before updating that > counter, so the NPU receives the function information before the > notification. > > Fixes: REAL_LINUX_SHA ("EXACT_ORIGINAL_COMMIT_SUBJECT") This does not seem a valid Fixes tag. Regards, Lorenzo > Signed-off-by: Faliang Wang <faliang.wang@airoha.com> > --- > drivers/net/ethernet/airoha/airoha_npu.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/airoha/airoha_npu.c > b/drivers/net/ethernet/airoha/airoha_npu.c > index edec6b111895..7f7cdc2553ad 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, > -- > 2.43.0 > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net 1/2] net: airoha: fix NPU mailbox notification ordering 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-12-01 4:37 ` netdev-bot+sashiko 1 sibling, 0 replies; 9+ messages in thread From: netdev-bot+sashiko @ 2026-12-01 4:37 UTC (permalink / raw) To: faliang.wang Cc: netdev, lorenzo, andrew+netdev, davem, edumazet, kuba, pabeni, linux-arm-kernel, linux-mediatek 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net 2/2] net: airoha: retry WLAN initialization commands 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 3:41 ` 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 2 siblings, 2 replies; 9+ messages in thread From: Faliang Wang @ 2026-11-30 3:41 UTC (permalink / raw) To: netdev Cc: lorenzo, andrew+netdev, davem, edumazet, kuba, pabeni, linux-arm-kernel, linux-mediatek, Faliang Wang DESCRIBE_THE_CONFIRMED_FAILURE_AND_WHY_RETRYING_IS_SAFE. Allow up to three total attempts for WLAN initialization commands,Sleep for 10 ms between failed attempts before reporting the final error. Fixes: REAL_LINUX_SHA ("EXACT_ORIGINAL_COMMIT_SUBJECT") Signed-off-by: Faliang Wang <faliang.wang@airoha.com> --- drivers/net/ethernet/airoha/airoha_npu.c | 41 ++++++++++++++++++------ 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/airoha/airoha_npu.c b/drivers/net/ethernet/airoha/airoha_npu.c index 7f7cdc2553ad..6fb4eec20c20 100644 --- a/drivers/net/ethernet/airoha/airoha_npu.c +++ b/drivers/net/ethernet/airoha/airoha_npu.c @@ -527,44 +527,65 @@ airoha_npu_wlan_set_reserved_memory(struct airoha_npu *npu, return airoha_npu_wlan_msg_send(npu, ifindex, func_id, &val, sizeof(val), GFP_KERNEL); } +static int airoha_npu_wlan_cmd_with_retry(struct airoha_npu *npu, + int ifindex, + enum airoha_npu_wlan_set_cmd cmd, + const char *name, bool is_msg_send, + u32 *val) +{ + int retry, err; + + for (retry = 0; retry < 3; retry++) { + if (is_msg_send) + err = airoha_npu_wlan_msg_send(npu, ifindex, cmd, val, + sizeof(*val), + GFP_KERNEL); + else + err = airoha_npu_wlan_set_reserved_memory(npu, ifindex, + name, cmd); + if (!err) + return 0; + + if (retry < 2) + msleep(10); + } + return err; +} static int airoha_npu_wlan_init_memory(struct airoha_npu *npu) { enum airoha_npu_wlan_set_cmd cmd = WLAN_FUNC_SET_WAIT_NPU_BAND0_ONCPU; u32 val = 0; - int err; - - err = airoha_npu_wlan_msg_send(npu, 1, cmd, &val, sizeof(val), - GFP_KERNEL); + int err = 0; + err = airoha_npu_wlan_cmd_with_retry(npu, 1, cmd, "band0_oncpu",1, &val); if (err) return err; cmd = WLAN_FUNC_SET_WAIT_TX_BUF_CHECK_ADDR; - err = airoha_npu_wlan_set_reserved_memory(npu, 0, "tx-bufid", cmd); + err = airoha_npu_wlan_cmd_with_retry(npu, 0, cmd, "tx-bufid", 0, NULL); if (err) return err; cmd = WLAN_FUNC_SET_WAIT_PKT_BUF_ADDR; - err = airoha_npu_wlan_set_reserved_memory(npu, 0, "pkt", cmd); + err = airoha_npu_wlan_cmd_with_retry(npu, 0, cmd, "pkt", 0, NULL); if (err) return err; cmd = WLAN_FUNC_SET_WAIT_TX_PKT_BUF_ADDR; - err = airoha_npu_wlan_set_reserved_memory(npu, 0, "tx-pkt", cmd); + err = airoha_npu_wlan_cmd_with_retry(npu, 0, cmd, "tx-pkt", 0, NULL); if (err) return err; if (of_property_match_string(npu->dev->of_node, "memory-region-names", "ba") >= 0) { cmd = WLAN_FUNC_SET_WAIT_DRAM_BA_NODE_ADDR; - err = airoha_npu_wlan_set_reserved_memory(npu, 0, "ba", cmd); + err = airoha_npu_wlan_cmd_with_retry(npu, 0, cmd, "ba",false, NULL); if (err) return err; } cmd = WLAN_FUNC_SET_WAIT_IS_FORCE_TO_CPU; - return airoha_npu_wlan_msg_send(npu, 0, cmd, &val, sizeof(val), - GFP_KERNEL); + return airoha_npu_wlan_cmd_with_retry(npu, 0, cmd, "force_to_cpu", 1,&val); } static u32 airoha_npu_wlan_queue_addr_get(struct airoha_npu *npu, int qid, -- 2.43.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net 2/2] net: airoha: retry WLAN initialization commands 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 1 sibling, 0 replies; 9+ messages in thread From: Lorenzo Bianconi @ 2026-11-30 8:31 UTC (permalink / raw) To: Faliang Wang Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, linux-arm-kernel, linux-mediatek [-- Attachment #1: Type: text/plain, Size: 3545 bytes --] > DESCRIBE_THE_CONFIRMED_FAILURE_AND_WHY_RETRYING_IS_SAFE. > > Allow up to three total attempts for WLAN initialization commands,Sleep for 10 ms between failed attempts before reporting the final error. Can you please provide more details about the issue? What is the root cause of the problem? Can you please explain why just commands in airoha_npu_wlan_init_memory() can fail? > > Fixes: REAL_LINUX_SHA ("EXACT_ORIGINAL_COMMIT_SUBJECT") Ivalid Fixes tag. Regards, Lorenzo > Signed-off-by: Faliang Wang <faliang.wang@airoha.com> > --- > drivers/net/ethernet/airoha/airoha_npu.c | 41 ++++++++++++++++++------ > 1 file changed, 31 insertions(+), 10 deletions(-) > > diff --git a/drivers/net/ethernet/airoha/airoha_npu.c b/drivers/net/ethernet/airoha/airoha_npu.c > index 7f7cdc2553ad..6fb4eec20c20 100644 > --- a/drivers/net/ethernet/airoha/airoha_npu.c > +++ b/drivers/net/ethernet/airoha/airoha_npu.c > @@ -527,44 +527,65 @@ airoha_npu_wlan_set_reserved_memory(struct airoha_npu *npu, > return airoha_npu_wlan_msg_send(npu, ifindex, func_id, &val, > sizeof(val), GFP_KERNEL); > } > +static int airoha_npu_wlan_cmd_with_retry(struct airoha_npu *npu, > + int ifindex, > + enum airoha_npu_wlan_set_cmd cmd, > + const char *name, bool is_msg_send, > + u32 *val) > +{ > + int retry, err; > + > + for (retry = 0; retry < 3; retry++) { > + if (is_msg_send) > + err = airoha_npu_wlan_msg_send(npu, ifindex, cmd, val, > + sizeof(*val), > + GFP_KERNEL); > + else > + err = airoha_npu_wlan_set_reserved_memory(npu, ifindex, > + name, cmd); > + if (!err) > + return 0; > + > + if (retry < 2) > + msleep(10); > + } > > + return err; > +} > static int airoha_npu_wlan_init_memory(struct airoha_npu *npu) > { > enum airoha_npu_wlan_set_cmd cmd = WLAN_FUNC_SET_WAIT_NPU_BAND0_ONCPU; > u32 val = 0; > - int err; > - > - err = airoha_npu_wlan_msg_send(npu, 1, cmd, &val, sizeof(val), > - GFP_KERNEL); > + int err = 0; > + err = airoha_npu_wlan_cmd_with_retry(npu, 1, cmd, "band0_oncpu",1, &val); > if (err) > return err; > > cmd = WLAN_FUNC_SET_WAIT_TX_BUF_CHECK_ADDR; > - err = airoha_npu_wlan_set_reserved_memory(npu, 0, "tx-bufid", cmd); > + err = airoha_npu_wlan_cmd_with_retry(npu, 0, cmd, "tx-bufid", 0, NULL); > if (err) > return err; > > cmd = WLAN_FUNC_SET_WAIT_PKT_BUF_ADDR; > - err = airoha_npu_wlan_set_reserved_memory(npu, 0, "pkt", cmd); > + err = airoha_npu_wlan_cmd_with_retry(npu, 0, cmd, "pkt", 0, NULL); > if (err) > return err; > > cmd = WLAN_FUNC_SET_WAIT_TX_PKT_BUF_ADDR; > - err = airoha_npu_wlan_set_reserved_memory(npu, 0, "tx-pkt", cmd); > + err = airoha_npu_wlan_cmd_with_retry(npu, 0, cmd, "tx-pkt", 0, NULL); > if (err) > return err; > > if (of_property_match_string(npu->dev->of_node, "memory-region-names", > "ba") >= 0) { > cmd = WLAN_FUNC_SET_WAIT_DRAM_BA_NODE_ADDR; > - err = airoha_npu_wlan_set_reserved_memory(npu, 0, "ba", cmd); > + err = airoha_npu_wlan_cmd_with_retry(npu, 0, cmd, "ba",false, NULL); > if (err) > return err; > } > > cmd = WLAN_FUNC_SET_WAIT_IS_FORCE_TO_CPU; > - return airoha_npu_wlan_msg_send(npu, 0, cmd, &val, sizeof(val), > - GFP_KERNEL); > + return airoha_npu_wlan_cmd_with_retry(npu, 0, cmd, "force_to_cpu", 1,&val); > } > > static u32 airoha_npu_wlan_queue_addr_get(struct airoha_npu *npu, int qid, > -- > 2.43.0 > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net 2/2] net: airoha: retry WLAN initialization commands 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 1 sibling, 0 replies; 9+ messages in thread From: netdev-bot+sashiko @ 2026-12-01 4:37 UTC (permalink / raw) To: faliang.wang Cc: netdev, lorenzo, andrew+netdev, davem, edumazet, kuba, pabeni, linux-arm-kernel, linux-mediatek Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 3 · Low: 2 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] The commit message is an unfilled template. - [Medium] airoha_npu_wlan_cmd_with_retry() resends a WLAN mailbox command after airoha_npu_send_msg() has failed. - [Medium] airoha_npu_wlan_cmd_with_retry() retries on any non-zero return, including errors that are certain to recur. - [Low] If NPU mailbox commands really can fail transiently, the patch handles it only in airoha_npu_wlan_init_memory(). - [Low] The new helper airoha_npu_wlan_cmd_with_retry() uses a bool flag to choose between two unrelated operations. -- net: airoha: retry WLAN initialization commands This commit adds airoha_npu_wlan_cmd_with_retry(). The helper wraps the WLAN initialization mailbox commands sent from airoha_npu_wlan_init_memory(). It makes up to three attempts and sleeps 10 ms between failed attempts. > net: airoha: retry WLAN initialization commands > > DESCRIBE_THE_CONFIRMED_FAILURE_AND_WHY_RETRYING_IS_SAFE. > > Allow up to three total attempts for WLAN initialization commands,Sleep for 10 ms between failed attempts before reporting the final error. > > Fixes: REAL_LINUX_SHA ("EXACT_ORIGINAL_COMMIT_SUBJECT") [Severity: Medium] The commit message looks like an unfilled template. The body is still the placeholder text. The Fixes: tag does not point at a real commit, so stable and backport tooling can't use it. Could the message say which of the WLAN init commands fail? It would help to know the error returned (-ETIMEDOUT from the mailbox poll, or -EINVAL from a firmware status), the platform or firmware version, and why resending an NPU mailbox command is safe. The message also says the code sleeps "before reporting the final error". airoha_npu_wlan_cmd_with_retry() doesn't report anything, though. It just returns err. There is also a missing space in "commands,Sleep". > diff --git a/drivers/net/ethernet/airoha/airoha_npu.c b/drivers/net/ethernet/airoha/airoha_npu.c > index 7f7cdc2553ad4..6fb4eec20c206 100644 > --- a/drivers/net/ethernet/airoha/airoha_npu.c > +++ b/drivers/net/ethernet/airoha/airoha_npu.c > @@ -527,44 +527,65 @@ airoha_npu_wlan_set_reserved_memory(struct airoha_npu *npu, > return airoha_npu_wlan_msg_send(npu, ifindex, func_id, &val, > sizeof(val), GFP_KERNEL); > } > +static int airoha_npu_wlan_cmd_with_retry(struct airoha_npu *npu, > + int ifindex, > + enum airoha_npu_wlan_set_cmd cmd, > + const char *name, bool is_msg_send, > + u32 *val) > +{ > + int retry, err; > + > + for (retry = 0; retry < 3; retry++) { > + if (is_msg_send) > + err = airoha_npu_wlan_msg_send(npu, ifindex, cmd, val, > + sizeof(*val), > + GFP_KERNEL); > + else > + err = airoha_npu_wlan_set_reserved_memory(npu, ifindex, > + name, cmd); > + if (!err) > + return 0; > + > + if (retry < 2) > + msleep(10); > + } [Severity: Medium] Is it safe to resend the mailbox command without first resetting or quiescing the NPU MBQ0 mailbox? When airoha_npu_send_msg() times out, nothing aborts the pending request. The CTRL(2) doorbell counter has already been advanced, the buffer is unmapped, and airoha_npu_wlan_msg_send() then frees it: airoha_npu_send_msg() { ... 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, val, (val & MBOX_MSG_DONE), 100, 100 * MSEC_PER_SEC); ... dma_unmap_single(npu->dev, dma_addr, size, DMA_BIDIRECTIONAL); ... } airoha_npu_wlan_msg_send() { ... err = airoha_npu_send_msg(npu, NPU_FUNC_WIFI, wlan_data, len); kfree(wlan_data); ... } The unmap and free after a single timeout predates this patch. Before it, though, a timeout ended mt76_npu_init(). Now the retry posts a new buffer, rewrites CTRL(0/1/3) and advances CTRL(2) again, while the first request may still be pending in the firmware. Suppose the NPU was slow rather than dead and completes the stale request late. Could the retry's poll then treat that DONE/STATUS as the completion of the new command? If so, the new buffer would be unmapped and freed while the firmware still has one more doorbell to process. Because the buffer is mapped DMA_BIDIRECTIONAL, could the device then touch freed memory, or run the command twice? The loop also retries -EINVAL. That error means the firmware already processed and rejected the command: if (!ret && FIELD_GET(MBOX_MSG_STATUS, val) != NPU_MBOX_SUCCESS) ret = -EINVAL; Are the WLAN_FUNC_SET_WAIT_* commands known to be idempotent, so that resending the same payload is harmless? If they are not, a safe retry would seem to need a mailbox reset or abort, or a confirmation from the firmware. > > + return err; > +} [Severity: Low] If NPU mailbox commands can fail transiently, why is the retry only applied in airoha_npu_wlan_init_memory()? Every other user of airoha_npu_send_msg() still fails on the first error. That includes airoha_npu_wlan_msg_send() and airoha_npu_wlan_msg_get() when mt76 reaches them through ops.wlan_send_msg and ops.wlan_get_msg. It also includes the PPE init, stats and flush commands. For example, mt76_npu_send_txrx_addr() in drivers/net/wireless/mediatek/mt76/npu.c does: err = airoha_npu_wlan_send_msg(npu, ifindex, WLAN_FUNC_SET_WAIT_INODE_TXRX_REG_ADDR, &info, sizeof(info), GFP_ATOMIC); A firmware not-ready condition right after boot would explain limiting the retry to init. The commit message doesn't say whether that is the cause, though. That caller runs under rcu_read_lock() with GFP_ATOMIC, and airoha_npu_send_msg() runs under spin_lock_bh(). An msleep() based retry couldn't simply be moved into the shared path either. > static int airoha_npu_wlan_init_memory(struct airoha_npu *npu) > { > enum airoha_npu_wlan_set_cmd cmd = WLAN_FUNC_SET_WAIT_NPU_BAND0_ONCPU; > u32 val = 0; > - int err; > - > - err = airoha_npu_wlan_msg_send(npu, 1, cmd, &val, sizeof(val), > - GFP_KERNEL); > + int err = 0; > + err = airoha_npu_wlan_cmd_with_retry(npu, 1, cmd, "band0_oncpu",1, &val); > if (err) > return err; > > cmd = WLAN_FUNC_SET_WAIT_TX_BUF_CHECK_ADDR; > - err = airoha_npu_wlan_set_reserved_memory(npu, 0, "tx-bufid", cmd); > + err = airoha_npu_wlan_cmd_with_retry(npu, 0, cmd, "tx-bufid", 0, NULL); [Severity: Medium] The loop retries any non-zero return. Should it be retrying errors that are certain to happen again? When is_msg_send is false, each attempt repeats the DT lookup in airoha_npu_wlan_set_reserved_memory(): err = of_reserved_mem_region_to_resource_byname(dev->of_node, name, &res); if (err) return err; The result of that lookup depends only on static DT content. When reserved-mem support isn't built, it is -ENOSYS from the stub. The binding in Documentation/devicetree/bindings/net/airoha,en7581-npu.yaml sets minItems: 1 for memory-region-names. That makes "pkt", "tx-pkt" and "tx-bufid" optional. Only "ba" is checked with of_property_match_string() before the call; the other three go straight into the retry loop. Requiring those regions predates this patch, but retrying the lookup is new. The loop also retries -ENOMEM, dma_mapping_error() failures and firmware rejections (-EINVAL), each time with the same payload. Each of these failures now costs three attempts and two msleep(10) calls, and the result is the same. Each mailbox attempt can also busy-wait for up to 100 ms with BH disabled under cores[0].lock. mt76_npu_init() holds dev->mutex for all of it. > if (err) > return err; > > cmd = WLAN_FUNC_SET_WAIT_PKT_BUF_ADDR; > - err = airoha_npu_wlan_set_reserved_memory(npu, 0, "pkt", cmd); > + err = airoha_npu_wlan_cmd_with_retry(npu, 0, cmd, "pkt", 0, NULL); > if (err) > return err; > > cmd = WLAN_FUNC_SET_WAIT_TX_PKT_BUF_ADDR; > - err = airoha_npu_wlan_set_reserved_memory(npu, 0, "tx-pkt", cmd); > + err = airoha_npu_wlan_cmd_with_retry(npu, 0, cmd, "tx-pkt", 0, NULL); > if (err) > return err; > > if (of_property_match_string(npu->dev->of_node, "memory-region-names", > "ba") >= 0) { > cmd = WLAN_FUNC_SET_WAIT_DRAM_BA_NODE_ADDR; > - err = airoha_npu_wlan_set_reserved_memory(npu, 0, "ba", cmd); > + err = airoha_npu_wlan_cmd_with_retry(npu, 0, cmd, "ba",false, NULL); > if (err) > return err; > } > > cmd = WLAN_FUNC_SET_WAIT_IS_FORCE_TO_CPU; > - return airoha_npu_wlan_msg_send(npu, 0, cmd, &val, sizeof(val), > - GFP_KERNEL); > + return airoha_npu_wlan_cmd_with_retry(npu, 0, cmd, "force_to_cpu", 1,&val); > } [Severity: Low] This isn't a bug, but there are a few style issues in the new code. The is_msg_send flag selects between two unrelated operations. name is ignored when is_msg_send is true, yet the callers pass "band0_oncpu" and "force_to_cpu", which are not DT region names. val is NULL on the other branch. The same bool is passed as 1, 0 and false at different call sites. The value in "int err = 0;" is overwritten right away, and there is no blank line after the declarations. The 3, 2 and 10 in the retry loop are magic numbers. Two blank lines between functions are missing: one after airoha_npu_wlan_set_reserved_memory() and one after the new helper, before airoha_npu_wlan_init_memory(). Spaces are missing after the commas in "band0_oncpu",1 and "ba",false and 1,&val. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130034106.869059-1-faliang.wang%40airoha.com ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net 0/2] net: airoha: fix NPU mailbox and WLAN initialization 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 3:41 ` [PATCH net 2/2] net: airoha: retry WLAN initialization commands Faliang Wang @ 2026-11-30 3:45 ` netdev-bot+sinfo 2 siblings, 0 replies; 9+ messages in thread From: netdev-bot+sinfo @ 2026-11-30 3:45 UTC (permalink / raw) To: Faliang Wang Cc: netdev, lorenzo, andrew+netdev, davem, edumazet, kuba, pabeni, linux-arm-kernel, linux-mediatek Hi! This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information: - What hardware the change was tested on. For driver fixes please mention the device (and if relevant firmware version) used for testing, or say that the change was not tested on real hardware. Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. *IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages. -- The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain. ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-12-01 4:37 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox