Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: saivarun@couthit.com
Cc: danishanwar@ti.com, parvathi@couthit.com, rogerq@kernel.org,
	pmohan@couthit.com, vadim.fedorenko@linux.dev,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, afd@ti.com,
	basharath@couthit.com, arnd@arndb.de, haokexin@gmail.com,
	linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, pratheesh@ti.com, vigneshr@ti.com,
	praneeth@ti.com, srk@ti.com, j-rameshbabu@ti.com,
	m-malladi@ti.com, rogerq@ti.com, krishna@couthit.com,
	mohan@couthit.com
Subject: Re: [PATCH net-next v6 1/3] net: ti: icssm-prueth: Add HSR and PRP HW offload mode support for AM57xx, AM437x and AM335x
Date: Tue, 17 Nov 2026 15:05:13 +0000	[thread overview]
Message-ID: <179492791328.3136.13687380666945826943@kernel.org> (raw)
In-Reply-To: <20261113143127.282466-2-saivarun@couthit.com>

Thank you for your contribution! Sashiko AI review found 8 potential
issue(s) to consider.

Critical: 0 · High: 0 (1) · Medium: 5 · Low: 3

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] In PRP mode with ports running, the firmware MAC address for
  slave B gets out of sync with ndev->dev_addr, and…
- [Medium] icssm_prueth_hsr_port_link() counts every prueth port linked
  under an HSR master into hsr_members, whatever its HSR port type.
- [Medium] icssm_emac_ndo_set_rx_mode() picks the multicast-table lock
  from prueth->eth_type without synchronization: prueth->addr_lock if…
- [Medium] The PRU firmware supervision address is hard-coded to
  01:15:4E:00:01:00.
- [Medium] net: ti: icssm-prueth: broken rollback in
  icssm_prueth_change_mode()
- [Low] icssm_emac_ndo_fix_features() writes ndev->wanted_features
  (`ndev->wanted_features |= NETIF_PRUETH_LRE_OFFLOAD_FEATURES` and `&=…
- [Low] The patch adds `.ndo_set_mac_address = eth_mac_addr` and
  `.ndo_validate_addr = eth_validate_addr` to emac_netdev_ops, which…
- [Low] The commit message does not match the feature semantics in a few
  places.

Pre-existing issues:
- [High] icssm_prueth_change_mode() calls ndo_stop() and then ndo_open()
  directly on ports that are netif_running().

--

net: ti: icssm-prueth: Add HSR and PRP HW offload mode support for AM57xx, AM437x and AM335x

This commit adds HSR and PRP firmware offload modes to the ICSSM PRUETH
driver on AM335x, AM437x and AM57xx. When both PRU ports join an hsr
master with the LRE offload features enabled, the driver switches the PRU
firmware to HSR or PRP mode. It also adds LRE table and timer setup, RX
tag handling and feature negotiation callbacks.

> To switch from dual-EMAC to PRP (example: eth2 and eth3 as slave raw
> ports):
>
> $ ip link set eth2 down && ip link set eth3 down
> $ ip link set eth2 address <mac-addr>
> $ ip link set eth3 address <mac-addr>
> $ ethtool -K eth2 hsr-tag-rm-offload on
> $ ethtool -K eth3 hsr-tag-rm-offload on

[Severity: Low]
This isn't a bug, but does the PRP recipe match what the driver does?

icssm_emac_ndo_fix_features() couples the LRE bits. Requesting only
hsr-tag-rm-offload also forces NETIF_F_HW_HSR_FWD on and writes it into
wanted_features. Later in the series NETIF_F_HW_HSR_DUP is forced on too.
So PRP ports will always report hsr-fwd-offload as enabled.

The changelog also doesn't mention two cases where, with offload enabled,
icssm_prueth_hsr_port_link() returns -EOPNOTSUPP from NETDEV_CHANGEUPPER:
an hsr version other than HSR_V1/PRP_V1, or a peer port without the
features. In both cases creating the hsr device fails outright instead of
falling back to software HSR.

Could the commit message describe this behaviour?

> diff --git a/drivers/net/ethernet/ti/icssm/icssm_prueth.c b/drivers/net/ethernet/ti/icssm/icssm_prueth.c
> index 1aadef061e923..4f631dcc4d509 100644
> --- a/drivers/net/ethernet/ti/icssm/icssm_prueth.c
> +++ b/drivers/net/ethernet/ti/icssm/icssm_prueth.c

[ ... ]

> @@ -1371,8 +1454,18 @@ static void icssm_emac_ndo_set_rx_mode(struct net_device *ndev)
>  	sram = prueth->mem[PRUETH_MEM_SHARED_RAM].va;
>  	reg = readl(sram + EMAC_PROMISCUOUS_MODE_OFFSET);
>
> +	/* In LRE mode, the HSR core syncs the master's multicast list and
> +	 * IFF_ALLMULTI to both slaves. Settings applied to a single slave are
> +	 * not merged into the shared filter, so configure them on the HSR
> +	 * master instead.
> +	 */
> +	if (prueth_is_lre(prueth))
> +		mc_filter_tbl_lock = &prueth->addr_lock;
> +	else
> +		mc_filter_tbl_lock = &emac->addr_lock;
> +
>  	/* It is a shared table. So lock the access */
> -	spin_lock_irqsave(&emac->addr_lock, flags);
> +	spin_lock_irqsave(mc_filter_tbl_lock, flags);

[Severity: Medium]
Is prueth->eth_type stable at this point? icssm_prueth_change_mode()
writes eth_type, and ndo_open rewrites prueth->fw_offsets through
icssm_prueth_set_fw_offsets(). Both run under RTNL only and take neither
addr_lock.

This driver uses the synchronous __dev_set_rx_mode() path. That means
ndo_set_rx_mode can run from dev_mc_add() callers that don't hold RTNL,
for example igmp6_group_added() reached through IPV6_ADD_MEMBERSHIP on a
slave.

During an EMAC to HSR/PRP transition, could one slave hold
emac->addr_lock while it writes the shared DRAM1 table, while the other
slave holds prueth->addr_lock?

The helpers icssm_emac_mc_filter_ctrl(), icssm_emac_mc_filter_reset(),
icssm_emac_mc_filter_hashmask() and icssm_emac_mc_filter_bin_update()
also each re-read prueth_is_lre() and prueth->fw_offsets. Consider the
window between the eth_type update in change_mode and
icssm_prueth_set_fw_offsets() in ndo_open. Could a call in that window
write the EMAC filter layout into DRAM1 while the LRE firmware, whose
filter is at different offsets, is loaded?

[ ... ]

> @@ -1429,15 +1522,126 @@ static void icssm_emac_ndo_set_rx_mode(struct net_device *ndev)
>  	}
>
>  unlock:
> -	spin_unlock_irqrestore(&emac->addr_lock, flags);
> +	spin_unlock_irqrestore(mc_filter_tbl_lock, flags);
> +}
> +
> +static netdev_features_t icssm_emac_ndo_fix_features(struct net_device *ndev,
> +						     netdev_features_t features)
> +{
> +	/* hsr tag removal offload and hsr fwd offload are tightly coupled in
> +	 * firmware implementation. Both these features need to be enabled /
> +	 * disabled together.
> +	 */
> +	if (!(ndev->features & NETIF_PRUETH_LRE_OFFLOAD_FEATURES)) {
> +		if ((features & NETIF_F_HW_HSR_FWD) ||
> +		    (features & NETIF_F_HW_HSR_TAG_RM)) {
> +			features |= NETIF_PRUETH_LRE_OFFLOAD_FEATURES;
> +			ndev->wanted_features |=
> +				NETIF_PRUETH_LRE_OFFLOAD_FEATURES;
> +		}
> +	}

[Severity: Low]
Documentation/networking/netdev-features.rst says ndo_fix_features
should not modify hardware or driver state (it should be stateless). It
also says it is safer to disable a feature whose dependencies are not
met than to force the dependency on.

This callback writes ndev->wanted_features, forces the other LRE bit on,
and its result depends on the current ndev->features.
icssm_emac_ndo_set_features() then has to undo the wanted_features
change on its error path.

Could the coupling be done by clearing the unmet bit, without touching
wanted_features?

[ ... ]

>  static const struct net_device_ops emac_netdev_ops = {
>  	.ndo_open = icssm_emac_ndo_open,
>  	.ndo_stop = icssm_emac_ndo_stop,
>  	.ndo_start_xmit = icssm_emac_ndo_start_xmit,
> +	.ndo_set_mac_address = eth_mac_addr,
> +	.ndo_validate_addr = eth_validate_addr,

[Severity: Low]
This isn't a bug, but every operating mode shares these ops. Changing
the MAC on a stopped port now also succeeds in plain dual-EMAC and
switch modes, where it used to return -EOPNOTSUPP.

Should the commit message mention this new capability? Should it also
say whether the two slaves need the same address for HSR/PRP?

[ ... ]

> @@ -1742,6 +1949,111 @@ static int icssm_prueth_ndev_port_unlink(struct net_device *ndev)
>  	return ret;
>  }
>
> +static int icssm_prueth_hsr_port_link(struct net_device *ndev,
> +				      struct net_device *hsr_ndev)
> +{

[ ... ]

> +	/* Reject HSR/PRP offload if the peer port does not have the offload
> +	 * features enabled.
> +	 */
> +	if (other_emac &&
> +	    !(other_emac->ndev->features & NETIF_PRUETH_LRE_OFFLOAD_FEATURES))
> +		return -EOPNOTSUPP;
> +
> +	spin_lock_irqsave(&prueth->addr_lock, flags);
> +
> +	if (!prueth->hsr_members) {
> +		prueth->hsr_dev = hsr_ndev;
> +	} else {
> +		/* Adding the port to a second master is not supported */
> +		if (prueth->hsr_dev != hsr_ndev) {
> +			spin_unlock_irqrestore(&prueth->addr_lock, flags);
> +			return -EOPNOTSUPP;
> +		}
> +	}
> +
> +	prueth->hsr_members |= BIT(emac->port_id);
> +
> +	spin_unlock_irqrestore(&prueth->addr_lock, flags);
> +
> +	if (!prueth_is_lre(prueth) && prueth->hsr_members == all_slaves) {
> +		ret = icssm_prueth_change_mode(prueth, mode);

[Severity: Medium]
What state is prueth left in when icssm_prueth_change_mode() fails here?

By the time change_mode() starts calling ndo_open(), it has already
called ndo_stop() on every running port and set prueth->eth_type to HSR
or PRP. A missing pruhsr or pruprp firmware, for example, makes
icssm_prueth_sw_boot_prus() fail, and change_mode() then returns
straight away. At that point:

- eth_type is not restored.
- A port that was already re-opened keeps running the LRE firmware.
- The failed port has its NAPI disabled and its rx_irq freed, but
  netif_running() is still true.

The free_hsr path only clears this port's bit in hsr_members. It does
not touch eth_type or hsr_dev, so prueth_is_lre() stays true.

The hsr core then unwinds hsr_dev_finalize() by unlinking the first
slave. icssm_prueth_hsr_port_unlink() sees prueth_is_lre() with
hsr_members == 0 and calls icssm_prueth_change_mode(EMAC). That runs
icssm_emac_ndo_stop() a second time on the port that was never
re-opened.

Wouldn't that block forever in napi_disable(&emac->napi) with RTNL
held? It would also call free_irq(emac->rx_irq, ndev) on an IRQ that
was already freed. Even without the unwind, a later dev_close() of
that port would hit the same double stop.

Should change_mode() restore the previous eth_type and re-open the
ports in the old mode when ndo_open() fails? Or should the free_hsr
path here revert to dual-EMAC itself, so that hsr_port_unlink() does
not attempt a second mode change on half-opened ports?

[Severity: Medium]
Does this also count a port that is linked as the RedBox interlink?
hsr_portdev_setup() links interlink ports with
netdev_master_upper_dev_link() too. So this notifier sees
is_hsr_master() for HSR_PT_INTERLINK ports as well.

Take a configuration like this one, where eth2 and eth3 are both prueth
ports with offload enabled:

  ip link add name hsr0 type hsr slave1 eth2 slave2 Y interlink eth3

hsr_members would reach all_slaves when hsr_dev_finalize() adds the
interlink, and change_mode(HSR) would run. The firmware would then run
an HSR ring between eth2 and the interlink port. It would forward and
duplicate HSR-tagged frames onto the SAN side. At the same time the hsr
core keeps doing software forwarding, because fwd_offloaded is false
for Y.

The peer-feature check above pushes users to enable offload on both
ports. Should the hsr port type be checked before updating hsr_members?

[ ... ]

> +static int icssm_prueth_hsr_port_unlink(struct net_device *ndev)
> +{
> +	struct prueth_emac *emac = netdev_priv(ndev);
> +	struct prueth *prueth = emac->prueth;
> +	unsigned long flags;
> +	int ret = 0;
> +
> +	spin_lock_irqsave(&prueth->addr_lock, flags);
> +
> +	prueth->hsr_members &= ~BIT(emac->port_id);
> +
> +	spin_unlock_irqrestore(&prueth->addr_lock, flags);
> +
> +	if (prueth_is_lre(prueth) && !prueth->hsr_members) {
> +		ret = icssm_prueth_change_mode(prueth, PRUSS_ETHTYPE_EMAC);
> +		if (ret < 0)
> +			dev_err(prueth->dev, "Failed to enable dual EMAC mode\n");
> +	}

[Severity: High]
This is a pre-existing issue in icssm_prueth_change_mode(), but this
patch adds a new way to reach it, inside the hsr device creation
rollback.

change_mode() calls ndo_stop() and ndo_open() directly on running ports
and returns on the first ndo_open() failure. The failed port, and any
port not yet re-opened, keeps IFF_UP but has no resources: no IRQ, NAPI
disabled, PHY stopped and PRUs not booted.

Consider eth2 and eth3 up with LRE offload enabled and the pruhsr
firmware missing:

hsr_dev_finalize()
  hsr_add_port(slave[1])
    icssm_prueth_hsr_port_link()
      icssm_prueth_change_mode(HSR)
        ndo_stop(eth2), ndo_stop(eth3)
        eth_type = HSR
        ndo_open(eth2) fails in icssm_prueth_sw_boot_prus()
  err_unregister:
    hsr_del_ports()
      hsr_del_port(slave A)
        netdev_upper_dev_unlink()
          icssm_prueth_hsr_port_unlink()
            icssm_prueth_change_mode(EMAC)
              ndo_stop(eth2)    <-- nothing left to tear down

Can this second icssm_emac_ndo_stop() spin forever with RTNL held? Its
napi_disable(&emac->napi) runs on a NAPI that is already disabled.
phy_stop() would also warn on this path.

Could change_mode() track which ports it actually re-opened, or could
ndo_stop() cope with a port whose open failed?

[ ... ]

> @@ -1749,13 +2061,27 @@ static int icssm_prueth_ndev_event(struct notifier_block *unused,
>  	struct netdev_notifier_changeupper_info *info;
>  	int ret = NOTIFY_DONE;
>
> -	if (!icssm_prueth_sw_port_dev_check(ndev))
> +	if (ndev->netdev_ops != &emac_netdev_ops)
>  		return NOTIFY_DONE;
>
>  	switch (event) {
>  	case NETDEV_CHANGEUPPER:
>  		info = ptr;
> +		if (is_hsr_master(info->upper_dev)) {
> +			if (info->linking) {
> +				if (ndev->features &
> +				    NETIF_PRUETH_LRE_OFFLOAD_FEATURES)
> +					ret = icssm_prueth_hsr_port_link
> +						(ndev, info->upper_dev);
> +			} else {
> +				ret = icssm_prueth_hsr_port_unlink(ndev);
> +			}
> +		}

[Severity: Medium]
In PRP mode with the ports running, can the firmware MAC for slave B
drift from ndev->dev_addr? The default case of this switch ignores
NETDEV_CHANGEADDR.

At creation, hsr_dev_finalize() adds slave B first. That runs
icssm_prueth_hsr_port_link()->icssm_prueth_change_mode(PRP), and
ndo_open copies the old dev_addr into emac->mac_addr and PORT_MAC_ADDR.
Only after that does hsr_dev_finalize() run:

	eth_hw_addr_set(slave[1], slave[0]->dev_addr);
	call_netdevice_notifiers(NETDEV_CHANGEADDR, slave[1]);

At deletion, hsr_del_port() unlinks slave B first. So
icssm_prueth_hsr_port_unlink()->icssm_prueth_change_mode(EMAC) re-opens
the ports while slave B still has slave A's MAC. Only then does it
restore port->original_macaddress and send NETDEV_CHANGEADDR.

After a PRP device is deleted, wouldn't the port B dual-EMAC firmware
keep filtering unicast on slave A's MAC? Frames to eth3's real address
would then be dropped until the interface is bounced. The recipe in the
commit message brings the ports down first, but nothing enforces that.

[ ... ]

> diff --git a/drivers/net/ethernet/ti/icssm/icssm_prueth_lre.c b/drivers/net/ethernet/ti/icssm/icssm_prueth_lre.c
> new file mode 100644
> index 0000000000000..9e84244e0649d
> --- /dev/null
> +++ b/drivers/net/ethernet/ti/icssm/icssm_prueth_lre.c

[ ... ]

> +static void icssm_prueth_lre_protocol_init(struct prueth *prueth)
> +{

[ ... ]

> +	/* PRU firmware matches supervision frames on 01:15:4E:00:01 only
> +	 * and forwards them to the host, bypassing the multicast filter.
> +	 */
> +	writel(ICSS_LRE_SUP_ADDRESS_INIT_OCTETS_HIGH,
> +	       dram1 + ICSS_LRE_SUP_ADDR);
> +	writel(ICSS_LRE_SUP_ADDRESS_INIT_OCTETS_LOW,
> +	       dram1 + ICSS_LRE_SUP_ADDR_LOW);

[Severity: Medium]
This writes a fixed 01:15:4E:00:01:00 whatever the hsr device's
supervision address is. The last byte of that address comes from the
supervision option. The commit message example uses supervision 45,
which gives 01:15:4E:00:01:2D.

In offload mode the hsr core doesn't make the slaves promiscuous and
doesn't add the supervision address to the slave mc lists. The driver
also ignores IFF_PROMISC in LRE mode.

The comment says the firmware matches 5 bytes. If it actually compares
the full 6-byte value written here, would supervision frames for any
non-zero supervision value be dropped by the LRE multicast filter?

Should the configured supervision address be programmed here, or could
the comment confirm how many bytes the firmware compares?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113143127.282466-1-saivarun%40couthit.com


  reply	other threads:[~2026-11-17 15:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 14:28 [PATCH net-next v6 0/3] Introduce HSR/PRP HW offload support for PRU-ICSSM Ethernet driver Sai Varun Mudepally
2026-11-13 14:28 ` [PATCH net-next v6 1/3] net: ti: icssm-prueth: Add HSR and PRP HW offload mode support for AM57xx, AM437x and AM335x Sai Varun Mudepally
2026-11-17 15:05   ` netdev-bot+sashiko [this message]
2026-11-13 14:28 ` [PATCH net-next v6 2/3] net: ti: icssm-prueth: Add priority based RX IRQ handlers Sai Varun Mudepally
2026-11-17 15:05   ` netdev-bot+sashiko
2026-11-13 14:28 ` [PATCH net-next v6 3/3] net: ti: icssm-prueth: Support duplicate HW offload feature for HSR and PRP Sai Varun Mudepally
2026-11-17 15:05   ` netdev-bot+sashiko

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=179492791328.3136.13687380666945826943@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=afd@ti.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=arnd@arndb.de \
    --cc=basharath@couthit.com \
    --cc=danishanwar@ti.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=haokexin@gmail.com \
    --cc=j-rameshbabu@ti.com \
    --cc=krishna@couthit.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m-malladi@ti.com \
    --cc=mohan@couthit.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=parvathi@couthit.com \
    --cc=pmohan@couthit.com \
    --cc=praneeth@ti.com \
    --cc=pratheesh@ti.com \
    --cc=rogerq@kernel.org \
    --cc=rogerq@ti.com \
    --cc=saivarun@couthit.com \
    --cc=srk@ti.com \
    --cc=vadim.fedorenko@linux.dev \
    --cc=vigneshr@ti.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