public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: michael.dege@renesas.com
Cc: paul@pbarker.dev, niklas.soderlund@ragnatech.se, kuba@kernel.org,
	yoshihiro.shimoda.uh@renesas.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, edumazet@google.com,
	pabeni@redhat.com, linux-renesas-soc@vger.kernel.org,
	andrew+netdev@lunn.ch, davem@davemloft.net
Subject: Re: [net-next,v3,01/13] net: renesas: rswitch: improve port change mode functions
Date: Thu,  2 Apr 2026 14:59:12 +0200	[thread overview]
Message-ID: <20260402125912.234434-1-pabeni@redhat.com> (raw)
In-Reply-To: <20260331-rswitch_add_vlans-v3-1-c37f41b1c556@renesas.com>

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.

For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: renesas: rswitch: improve port change mode functions

For ETHA and GWCA ports every mode change from operational to
configuration and vice-versa requires to change the mode to "disable"
first. This was done by calling the function twice. Let the change_mode
function take care of this required step in a single call.

> diff --git a/drivers/net/ethernet/renesas/rswitch_main.c b/drivers/net/ethernet/renesas/rswitch_main.c
> index 6fe964816322..f6d1e610e7fa 100644
> --- a/drivers/net/ethernet/renesas/rswitch_main.c
> +++ b/drivers/net/ethernet/renesas/rswitch_main.c
> @@ -176,14 +176,19 @@ static int rswitch_gwca_change_mode(struct rswitch_private *priv,
>  	if (!rswitch_agent_clock_is_enabled(priv->addr, priv->gwca.index))
>  		rswitch_agent_clock_ctrl(priv->addr, priv->gwca.index, 1);
>
> -	iowrite32(mode, priv->addr + GWMC);
> +	iowrite32(GWMC_OPC_DISABLE, priv->addr + GWMC);
>
> -	ret = rswitch_reg_wait(priv->addr, GWMS, GWMS_OPS_MASK, mode);
> +	ret = rswitch_reg_wait(priv->addr, GWMS, GWMS_OPS_MASK, GWMC_OPC_DISABLE);
>
> -	if (mode == GWMC_OPC_DISABLE)
> +	if (mode == GWMC_OPC_DISABLE) {
>  		rswitch_agent_clock_ctrl(priv->addr, priv->gwca.index, 0);
>
> -	return ret;
> +		return ret;
> +	}
> +
> +	iowrite32(mode, priv->addr + GWMC);
> +
> +	return rswitch_reg_wait(priv->addr, GWMS, GWMS_OPS_MASK, mode);

Should the error from the initial DISABLE transition be checked before
proceeding? When mode != GWMC_OPC_DISABLE, this code stores the result of
rswitch_reg_wait() for the DISABLE transition in 'ret' but never checks it.
If the hardware fails to reach DISABLE state, the function silently proceeds
to write the target mode.

Before this patch, callers explicitly checked the error after calling
rswitch_gwca_change_mode(priv, GWMC_OPC_DISABLE):

rswitch_gwca_hw_init() and rswitch_gwca_hw_deinit():
    err = rswitch_gwca_change_mode(priv, GWMC_OPC_DISABLE);
    if (err < 0)
        return err;

This patch removes those caller-side checks but doesn't replicate the error
checking inside rswitch_gwca_change_mode(). If the first rswitch_reg_wait()
returns -ETIMEDOUT, should the function return that error before attempting
to write the target mode?

>  }
>
>  static int rswitch_gwca_mcast_table_reset(struct rswitch_private *priv)
> @@ -682,9 +687,6 @@ static int rswitch_gwca_hw_init(struct rswitch_private *priv)
>  	unsigned int i;
>  	int err;
>
> -	err = rswitch_gwca_change_mode(priv, GWMC_OPC_DISABLE);
> -	if (err < 0)
> -		return err;
>  	err = rswitch_gwca_change_mode(priv, GWMC_OPC_CONFIG);
>  	if (err < 0)
>  		return err;

[ ... ]

> @@ -717,9 +719,6 @@ static int rswitch_gwca_hw_init(struct rswitch_private *priv)
>  			return err;
>  	}
>
> -	err = rswitch_gwca_change_mode(priv, GWMC_OPC_DISABLE);
> -	if (err < 0)
> -		return err;
>  	return rswitch_gwca_change_mode(priv, GWMC_OPC_OPERATION);
>  }
>
> @@ -727,9 +726,6 @@ static int rswitch_gwca_hw_deinit(struct rswitch_private *priv)
>  {
>  	int err;
>
> -	err = rswitch_gwca_change_mode(priv, GWMC_OPC_DISABLE);
> -	if (err < 0)
> -		return err;
>  	err = rswitch_gwca_change_mode(priv, GWMC_OPC_RESET);
>  	if (err < 0)
>  		return err;

[ ... ]

> @@ -1116,14 +1112,18 @@ static int rswitch_etha_change_mode(struct rswitch_etha *etha,
>  	if (!rswitch_agent_clock_is_enabled(etha->coma_addr, etha->index))
>  		rswitch_agent_clock_ctrl(etha->coma_addr, etha->index, 1);
>
> -	iowrite32(mode, etha->addr + EAMC);
> -
> -	ret = rswitch_reg_wait(etha->addr, EAMS, EAMS_OPS_MASK, mode);
> +	iowrite32(EAMC_OPC_DISABLE, etha->addr + EAMC);
> +	ret = rswitch_reg_wait(etha->addr, EAMS, EAMS_OPS_MASK, EAMC_OPC_DISABLE);
>
> -	if (mode == EAMC_OPC_DISABLE)
> +	if (mode == EAMC_OPC_DISABLE) {
>  		rswitch_agent_clock_ctrl(etha->coma_addr, etha->index, 0);
>
> -	return ret;
> +		return ret;
> +	}
> +
> +	iowrite32(mode, etha->addr + EAMC);
> +
> +	return rswitch_reg_wait(etha->addr, EAMS, EAMS_OPS_MASK, mode);

Same pattern here in rswitch_etha_change_mode(). When mode !=
EAMC_OPC_DISABLE, the return value from rswitch_reg_wait() for the
intermediate DISABLE transition is stored in 'ret' but never checked.

Before this patch, rswitch_etha_hw_init() explicitly called
rswitch_etha_change_mode(etha, EAMC_OPC_DISABLE) with error checking before
calling it with EAMC_OPC_CONFIG. This patch removes that caller-side check
but doesn't replicate it inside the function. Should there be a check like
'if (ret < 0) return ret;' after the first rswitch_reg_wait()?

>  }
>
>  static void rswitch_etha_read_mac_address(struct rswitch_etha *etha)

[ ... ]


  reply	other threads:[~2026-04-02 12:59 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-31 10:03 [net-next PATCH v3 00/13] net: renesas: rswitch: R-Car S4 add VLAN aware switching Michael Dege
2026-03-31 10:03 ` [PATCH net-next v3 01/13] net: renesas: rswitch: improve port change mode functions Michael Dege
2026-04-02 12:59   ` Paolo Abeni [this message]
2026-03-31 10:03 ` [PATCH net-next v3 02/13] net: renesas: rswitch: use device instead of net_device Michael Dege
2026-03-31 10:03 ` [PATCH net-next v3 03/13] net: renesas: rswitch: fix FWPC2 register access macros Michael Dege
2026-03-31 10:03 ` [PATCH net-next v3 04/13] net: renesas: rswitch: add register definitions for vlan support Michael Dege
2026-04-02 12:59   ` [net-next,v3,04/13] " Paolo Abeni
2026-04-02 13:02   ` [PATCH net-next v3 04/13] " Paolo Abeni
2026-03-31 10:03 ` [PATCH net-next v3 05/13] net: renesas: rswitch: add exception path for packets with unknown dst MAC Michael Dege
2026-04-02 12:59   ` [net-next,v3,05/13] " Paolo Abeni
2026-03-31 10:04 ` [PATCH net-next v3 06/13] net: renesas: rswitch: add forwarding rules for gwca Michael Dege
2026-04-02 12:59   ` [net-next,v3,06/13] " Paolo Abeni
2026-03-31 10:04 ` [PATCH net-next v3 07/13] net: renesas: rswitch: make helper functions available to whole driver Michael Dege
2026-03-31 10:04 ` [PATCH net-next v3 08/13] net: renesas: rswitch: add basic vlan init to rswitch_fwd_init Michael Dege
2026-03-31 10:04 ` [PATCH net-next v3 09/13] net: renesas: rswitch: update port HW init Michael Dege
2026-03-31 10:04 ` [PATCH net-next v3 10/13] net: renesas: rswitch: clean up is_rdev rswitch_device checking Michael Dege
2026-03-31 10:04 ` [PATCH net-next v3 11/13] net: renesas: rswitch: add passing of rswitch_private into notifiers Michael Dege
2026-03-31 10:04 ` [PATCH net-next v3 12/13] net: renesas: rswitch: add handler for FDB notification Michael Dege
2026-04-02 12:59   ` [net-next,v3,12/13] " Paolo Abeni
2026-04-02 13:06   ` [PATCH net-next v3 12/13] " Paolo Abeni
2026-03-31 10:04 ` [PATCH net-next v3 13/13] net: renesas: rswitch: add vlan aware switching Michael Dege
2026-04-02 12:59   ` [net-next,v3,13/13] " Paolo Abeni

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=20260402125912.234434-1-pabeni@redhat.com \
    --to=pabeni@redhat.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=michael.dege@renesas.com \
    --cc=netdev@vger.kernel.org \
    --cc=niklas.soderlund@ragnatech.se \
    --cc=paul@pbarker.dev \
    --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