From: sashiko-bot@kernel.org
To: "Christian Marangi" <ansuelsmth@gmail.com>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [RFC PATCH net-next v8 03/12] net: phylink: add phylink_release_pcs() to externally release a PCS
Date: Fri, 19 Jun 2026 14:11:12 +0000 [thread overview]
Message-ID: <20260619141112.9271B1F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <20260618125752.1223-4-ansuelsmth@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unconditional and unbalanced `phylink_link_down()` in `phylink_release_pcs()` causes duplicate `mac_link_down()` callbacks and corrupts the internal phylink state machine.
--
commit 2b29c68aa2ea3d8d4cc5979668a733bbdab7236c
Author: Christian Marangi <ansuelsmth@gmail.com>
net: phylink: add phylink_release_pcs() to externally release a PCS
This commit introduces phylink_release_pcs() to allow removing a PCS from a
phylink instance. When the released PCS is the active one, the link is
brought down and a major config is forced to trigger a reconfiguration.
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index c38bcd43b8c8b..064d6f5a06da4 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
[ ... ]
> @@ -918,6 +920,60 @@ static void phylink_resolve_an_pause(struct phylink_link_state *state)
[ ... ]
> + /*
> + * Check if we are removing the PCS currently
> + * in use by phylink. If this is the case, tear down
> + * the link, force phylink resolve to reconfigure the
> + * interface mode, disable the current PCS and set the
> + * phylink PCS to NULL.
> + */
> + if (pl->pcs == pcs) {
> + phylink_link_down(pl);
> + phylink_pcs_disable(pl->pcs);
> +
> + pl->force_major_config = true;
[Severity: High]
Does this unconditional call to phylink_link_down() cause unbalanced
mac_link_down() callbacks if the link is already down?
Also, if the link was up, does pl->old_link_state need to be cleared here?
For PHYLINK_DEV instances that lack a netdev, phylink_link_is_up(pl) relies
entirely on pl->old_link_state. Because pl->old_link_state remains true, the
scheduled phylink_resolve() evaluates cur_link_state as true.
Inside phylink_resolve():
1. The force_major_config block sees cur_link_state == true and calls
phylink_link_down() a second time, then sets cur_link_state = false.
2. Later, the state update block compares link_state.link != cur_link_state
(false != false), evaluating to false. As a result, pl->old_link_state is
NOT updated and remains true permanently.
3. On the next phylink_resolve() run, cur_link_state again evaluates to
true. The state update block compares link_state.link != cur_link_state
(false != true), evaluating to true, and calls phylink_link_down(pl) a third
time.
Can this state machine corruption result in multiple unbalanced
mac_link_down() calls and cause clock underflows, regulator warnings, or
hardware lockups in MAC drivers?
> + pl->pcs = NULL;
> + }
> +
> + mutex_unlock(&pl->state_mutex);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260618125752.1223-1-ansuelsmth@gmail.com?part=3
next prev parent reply other threads:[~2026-06-19 14:11 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-18 12:57 [RFC PATCH net-next v8 00/12] net: pcs: Introduce support for fwnode PCS Christian Marangi
2026-06-18 12:57 ` [RFC PATCH net-next v8 01/12] net: phylink: keep and use MAC supported_interfaces in phylink struct Christian Marangi
2026-06-18 12:57 ` [RFC PATCH net-next v8 02/12] net: phylink: introduce internal phylink PCS handling Christian Marangi
2026-06-19 14:11 ` sashiko-bot
2026-06-18 12:57 ` [RFC PATCH net-next v8 03/12] net: phylink: add phylink_release_pcs() to externally release a PCS Christian Marangi
2026-06-19 14:11 ` sashiko-bot [this message]
2026-06-18 12:57 ` [RFC PATCH net-next v8 04/12] net: pcs: implement Firmware node support for PCS driver Christian Marangi
2026-06-19 14:11 ` sashiko-bot
2026-06-18 12:57 ` [RFC PATCH net-next v8 05/12] net: phylink: support late PCS provider attach Christian Marangi
2026-06-19 14:11 ` sashiko-bot
2026-06-18 12:57 ` [RFC PATCH net-next v8 06/12] net: Document PCS subsystem Christian Marangi
2026-06-18 12:57 ` [RFC PATCH net-next v8 07/12] MAINTAINERS: add myself as PCS subsystem maintainer Christian Marangi
2026-06-18 12:57 ` [RFC PATCH net-next v8 08/12] of: property: fw_devlink: Add support for "pcs-handle" Christian Marangi
2026-06-19 14:11 ` sashiko-bot
2026-06-18 12:57 ` [RFC PATCH net-next v8 09/12] net: phylink: add .pcs_link_down PCS OP Christian Marangi
2026-06-19 14:11 ` sashiko-bot
2026-06-18 12:57 ` [RFC PATCH net-next v8 10/12] dt-bindings: net: pcs: Document support for Airoha Ethernet PCS Christian Marangi
2026-06-18 12:57 ` [RFC PATCH net-next v8 11/12] net: pcs: airoha: add PCS driver for Airoha AN7581 SoC Christian Marangi
2026-06-18 13:30 ` Benjamin Larsson
2026-06-19 14:11 ` sashiko-bot
2026-06-18 12:57 ` [RFC PATCH net-next v8 12/12] net: airoha: add phylink support Christian Marangi
2026-06-18 13:15 ` Lorenzo Bianconi
2026-06-19 14:11 ` 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=20260619141112.9271B1F00A3E@smtp.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.