Linux-mediatek Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
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 2/2] net: airoha: retry WLAN initialization commands
Date: Mon, 30 Nov 2026 09:31:07 +0100	[thread overview]
Message-ID: <aw00S0kxEC5UVEv1@lore-desk> (raw)
In-Reply-To: <20261130034106.869059-3-faliang.wang@airoha.com>

[-- 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 --]

  reply	other threads:[~2026-11-30  8:31 UTC|newest]

Thread overview: 7+ 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-11-30  3:41 ` [PATCH net 2/2] net: airoha: retry WLAN initialization commands Faliang Wang
2026-11-30  8:31   ` Lorenzo Bianconi [this message]
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=aw00S0kxEC5UVEv1@lore-desk \
    --to=lorenzo@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=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