🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #22061

Re: [PATCH net-next v5 1/4] net: phy: Map C45 probe read errors to -ENODEV during bus scan

#22061
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 20:04
147 lines
13572 bytes
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
Technical Details
Message-ID: <179555064950.3135.13167713470470981003@kernel.org>
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370725-linux-kernel-netdev=dewy.ru
References: <20261120194318.3952487-2-florian.fainelli@broadcom.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370725-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <179555064950.3135.13167713470470981003@kernel.org>
References: <20261120194318.3952487-2-florian.fainelli@broadcom.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="28305"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:baGdw/RIYssin0fLxHYESlA0n/w= sha256:jW/YvZGeixetm9+cG9Pcz28iybEBD99OXJTKKbRpBpI=
	sha1:yfi6F+9JD0EnrMBdwpNFG97k88g= sha256:kSQs3m6hC3+eZ/OnUw2NZxI8pkNpYZ2uwOnri6TZI4E=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 93E5E125E2F; Tue, 24 Nov 2026 23:04:30 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id FT4FeXLQme0D;
	Tue, 24 Nov 2026 23:04:26 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-370725-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 0F92C125E29; Tue, 24 Nov 2026 23:04:16 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 89DAB35280; Tue, 24 Nov 2026 20:04:13 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795550652;
	b=bS4OJvBVJzD6I2gt8+Wc2bO23f161Fj86PvZm3YdNTk7eJdjNQLFSh7nbedsHrmri1xv
	 ojh4YfhwFmWsv4xwz0GQxookKRXL/jBZm+Xiadha+icRHsFtpOUh6t7qEb9bpWOjhXjrE
	 8yZkWNNK5db65kZjm0L8MqEjMYpVOU4Zxn34Ic/r+pxOp9u4vFG3229bxHAVV8kTYQkeS
	 NDSWXs9vKO6EJ2uhg4ofnQxmBZl7XEaNc64Gc4ZnWC2msq137yqa2zX3Tsw+FfgZSn5zp
	 X8w240G+xh4Ni9CfKmJWmNbqhdQ6Vs1FOyahVeSPmKwQNlsEOJdDw6S+sLyhsBenZnA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795550652;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=NJgrCbYf5ZnAx28JrKUhZHLhXQt7+fhD6OiPtOw/Y6M=;
	b=ZA0ZjKoOIgs+pzEhck6U0Jrgs99Nl1T3MExKD1DPceaZiXXXL21LHpRBR85GFffWU7rg
	 hbbigRxAZGeXBm+zZo1LZMCGLietS+RlQ3kueTgnSDDssluyb4kb7pWp0FEohxqFVeBPC
	 36loXVfz48iWDk3+D+KBnq+bHRm9hxX1yI7HYVpRUjR+zaymgdb22y7Z1umafj2fXOxxv
	 L08GOpIRgXrL5RCA+OFB944ofl0PG5ZlubUTJ1GZG0ZAwS6432a92VgcwW4QNOF0v2AXh
	 b6WGfd4ruAQH0cscodn4C+Zz+uJSavlSHYvkTvfMDmolF+GhR/5q9aQ+522ZleZlChw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ba7D17X9;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 6105D606A333;
	Tue, 24 Nov 2026 20:04:12 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ba7D17X9
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795550651;
	b=az3PoEIFYpSuj39TvsdJLkmf6YNHafCcy2KFWqjo1rka1dJdECgVYOfRQi4S6mWDeXok
	 IhGsPPodzjJazRgLT7psmfuaESjAv0spMM0pw96PEXiFagHkgmy92i9QvI/whf6crDFOi
	 8tmPtbKYo/7wBdkK2ZuQp9cYkEIoHNvxdnNh324TH9J+qYqkEODsA7yP71niVDNjbpBKp
	 kJjkq1QpHSmbbo5jaHoUvGMXrUgwJtFUDg6fIaKzGE7FQS8noR0H3B4uH+Fyvx0aIn0Ly
	 mVXCqUL1Z2rifXXTfIV1x9KeVafAXieVvEloYC4E7mWPAbf0pUj7oKvFsfe3lGluKOg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795550651;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=NJgrCbYf5ZnAx28JrKUhZHLhXQt7+fhD6OiPtOw/Y6M=;
	b=TSFZgyMmu3Bhqciv9u9ytSi8ZYMQ7xggwYVFGidorSNRSfTktVnR4dbnzHTh58mt5o00
	 hvuSts5qPJaj1NrmsgRmduYVmbWySXkDc8IsbsFpD2NQO+eX6NKn3m2ddDicqbu2ZQdg4
	 CM4OAKqY9IiLx7OhlXyMzje4DEXtVnSrEVWry2LR61URN03nr/i8aBL+IFOy29mMqryHI
	 uod2RRx0zjR+4nW5H3XLMqz4rjDthHojzX1g1xykA1iN9JXOEb9JPh3oMbXnlB+5DrAqb
	 v3cDzuVc9Qn6o7FJdPJIsXI3VB9aqWXtYFDm4xPPfMcevImG0zEVeHaxUII81SvlviQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ba7D17X9;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F9A0606A31E;
	Tue, 24 Nov 2026 20:04:11 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0373C1F000D3;
	Tue, 24 Nov 2026 20:04:09 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795550650;
	bh=NJgrCbYf5ZnAx28JrKUhZHLhXQt7+fhD6OiPtOw/Y6M=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Ba7D17X9KKc/O6jWOYNnrJadNorAyllIAwp1xUCI7rB2M6T3YxSy8vv6aVC1uwAHt
	 YQwUmv2MHN89o6oSInMqKhhr99fFdjLGwx8Hu9CISwqqhOvnN8GDpb0Al1LOmP8NLf
	 zsYrEUAMEeK1vCcRKthT2HGjO98j0KcXyLLlh+L+CZhP24+HZoLGEOV18AyKzne0O+
	 152AuayfzngfdBBvRL8qdRcwOxtuOcFZCSd6MoQqCEO8rshFcYt3+/H59c4fVTHK1j
	 YiCk5ANIjuywYqntqORwLaWg2r+8oQvZ5ePO/QdK1R97KFWfAynmMBcXmZJCmNy1Z7
	 /vRFkumQwy1oA==
X-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
X-In-Reply-To: <20261120194318.3952487-2-florian.fainelli@broadcom.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list