From: Christian Marangi <ansuelsmth@gmail.com>
To: sashiko-reviews@lists.linux.dev
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH net-next v6 01/12] net: phylink: keep and use MAC supported_interfaces in phylink struct
Date: Fri, 12 Jun 2026 12:10:35 +0200 [thread overview]
Message-ID: <6a2bdb1d.dc59d6a3.e1f11.8388@mx.google.com> (raw)
In-Reply-To: <20260610161620.99C121F00893@smtp.kernel.org>
On Wed, Jun 10, 2026 at 04:16:20PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] Late modification to `config->supported_interfaces` by drivers is silently ignored due to by-value copying in `phylink_create()`, breaking support for devices like MTK GMAC2.
> --
>
> commit eaea53b185dbdc4c75406c542c97543c4c451c9d
> Author: Christian Marangi <ansuelsmth@gmail.com>
>
> net: phylink: keep and use MAC supported_interfaces in phylink struct
>
> This patch copies supported_interfaces from phylink_config into the phylink
> structure to prepare for internal PCS handling. The internal copy is then
> used in place of the config structure's bitmap.
>
> > diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> > index 087ac63f9193d..4d59c0dd78dbf 100644
> > --- a/drivers/net/phy/phylink.c
> > +++ b/drivers/net/phy/phylink.c
> [ ... ]
> > @@ -1868,6 +1873,9 @@ struct phylink *phylink_create(struct phylink_config *config,
> > mutex_init(&pl->state_mutex);
> > INIT_WORK(&pl->resolve, phylink_resolve);
> >
> > + phy_interface_copy(pl->supported_interfaces,
> > + config->supported_interfaces);
> > +
>
> [Severity: High]
> Will this by-value copy break drivers that modify supported_interfaces after
> calling phylink_create()?
>
> For example, looking at the mtk_eth_soc driver in mtk_add_mac(), the
> supported_interfaces bitmap is modified after phylink_create() returns:
>
> drivers/net/ethernet/mediatek/mtk_eth_soc.c:mtk_add_mac() {
> ...
> mac->phylink = phylink_create(&mac->phylink_config, ...);
> ...
> if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_2P5GPHY) &&
> id == MTK_GMAC2_ID)
> __set_bit(PHY_INTERFACE_MODE_INTERNAL,
> mac->phylink_config.supported_interfaces);
> ...
> }
>
> Since phylink_create() has already taken a snapshot of the interfaces,
> this late addition of PHY_INTERFACE_MODE_INTERNAL will be dropped.
> Could this cause phylink_validate() to incorrectly reject the internal PHY
> capability for the MTK GMAC2?
>
> > pl->config = config;
> > if (config->type == PHYLINK_NETDEV) {
> > pl->netdev = to_net_dev(config->dev);
>
I was with the idea that value of phylink_config should be used only for
phylink_create and then in theory they should not be changed.
Isn't this a bug in MTK code to modify the phylink_config AFTER
phylink_create?
It was never a problem since it's it's INTERNAL interface mode and a PCS is
not needed for it but still I feel this should be fixed and this change
doesn't introduce some kind of regression.
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260609151212.29469-1-ansuelsmth@gmail.com?part=1
--
Ansuel
next prev parent reply other threads:[~2026-06-12 10:10 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 15:11 [PATCH net-next v6 00/12] net: pcs: Introduce support for fwnode PCS Christian Marangi
2026-06-09 15:11 ` [PATCH net-next v6 01/12] net: phylink: keep and use MAC supported_interfaces in phylink struct Christian Marangi
2026-06-10 16:16 ` sashiko-bot
2026-06-12 10:10 ` Christian Marangi [this message]
2026-06-09 15:11 ` [PATCH net-next v6 02/12] net: phylink: introduce internal phylink PCS handling Christian Marangi
2026-06-10 16:16 ` sashiko-bot
2026-06-09 15:11 ` [PATCH net-next v6 03/12] net: phylink: add phylink_release_pcs() to externally release a PCS Christian Marangi
2026-06-10 16:16 ` sashiko-bot
2026-06-09 15:12 ` [PATCH net-next v6 04/12] net: pcs: implement Firmware node support for PCS driver Christian Marangi
2026-06-10 16:16 ` sashiko-bot
2026-06-09 15:12 ` [PATCH net-next v6 05/12] net: phylink: support late PCS provider attach Christian Marangi
2026-06-10 16:16 ` sashiko-bot
2026-06-09 15:12 ` [PATCH net-next v6 06/12] net: Document PCS subsystem Christian Marangi
2026-06-10 16:16 ` sashiko-bot
2026-06-09 15:12 ` [PATCH net-next v6 07/12] MAINTAINERS: add myself as PCS subsystem maintainer Christian Marangi
2026-06-09 15:12 ` [PATCH net-next v6 08/12] of: property: fw_devlink: Add support for "pcs-handle" Christian Marangi
2026-06-10 22:43 ` Rob Herring
2026-06-09 15:12 ` [PATCH net-next v6 09/12] net: phylink: add .pcs_link_down PCS OP Christian Marangi
2026-06-10 16:16 ` sashiko-bot
2026-06-09 15:12 ` [PATCH net-next v6 10/12] dt-bindings: net: pcs: Document support for Airoha Ethernet PCS Christian Marangi
2026-06-10 16:16 ` sashiko-bot
2026-06-09 15:12 ` [PATCH net-next v6 11/12] net: pcs: airoha: add PCS driver for Airoha AN7581 SoC Christian Marangi
2026-06-10 16:16 ` sashiko-bot
2026-06-09 15:12 ` [PATCH net-next v6 12/12] net: airoha: add phylink support Christian Marangi
2026-06-09 15:29 ` Lorenzo Bianconi
2026-06-09 23:51 ` Christian Marangi
2026-06-10 16:16 ` sashiko-bot
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=6a2bdb1d.dc59d6a3.e1f11.8388@mx.google.com \
--to=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.