From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54CD22D948A for ; Fri, 30 Jan 2026 09:12:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769764373; cv=none; b=n55JUMB9VIkdoRO5Ufuv01K+N8aDOR3viM1rAcp/1X0SDP4BRkl/w+Ss8otjLLLPUzJqqvfWOPUFfv2x7l2PV9NELgkpnyO8Ci1M+xxVIyuE0aCytjz2Zm/gkvsXSxTpTHAjYV5lXOQEJ9d9a2m+IL+tPXugdlAACoPPDmqFND0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769764373; c=relaxed/simple; bh=o4qpJAfiNyeL6Fj9BGIqCCcCv4uIJ4uVIS/X4VFGV64=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eJEMa0cmvbiv5jYAZGGmDHafY9hg5tb7W1Q874DmQYvzCiWyrQvBesCyE/sicR1XOWVXjTTgLqeURImAIWXeB2eCvAYWfFujUzvJNoA1S30FpYorsx6NGTjlB3sELBsMOSnELxyYlmCAqumTPo5+MCYdjWxddnbJK0/IOuUMfws= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=kZ65059O; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="kZ65059O" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id ED276C22F5B; Fri, 30 Jan 2026 09:12:52 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 944CF6075A; Fri, 30 Jan 2026 09:12:49 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B8D95119A8884; Fri, 30 Jan 2026 10:12:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769764368; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:content-language:in-reply-to:references; bh=7Z16KRUuvvver/+C25LTNG/C+Q38nHHdfZUCB5foSSU=; b=kZ65059O4gt6+PeWcYsv5PEpVuCXbD6Re1yntra0/GSQDtgvYup9hlwb9WZK/KoU9vIOWq MoTWngAqbmZFpyhy26iQ9HhTmHBMVfV5nJwvXvub12qnez4O/zScYiVND5UybdaxfJW4ab v75QCHZqML3qCqA1XFz6p7g1K9UrLLOu2meH+g/NM0V9FX0fvDqBRsc9JoVL0cVXEDkLAv NZvxrjMZNfjUi4dpca/8l2/iW/TDZv892cbWt8pdJt6s8fxzPnSUEiAf9QvvccYqQuaK2A NUZ9gHvNmtkWNvxJA0h+A4s4XC4sab4jg9vRbEZGafdY+zZ4zUjh6Y6gO6Ak8A== Message-ID: <7fc065e8-c85b-4faf-9104-1b6b54327a02@bootlin.com> Date: Fri, 30 Jan 2026 10:12:40 +0100 Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net] net: phy: add device link between MAC device and MDIO device To: Wei Fang , Russell King , Jakub Kicinski Cc: "andrew@lunn.ch" , "hkallweit1@gmail.com" , "florian.fainelli@broadcom.com" , "xiaolei.wang" , "davem@davemloft.net" , "edumazet@google.com" , "pabeni@redhat.com" , "quic_abchauha@quicinc.com" , "quic_sarohasa@quicinc.com" , "imx@lists.linux.dev" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20260126104409.1070403-1-wei.fang@nxp.com> <20260128201501.04bb6e5c@kernel.org> From: Maxime Chevallier Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Last-TLS-Session-Version: TLSv1.3 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