From: Florian Fainelli <florian.fainelli@broadcom.com>
To: netdev-bot+sashiko@kernel.org
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 v2 1/4] net: phy: Map C45 probe read errors to -ENODEV during bus scan
Date: Wed, 18 Nov 2026 16:48:02 -0800 [thread overview]
Message-ID: <4ad5124e-c063-48cc-97cf-ac1acc54351c@broadcom.com> (raw)
In-Reply-To: <179504864618.3136.11725933579190133133@kernel.org>
On 11/18/26 16:37, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 2
>
> 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] In get_phy_c45_ids() (drivers/net/phy/phy_device.c), the first
> MMD loop (lines 859-862) now returns get_phy_c45_probe_err(phy_reg),…
> - [Low] The patch fixes a real, user-visible failure but has no Fixes:
> tag.
> - [Low] The kernel-doc of the exported phy_get_c45_ids()
> (drivers/net/phy/phy_device.c:1091-1096) still says it returns '%-EIO…
>
> --
>
> net: phy: Map C45 probe read errors to -ENODEV during bus scan
>
> This commit makes get_phy_c45_devs_in_pkg() return the raw bus error. In
> get_phy_c45_ids(), an -EIO or -ENODEV from the devices in package reads is
> now mapped to -ENODEV. A C45 bus scan can then skip empty addresses on
> controllers that report a read from an empty address as a bus error.
>
>> Let get_phy_c45_devs_in_pkg() return the bus error and apply the same
>> mapping as get_phy_c22_id() to the two places that look for a device at an
>> address: the loop over the MMDs and the MMD 0 fallback. Errors from the
>> reads of the per-MMD identifiers, which only happen once a device has
>> answered, are still reported as -EIO.
>>
>> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
>
> [Severity: Low]
> Should this carry a Fixes: tag?
Agreed, v4 adds:
Fixes: 17b447539408 ("net: phy: c45 scanning: Don't consider
-ENODEV fatal")
>
> Commit 17b447539408 ("net: phy: c45 scanning: Don't consider -ENODEV
> fatal") was meant to make the C45 scan treat -ENODEV as non-fatal. It only
> changed the phy_c45_probe_present() call, on the assumption that this was
> the first place a read occurs.
>
> In get_phy_c45_ids(), the first read for an address is actually the MMD 1
> devices in package read. phy_c45_probe_present() only runs for MMD 30/31.
> Commit 6f533abe7bbad2 already fixed a related problem in the same mapping
> and carries Fixes: 17b447539408.
>
> This can be hit in mainline today, without the rest of the series.
> orion_mdio_xsmi_read_c45() in drivers/net/ethernet/marvell/mvmdio.c
> returns -ENODEV for an invalid read:
>
> dev_err(bus->parent, "XSMI bus read not valid\n");
> return -ENODEV;
>
> Take a DT child with "ethernet-phy-ieee802.3-c45" at an address where no
> PHY is present. Before this patch the path was:
>
> fwnode_mdiobus_register_phy()
> get_phy_device(is_c45=true)
> get_phy_c45_ids()
> get_phy_c45_devs_in_pkg() -> -ENODEV, returned as -EIO
>
> __of_mdiobus_parse_phys() treats anything other than -ENODEV as fatal and
> unregisters the whole MDIO bus.
>
> Without the tag, stable kernels that carry 17b447539408 and 6f533abe7bbad2
> keep the half-applied behaviour.
>
>> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
>> index b39e945cebd73..4071041e1051d 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,
>
> [ ... ]
>
>> +/* get_phy_c45_probe_err - map a bus error seen while looking for a device.
>> + * @err: negative error code returned by a bus read
>> + *
>> + * Like get_phy_c22_id(), report -ENODEV when the bus read failed with -EIO or
>> + * -ENODEV, which is how a controller signals that nothing answered at this
>> + * address, so that bus scanning carries on with the next address. Anything
>> + * else is reported as -EIO.
>> + */
>> +static int get_phy_c45_probe_err(int err)
>> +{
>> + return (err == -EIO || err == -ENODEV) ? -ENODEV : -EIO;
>> +}
>> +
>
> [ ... ]
>
>> @@ -845,7 +858,8 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr,
>> }
>> phy_reg = get_phy_c45_devs_in_pkg(bus, addr, i, &devs_in_pkg);
>> if (phy_reg < 0)
>> - return -EIO;
>> + /* returning -ENODEV doesn't stop bus scanning */
>> + return get_phy_c45_probe_err(phy_reg);
>> }
>
> [Severity: Medium]
> Can this early return skip a device that is present but does not drive
> the bus on the first MMD probed?
Yes, this was a legitimate issue. A PHY that only responds on MMD 0
(Cortina CS4315/CS4340) would never reach the MMD 0 fallback on a
controller that checks turnaround (UniMAC, mvmdio XSMI), because the MMD
1 read would terminate the probe of the whole address.
In v4, a failed "devices in package" read in the MMD loop (-EIO or
-ENODEV) is handled like an all-Fs reply: the loop moves on to the next
MMD and then to the MMD 0 fallback, and -ENODEV is only returned if
nothing answered.
Any other error code is still returned as -EIO immediately, and errors
on the per-MMD identifier reads are still -EIO, as the commit message says.
For a device that answers MMD 1 with 0x0000 and then fails turnaround on
MMD 2, the probe now also continues to MMD 0 rather than returning right
away. If MMD 0 does not answer either, it is dropped with -ENODEV. That
device violates turnaround, so I think this is acceptable.
>
> On a controller that samples the pull-up, an MMD that does not respond
> reads as 0xffff. The loop then moves on to the next MMD, and after that to
> the MMD 0 fallback.
>
> On a controller that checks turnaround, the same MMD now ends the probe of
> the whole address with -ENODEV. Examples are UniMAC, which returns -EIO on
> MDIO_READ_FAIL and gets read_c45 later in this series ("net: mdio:
> mdio-bcm-unimac: Add Clause 45 support"), and mvmdio XSMI, which returns
> -ENODEV when READ_VALID is clear.
>
> A Cortina CS4315/CS4340 style PHY only uses MMD 0:
>
> drivers/net/phy/cortina.c:cortina_read_reg() {
> return mdiobus_c45_read(phydev->mdio.bus, phydev->mdio.addr, 0, regnum);
> }
>
> On these controllers, can the MMD 0 fallback below ever be reached for such
> a PHY, given that the MMD 1 read fails first?
>
> A device can also answer MMD 1 with devs_in_pkg == 0x0000, which means it
> drove MDIO low, and then fail turnaround on MMD 2. That failure is also
> mapped to -ENODEV here. This seems to go against the commit message:
>
> Errors from the reads of the per-MMD identifiers, which only happen
> once a device has answered, are still reported as -EIO.
>
> mdiobus_scan_bus_c45() then swallows the error:
>
> phydev = mdiobus_scan_c45(bus, i);
> if (IS_ERR(phydev) && (PTR_ERR(phydev) != -ENODEV))
> return PTR_ERR(phydev);
>
> So the device is dropped with no message. Before this patch, bus
> registration failed and the problem was visible.
>
> Would it work to treat the bus error the same way as a 0xffff reply? That
> would mean continuing the loop, trying MMD 0, and returning -ENODEV only if
> nothing answered, instead of returning early.
>
>> @@ -855,7 +869,7 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr,
>> */
>> phy_reg = get_phy_c45_devs_in_pkg(bus, addr, 0, &devs_in_pkg);
>> if (phy_reg < 0)
>> - return -EIO;
>> + return get_phy_c45_probe_err(phy_reg);
>
> [Severity: Low]
> Does the kernel-doc of the exported phy_get_c45_ids() still match after
> this change? The doc for get_phy_c45_devs_in_pkg() was updated, but this
> one still says:
>
> * Returns zero on success, %-EIO on bus access error, or %-ENODEV if
> * the "devices in package" is invalid.
> */
> int phy_get_c45_ids(struct phy_device *phydev)
>
> Both call sites in get_phy_c45_ids() now go through
> get_phy_c45_probe_err(). A real bus -EIO on a PHY that already exists
> therefore comes back as -ENODEV.
>
> phy_get_c45_ids() is not a bus scan. gpy_probe() in mxl-gpy.c calls it on a
> bound PHY and returns the result as its probe status:
>
> if (!phydev->is_c45) {
> ret = phy_get_c45_ids(phydev);
> if (ret < 0)
> return ret;
> }
>
> call_driver_probe() logs -ENODEV only with dev_dbg(), as "rejects match".
> -EIO gets a dev_err().
>
> Would a real MDIO bus fault during gpy_probe() now turn into a silent
> failure to bind?
>
It did not; v4 updates the kernel-doc of both get_phy_c45_ids() and
phy_get_c45_ids(). On the gpy_probe() concern: a bus -EIO while looking
for a device is now reported as -ENODEV, the same mapping that
phy_c45_probe_present() already gets in this function. gpy_probe() runs
on a PHY that the scan already found, so I don't think this is a
practical regression and I would rather keep one mapping in
get_phy_c45_ids() than split it by caller. Happy to move it into
get_phy_device(), as the C22 path does, if reviewers prefer.
pw-bot: cr
--
Florian
next prev parent reply other threads:[~2026-11-19 0:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 21:34 [PATCH net-next v2 0/4] net: mdio: Clause 45 support for mdio-bcm-unimac Florian Fainelli
2026-11-16 21:34 ` [PATCH net-next v2 1/4] net: phy: Map C45 probe read errors to -ENODEV during bus scan Florian Fainelli
2026-11-17 9:33 ` Nicolai Buchwitz
2026-11-19 0:37 ` netdev-bot+sashiko
2026-11-19 0:48 ` Florian Fainelli [this message]
2026-11-16 21:34 ` [PATCH net-next v2 2/4] net: mdio: mdio-bcm-unimac: Define MDIO_OP_SHIFT Florian Fainelli
2026-11-16 21:34 ` [PATCH net-next v2 3/4] net: mdio: mdio-bcm-unimac: Poll for completion at 1us granularity Florian Fainelli
2026-11-16 21:34 ` [PATCH net-next v2 4/4] net: mdio: mdio-bcm-unimac: Add Clause 45 support Florian Fainelli
2026-11-17 12:36 ` Nicolai Buchwitz
2026-11-19 0:37 ` netdev-bot+sashiko
2026-11-19 0:53 ` Florian Fainelli
2026-11-16 22:38 ` [PATCH net-next v2 0/4] net: mdio: Clause 45 support for mdio-bcm-unimac Kordian Chmielewski
2026-11-17 12:36 ` Nicolai Buchwitz
2026-11-17 23:17 ` 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=4ad5124e-c063-48cc-97cf-ac1acc54351c@broadcom.com \
--to=florian.fainelli@broadcom.com \
--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=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-bot+sashiko@kernel.org \
--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