Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: coiaprant@gmail.com
Cc: kuba@kernel.org, pabeni@redhat.com, jiawenwu@trustnetic.com,
	mengyuanlou@net-swift.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, hkallweit1@gmail.com,
	linux@armlinux.org.uk, heiko@sntech.de,
	aleksandr.loktionov@intel.com, fabio.baltieri@gmail.com,
	netdev@vger.kernel.org, linux-rockchip@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v4 2/2] net: pcs: xpcs: make supported_interfaces authoritative
Date: Fri, 13 Nov 2026 04:06:42 +0000	[thread overview]
Message-ID: <179454280276.2199510.48600645261637152@kernel.org> (raw)
In-Reply-To: <20261110160554.918652-3-coiaprant@gmail.com>

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

Critical: 0 · High: 0 · Medium: 1 · Low: 2

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] The commit message overstates what the core hunk fixes.
- [Low] The commit message leaves out the behaviour change that actually
  matters.
- [Low] xpcs_rk_create() puts PHY_INTERFACE_MODE_QSGMII into the platform
  mask, and its comment says "The RK3568 XPCS supports 1000BASE-X, SGMII…

--

net: pcs: xpcs: make supported_interfaces authoritative

This commit makes xpcs_find_compat() return NULL for any interface that
is not set in pcs.supported_interfaces. It also narrows the Rockchip
XPCS mask in xpcs_rk_create(). It does this by intersecting the mask
with a platform mask of 1000BASE-X, SGMII and QSGMII.

> However, xpcs_find_compat() only walks desc->compat[] and does not look
> at pcs.supported_interfaces. If a caller ever passes an interface
> outside the mask, the core would still find and configure a compat
> entry for it, contradicting the mask the glue already set. This was a
> known gap: the mask was written but never consulted by the core.

[Severity: Medium]
Does this describe the code as it was before this patch?

In the core, only xpcs_create() writes pcs.supported_interfaces. It does
so through xpcs_get_interfaces(), which builds the mask from the same
table that xpcs_find_compat() walks:

drivers/net/pcs/pcs-xpcs.c:xpcs_get_interfaces() {
	for (compat = xpcs->desc->compat; compat->supported; compat++)
		__set_bit(compat->interface, interfaces);
}

For every existing user, a set bit and a compat entry mean the same
thing. The new test_bit() in xpcs_find_compat() therefore can't reject
anything.

Before this patch, xpcs_rk_create() didn't touch pcs.supported_interfaces
either. So no mask had been "already set" by the glue. This same patch
adds the narrowing.

phylink also already checks the mask before it uses the PCS:

drivers/net/phy/phylink.c:phylink_validate_mac_and_pcs() {
    ...
		if (!phy_interface_empty(pcs->supported_interfaces) &&
		    !test_bit(state->interface, pcs->supported_interfaces)) {
			phylink_err(pl, "MAC returned PCS which does not support %s\n",
				    phy_modes(state->interface));
			return -EINVAL;
		}
    ...
}

The only path that skips phylink seems to be the exported
xpcs_get_an_mode(). It is called from stmmac_init_phy() with
plat->phy_interface. On RK that is always SGMII, which stays in the
mask.

Could the commit message say that the xpcs_find_compat() change is
defensive, and that the behaviour change comes from the glue narrowing
the mask?

> diff --git a/drivers/net/pcs/pcs-xpcs-rk.c b/drivers/net/pcs/pcs-xpcs-rk.c
> index 6f0a110e32d24..b14b55dbd26cc 100644
> --- a/drivers/net/pcs/pcs-xpcs-rk.c
> +++ b/drivers/net/pcs/pcs-xpcs-rk.c

[ ... ]

> @@ -536,6 +537,15 @@ struct dw_xpcs *xpcs_rk_create(struct device *dev, struct device_node *pcs, int
>  		return xpcs;
>  	}
>  
> +	/*
> +	 * The RK3568 XPCS supports 1000BASE-X, SGMII and QSGMII.
> +	 */
> +	__set_bit(PHY_INTERFACE_MODE_1000BASEX, supported_interfaces);
> +	__set_bit(PHY_INTERFACE_MODE_SGMII, supported_interfaces);
> +	__set_bit(PHY_INTERFACE_MODE_QSGMII, supported_interfaces);

[Severity: Low]
Should QSGMII be in this mask?

synopsys_xpcs_compat[] has no QSGMII entry. phy_interface_and() always
clears this bit, so it is dead code today.

The commit message says the glue "will automatically pick it up" once
the core supports QSGMII. However, nothing in the RK integration seems
to handle QSGMII:

- pcs-xpcs-rk.c only calls phy_init() and phy_power_on() on the SerDes.
  It never sets a SerDes mode for each interface.
- rk_gmac_probe() only installs rk_pcs_init() and rk_select_pcs() when
  plat_dat->phy_interface is PHY_INTERFACE_MODE_SGMII.
- rk_gmac_check_ops() and rk_gmac_powerup() only accept RGMII*, RMII
  and SGMII.

Another integration might later need a QSGMII entry in
synopsys_xpcs_compat[]. In that case the bit would survive here, and
stmmac_phylink_setup() would OR it into phylink's supported_interfaces
for dwmac-rk.

Would phylink then be able to select QSGMII, even though neither the
SerDes nor the MAC glue is set up for it?

> +	phy_interface_and(xpcs->pcs.supported_interfaces, xpcs->pcs.supported_interfaces,
> +			  supported_interfaces);

[Severity: Low]
Should the commit message mention that this narrowing changes the
phylink configuration of dwmac-rk?

rk_pcs_init() stores this XPCS in priv->hw->xpcs. stmmac_phylink_setup()
then ORs its mask into phylink's interface masks:

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:stmmac_phylink_setup() {
    ...
	if (pcs)
		phy_interface_or(config->supported_interfaces,
				 config->supported_interfaces,
				 pcs->supported_interfaces);
    ...
		if (pcs)
			phy_interface_or(config->lpi_interfaces,
					 config->lpi_interfaces,
					 pcs->supported_interfaces);
    ...
}

The lpi_interfaces update only happens when priv->dma_cap.eee is set
and STMMAC_FLAG_EEE_DISABLE is not.

Before this patch, the full synopsys_xpcs_compat[] set was advertised to
phylink for dwmac-rk as both supported and LPI-capable. That set is
USXGMII, 10GKR, 25GBASER, XLGMII, 50GBASER, LAUI, 100GBASEP, 10GBASER,
SGMII, 1000BASEX and 2500BASEX. After this patch, both masks shrink to
SGMII and 1000BASEX.

rk_select_pcs() returns the XPCS for any interface. That makes this
narrowing the part of the patch that actually changes behaviour.

The commit message only describes the xpcs_find_compat() change, and
says:

  the MAC side forces the phy mode, so phylink does not normally pass an
  interface outside the mask.

Could the message also describe the change to the dwmac-rk phylink
supported_interfaces and lpi_interfaces?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261110160554.918652-1-coiaprant%40gmail.com

      reply	other threads:[~2026-11-13  4:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 16:05 [PATCH net-next v4 0/2] net: phy: fix PHY interface mask initialization and XPCS usage Coia Prant
2026-11-10 16:05 ` [PATCH net-next v4 1/2] net: phy: move DECLARE_PHY_INTERFACE_MASK_ZERO to core Coia Prant
2026-11-10 16:05 ` [PATCH net-next v4 2/2] net: pcs: xpcs: make supported_interfaces authoritative Coia Prant
2026-11-13  4:06   ` netdev-bot+sashiko [this message]

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=179454280276.2199510.48600645261637152@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=aleksandr.loktionov@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=coiaprant@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=fabio.baltieri@gmail.com \
    --cc=heiko@sntech.de \
    --cc=hkallweit1@gmail.com \
    --cc=jiawenwu@trustnetic.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=mengyuanlou@net-swift.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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