Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: Prabhakar <prabhakar.csengg@gmail.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
	wsa+renesas@sang-engineering.com
Subject: Re: [PATCH net-next v6 14/15] net: dsa: rzn1-a5psw: Keep MAC TX enabled on RZ/T2H
Date: Thu, 03 Dec 2026 09:35:22 +0000	[thread overview]
Message-ID: <sashiko-outbox-247479@kernel.org> (raw)
In-Reply-To: <20261202093357.15693-15-prabhakar.mahadev-lad.rj@bp.renesas.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] net: dsa: rzn1-a5psw: tx_allowed conflates admin enable and
  STP state
--

commit 199f37d694278c06a0ad4680d71540126836f14a
Author: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

net: dsa: rzn1-a5psw: Keep MAC TX enabled on RZ/T2H

This commit keeps CMD_CFG.TX_ENA enabled on SoCs that require it, gating
port transmission through PORT_ENA.TXENA based on link and port state and
pulsing the hardware reset line during probe instead of issuing
CMD_CFG.SW_RESET.

> diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c
> index 03d7f928e3e63..e4fd4425f52ed 100644
> --- a/drivers/net/dsa/rzn1_a5psw.c
> +++ b/drivers/net/dsa/rzn1_a5psw.c
> @@ -133,11 +133,20 @@ static void a5psw_set_learncount(struct a5psw *a5psw, u32 mode)
>  			 FIELD_PREP(A5PSW_LK_LEARNCOUNT_MODE, mode));
>  }
>  
> -static void a5psw_port_tx_enable(struct a5psw *a5psw, int port, bool enable)
> +/* Must be called with reg_lock held */
> +static void a5psw_port_tx_update(struct a5psw *a5psw, int port)
>  {
>  	u32 mask = A5PSW_PORT_ENA_TX(port);
> -	u32 reg = enable ? mask : 0;
> +	u32 reg;
>  
> +	reg = a5psw_reg_readl(a5psw, A5PSW_PORT_ENA) & ~mask;
> +	if (a5psw->tx_allowed & a5psw->link_up & BIT(port))
> +		reg |= mask;
> +	a5psw_reg_writel(a5psw, A5PSW_PORT_ENA, reg);
> +}
> +
> +static void a5psw_port_tx_enable(struct a5psw *a5psw, int port, bool enable)
> +{
>  	/* Even though the port TX is disabled through TXENA bit in the
>  	 * PORT_ENA register, it can still send BPDUs. This depends on the tag
>  	 * configuration added when sending packets from the CPU port to the
> @@ -146,18 +155,38 @@ static void a5psw_port_tx_enable(struct a5psw *a5psw, int port, bool enable)
>  	 * This allows to implement STP support when ports are in a state where
>  	 * forwarding traffic should be stopped but BPDUs should still be sent.
>  	 */
> -	a5psw_reg_rmw(a5psw, A5PSW_PORT_ENA, mask, reg);
> +	spin_lock(&a5psw->reg_lock);
> +
> +	if (enable)
> +		a5psw->tx_allowed |= BIT(port);
> +	else
> +		a5psw->tx_allowed &= ~BIT(port);
> +
> +	a5psw_port_tx_update(a5psw, port);
> +
> +	spin_unlock(&a5psw->reg_lock);
>  }
>  
> -static void a5psw_port_enable_set(struct a5psw *a5psw, int port, bool enable)
> +static void a5psw_port_link_set(struct a5psw *a5psw, int port, bool up)
>  {
> -	u32 port_ena = 0;
> +	spin_lock(&a5psw->reg_lock);
>  
> -	if (enable)
> -		port_ena |= A5PSW_PORT_ENA_TX_RX(port);
> +	if (up)
> +		a5psw->link_up |= BIT(port);
> +	else
> +		a5psw->link_up &= ~BIT(port);
> +
> +	a5psw_port_tx_update(a5psw, port);
>  
> -	a5psw_reg_rmw(a5psw, A5PSW_PORT_ENA, A5PSW_PORT_ENA_TX_RX(port),
> -		      port_ena);
> +	spin_unlock(&a5psw->reg_lock);
> +}
> +
> +static void a5psw_port_enable_set(struct a5psw *a5psw, int port, bool enable)
> +{
> +	u32 rx_mask = BIT(port + A5PSW_PORT_ENA_RX_SHIFT);
> +
> +	a5psw_reg_rmw(a5psw, A5PSW_PORT_ENA, rx_mask, enable ? rx_mask : 0);
> +	a5psw_port_tx_enable(a5psw, port, enable);
>  }

[Severity: Medium]
Does sharing a single a5psw->tx_allowed bitmask between
a5psw_port_enable_set() and a5psw_port_stp_state_set() allow one state to
overwrite the other?

Both callers update a5psw->tx_allowed through a5psw_port_tx_enable().
When a bridged port is in BR_STATE_DISABLED and is brought
administratively up, dsa_port_enable_rt() calls a5psw_port_enable() ->
a5psw_port_enable_set(a5psw, port, true) without changing the port's STP
state (since dp->bridge is set).  That sets BIT(port) in
a5psw->tx_allowed, so when the link comes up, a5psw_phylink_mac_link_up()
-> a5psw_port_link_set() enables A5PSW_PORT_ENA_TX(port) even though the
port is still in BR_STATE_DISABLED (remaining enabled while the bridge
device itself is down, or until linkwatch and deferred switchdev STP work
run).

Conversely, when an administratively down port leaves a bridge,
dsa_port_switchdev_unsync_attrs() resets its STP state to
BR_STATE_FORWARDING via a5psw_port_stp_state_set() ->
a5psw_port_tx_enable(a5psw, port, true), setting BIT(port) in
a5psw->tx_allowed (and immediately enabling A5PSW_PORT_ENA_TX in hardware
when keep_mac_tx_enabled is false) while the port is still
administratively disabled.

Tracking administrative enable and STP forwarding in separate bitmasks
combined in a5psw_port_tx_update() would avoid this.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202093357.15693-1-prabhakar.mahadev-lad.rj@bp.renesas.com?part=14

  reply	other threads:[~2026-12-03  9:35 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  9:33 [PATCH net-next v6 00/15] Add ETHSW support for Renesas RZ/T2H and RZ/N2H SoCs Prabhakar
2026-12-02  9:33 ` [PATCH net-next v6 01/15] net: dsa: tag_rzn1_a5psw: Drop redundant ETH_P_DSA_A5PSW definition Prabhakar
2026-12-02  9:33 ` [PATCH net-next v6 02/15] net: dsa: tag_rzn1_a5psw: Fix RZ/N1 tagger module alias Prabhakar
2026-12-02  9:39   ` Clement Leger
2026-12-02  9:33 ` [PATCH net-next v6 03/15] net: dsa: tag_rzn1_a5psw: Add RZ/T2H ETHSW tag protocol support Prabhakar
2026-12-02  9:33 ` [PATCH net-next v6 04/15] net: pcs: rzn1-miic: Select ETHSW port speed through SWCTRL Prabhakar
2026-12-02  9:33 ` [PATCH net-next v6 05/15] dt-bindings: net: dsa: renesas,rzn1-a5psw: Reject the "ports" node Prabhakar
2026-12-02  9:33 ` [PATCH net-next v6 06/15] dt-bindings: net: dsa: renesas,rzn1-a5psw: Limit port reg values Prabhakar
2026-12-02  9:33 ` [PATCH net-next v6 07/15] dt-bindings: net: dsa: renesas,rzn1-a5psw: Add RZ/T2H and RZ/N2H ETHSW support Prabhakar
2026-12-03  9:35   ` sashiko-bot
2026-12-02  9:33 ` [PATCH net-next v6 08/15] net: dsa: rzn1-a5psw: Add support for optional reset control Prabhakar
2026-12-02  9:33 ` [PATCH net-next v6 09/15] net: dsa: rzn1-a5psw: Add support for optional timestamp clock Prabhakar
2026-12-02  9:33 ` [PATCH net-next v6 10/15] net: dsa: rzn1-a5psw: Make use dev_err_probe() Prabhakar
2026-12-02  9:33 ` [PATCH net-next v6 11/15] net: dsa: rzn1-a5psw: Get switch configuration from OF data Prabhakar
2026-12-02  9:33 ` [PATCH net-next v6 12/15] net: dsa: rzn1-a5psw: Add fixed frame length workaround for management port Prabhakar
2026-12-02  9:42   ` Clement Leger
2026-12-02  9:33 ` [PATCH net-next v6 13/15] net: dsa: rzn1-a5psw: Get register layout from OF data Prabhakar
2026-12-02  9:37   ` Clement Leger
2026-12-02  9:33 ` [PATCH net-next v6 14/15] net: dsa: rzn1-a5psw: Keep MAC TX enabled on RZ/T2H Prabhakar
2026-12-03  9:35   ` sashiko-bot [this message]
2026-12-02  9:33 ` [PATCH net-next v6 15/15] net: dsa: rzn1-a5psw: Add support for RZ/T2H Ethernet switch Prabhakar
2026-12-02  9:38   ` Clement Leger
2026-12-02  9:40 ` [PATCH net-next v6 00/15] Add ETHSW support for Renesas RZ/T2H and RZ/N2H SoCs 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=sashiko-outbox-247479@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=prabhakar.csengg@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wsa+renesas@sang-engineering.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