All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Ryosuke Saito <ryosuke.saito@linaro.org>
Cc: jaswinder.singh@linaro.org, ilias.apalodimas@linaro.org,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, masahisa.kojima@linaro.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: netsec: replace cpu_relax() with timeout handling for register checks
Date: Sun, 19 Nov 2023 18:53:37 +0000	[thread overview]
Message-ID: <20231119185337.GE186930@vergenet.net> (raw)
In-Reply-To: <20231117081002.60107-1-ryosuke.saito@linaro.org>

On Fri, Nov 17, 2023 at 05:10:02PM +0900, Ryosuke Saito wrote:
> The cpu_relax() loops have the potential to hang if the specified
> register bits are not met on condition. The patch replaces it with
> usleep_range() and netsec_wait_while_busy() which includes timeout
> logic.
> 
> Additionally, if the error condition is met during interrupting DMA
> transfer, there's no recovery mechanism available. In that case, any
> frames being sent or received will be discarded, which leads to
> potential frame loss as indicated in the comments.
> 
> Signed-off-by: Ryosuke Saito <ryosuke.saito@linaro.org>
> ---
>  drivers/net/ethernet/socionext/netsec.c | 35 ++++++++++++++++---------
>  1 file changed, 23 insertions(+), 12 deletions(-)

...

> @@ -1476,9 +1483,13 @@ static int netsec_reset_hardware(struct netsec_priv *priv,
>  	netsec_write(priv, NETSEC_REG_DMA_MH_CTRL, MH_CTRL__MODE_TRANS);
>  	netsec_write(priv, NETSEC_REG_PKT_CTRL, value);
>  
> -	while ((netsec_read(priv, NETSEC_REG_MODE_TRANS_COMP_STATUS) &
> -		NETSEC_MODE_TRANS_COMP_IRQ_T2N) == 0)
> -		cpu_relax();
> +	usleep_range(100000, 120000);
> +
> +	if ((netsec_read(priv, NETSEC_REG_MODE_TRANS_COMP_STATUS) &
> +			 NETSEC_MODE_TRANS_COMP_IRQ_T2N) == 0) {
> +		dev_warn(priv->dev,
> +			 "%s: trans comp timeout.\n", __func__);
> +	}

Hi Saito-san,

could you add some colour to how the new code satisfies the
requirements of the hardware?  In particular, the use of
usleep_range(), and the values passed to it.

>  
>  	/* clear any pending EMPTY/ERR irq status */
>  	netsec_write(priv, NETSEC_REG_NRM_TX_STATUS, ~0);
> -- 
> 2.34.1
> 

  reply	other threads:[~2023-11-19 18:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-17  8:10 [PATCH] net: netsec: replace cpu_relax() with timeout handling for register checks Ryosuke Saito
2023-11-19 18:53 ` Simon Horman [this message]
2023-11-20  2:19   ` Ryosuke Saito
2023-11-21 11:02     ` Simon Horman

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=20231119185337.GE186930@vergenet.net \
    --to=horms@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jaswinder.singh@linaro.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahisa.kojima@linaro.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ryosuke.saito@linaro.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.