From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: yicongsrfy@163.com
Cc: andrew@lunn.ch, davem@davemloft.net, edumazet@google.com,
hkallweit1@gmail.com, kuba@kernel.org,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
pabeni@redhat.com, yicong@kylinos.cn
Subject: Re: [PATCH] net: phy: avoid config_init failure on unattached PHY during resume
Date: Wed, 17 Sep 2025 11:06:37 +0100 [thread overview]
Message-ID: <aMqILVD_F7Rm-mfx@shell.armlinux.org.uk> (raw)
In-Reply-To: <20250911112525.3824360-1-yicongsrfy@163.com>
On Thu, Sep 11, 2025 at 07:25:25PM +0800, yicongsrfy@163.com wrote:
> However, there is a particular scenario as follows:
>
> Some PHY chips support two addresses, using address 0 as a broadcast address
> and address 1 as the hardware address. Both addresses respond to GMAC's MDIO
> read/write operations. As a result, during 'mdio_scan', both PHY addresses are
> detected, leading to the creation of two PHY device instances (for example,
> as in my previous email: xxxxmac_mii_bus-XXXX:00:00 and xxxxmac_mii_bus-XXXX:00:01).
IEEE 802.3 makes no provision for a broadcast address. Here is what it
says about the PHY address:
22.2.4.5.5 PHYAD (PHY Address)
The PHY Address is five bits, allowing 32 unique PHY addresses. The
first PHY address bit transmitted and received is the MSB of the
address. A PHY that is connected to the station management entity
via the mechanical interface defined in 22.6 shall always respond to
transactions addressed to PHY Address zero <00000>. A station
management entity that is attached to multiple PHYs must have prior
knowledge of the appropriate PHY Address for each PHY.
So, phylib code can't make any special exception for address zero.
We definitely have network adapters where their PHYs are at address
zero, so blocking that address will break them.
As for Andrew's suggestion, returning an error in the probe function
doesn't prevent the phy_device being created, and it will mean that
if a MAC driver attempts to attach to that instance, phylib will use
the generic PHY driver instead. So, this doesn't solve the problem.
I don't see that there is anything that a PHY driver can do to solve
this as the code currently stands, especially if the MAC driver is
coded to "use the lowest PHY address present on the MDIO bus" (which
in this case will be your vendor's idea of a broadcast address.)
I really don't think we should start adding hacks for this kind of
stuff into phylib's core - we can't know that PHY address 0 is a
duplicate of another address.
The only thing I can come up with is:
1. There must be a way to configure the PHY to disable its non-
standard "broadcast MDIO address" to make it compliant with 802.3.
I suggest that board firmware needs to set that to make the PHY
compliant.
2. As a hard reset of the PHY will likely clear that setting, this is
another nail in the coffin of PHY hard reset handling in the kernel
which has been the cause of many issues. (Another nail in that
coffin is that some MACs require the RX clock from the PHY to be
running in order to properly reset.)
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2025-09-17 10:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-10 2:58 [PATCH] net: phy: avoid config_init failure on unattached PHY during resume yicongsrfy
2025-09-10 8:15 ` Russell King (Oracle)
2025-09-10 9:17 ` yicongsrfy
2025-09-10 9:31 ` yicongsrfy
2025-09-10 9:57 ` Russell King (Oracle)
2025-09-10 9:54 ` Russell King (Oracle)
2025-09-11 11:25 ` yicongsrfy
2025-09-11 12:58 ` Andrew Lunn
2025-09-17 8:24 ` yicongsrfy
2025-09-17 10:06 ` Russell King (Oracle) [this message]
2025-09-19 7:38 ` yicongsrfy
2025-09-19 12:45 ` Andrew Lunn
2025-09-22 1:56 ` yicongsrfy
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=aMqILVD_F7Rm-mfx@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--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=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=yicong@kylinos.cn \
--cc=yicongsrfy@163.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;
as well as URLs for NNTP newsgroup(s).