public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: Wei Fang <wei.fang@nxp.com>, Russell King <linux@armlinux.org.uk>,
	Jakub Kicinski <kuba@kernel.org>
Cc: "andrew@lunn.ch" <andrew@lunn.ch>,
	"hkallweit1@gmail.com" <hkallweit1@gmail.com>,
	"florian.fainelli@broadcom.com" <florian.fainelli@broadcom.com>,
	"xiaolei.wang" <xiaolei.wang@windriver.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"edumazet@google.com" <edumazet@google.com>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"quic_abchauha@quicinc.com" <quic_abchauha@quicinc.com>,
	"quic_sarohasa@quicinc.com" <quic_sarohasa@quicinc.com>,
	"imx@lists.linux.dev" <imx@lists.linux.dev>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net] net: phy: add device link between MAC device and MDIO device
Date: Fri, 30 Jan 2026 10:12:40 +0100	[thread overview]
Message-ID: <7fc065e8-c85b-4faf-9104-1b6b54327a02@bootlin.com> (raw)
In-Reply-To: <PAXPR04MB85106B63AF43DE0830B4C362889FA@PAXPR04MB8510.eurprd04.prod.outlook.com>

Hi again,

On 30/01/2026 04:41, Wei Fang wrote:
[...]
> 
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 81984d4ebb7c..c48335bfc7b6 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -1771,9 +1771,17 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
>          * another mac interface, so we should create a device link between
>          * phy dev and mac dev.
>          */
> -       if (dev && phydev->mdio.bus->parent && dev->dev.parent != phydev->mdio.bus->parent)
> -               phydev->devlink = device_link_add(dev->dev.parent, &phydev->mdio.dev,
> -                                                 DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS);
> +       if (dev && bus->parent && dev->dev.parent != bus->parent) {
> +               if (phydev->sfp_bus_attached)
                      ^ assuming we replace with phy_on_sfp()
> +                       phydev->devlink = device_link_add(dev->dev.parent,
> +                                                         bus->parent,
> +                                                         DL_FLAG_PM_RUNTIME |
> +                                                         DL_FLAG_STATELESS);
> +               else
> +                       device_link_add(dev->dev.parent, bus->parent,
> +                                       DL_FLAG_PM_RUNTIME |
> +                                       DL_FLAG_AUTOREMOVE_SUPPLIER);
> +       }

I think we should let the phy_on_sfp() case alone for now. The lifetime
of the SFP phydev and the MAC are completely independent here, the PHY
can be probed/removed without the MAC being there, and vice versa.

The MDIO bus that controls that SFP PHY's lifetime is the same as the
PHY itself, the mdio bus in that case exists solely to drive that single
PHY, and in can't be shared between multiple PHYs even if we have
multiple SFP ports in the entire system.

The logical thing to do IMO is not to tie the MAC and the MDIO Bus
itself, but rather the MAC and the PHY as was done before. As you state,
we couldn't set DL_FLAG_AUTOREMOVE_SUPPLIER because of SFP PHYs, but
if we add the check on "phy_on_sfp()", it should now be fine.

Maxime




  parent reply	other threads:[~2026-01-30  9:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-26 10:44 [PATCH net] net: phy: add device link between MAC device and MDIO device Wei Fang
2026-01-26 14:13 ` Andrew Lunn
2026-01-26 14:19   ` Russell King (Oracle)
2026-01-27  3:01   ` Wei Fang
2026-01-29  4:15 ` Jakub Kicinski
2026-01-29 10:06   ` Russell King (Oracle)
2026-01-30  3:41     ` Wei Fang
2026-01-30  8:29       ` Maxime Chevallier
2026-01-30  8:45         ` Wei Fang
2026-01-30  9:12       ` Maxime Chevallier [this message]
2026-01-30 10:09         ` Wei Fang
2026-01-29  9:10 ` Maxime Chevallier
2026-01-29 10:00   ` Wei Fang
2026-01-29 10:18     ` Maxime Chevallier
2026-01-29 10:47       ` Wei Fang

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=7fc065e8-c85b-4faf-9104-1b6b54327a02@bootlin.com \
    --to=maxime.chevallier@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=hkallweit1@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=quic_abchauha@quicinc.com \
    --cc=quic_sarohasa@quicinc.com \
    --cc=wei.fang@nxp.com \
    --cc=xiaolei.wang@windriver.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox