mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: Claudiu <claudiu.beznea@tuxon.dev>
Cc: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com,
	claudiu.beznea.uj@bp.renesas.com,
	yoshihiro.shimoda.uh@renesas.com,
	wsa+renesas@sang-engineering.com, biju.das.jz@bp.renesas.com,
	prabhakar.mahadev-lad.rj@bp.renesas.com,
	mitsuhiro.kimura.kc@renesas.com, geert+renesas@glider.be,
	netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 1/2] net: ravb: Wait for operation mode to be applied
Date: Thu, 14 Dec 2023 13:11:09 +0100	[thread overview]
Message-ID: <20231214121109.GK1863068@ragnatech.se> (raw)
In-Reply-To: <20231214113137.2450292-2-claudiu.beznea.uj@bp.renesas.com>

Hi Claudiu,

Thanks for your patch.

On 2023-12-14 13:31:36 +0200, Claudiu wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> 
> CSR.OPS bits specify the current operating mode and (according to
> documentation) they are updated when the operating mode change request
> is processed. Thus, check CSR.OPS before proceeding.
> 
> Fixes: 568b3ce7a8ef ("ravb: factor out register bit twiddling code")
> Fixes: 0184165b2f42 ("ravb: add sleep PM suspend/resume support")
> Fixes: 7e09a052dc4e ("ravb: Exclude gPTP feature support for RZ/G2L")
> Fixes: 3e3d647715d4 ("ravb: add wake-on-lan support via magic packet")
> Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper")

I think the list of fixes tags can be reduced. The last item in the list 
is the patch which adds the RAVB driver so what's the point of listing 
the rest?

> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> ---
>  drivers/net/ethernet/renesas/ravb_main.c | 47 ++++++++++++++++++++----
>  1 file changed, 39 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 9178f6d60e74..ce95eb5af354 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -683,8 +683,11 @@ static int ravb_dmac_init(struct net_device *ndev)
>  
>  	/* Setting the control will start the AVB-DMAC process. */
>  	ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_OPERATION);
> +	error = ravb_wait(ndev, CSR, CSR_OPS, CSR_OPS_OPERATION);
> +	if (error)
> +		netdev_err(ndev, "failed to switch device to operation mode\n");

As you add ravb_set_reset_mode() to compliment the existing 
ravb_set_config_mode(), would it not be coherent to also add a 
ravb_set_operation_mode() instead of open coding it here?

>  
> -	return 0;
> +	return error;
>  }
>  
>  static void ravb_get_tx_tstamp(struct net_device *ndev)
> @@ -1744,6 +1747,18 @@ static inline int ravb_hook_irq(unsigned int irq, irq_handler_t handler,
>  	return error;
>  }
>  
> +static int ravb_set_reset_mode(struct net_device *ndev)

nit: Maybe move this to be close to ravb_set_config_mode() to co-locate 
all mode changing logic?

> +{
> +	int error;
> +
> +	ravb_write(ndev, CCC_OPC_RESET, CCC);
> +	error = ravb_wait(ndev, CSR, CSR_OPS, CSR_OPS_RESET);
> +	if (error)
> +		netdev_err(ndev, "failed to switch device to reset mode\n");
> +
> +	return error;
> +}
> +
>  /* Network device open function for Ethernet AVB */
>  static int ravb_open(struct net_device *ndev)
>  {
> @@ -2551,10 +2566,11 @@ static int ravb_set_gti(struct net_device *ndev)
>  	return 0;
>  }
>  
> -static void ravb_set_config_mode(struct net_device *ndev)
> +static int ravb_set_config_mode(struct net_device *ndev)
>  {
>  	struct ravb_private *priv = netdev_priv(ndev);
>  	const struct ravb_hw_info *info = priv->info;
> +	int error;
>  
>  	if (info->gptp) {
>  		ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_CONFIG);
> @@ -2566,6 +2582,12 @@ static void ravb_set_config_mode(struct net_device *ndev)
>  	} else {
>  		ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_CONFIG);
>  	}
> +
> +	error = ravb_wait(ndev, CSR, CSR_OPS, CSR_OPS_CONFIG);
> +	if (error)
> +		netdev_err(ndev, "failed to switch device to config mode\n");
> +
> +	return error;
>  }
>  
>  /* Set tx and rx clock internal delay modes */
> @@ -2785,7 +2807,9 @@ static int ravb_probe(struct platform_device *pdev)
>  	ndev->ethtool_ops = &ravb_ethtool_ops;
>  
>  	/* Set AVB config mode */
> -	ravb_set_config_mode(ndev);
> +	error = ravb_set_config_mode(ndev);
> +	if (error)
> +		goto out_disable_refclk;
>  
>  	if (info->gptp || info->ccc_gac) {
>  		/* Set GTI value */
> @@ -2893,6 +2917,7 @@ static void ravb_remove(struct platform_device *pdev)
>  	struct net_device *ndev = platform_get_drvdata(pdev);
>  	struct ravb_private *priv = netdev_priv(ndev);
>  	const struct ravb_hw_info *info = priv->info;
> +	int error;
>  
>  	unregister_netdev(ndev);
>  	if (info->nc_queues)
> @@ -2908,8 +2933,9 @@ static void ravb_remove(struct platform_device *pdev)
>  	dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat,
>  			  priv->desc_bat_dma);
>  
> -	/* Set reset mode */
> -	ravb_write(ndev, CCC_OPC_RESET, CCC);
> +	error = ravb_set_reset_mode(ndev);
> +	if (error)
> +		netdev_err(ndev, "Failed to reset ndev\n");
>  
>  	clk_disable_unprepare(priv->gptp_clk);
>  	clk_disable_unprepare(priv->refclk);
> @@ -2991,8 +3017,11 @@ static int __maybe_unused ravb_resume(struct device *dev)
>  	int ret = 0;
>  
>  	/* If WoL is enabled set reset mode to rearm the WoL logic */
> -	if (priv->wol_enabled)
> -		ravb_write(ndev, CCC_OPC_RESET, CCC);
> +	if (priv->wol_enabled) {
> +		ret = ravb_set_reset_mode(ndev);
> +		if (ret)
> +			return ret;
> +	}
>  
>  	/* All register have been reset to default values.
>  	 * Restore all registers which where setup at probe time and
> @@ -3000,7 +3029,9 @@ static int __maybe_unused ravb_resume(struct device *dev)
>  	 */
>  
>  	/* Set AVB config mode */
> -	ravb_set_config_mode(ndev);
> +	ret = ravb_set_config_mode(ndev);
> +	if (ret)
> +		return ret;
>  
>  	if (info->gptp || info->ccc_gac) {
>  		/* Set GTI value */
> -- 
> 2.39.2
> 

-- 
Kind Regards,
Niklas Söderlund

  reply	other threads:[~2023-12-14 12:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-14 11:31 [PATCH net 0/2] net: ravb: fixes for the ravb driver Claudiu
2023-12-14 11:31 ` [PATCH net 1/2] net: ravb: Wait for operation mode to be applied Claudiu
2023-12-14 12:11   ` Niklas Söderlund [this message]
2023-12-14 12:25     ` claudiu beznea
2023-12-14 12:39       ` Niklas Söderlund
2023-12-14 12:57         ` claudiu beznea
2023-12-14 19:41   ` Sergey Shtylyov
2023-12-15 10:04     ` claudiu beznea
2023-12-19 16:49       ` Sergey Shtylyov
2023-12-20 11:27         ` claudiu beznea
2023-12-14 11:31 ` [PATCH net 2/2] net: ravb: Check that GTI loading request is done Claudiu
2023-12-14 12:33   ` Niklas Söderlund
2023-12-14 13:02     ` claudiu beznea
2023-12-14 20:22   ` Sergey Shtylyov
2023-12-15 10:13     ` claudiu beznea

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=20231214121109.GK1863068@ragnatech.se \
    --to=niklas.soderlund+renesas@ragnatech.se \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=claudiu.beznea.uj@bp.renesas.com \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=geert+renesas@glider.be \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=mitsuhiro.kimura.kc@renesas.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=s.shtylyov@omp.ru \
    --cc=wsa+renesas@sang-engineering.com \
    --cc=yoshihiro.shimoda.uh@renesas.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

all inboxes | Powered by JetHome®