Article View: linux.kernel.netdev
Article #18122Re: [PATCH net-next 3/3] net: mdio: mdio-bcm-unimac: Add Clause 45 support
From: netdev-bot+sashiko
Date: Tue, 17 Nov 2026 21:39
Date: Tue, 17 Nov 2026 21:39
225 lines
16088 bytes
16088 bytes
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 2 · 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).
- [High] This patch sets bus->read_c45 unconditionally.
- [Medium] In the new two-cycle C45 sequence, the only completion check
for the ADDR cycle is the return value of priv->wait_func().
- [Medium] MDIO_CFG now has two read-modify-write paths that share no
lock.
- [Low] C45 callbacks and the MDIO_CFG clause switch are turned on for
every compatible in unimac_mdio_ids: brcm,asp-v3.0/v2.2/v2.1-mdio,…
--
net: mdio: mdio-bcm-unimac: Add Clause 45 support
This commit adds Clause 45 read/write callbacks to the UniMAC MDIO driver.
Each C45 access issues an ADDR cycle followed by a READ/WRITE cycle, and
MDIO_CFG is switched between C22 and C45 mode as needed. The BMSR
workaround read in unimac_mdio_reset() is also skipped for children
compatible with "ethernet-phy-ieee802.3-c45".
> diff --git a/drivers/net/mdio/mdio-bcm-unimac.c b/drivers/net/mdio/mdio-bcm-unimac.c
> index df267bb826966..6059b32580c54 100644
> --- a/drivers/net/mdio/mdio-bcm-unimac.c
> +++ b/drivers/net/mdio/mdio-bcm-unimac.c
[ ... ]
> @@ -96,7 +102,43 @@ static int unimac_mdio_poll(void *wait_func_data)
[ ... ]
> +static void unimac_mdio_set_clause(struct unimac_mdio_priv *priv, bool is_c45)
> +{
> + u32 cfg = unimac_mdio_readl(priv, MDIO_CFG);
> + u32 new_cfg = cfg;
> +
> + if (is_c45)
> + new_cfg &= ~MDIO_C22;
> + else
> + new_cfg |= MDIO_C22;
> +
[Severity: Low]
Do all of the IP revisions in unimac_mdio_ids support the MDIO_CFG clause
bit and the C45 opcodes (ADDR=0b00, READ=0b11)?
The C45 callbacks and this MDIO_CFG read-modify-write are now enabled for
every compatible: brcm,asp-v3.0/v2.2/v2.1-mdio, brcm,bcm6846-mdio,
brcm,genet-mdio-v1..v5 and brcm,unimac-mdio. They are also enabled for the
non-DT GENET pdata instantiation. Nothing gates this per compatible through
match data, and unimac_mdio_set_clause() also runs on every C22 access.
If a revision lacks C45 support, C45 accesses would put undefined frames
on the bus. Those accesses can come from the core C45 scan on an unmasked
bus or from SIOCGMIIREG with a C45 phy_id.
Could the commit message say whether all of these revisions implement C45?
> + if (new_cfg != cfg)
> + unimac_mdio_writel(priv, new_cfg, MDIO_CFG);
> +}
[Severity: Medium]
Can this read-modify-write of MDIO_CFG race with unimac_mdio_clk_set()?
unimac_mdio_set_clause() runs under bus->mdio_lock. unimac_mdio_clk_set()
writes the same register with no lock held:
unimac_mdio_clk_set() {
...
reg = unimac_mdio_readl(priv, MDIO_CFG);
reg &= ~(MDIO_CLK_DIV_MASK << MDIO_CLK_DIV_SHIFT);
reg |= div << MDIO_CLK_DIV_SHIFT;
unimac_mdio_writel(priv, reg, MDIO_CFG);
...
}
It is reached from unimac_mdio_resume() after the bus is registered.
Before this patch, bus accesses never wrote MDIO_CFG.
The GENET parent resumes first. bcmgenet_resume() calls
phy_start_machine() (or phy_start() through bcmgenet_netif_start()). With
mac_managed_pm set, the PHY state machine work can then issue MDIO
accesses while the child unimac resume is running clk_set.
Two interleavings look possible:
(a) clk_set reads cfg, set_clause flips MDIO_C22, then clk_set writes
back the stale clause bit. The next ADDR and data cycles go out in the
wrong framing. For example, a WR_C45 becomes a C22 write of val to
register devad.
(b) set_clause reads cfg, clk_set writes the new MDC divider, then
set_clause writes back the old divider. The restored MDIO clock frequency
is lost until the next resume.
This needs a "clock-frequency" property, otherwise clk_set returns early,
plus mixed C22/C45 traffic so that the clause bit actually changes.
[ ... ]
> @@ -107,8 +149,19 @@ static int unimac_mdio_read(struct mii_bus *bus, int phy_id, int reg)
> return ret;
>
> /* Prepare the read operation */
> - cmd = MDIO_RD_C22 | (phy_id << MDIO_PMD_SHIFT) |
> - (reg << MDIO_REG_SHIFT);
> + unimac_mdio_set_clause(priv, is_c45);
> + if (is_c45) {
> + ret = unimac_mdio_addr_c45(priv, phy_id, devad, reg);
> + if (ret)
> + goto out;
> +
> + cmd = MDIO_RD_C45 | (phy_id << MDIO_PMD_SHIFT) |
> + unimac_mdio_c45_devad(devad) |
> + (reg & MDIO_C45_REG_MASK);
> + } else {
> + cmd = MDIO_RD_C22 | (phy_id << MDIO_PMD_SHIFT) |
> + (reg << MDIO_REG_SHIFT);
> + }
> unimac_mdio_writel(priv, cmd, MDIO_CMD);
[Severity: Medium]
Is the ADDR cycle guaranteed to have finished before MDIO_CMD is
overwritten here?
The only completion check is the return value of priv->wait_func() in
unimac_mdio_addr_c45(). For GENET-instantiated buses, that is
bcmgenet_mii_wait():
bcmgenet_mii_wait() {
...
wait_event_timeout(priv->wq,
!(bcmgenet_umac_readl(priv, UMAC_MDIO_CMD)
& MDIO_START_BUSY),
HZ / 100);
return 0;
}
It returns 0 even when the wait timed out with START_BUSY still set. With
HZ=100, HZ / 100 is a single jiffy. That can expire well before a ~25 us
MDIO frame completes, and the same happens if the MDIO_DONE interrupt is
delayed.
In that case unimac_mdio_addr_c45() reports success while the ADDR frame
is still in flight. unimac_mdio_do_read() and unimac_mdio_do_write() then
write the RD_C45/WR_C45 command and set START_BUSY again without checking
that the controller is idle. Could this corrupt the frame, return data
from an incomplete read, or send a C45 write to the wrong register?
bcmgenet_mii_wait() behaves this way independently of this patch. What
this patch adds is the dependency of the data cycle on the ADDR cycle.
The "if (ret) goto out" after the ADDR cycle can never trigger on GENET
buses.
[ ... ]
> @@ -301,6 +390,8 @@ static int unimac_mdio_probe(struct platform_device *pdev)
> bus->parent = &pdev->dev;
> bus->read = unimac_mdio_read;
> bus->write = unimac_mdio_write;
> + bus->read_c45 = unimac_mdio_read_c45;
> + bus->write_c45 = unimac_mdio_write_c45;
[Severity: High]
Can setting read_c45 unconditionally make bus registration fail on the
non-DT GENET path?
With read_c45 set, __mdiobus_register() runs mdiobus_scan_bus_c45() on
every address that is not masked and has no C22 device. On an empty
address, a C45 read sets MDIO_READ_FAIL, and unimac_mdio_do_read()
returns -EIO:
if (!(bus->phy_ignore_ta_mask & 1 << phy_id) && (cmd & MDIO_READ_FAIL)) {
ret = -EIO;
goto out;
}
get_phy_c22_id() converts -EIO to -ENODEV. get_phy_c45_ids() does not:
phy_reg = get_phy_c45_devs_in_pkg(bus, addr, i, &devs_in_pkg);
if (phy_reg < 0)
return -EIO;
mdiobus_scan_bus_c45() then aborts on any error other than -ENODEV:
if (IS_ERR(phydev) && (PTR_ERR(phydev) != -ENODEV))
return PTR_ERR(phydev);
On the non-DT GENET path, bcmgenet_mii_register() does:
if (dn)
platform_device_set_of_node(ppdev, bcmgenet_mii_of_find_mdio(priv));
else
ppd.phy_mask = ~0;
That leaves bus->phy_mask = ~pdata->phy_mask = 0. With np == NULL,
of_mdiobus_register() calls __mdiobus_register() directly, so all 32
addresses are scanned.
The C45 scan starts at address 0. With a PHY at address 1, as on ACPI
systems such as RPi4 BCM6E4E, the first empty address returns -EIO.
__mdiobus_register() then removes the C22 PHYs it already found, and
unimac_mdio_probe() fails with "MDIO bus registration failed". The MAC
is left without a PHY.
DT-described buses are not affected, because __of_mdiobus_register()
forces phy_mask = ~0.
Should C45 read failures on empty addresses be reported as -ENODEV (or
0xffff) instead of -EIO, or should the C45 callbacks be limited to buses
where the scan is masked?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113211554.2058181-1-florian.fainelli%40broadcom.com
Technical Details
Message-ID:
<179495158559.3136.13854046342906426133@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365631-linux-kernel-netdev=dewy.ruReferences:
<20261113211554.2058181-4-florian.fainelli@broadcom.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365631-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 3/3] net: mdio: mdio-bcm-unimac: Add Clause 45 support Date: Tue, 17 Nov 2026 21:39:45 +0000 Organization: Usenet Network Message-ID: <179495158559.3136.13854046342906426133@kernel.org> References: <20261113211554.2058181-4-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="2433501"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:kqJcyt/+mYMsIiKH+C9kYlrWerk= sha256:Gd7Tr8qYqs/t67zSALxprHWyWm5W7zcMfQUWazvufrU= sha1:YQvgM7LI2oO7BdRJ8zDI9F9VOyY= sha256:ghdzzSUMsyW9XWzAjUKUe26gesGB6oZ7BLEp39qmN5s= 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 394E0115091; Wed, 18 Nov 2026 00:40:05 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 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] 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 2E-IQ_NY97pp; Wed, 18 Nov 2026 00:40:01 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-365631-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 B2F6D115093; Wed, 18 Nov 2026 00:39:52 +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 3EC9662CB1; Tue, 17 Nov 2026 21:39:49 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1794951588; b=QhlydxGghMGhQ/wW/ReZqKPwQ1c63DKawKK1THi8YQj/7Yn0Ie//rTM5BTtp3CmRIzOb 9e4dGk8JHW1lQa7Vfwp9dwl3St0BGkGSTaiw43eQsXdQsxGpUjpeM+ah7C3SThiVT3lL7 cGwPBD4M7WrF8vagjaWxwlfejtRKH4RHd2Ak3TudJgrlOL/to8dasZw93tf3tSaKFaiSV 1hk/gm5rBHbv34lZ14zbRsbOzhsTImksIoXS0eZBA6O0VHEAiOwCswA09gNd2FWD1ovl0 fsDbwi4CBRiYXQIyMfidXgEk3E3qFsSzUwPntsEu/R11eyv1KZxHWgHiSNoCGL03MOQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794951588; 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=nYYC2xC8vF6voVEKyIhR0QplX4ecu6RMdRgEFOEfxB8=; b=4Nx6g4E5uiDUBdOYPiUl8D2DeFjKPbGiOJ4Wlv6ydNjGu7HtS81dJ8TxjyWWOf8d4LBJ IsL54IOe/qqm0ByYfoS+zCk53L3HpQgby/B7F9IKxKrgKO3Yd3Hv2GltvUXwke1hZSD+T uvByA5uOesaa/7SERzjXPfiXi+lnHgei8cnLc4AfafbNh6ELAKnj1xaTqhQMDdlf3A0uJ cDvv6PDMr64zcj+RiygXaKEcwv5Mpj9hEESvg0CQtUchMn3ZPsroIfxO8S0Nls2bFpTdP Ak21FUU34WqtA003iHFJAB2/hXUqx/hWQs+05i2y9d/aaLs4GC53Y36ci0YC4Um5GTA== 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=eNfibGzj; arc=fail 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 1091E606A338; Tue, 17 Nov 2026 21:39:48 +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=eNfibGzj 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=1794951587; b=49JKZtlESIvF6EM7tI4vZ1zFldDAxo8dLDLMTVkhtZoPtZi1zr7ye/sNkai2399EUOrG p5uehfkeRQjM/Y6aIjZKAToQY3WbQK9i4X324CAm7N3hoHQfNJ4Ef/tO3SvnaNkRkequQ 9xejwCwa8NdkIP0lO9IB1wFRyxub5bE0S6bZ3wePVnCLjVEFq0I5tt+49VJiL/03voKMl ReYaCQoVujEL/Hj1LWv3ian5hgyLBYsBpPO5TRvSXa8gUiY6r9KTyq8VlKw+TSjLNF4Qt XcE/iVPZAF+MgsgbHXIKbg0HiwP2p5IqnFYA/vrusAf8CYReOE3QnpbvBOTXbQQaRFQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794951587; 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=nYYC2xC8vF6voVEKyIhR0QplX4ecu6RMdRgEFOEfxB8=; b=h1DJ7mEFLFsiqvoArGgjKmsxS7VVhGsrGLkWXQGO0lp17EmXw+HNPkUXp3KeMALLOc8B acrXqvYiNH01PzmDMR0yGd3HbcmbfvHAdeRzKcCApJQ9UNUQWmESaexqg9Cornfr3CQEK 0TVf8F/pqdSWO0ZwB4xHlDu8bmWNp+M/oF8FagLDRgV3pkZwzss1ghCEqIFkWvCoaQH7t FktpYbaX+isAC1FbJqyg4AwftCEBH8vWhGfpMEM4NlfxgWH1Na6FrCsM26gcyS6FC4+zn GUCEC35Nn/A6Ml8EU0+ezfewUaYK3v+sH/zaIFCp7TsTSBByW0JacpYSA/SnCHr4SsA== 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=eNfibGzj; 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 2DFC6606A31C; Tue, 17 Nov 2026 21:39:47 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1FF0E1F000C4; Tue, 17 Nov 2026 21:39:46 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794951587; bh=nYYC2xC8vF6voVEKyIhR0QplX4ecu6RMdRgEFOEfxB8=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=eNfibGzjDdrNQm474gUXgsB/rV1VrvwV805LTYqiMBbBcMO23M9bdn608QvWBUNxo KPSc3xqtQ1oJhw0cSHFAwACLi2QAtFdDB5PDGt9isWeHncIi3U+H5vIQ6TnmUpFNaO 9t+YyUYqra/h65BafwYt8Dr4x+ZRQPI+H6Q+9AxdSKRjlAu+PrRw8476kFtowltKfO L3wtNR60pkvPtDnS8l/P6+EyjakotcTPdRnoDoTtnwka1jcJozduHb889nsYQfzyRX 8hZfK5XySnV3WRDYn+oBRILZSoZmlDn7w8qQxYbTivrYwW8DRDecj8TRLlbO2dyuP9 KE76K+vg1qj9Q== X-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 X-In-Reply-To: <20261113211554.2058181-4-florian.fainelli@broadcom.com> X-sashiko-severity: High 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 X-Received-Bytes: 15802