From: sashiko-bot@kernel.org
To: "Wei Fang" <wei.fang@nxp.com>
Cc: Frank.Li@kernel.org, robh@kernel.org, conor+dt@kernel.org,
devicetree@vger.kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH v8 net-next 11/15] net: dsa: netc: add phylink MAC operations
Date: Tue, 19 May 2026 08:25:36 +0000 [thread overview]
Message-ID: <20260519082537.4A3FDC2BCF5@smtp.kernel.org> (raw)
In-Reply-To: <20260518082506.1318236-12-wei.fang@nxp.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The `netc_mac_port_rmw()` function can silently fail to synchronize the pMAC and eMAC registers due to a flawed early return optimization.
- [High] The `netc_port_mac_tx_graceful_stop()` function fails to wait for the switch port to become idle (`PSR_TX_BUSY`), risking trapped data and FIFO overflows.
- [High] Missing MAC-level speed, duplex, and PCS configuration for SGMII and 2500BASE-X interfaces renders them non-functional.
--
commit 1c39a10b5175a16ff2753fc6b076dd4c1bbc15de
Author: Wei Fang <wei.fang@nxp.com>
net: dsa: netc: add phylink MAC operations
This commit adds .phylink_get_caps() to struct netc_switch_info to handle
different numbers of ports and MAC capabilities across NETC switch versions.
It implements the phylink_mac_ops callbacks .mac_config(), .mac_link_up(),
and .mac_link_down().
> diff --git a/drivers/net/dsa/netc/netc_main.c b/drivers/net/dsa/netc/netc_main.c
> index 8e3a3230226c3..2141b3aa96b7a 100644
> --- a/drivers/net/dsa/netc/netc_main.c
> +++ b/drivers/net/dsa/netc/netc_main.c
[ ... ]
> +static void netc_mac_port_rmw(struct netc_port *np, u32 reg,
> + u32 mask, u32 val)
> +{
> + u32 old, new;
> +
> + if (is_netc_pseudo_port(np))
> + return;
> +
> + WARN_ON((mask | val) != mask);
> +
> + old = netc_port_rd(np, reg);
> + new = (old & ~mask) | val;
> + if (new == old)
> + return;
Does this early return prevent the pMAC register from synchronizing correctly
if the bootloader or previous state left the eMAC and pMAC desynchronized?
Since old is read exclusively from the eMAC, if the new value matches the
eMAC's current value but the pMAC's state differs, returning early skips writing
to the pMAC register entirely. This could leave the preemptable MAC operating
with incorrect settings.
> +
> + netc_port_wr(np, reg, new);
> + if (np->caps.pmac)
> + netc_port_wr(np, reg + NETC_PMAC_OFFSET, new);
> +}
[ ... ]
> +static void netc_port_mac_tx_graceful_stop(struct netc_port *np)
> +{
> + netc_port_rmw(np, NETC_POR, POR_TXDIS, POR_TXDIS);
> +
> + if (is_netc_pseudo_port(np))
> + return;
> +
> + netc_port_wait_tx_empty(np, 0);
Could this disable the MAC TX prematurely, trapping data in the pipeline?
The code disables the Switch Port from feeding new data and then waits for the
MAC TX FIFO to empty. However, it doesn't wait for the Switch Port to finish
pushing its current data into the MAC (PSR_TX_BUSY == 1).
If the MAC momentarily drains its FIFO to the wire faster than the port fills
it, PM_IEVENT_TX_EMPTY might briefly read true while the port is still
actively transmitting data into the MAC.
Should we poll !(val & PSR_TX_BUSY) from NETC_PSR immediately after setting
POR_TXDIS, similar to how the RX path waits for PSR_RX_BUSY before disabling
the port?
> + if (np->caps.pmac)
> + netc_port_wait_tx_empty(np, 1);
> +
> + netc_mac_port_rmw(np, NETC_PM_CMD_CFG(0), PM_CMD_CFG_TX_EN, 0);
> +}
[ ... ]
> +static void netc_mac_link_up(struct phylink_config *config,
> + struct phy_device *phy, unsigned int mode,
> + phy_interface_t interface, int speed,
> + int duplex, bool tx_pause, bool rx_pause)
> +{
> + struct dsa_port *dp = dsa_phylink_to_port(config);
> + struct netc_port *np;
> +
> + np = NETC_PORT(dp->ds, dp->index);
> + netc_port_set_speed(np, speed);
> +
> + if (phy_interface_mode_is_rgmii(interface))
> + netc_port_set_rgmii_mac(np, speed, duplex);
> +
> + if (interface == PHY_INTERFACE_MODE_RMII ||
> + interface == PHY_INTERFACE_MODE_REVMII ||
> + interface == PHY_INTERFACE_MODE_MII)
> + netc_port_set_rmii_mii_mac(np, speed, duplex);
Are SGMII and 2500BASE-X interfaces left unconfigured at the MAC level?
The driver advertises support for PHY_INTERFACE_MODE_SGMII and
PHY_INTERFACE_MODE_2500BASEX in imx94_switch_phylink_get_caps(), including
10/100 half-duplex capabilities for SGMII.
However, MAC-level speed and duplex configurations are bypassed here for SGMII
and 2500BASE-X, and the driver doesn't implement the .mac_select_pcs callback
nor configure in-band autonegotiation. Without these, the interfaces might fail
to establish a correct link, especially at lower speeds or half-duplex.
> +
> + netc_port_mac_tx_enable(np);
> + netc_port_mac_rx_enable(np);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260518082506.1318236-1-wei.fang@nxp.com?part=11
next prev parent reply other threads:[~2026-05-19 8:25 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 8:24 [PATCH v8 net-next 00/15] Add preliminary NETC switch support for i.MX94 Wei Fang
2026-05-18 8:24 ` [PATCH v8 net-next 01/15] dt-bindings: net: dsa: update the description of 'dsa,member' property Wei Fang
2026-05-18 8:24 ` [PATCH v8 net-next 02/15] dt-bindings: net: dsa: add NETC switch Wei Fang
2026-05-19 8:25 ` sashiko-bot
2026-05-18 8:24 ` [PATCH v8 net-next 03/15] net: enetc: add pre-boot initialization for i.MX94 switch Wei Fang
2026-05-18 8:24 ` [PATCH v8 net-next 04/15] net: enetc: add basic operations to the FDB table Wei Fang
2026-05-18 8:24 ` [PATCH v8 net-next 05/15] net: enetc: add support for the "Add" operation to VLAN filter table Wei Fang
2026-05-18 8:24 ` [PATCH v8 net-next 06/15] net: enetc: add support for the "Update" operation to buffer pool table Wei Fang
2026-05-18 8:24 ` [PATCH v8 net-next 07/15] net: enetc: add support for "Add" and "Delete" operations to IPFT Wei Fang
2026-05-18 8:24 ` [PATCH v8 net-next 08/15] net: enetc: add multiple command BD rings support Wei Fang
2026-05-18 8:25 ` [PATCH v8 net-next 09/15] net: dsa: add NETC switch tag support Wei Fang
2026-05-19 8:25 ` sashiko-bot
2026-05-19 9:23 ` Wei Fang
2026-05-18 8:25 ` [PATCH v8 net-next 10/15] net: dsa: netc: introduce NXP NETC switch driver for i.MX94 Wei Fang
2026-05-19 8:25 ` sashiko-bot
2026-05-19 9:34 ` Wei Fang
2026-05-18 8:25 ` [PATCH v8 net-next 11/15] net: dsa: netc: add phylink MAC operations Wei Fang
2026-05-19 8:25 ` sashiko-bot [this message]
2026-05-19 10:00 ` Wei Fang
2026-05-18 8:25 ` [PATCH v8 net-next 12/15] net: dsa: netc: add FDB, STP, MTU, port setup and host flooding support Wei Fang
2026-05-19 8:25 ` sashiko-bot
2026-05-19 9:42 ` Wei Fang
2026-05-18 8:25 ` [PATCH v8 net-next 13/15] net: dsa: netc: initialize buffer pool table and implement flow-control Wei Fang
2026-05-18 8:25 ` [PATCH v8 net-next 14/15] net: dsa: netc: add support for the standardized counters Wei Fang
2026-05-19 8:25 ` sashiko-bot
2026-05-19 10:08 ` Wei Fang
2026-05-18 8:25 ` [PATCH v8 net-next 15/15] net: dsa: netc: add support for ethtool private statistics Wei Fang
2026-05-19 8:25 ` sashiko-bot
2026-05-19 10:07 ` Wei Fang
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=20260519082537.4A3FDC2BCF5@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=imx@lists.linux.dev \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wei.fang@nxp.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