mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: florian.fainelli@broadcom.com
Cc: netdev@vger.kernel.org, andrew@lunn.ch, nb@tipi-net.de,
	carlos.soto@broadcom.com, opendmb@gmail.com,
	bcm-kernel-feedback-list@broadcom.com, 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 v5 1/4] net: phy: Map C45 probe read errors to -ENODEV during bus scan
Date: Tue, 24 Nov 2026 20:04:09 +0000	[thread overview]
Message-ID: <179555064950.3135.13167713470470981003@kernel.org> (raw)
In-Reply-To: <20261120194318.3952487-2-florian.fainelli@broadcom.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

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), a
  devices-in-package read that fails with -EIO or -ENODEV during the MMD…
- [Low] phy_get_c45_ids() now returns -ENODEV when the devices-in-package
  read (and then the MMD 0 read) fails with -EIO or -ENODEV.

--

net: phy: Map C45 probe read errors to -ENODEV during bus scan

This commit maps -EIO and -ENODEV from the C45 devices in package reads in
get_phy_c45_ids() to -ENODEV, the same way get_phy_c22_id() does. The goal
is that mdiobus_scan_bus_c45() moves on to the next address when nothing
answers, instead of failing the whole bus registration. When an MMD read
fails this way inside the MMD search loop, the loop stops and only the
MMD 0 fallback is tried.

> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index b39e945cebd73..2f17c9d4a2b9f 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c

[ ... ]

> @@ -844,8 +859,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 MMD is treated like a read of all Fs. With the
break, doesn't it behave differently from a real all-Fs read?

On a real all-Fs read, the loop condition in get_phy_c45_ids() keeps
searching the later MMDs:

	for (i = 1; i < MDIO_MMD_NUM && (devs_in_pkg == 0 ||
	     (devs_in_pkg & 0x1fffffff) == 0x1fffffff); i++) {

Commit bba238ed037c ("continue searching for C45 MMDs even if first
returned ffff:ffff") added that on purpose, so that a device without a
PMA/PMD MMD is still found. One example is the Lynx PCS, which only answers
on MMD 3 (DEVS1=0x008a).

After the break, MMD 0 is the only probe left. If that read fails too,
get_phy_c45_probe_err() returns -ENODEV. mdiobus_scan_bus_c45() or
fwnode_mdiobus_register_phy() then skips the device without printing
anything.

Controllers report the same missing turnaround on an unimplemented MMD in
different ways. enetc_mdio_read_c45() returns all Fs:

	/* return all Fs if nothing was there */
	if (enetc_mdio_rd(mdio_priv, ENETC_MDIO_CFG) & MDIO_CFG_RD_ER) {
		...
		return 0xffff;

UniMAC with read_c45 (MDIO_READ_FAIL -> -EIO, added later in this series)
and mvmdio XSMI (!READ_VALID -> -ENODEV) return an error instead.

Could the same PHY or PCS be found behind ENETC but missed behind UniMAC or
mvmdio?

There is a second case. MMD 1 answers (for example, it reads 0), so the
loop goes on, and then MMD 2 fails the turnaround. If MMD 0 also fails,
isn't a device that has already answered skipped silently? That seems to
conflict with this part of the commit message:

  "so a PHY that fails midway is not silently skipped"

The commit message says the remaining MMDs are not probed. Would using
continue with devs_in_pkg = 0xffffffff instead of break keep the detection
rules from bba238ed037c, at the cost of the extra bus reads?

>  	}
>  
>  	if ((devs_in_pkg & 0x1fffffff) == 0x1fffffff) {
> @@ -855,7 +882,8 @@ 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;
> +			/* returning -ENODEV doesn't stop bus scanning */
> +			return get_phy_c45_probe_err(phy_reg);

[Severity: Low]
phy_get_c45_ids() also takes this path. Its only caller is gpy_probe() in
drivers/net/phy/mxl-gpy.c, and it calls it for a PHY that has already been
found over C22 and matched to the driver:

	if (!phydev->is_c45) {
		ret = phy_get_c45_ids(phydev);
		if (ret < 0)
			return ret;
	}

If the C45 devices in package reads on MMD 1 and MMD 0 fail with -EIO,
gpy_probe() now returns -ENODEV. call_driver_probe() in drivers/base/dd.c
logs that only at debug level:

	case -ENODEV:
	case -ENXIO:
		dev_dbg(dev, "probe with driver %s rejects match %d\n",
			drv->name, ret);

Before this patch, -EIO was logged with dev_err() as "probe with driver %s
failed with error %d".

The commit message mentions this change. Is -ENODEV the right code for a
device that has already been identified, though? "No MMD responds" makes
sense during a bus scan. Here it turns a C45 access failure on a known PHY
into a silent match rejection. The binding ends up the same either way, so
what changes is how easy the fault is to diagnose.

>  
>  		/* no device there, let's get out of here */
>  		if ((devs_in_pkg & 0x1fffffff) == 0x1fffffff)

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120194318.3952487-1-florian.fainelli%40broadcom.com

  reply	other threads:[~2026-11-24 20:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 19:43 [PATCH net-next v5 0/4] net: mdio: Clause 45 support for mdio-bcm-unimac Florian Fainelli
2026-11-20 19:43 ` [PATCH net-next v5 1/4] net: phy: Map C45 probe read errors to -ENODEV during bus scan Florian Fainelli
2026-11-24 20:04   ` netdev-bot+sashiko [this message]
2026-11-20 19:43 ` [PATCH net-next v5 2/4] net: mdio: mdio-bcm-unimac: Define MDIO_OP_SHIFT Florian Fainelli
2026-11-20 19:43 ` [PATCH net-next v5 3/4] net: mdio: mdio-bcm-unimac: Poll for completion at 1us granularity Florian Fainelli
2026-11-24 20:04   ` netdev-bot+sashiko
2026-11-20 19:43 ` [PATCH net-next v5 4/4] net: mdio: mdio-bcm-unimac: Add Clause 45 support Florian Fainelli
2026-11-20 20:23   ` Nicolai Buchwitz
2026-11-20 20:29   ` Nicolai Buchwitz
2026-11-20 22:01     ` Florian Fainelli
2026-11-24 20:04   ` netdev-bot+sashiko

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=179555064950.3135.13167713470470981003@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=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

all inboxes | Powered by JetHome®