From: netdev-bot+sashiko@kernel.org
To: florian.fainelli@broadcom.com
Cc: netdev@vger.kernel.org, carlos.soto@broadcom.com,
justin.chen@broadcom.com, opendmb@gmail.com, nb@tipi-net.de,
bcm-kernel-feedback-list@broadcom.com, andrew@lunn.ch,
hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net,
edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
linux-kernel@vger.kernel.org, kudzo51@gmail.com
Subject: Re: [PATCH net-next v4 1/4] net: phy: Map C45 probe read errors to -ENODEV during bus scan
Date: Tue, 24 Nov 2026 05:38:57 +0000 [thread overview]
Message-ID: <179549873735.3135.6221350265873603736@kernel.org> (raw)
In-Reply-To: <20261120051653.1433677-2-florian.fainelli@broadcom.com>
Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 3
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] When a C45 package does not answer on the first MMD it probes,
get_phy_c45_ids() stops probing (drivers/net/phy/phy_device.c:860-873).
- [Medium] phy_get_c45_ids() is exported.
- [Low] The subject ("... during bus scan") and the body describe only
the mdiobus_scan_bus_c45()/__mdiobus_register() path.
- [Low] The kernel-doc rewritten for get_phy_c45_ids()
(phy_device.c:826-828) and phy_get_c45_ids() (around 1104-1110) says…
- [Low] get_phy_c45_devs_in_pkg() (phy_device.c:785-801) issues
MDIO_DEVS2 and then MDIO_DEVS1 to the same MMD, and now returns the…
--
net: phy: Map C45 probe read errors to -ENODEV during bus scan
This patch makes get_phy_c45_devs_in_pkg() return the raw bus error. In
get_phy_c45_ids() it maps -EIO and -ENODEV to -ENODEV, both in the MMD loop
and in the MMD 0 fallback, so that mdiobus_scan_bus_c45() keeps scanning
past empty addresses. A failed devices-in-package read in the MMD loop now
skips the remaining MMDs and goes straight to the MMD 0 probe.
> net: phy: Map C45 probe read errors to -ENODEV during bus scan
[Severity: Low]
The subject and the body only describe the mdiobus_scan_bus_c45() and
__mdiobus_register() path. get_phy_c45_ids() is also reached outside the bus
scan.
fwnode_mdiobus_register_phy() calls get_phy_device(bus, addr, true) for
"ethernet-phy-ieee802.3-c45" nodes, and of_mdiobus_register_phy() goes
through it. Before this patch, an -EIO from a devices-in-package read made
__of_mdiobus_parse_phys() take the goto exit path, and the bus was
unregistered. Now it gets -ENODEV, which is only logged:
drivers/net/mdio/of_mdio.c:__of_mdiobus_parse_phys() {
...
if (rc == -ENODEV)
dev_err(&mdio->dev,
"MDIO device at address %d is missing.\n",
addr);
else if (rc)
goto exit;
...
}
As a result the bus registers without the PHY. The exported
phy_get_c45_ids() changes too, so gpy_probe() now fails with -ENODEV
instead of -EIO.
The patch carries a Fixes: tag. Could the commit message mention these
non-scan behaviour changes?
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index b39e945cebd73..79f3fa1e9a036 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
[ ... ]
> @@ -789,17 +789,30 @@ static int get_phy_c45_devs_in_pkg(struct mii_bus *bus, int addr, int dev_addr,
>
> phy_reg = mdiobus_c45_read(bus, addr, dev_addr, MDIO_DEVS2);
> if (phy_reg < 0)
> - return -EIO;
> + return phy_reg;
> *devices_in_package = phy_reg << 16;
>
> phy_reg = mdiobus_c45_read(bus, addr, dev_addr, MDIO_DEVS1);
> if (phy_reg < 0)
> - return -EIO;
> + return phy_reg;
[Severity: Low]
Suppose the MDIO_DEVS2 read above succeeds and this MDIO_DEVS1 read then
fails with -EIO. get_phy_c45_ids() passes the error through
get_phy_c45_probe_err() in the same way as a failure on the first contact.
Should that count as "nothing answered at this address"?
The successful DEVS2 read already shows that a device at this port address
and MMD drove the bus. With the new code, the loop breaks with devs_in_pkg
forced to all Fs. The MMD 0 read will usually fail the turnaround as well,
and get_phy_c45_ids() returns -ENODEV. mdiobus_scan_bus_c45() then skips
the address without logging anything:
phydev = mdiobus_scan_c45(bus, i);
if (IS_ERR(phydev) && (PTR_ERR(phydev) != -ENODEV))
return PTR_ERR(phydev);
In gpy_probe(), the same path turns a real bus error into a rejected match.
Before this patch, the same case made the whole bus registration fail.
get_phy_c22_id() also handles a PHYSID2 failure after a successful PHYSID1
read this way. So the main cost here is lost diagnostics.
> *devices_in_package |= phy_reg;
[ ... ]
> @@ -810,8 +823,9 @@ static int get_phy_c45_devs_in_pkg(struct mii_bus *bus, int addr, int dev_addr,
> * the PHY identifiers for each device. Return the "devices in package"
> * and identifiers in @c45_ids.
> *
> - * Returns zero on success, %-EIO on bus access error, or %-ENODEV if
> - * the "devices in package" is invalid or no device responds.
> + * Returns zero on success, %-ENODEV if the "devices in package" is invalid or
> + * if no MMD responds (including when the bus reports -EIO or -ENODEV for the
> + * reads that look for a device), or %-EIO on any other bus access error.
[Severity: Low]
Is the "%-EIO on any other bus access error" part accurate? Further down in
get_phy_c45_ids(), the identifier loop still returns the raw error from
phy_c45_probe_present() for the vendor MMDs:
if (i == MDIO_MMD_VEND1 || i == MDIO_MMD_VEND2) {
...
ret = phy_c45_probe_present(bus, addr, i);
if (ret < 0)
return ret;
phy_c45_probe_present() returns whatever mdiobus_c45_read() returned. That
means -ETIMEDOUT, -EBUSY or a raw -ENODEV can reach callers of
get_phy_device() and phy_get_c45_ids().
If a raw -ENODEV arrives here, a device has already answered, yet
mdiobus_scan_bus_c45() ignores it silently.
The commit message says something similar: errors from the per-MMD
identifier reads "are still reported as -EIO". The phy_get_c45_ids()
kernel-doc repeats the same wording.
> */
> static int get_phy_c45_ids(struct mii_bus *bus, int addr,
> struct phy_c45_device_ids *c45_ids)
> @@ -844,8 +858,20 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr,
> continue;
> }
> phy_reg = get_phy_c45_devs_in_pkg(bus, addr, i, &devs_in_pkg);
> - if (phy_reg < 0)
> - return -EIO;
> + if (phy_reg < 0) {
> + ret = get_phy_c45_probe_err(phy_reg);
> + if (ret != -ENODEV)
> + return ret;
> +
> + /* The MMD did not answer: treat it like a read of all
> + * Fs, which is what controllers that do not check the
> + * turnaround return, and go straight to the MMD 0
> + * probe below. Do not probe the remaining MMDs, each
> + * one costs two bus reads on a slow bus.
> + */
> + devs_in_pkg = 0xffffffff;
> + break;
[Severity: Medium]
The comment says a failed read is treated "like a read of all Fs". Do the
two cases behave the same?
After an all-Fs read, the loop condition still holds, so the loop moves on
to MMD 2..29 and to the vendor MMDs after their presence check. This break
ends the search at the first MMD that fails. The only probe left is the
MMD 0 fallback, and most C45 PHYs do not implement MMD 0.
Take a controller whose read_c45 returns -EIO on a turnaround failure, such
as cavium_mdiobus_read_c45() today, or UniMAC once read_c45 is added later
in the series. Would these packages now come back as -ENODEV and be skipped
silently by mdiobus_scan_bus_c45()?
- packages without MMD 1, whose lowest MMD is PCS, PHY XS, DTE XS, AN
and so on
- packages where MMD 1 answers with Devices-In-Package = 0 (the loop
already allows for this with devs_in_pkg == 0) and the next MMD, for
example WIS (MMD 2), is not implemented
In the second case, the device has already answered at this address.
A controller that does not check the turnaround would find both kinds of
package. So whether the PHY is found now depends on the controller.
Before this patch, these cases made the bus registration fail. This is a
gap in the fix, not a regression from the old behaviour.
> + }
> }
[ ... ]
> @@ -1077,8 +1104,9 @@ EXPORT_SYMBOL(phy_device_remove);
> * phy_get_c45_ids - Read 802.3-c45 IDs for phy device.
> * @phydev: phy_device structure to read 802.3-c45 IDs
> *
> - * Returns zero on success, %-EIO on bus access error, or %-ENODEV if
> - * the "devices in package" is invalid.
> + * Returns zero on success, %-ENODEV if the "devices in package" is invalid or
> + * no MMD responds (this includes a bus read failing with -EIO or -ENODEV while
> + * looking for a device), or %-EIO on any other bus access error.
> */
> int phy_get_c45_ids(struct phy_device *phydev)
[Severity: Medium]
phy_get_c45_ids() is exported and is used outside bus scanning. Is -ENODEV
the right result for a bus read error here?
Its only in-tree caller, gpy_probe() in drivers/net/phy/mxl-gpy.c, returns
the value directly from its probe callback:
if (!phydev->is_c45) {
ret = phy_get_c45_ids(phydev);
if (ret < 0)
return ret;
}
This phydev was already found over C22, so a C45 read failure is a real
fault, not an empty address. Take a read_c45 that returns -EIO on a
turnaround failure. The MMD 1 read fails and the loop breaks. The MMD 0
read then fails too, and get_phy_c45_probe_err() returns -ENODEV.
call_driver_probe() in drivers/base/dd.c treats that as a rejected match
and logs it only at debug level:
case -ENODEV:
case -ENXIO:
dev_dbg(dev, "probe with driver %s rejects match %d\n",
drv->name, ret);
break;
default:
/* driver matched but the probe failed */
dev_err(dev, "probe with driver %s failed with error %d\n",
drv->name, ret);
Before this patch, the -EIO produced the dev_err() line. The PHY still ends
up on genphy at attach time, but nothing visible says why.
Could the -ENODEV mapping be limited to the scan path?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120051653.1433677-1-florian.fainelli%40broadcom.com
next prev parent reply other threads:[~2026-11-24 5:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 5:16 [PATCH net-next v4 0/4] net: mdio: Clause 45 support for mdio-bcm-unimac Florian Fainelli
2026-11-20 5:16 ` [PATCH net-next v4 1/4] net: phy: Map C45 probe read errors to -ENODEV during bus scan Florian Fainelli
2026-11-24 5:38 ` netdev-bot+sashiko [this message]
2026-11-20 5:16 ` [PATCH net-next v4 2/4] net: mdio: mdio-bcm-unimac: Define MDIO_OP_SHIFT Florian Fainelli
2026-11-20 5:16 ` [PATCH net-next v4 3/4] net: mdio: mdio-bcm-unimac: Poll for completion at 1us granularity Florian Fainelli
2026-11-20 5:16 ` [PATCH net-next v4 4/4] net: mdio: mdio-bcm-unimac: Add Clause 45 support Florian Fainelli
2026-11-24 5:38 ` netdev-bot+sashiko
2026-11-20 8:30 ` [PATCH net-next v4 0/4] net: mdio: Clause 45 support for mdio-bcm-unimac Nicolai Buchwitz
2026-11-20 17:50 ` Florian Fainelli
-- strict thread matches above, loose matches on Subject: below --
2026-11-19 0:59 Florian Fainelli
2026-11-19 0:59 ` [PATCH net-next v4 1/4] net: phy: Map C45 probe read errors to -ENODEV during bus scan Florian Fainelli
2026-11-20 5:38 ` netdev-bot+sashiko
2026-11-20 19:04 ` Florian Fainelli
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=179549873735.3135.6221350265873603736@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew@lunn.ch \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=carlos.soto@broadcom.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=florian.fainelli@broadcom.com \
--cc=hkallweit1@gmail.com \
--cc=justin.chen@broadcom.com \
--cc=kuba@kernel.org \
--cc=kudzo51@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=nb@tipi-net.de \
--cc=netdev@vger.kernel.org \
--cc=opendmb@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox