From: netdev-bot+sashiko@kernel.org
To: mail@birger-koblitz.de
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk,
andrew@lunn.ch, hkallweit1@gmail.com, linux-usb@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
neuromoments@gmail.com
Subject: Re: [PATCH net-next v12 01/15] phylink: Add phylink_mac_interrupt
Date: Thu, 17 Sep 2026 21:24:50 +0000 [thread overview]
Message-ID: <178968029017.22033.2874254681410388676@kernel.org> (raw)
In-Reply-To: <20260916-ax88179a-v12-1-60c04c9924a2@birger-koblitz.de>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider:
Critical: 0 · High: 0 · Medium: 1 · Low: 1
- [Medium] `phylink_mac_interrupt()`
(drivers/net/phy/phylink.c:1621-1628) reads `pl->phydev` with no…
- [Low] Claim that the newly exported `phylink_mac_interrupt()`
(drivers/net/phy/phylink.c) and its prototype…
--
phylink: Add phylink_mac_interrupt
This adds an exported phylink_mac_interrupt() helper which forwards a
link-change interrupt received by the MAC to phylib by calling
phy_mac_interrupt() on pl->phydev. It is intended for drivers that want to
avoid polling the PHY.
(no Link: tags in the commit header)
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index 3ec3bb4391095..96ed13458e9f3 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
> @@ -1612,6 +1612,22 @@ static bool phylink_link_is_up(struct phylink *pl)
> return pl->netdev ? netif_carrier_ok(pl->netdev) : pl->old_link_state;
> }
>
> +/**
> + * phylink_mac_interrupt() - wrapper for phy_mac_interrupt()
> + * @pl: a pointer to a &struct phylink returned from phylink_create()
> + *
> + * Passes a link-change interrupt received by the MAC to phylib.
> + */
> +void phylink_mac_interrupt(struct phylink *pl)
> +{
> + struct phy_device *phy;
> +
> + phy = pl->phydev;
> + if (phy)
> + phy_mac_interrupt(phy);
> +}
> +EXPORT_SYMBOL_GPL(phylink_mac_interrupt);
[Severity: Medium]
Is the unsynchronized read of pl->phydev here safe? Every other reader of
that field in phylink.c is serialized, and the struct member carries the
comment describing that rule:
/* Serialize updates to pl->phydev with phylink_resolve() */
struct mutex phydev_mutex;
phylink_resolve() and phylink_bringup_phy() take pl->phydev_mutex, and the
ethtool/ioctl/phylink_speed_up()/phylink_speed_down() readers run under
ASSERT_RTNL(). Since this new helper is documented as being called from a
MAC link-change interrupt, it can take neither the mutex nor RTNL, and the
signature (struct phylink * only) gives the caller no way to pin the
phy_device across the call.
Can this race with teardown? phylink_disconnect_phy() is the only writer
that clears the pointer:
drivers/net/phy/phylink.c:phylink_disconnect_phy() {
mutex_lock(&pl->phydev_mutex);
phy = pl->phydev;
if (phy) {
...
pl->phydev = NULL;
...
}
mutex_unlock(&pl->phydev_mutex);
if (phy) {
flush_work(&pl->resolve);
phy_disconnect(phy);
}
}
So the sequence would be:
CPU0 (MAC link IRQ)
phylink_mac_interrupt()
phy = pl->phydev; /* latched */
CPU1 (RTNL)
phylink_disconnect_phy()
pl->phydev = NULL;
phy_disconnect(phy) /* phy_stop_machine() ->
cancel_delayed_work_sync(
&phydev->state_queue) */
CPU0 resumes
phy_mac_interrupt(phy)
phy_trigger_machine(phy)
phy_queue_state_machine()
mod_delayed_work(..., &phy->state_queue, ...)
Does that re-arm the PHY state machine work after the teardown path already
did its synchronous cancel, so the state machine runs on a detached phydev?
For an SFP cage the phy_device is also freed while the interface is still
up:
drivers/net/phy/sfp.c:sfp_sm_phy_detach() {
sfp_remove_phy(sfp->sfp_bus); /* -> phylink_sfp_disconnect_phy()
-> phylink_disconnect_phy() */
phy_device_remove(sfp->mod_phy);
phy_device_free(sfp->mod_phy);
sfp->mod_phy = NULL;
}
Can the mod_delayed_work() above then write into the freed phy_device?
Separately, the load of pl->phydev is a plain access to a field written
under a mutex on another CPU. Should this at least be READ_ONCE()? As
written, nothing prevents the compiler from re-loading pl->phydev when
forming the call argument, which would make the "if (phy)" test useless and
pass NULL into phy_mac_interrupt() -> mod_delayed_work().
Would it make sense to either make pl->phydev lookup IRQ-safe (RCU with
deferred free, or hold a device reference), or to document in the kernel-doc
that the caller must quiesce its link interrupt before
phylink_disconnect_phy()/phylink_destroy()? The added kernel-doc currently
states no calling context or lifetime contract.
> +
> static void phylink_resolve(struct work_struct *w)
> {
> struct phylink *pl = container_of(w, struct phylink, resolve);
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260916-ax88179a-v12-0-60c04c9924a2%40birger-koblitz.de
next prev parent reply other threads:[~2026-09-17 21:24 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 3:23 [PATCH net-next v12 00/15] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
2026-09-16 3:24 ` [PATCH net-next v12 01/15] phylink: Add phylink_mac_interrupt Birger Koblitz
2026-09-17 21:24 ` netdev-bot+sashiko [this message]
2026-09-27 9:03 ` Birger Koblitz
2026-09-27 14:18 ` Andrew Lunn
2026-09-28 4:48 ` Birger Koblitz
2026-09-28 15:27 ` Andrew Lunn
2026-09-16 3:24 ` [PATCH net-next v12 02/15] phylib: Add support for PHYs with broken forced mode Birger Koblitz
2026-09-17 21:24 ` netdev-bot+sashiko
2026-09-27 9:04 ` Birger Koblitz
2026-09-16 3:24 ` [PATCH net-next v12 03/15] ax88179_178a: Fix endianness of pause watermark register Birger Koblitz
2026-09-17 21:24 ` netdev-bot+sashiko
2026-09-27 9:05 ` Birger Koblitz
2026-09-16 3:24 ` [PATCH net-next v12 04/15] ax88179_178a: Split driver into library and device specific code Birger Koblitz
2026-09-17 21:24 ` netdev-bot+sashiko
2026-09-19 22:04 ` Jakub Kicinski
2026-09-27 9:01 ` Birger Koblitz
2026-09-27 9:08 ` Birger Koblitz
2026-09-16 3:24 ` [PATCH net-next v12 05/15] ax88179_178a: Add netdev2data() convenience function Birger Koblitz
2026-09-17 21:24 ` netdev-bot+sashiko
2026-09-27 9:09 ` Birger Koblitz
2026-09-19 22:05 ` Jakub Kicinski
2026-09-27 8:17 ` Birger Koblitz
2026-09-16 3:24 ` [PATCH net-next v12 06/15] ax88179_178a: Add HW support for AX179A-based chips Birger Koblitz
2026-09-17 21:24 ` netdev-bot+sashiko
2026-09-19 22:15 ` Jakub Kicinski
2026-09-19 23:22 ` Birger Koblitz
2026-09-19 23:32 ` Jakub Kicinski
2026-09-27 9:18 ` Birger Koblitz
2026-09-19 22:12 ` Jakub Kicinski
2026-09-27 8:20 ` Birger Koblitz
2026-09-16 3:24 ` [PATCH net-next v12 07/15] ax88179_178a: Add EEE configuration support for AX88179A MACs Birger Koblitz
2026-09-17 21:24 ` netdev-bot+sashiko
2026-09-27 9:20 ` Birger Koblitz
2026-09-16 3:24 ` [PATCH net-next v12 08/15] ax88179_178a: Add EEE configuration support for AX88179A PHYs Birger Koblitz
2026-09-17 21:24 ` netdev-bot+sashiko
2026-09-27 9:21 ` Birger Koblitz
2026-09-16 3:24 ` [PATCH net-next v12 09/15] ax88179_178a: Add VLAN offload support for AX88179A Birger Koblitz
2026-09-17 21:25 ` netdev-bot+sashiko
2026-09-27 9:24 ` Birger Koblitz
2026-09-27 14:24 ` Andrew Lunn
2026-09-28 4:41 ` Birger Koblitz
2026-09-28 12:28 ` Andrew Lunn
2026-09-16 3:24 ` [PATCH net-next v12 10/15] ax88179_178a: Add AX179A/AX279 multicast configuration Birger Koblitz
2026-09-17 21:25 ` netdev-bot+sashiko
2026-09-27 9:25 ` Birger Koblitz
2026-09-16 3:24 ` [PATCH net-next v12 11/15] ax88179_178a: Add Suspend/resume support for AX88179A/772D/279 Birger Koblitz
2026-09-17 21:25 ` netdev-bot+sashiko
2026-09-27 9:36 ` Birger Koblitz
2026-09-16 3:24 ` [PATCH net-next v12 12/15] ax88179_178a: Add ethtool get_drvinfo Birger Koblitz
2026-09-17 21:25 ` netdev-bot+sashiko
2026-09-27 9:37 ` Birger Koblitz
2026-09-16 3:24 ` [PATCH net-next v12 13/15] ax88179_178a: Update driver name and information Birger Koblitz
2026-09-17 21:25 ` netdev-bot+sashiko
2026-09-27 9:38 ` Birger Koblitz
2026-09-16 3:24 ` [PATCH net-next v12 14/15] ax88179_178a: Add support for AX88179A/772D/279 EEPROM access Birger Koblitz
2026-09-17 21:25 ` netdev-bot+sashiko
2026-09-27 9:40 ` Birger Koblitz
2026-09-16 3:24 ` [PATCH net-next v12 15/15] ax88796b: Add support for AX88772D, AX88179A and AX88279 Birger Koblitz
2026-09-17 21:25 ` netdev-bot+sashiko
2026-09-27 9:42 ` Birger Koblitz
2026-09-19 5:28 ` [PATCH v12 0/15] ax88179_178a: Add support for AX88179A-based chips Jianhui Xu
2026-09-19 22:30 ` [PATCH net-next v12 00/15] " patchwork-bot+netdevbpf
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=178968029017.22033.2874254681410388676@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mail@birger-koblitz.de \
--cc=netdev@vger.kernel.org \
--cc=neuromoments@gmail.com \
--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 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.