From: Jakub Kicinski <kuba@kernel.org>
To: ansuelsmth@gmail.com
Cc: Jakub Kicinski <kuba@kernel.org>,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, horms@kernel.org, corbet@lwn.net,
skhan@linuxfoundation.org, rdunlap@infradead.org,
lorenzo@kernel.org, hkallweit1@gmail.com, linux@armlinux.org.uk,
maxime.chevallier@bootlin.com, p.zabel@pengutronix.de,
nathan@kernel.org, ndesaulniers@google.com, morbo@google.com,
justinstitt@google.com, rmk+kernel@armlinux.org.uk,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, llvm@lists.linux.dev,
zhengping.zhang@airoha.com
Subject: Re: [PATCH net-next v22 03/15] net: phylink: introduce internal phylink PCS handling
Date: Sat, 21 Nov 2026 15:26:43 -0800 [thread overview]
Message-ID: <20261121232643.1365333-1-kuba@kernel.org> (raw)
In-Reply-To: <20261117123956.11981-4-ansuelsmth@gmail.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.
---
net: phylink: introduce internal phylink PCS handling
This adds an alternative to .mac_select_pcs. The MAC hands phylink a list
of PCS through .fill_available_pcs and .num_possible_pcs, and phylink
picks a PCS by matching the interface against each PCS's
supported_interfaces. A new pcs_interfaces mask in phylink_config marks
the modes that need a dedicated PCS, and phylink_create() widens
pl->supported_interfaces with the supported_interfaces of every listed
PCS.
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index f482dc6088102..e8ba906cfba68 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
[ ... ]
> @@ -2096,16 +2220,31 @@ struct phylink *phylink_create(struct phylink_config *config,
> __set_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state);
> timer_setup(&pl->link_poll, phylink_fixed_poll, 0);
>
> + /* Fill the PCS list with available PCS from phylink config */
> + ret = phylink_fill_available_pcs(pl, config);
> + if (ret < 0)
> + goto free_pl;
> +
> + /* Link available PCS to phylink */
> + list_for_each_entry(pcs, &pl->pcs_list, list)
> + rcu_assign_pointer(pcs->phylink, pl);
> +
> phy_interface_copy(pl->supported_interfaces,
> pl->config->supported_interfaces);
>
> + /* Update supported interfaces */
> + list_for_each_entry(pcs, &pl->pcs_list, list)
> + phy_interface_or(pl->supported_interfaces,
> + pl->supported_interfaces,
> + pcs->supported_interfaces);
> +
[Severity: Medium]
Can this OR put modes into pl->supported_interfaces that phylink will
never select a PCS for?
The PCS modes are not masked with config->pcs_interfaces. However, the
PCS lookup this patch adds only runs when the interface is in
pcs_interfaces. The check in phylink_validate_mac_and_pcs(),
phylink_inband_caps() and phylink_major_config() is:
} else if (test_bit(state->interface, pl->config->pcs_interfaces)) {
Suppose a listed PCS advertises a mode that is not in pcs_interfaces.
__phylink_validate() accepts that mode after checking only the MAC
capabilities.
SFP interface selection uses the same widened mask. It also ends up in
the SFP PHY's host_interfaces through phylink_sfp_connect_phy():
phy_interface_and(phy->host_interfaces, phylink_sfp_interfaces,
pl->supported_interfaces);
If that mode is then picked, phylink_major_config() skips the PCS list
branch and pcs stays NULL:
pcs_changed = pl->pcs != pcs;
...
if (pcs_changed) {
phylink_pcs_disable(pl->pcs);
...
WRITE_ONCE(pl->pcs, pcs);
}
So the active PCS is disabled and pl->pcs becomes NULL. mac_config() is
then called for a mode the MAC never listed in
config->supported_interfaces. No PCS is programmed for that mode.
The "couldn't find a PCS for %s" error is not printed either, because it
is only reached inside the pcs_interfaces branch.
The Documentation/networking/pcs.rst added later in the series describes
supported_interfaces as holding every MAC mode. It describes
pcs_interfaces as the subset that needs a PCS ("PCS required only for
USXGMII").
Under that model the OR either adds nothing new, or it adds modes outside
pcs_interfaces that never get a PCS. One example is a USXGMII PCS that
also supports 10GBASER, 2500BASEX and 1000BASEX, such as the Airoha PCS
added later in the series.
The airoha user in the series does not hit this, because it copies
supported_interfaces into pcs_interfaces. The final state of the series
still has the unmasked OR in both phylink_create() and
pcs_provider_notify().
Should the OR be limited to config->pcs_interfaces? Alternatively, should
phylink_create() reject a PCS mode that is not in pcs_interfaces?
phylink_create() also does not check that the new fields are consistent:
- It accepts num_possible_pcs with an empty pcs_interfaces. In that case
the listed PCS are never selected.
- It accepts pcs_interfaces together with .mac_select_pcs. In that case
pcs_interfaces is silently ignored.
Would it make sense to reject these combinations here?
Separately, the kernel-doc for @supported_interfaces ("supported by the
MAC/PCS") and @pcs_interfaces ("dedicated PCS is required") in
include/linux/phylink.h does not match how phylink combines the two
masks.
next prev parent reply other threads:[~2026-11-21 23:26 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 12:39 [PATCH net-next v22 00/15] net: pcs: Introduce support for fwnode PCS Christian Marangi
2026-11-17 12:39 ` [PATCH net-next v22 01/15] net: phylink: make PCS phylink instance access RCU protected Christian Marangi
2026-11-21 23:26 ` Jakub Kicinski
2026-11-17 12:39 ` [PATCH net-next v22 02/15] net: phylink: keep and use MAC supported_interfaces in phylink struct Christian Marangi
2026-11-17 12:39 ` [PATCH net-next v22 03/15] net: phylink: introduce internal phylink PCS handling Christian Marangi
2026-11-21 23:26 ` Jakub Kicinski [this message]
2026-11-17 12:39 ` [PATCH net-next v22 04/15] net: pcs: implement Firmware node support for PCS driver Christian Marangi
2026-11-17 12:39 ` [PATCH net-next v22 05/15] net: phylink: save phylink instance fwnode on phylink_create Christian Marangi
2026-11-17 12:39 ` [PATCH net-next v22 06/15] net: phylink: make phylink_validate state locked Christian Marangi
2026-11-17 12:39 ` [PATCH net-next v22 07/15] net: phylink: add capabilities helpers and track modified advertising Christian Marangi
2026-11-21 23:26 ` Jakub Kicinski
2026-11-17 12:39 ` [PATCH net-next v22 08/15] net: phylink: support PCS provider release Christian Marangi
2026-11-21 23:26 ` Jakub Kicinski
2026-11-17 12:39 ` [PATCH net-next v22 09/15] net: phylink: support late PCS provider attach Christian Marangi
2026-11-21 23:26 ` Jakub Kicinski
2026-11-17 12:39 ` [PATCH net-next v22 10/15] net: Document PCS subsystem Christian Marangi
2026-11-21 23:26 ` Jakub Kicinski
2026-11-17 12:39 ` [PATCH net-next v22 11/15] MAINTAINERS: add myself as PCS subsystem maintainer Christian Marangi
2026-11-17 12:39 ` [PATCH net-next v22 12/15] net: phylink: add .pcs_link_down PCS OP Christian Marangi
2026-11-17 12:39 ` [PATCH net-next v22 13/15] dt-bindings: net: pcs: Document support for Airoha Ethernet PCS Christian Marangi
2026-11-21 23:26 ` Jakub Kicinski
2026-11-17 12:39 ` [PATCH net-next v22 14/15] net: pcs: airoha: add PCS driver for Airoha AN7581 SoC Christian Marangi
2026-11-17 12:39 ` [PATCH net-next v22 15/15] net: airoha: add phylink support Christian Marangi
2026-11-21 23:26 ` Jakub Kicinski
2026-11-17 12:43 ` [PATCH net-next v22 00/15] net: pcs: Introduce support for fwnode PCS netdev-bot+sinfo
2026-11-17 12:47 ` Christian Marangi
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=20261121232643.1365333-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=ansuelsmth@gmail.com \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@kernel.org \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=justinstitt@google.com \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=llvm@lists.linux.dev \
--cc=lorenzo@kernel.org \
--cc=maxime.chevallier@bootlin.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=netdev@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
--cc=rmk+kernel@armlinux.org.uk \
--cc=robh@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=zhengping.zhang@airoha.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
all inboxes | Powered by JetHome®