All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Markus Stockhausen" <markus.stockhausen@gmx.de>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH net-next v8 3/9] net: phy: add (*notify_phy_attach/detach)() hooks to struct mii_bus
Date: Thu, 30 Jul 2026 16:03:29 +0000	[thread overview]
Message-ID: <20260730160330.32ABC1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260729160227.155613-4-markus.stockhausen@gmx.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Calling phy_attach_direct() on an already-attached PHY destructively tears down the existing valid attachment and leaves the bus driver state dangling.
--

--- Patch [3]: [PATCH net-next v8 3/9] net: phy: add (*notify_phy_attach/detach)() hooks to struct mii_bus ---
commit f45546de5e393510abd217da3bdb7bad6d759d93
Author: Daniel Golle <daniel@makrotopia.org>

net: phy: add (*notify_phy_attach/detach)() hooks to struct mii_bus

This commit introduces notify_phy_attach and notify_phy_detach hooks to
the mii_bus structure. This allows MDIO bus drivers to handle PHY specific
configurations, such as polling registers, symmetrically during attach and
detach phases.

Link: https://github.com/openwrt/openwrt/pull/21515#discussion_r2714069716
Link: https://lore.kernel.org/netdev/cover.1769053496.git.daniel@makrotopia.org/

> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c

[ ... ]

> @@ -1890,8 +1986,8 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
>  	return err;
>  
>  error:
> -	/* phy_detach() does all of the cleanup below */
> -	phy_detach(phydev);
> +	/* cleanup without bus notification */
> +	__phy_detach(phydev, false);
>  	return err;

[Severity: High]
This is a pre-existing issue, but does this error path incorrectly tear down
a valid pre-existing attachment when phy_attach_direct() is called on an
already-attached PHY?

When phy_attach_direct() detects the PHY is already attached:

drivers/net/phy/phy_device.c:phy_attach_direct() {
        ...
        if (phydev->attached_dev) {
                dev_err(&dev->dev, "PHY already attached\n");
                err = -EBUSY;
                goto error;
        }
        ...
}

It jumps to the shared error path. Since the error path calls
__phy_detach(phydev, false) and phydev->attached_dev still points to the
old, valid network device, it destroys the existing attachment behind the
scenes.

Additionally, because the patch explicitly suppresses the bus detach
notification by passing false to __phy_detach(), doesn't this leave the
MDIO bus driver's state (like hardware polling configurations) permanently
out of sync?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260729160227.155613-1-markus.stockhausen@gmx.de?part=3

  reply	other threads:[~2026-07-30 16:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29 16:02 [PATCH net-next v8 0/9] net: mdio: realtek-rtl9300: Add RTL83xx support Markus Stockhausen
2026-07-29 16:02 ` [PATCH net-next v8 1/9] dt-bindings: net: realtek,rtl9301-mdio: Add RTL83xx series Markus Stockhausen
2026-07-29 16:02 ` [PATCH net-next v8 2/9] net: mdio: realtek-rtl9300: Add polling documentation Markus Stockhausen
2026-07-29 16:02 ` [PATCH net-next v8 3/9] net: phy: add (*notify_phy_attach/detach)() hooks to struct mii_bus Markus Stockhausen
2026-07-30 16:03   ` sashiko-bot [this message]
2026-07-29 16:02 ` [PATCH net-next v8 4/9] net: mdio: realtek-rtl9300: extend controller structure lifetime Markus Stockhausen
2026-07-30 16:03   ` sashiko-bot
2026-07-29 16:02 ` [PATCH net-next v8 5/9] net: mdio: realtek-rtl9300: Configure hardware polling during probing Markus Stockhausen
2026-07-30 16:03   ` sashiko-bot
2026-07-29 16:02 ` [PATCH net-next v8 6/9] net: mdio: realtek-rtl9300: Add page tracking Markus Stockhausen
2026-07-30 16:03   ` sashiko-bot
2026-07-29 16:02 ` [PATCH net-next v8 7/9] net: mdio: realtek-rtl9300: Increase MDIO timeout Markus Stockhausen
2026-07-29 16:02 ` [PATCH net-next v8 8/9] net: mdio: realtek-rtl9300: Add support for RTL838x Markus Stockhausen
2026-07-29 16:02 ` [PATCH net-next v8 9/9] net: mdio: realtek-rtl9300: Add support for RTL839x Markus Stockhausen
  -- strict thread matches above, loose matches on Subject: below --
2026-07-27 19:15 [PATCH net-next v8 0/9] net: mdio: realtek-rtl9300: Add RTL83xx support Markus Stockhausen
2026-07-27 19:15 ` [PATCH net-next v8 3/9] net: phy: add (*notify_phy_attach/detach)() hooks to struct mii_bus Markus Stockhausen
2026-07-28 19: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=20260730160330.32ABC1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=markus.stockhausen@gmx.de \
    --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.