From: sashiko-bot@kernel.org
To: "Christian Marangi" <ansuelsmth@gmail.com>, devicetree@vger.kernel.org
Cc: robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH net-next v20 03/15] net: phylink: introduce internal phylink PCS handling
Date: Sun, 15 Nov 2026 10:45:14 +0000 [thread overview]
Message-ID: <sashiko-outbox-215394@kernel.org> (raw)
In-Reply-To: <20261114104426.235620-4-ansuelsmth@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] net: phylink: missing error return in
phylink_validate_mac_and_pcs()
- [Medium] net: phylink: broken PCS interface filtering in
phylink_create()
--
commit 68a6b41cb9652b8b9ee28ac370dd9685425db77b
Author: Christian Marangi <ansuelsmth@gmail.com>
net: phylink: introduce internal phylink PCS handling
This commit introduces internal PCS tracking and selection in phylink via a
per-instance PCS list populated through .fill_available_pcs, as an
alternative to the .mac_select_pcs callback.
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index 51c147eb8c2b6..35bfdffc86ba8 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
[ ... ]
> @@ -535,6 +554,21 @@ static int phylink_validate_mac_and_pcs(struct phylink *pl,
> pcs = pl->mac_ops->mac_select_pcs(pl->config, state->interface);
> if (IS_ERR(pcs))
> return PTR_ERR(pcs);
> + /*
> + * Find a PCS in available PCS list for the requested interface.
> + *
> + * Skip searching if the MAC doesn't require a dedicated PCS for
> + * the requested interface.
> + */
> + } else if (test_bit(state->interface, pl->config->pcs_interfaces)) {
> + struct phylink_pcs *tmp;
> +
> + list_for_each_entry(tmp, &pl->pcs_list, list) {
> + if (!phylink_validate_pcs_interface(tmp, state->interface)) {
> + pcs = tmp;
> + break;
> + }
> + }
> }
[Severity: Medium]
Should phylink_validate_mac_and_pcs() return -EINVAL when state->interface is
set in pl->config->pcs_interfaces but no matching PCS is found in
pl->pcs_list?
When no PCS in pl->pcs_list supports state->interface, pcs remains NULL and
phylink_validate_mac_and_pcs() skips the if (pcs) block, validating the mode
against MAC capabilities alone and returning 0. Unsupported PCS-dependent
interface modes then pass validation during phylink_create() or SFP/PHY
setup, only to fail later in phylink_major_config() when !pcs sets
pl->major_config_failed = true.
Also, this isn't a bug, but the pl->pcs_list lookup loop is duplicated across
phylink_validate_mac_and_pcs(), phylink_inband_caps(), and
phylink_major_config() and could be moved into a helper.
[ ... ]
> @@ -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]
As reported by Maxime Chevallier on v7 [1], does ORing
pcs->supported_interfaces into pl->supported_interfaces leave unsupported
PCS modes enabled while adding modes the MAC itself does not support?
Any mode in config->pcs_interfaces that is also in
config->supported_interfaces stays set in pl->supported_interfaces even when
no PCS in pl->pcs_list supports it. Conversely, if a PCS advertises an
interface mode in pcs->supported_interfaces that the MAC does not support in
config->supported_interfaces or config->pcs_interfaces, phy_interface_or()
adds it to pl->supported_interfaces, and phylink then treats it as a native
MAC mode requiring no PCS. Callers inspecting pl->supported_interfaces
such as phylink_validate_phy() and SFP interface selection will therefore
see unsupported modes as valid.
[1] https://lore.kernel.org/r/3bbacda3-4225-4536-a4b4-3aa31a47a3aa@bootlin.com
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261114104426.235620-1-ansuelsmth@gmail.com?part=3
next prev parent reply other threads:[~2026-11-15 10:45 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 10:43 [PATCH net-next v20 00/15] net: pcs: Introduce support for fwnode PCS Christian Marangi
2026-11-14 10:43 ` [PATCH net-next v20 01/15] net: phylink: keep and use MAC supported_interfaces in phylink struct Christian Marangi
2026-11-15 10:45 ` sashiko-bot
2026-11-14 10:43 ` [PATCH net-next v20 02/15] net: phylink: make PCS phylink instance access RCU protected Christian Marangi
2026-11-15 10:45 ` sashiko-bot
2026-11-14 10:43 ` [PATCH net-next v20 03/15] net: phylink: introduce internal phylink PCS handling Christian Marangi
2026-11-15 10:45 ` sashiko-bot [this message]
2026-11-14 10:43 ` [PATCH net-next v20 04/15] net: pcs: implement Firmware node support for PCS driver Christian Marangi
2026-11-15 10:45 ` sashiko-bot
2026-11-14 10:43 ` [PATCH net-next v20 05/15] net: phylink: save phylink instance fwnode on phylink_create Christian Marangi
2026-11-14 10:43 ` [PATCH net-next v20 06/15] net: phylink: make phylink_validate state locked Christian Marangi
2026-11-15 10:45 ` sashiko-bot
2026-11-14 10:43 ` [PATCH net-next v20 07/15] net: phylink: add capabilities helper and track modified advertising Christian Marangi
2026-11-15 10:45 ` sashiko-bot
2026-11-14 10:43 ` [PATCH net-next v20 08/15] net: phylink: support PCS provider release Christian Marangi
2026-11-15 10:45 ` sashiko-bot
2026-11-14 10:43 ` [PATCH net-next v20 09/15] net: phylink: support late PCS provider attach Christian Marangi
2026-11-15 10:45 ` sashiko-bot
2026-11-14 10:43 ` [PATCH net-next v20 10/15] net: Document PCS subsystem Christian Marangi
2026-11-14 10:43 ` [PATCH net-next v20 11/15] MAINTAINERS: add myself as PCS subsystem maintainer Christian Marangi
2026-11-14 10:43 ` [PATCH net-next v20 12/15] net: phylink: add .pcs_link_down PCS OP Christian Marangi
2026-11-14 10:43 ` [PATCH net-next v20 13/15] dt-bindings: net: pcs: Document support for Airoha Ethernet PCS Christian Marangi
2026-11-15 10:45 ` sashiko-bot
2026-11-14 10:43 ` [PATCH net-next v20 14/15] net: pcs: airoha: add PCS driver for Airoha AN7581 SoC Christian Marangi
2026-11-15 10:45 ` sashiko-bot
2026-11-14 10:43 ` [PATCH net-next v20 15/15] net: airoha: add phylink support Christian Marangi
2026-11-15 10:45 ` sashiko-bot
2026-11-14 13:27 ` [PATCH net-next v20 00/15] net: pcs: Introduce support for fwnode PCS Frank Wunderlich
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-215394@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ansuelsmth@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.