Article View: linux.kernel.netdev
Article #21528Re: [PATCH net-next v4 4/4] net: mdio: mdio-bcm-unimac: Add Clause 45 support
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 05:38
Date: Tue, 24 Nov 2026 05:38
184 lines
14443 bytes
14443 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 0
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] This patch sets bus->read_c45/bus->write_c45 unconditionally
in unimac_mdio_probe() (drivers/net/mdio/mdio-bcm-unimac.c:404-405).
- [Medium] The patch itself says (comment in unimac_mdio_addr_c45(),
lines 129-133) that bcmgenet_mii_wait() returns 0 even when it times…
--
net: mdio: mdio-bcm-unimac: Add Clause 45 support
This adds read_c45/write_c45 callbacks to the UniMAC MDIO driver. Each
access does an ADDR cycle followed by a READ/WRITE cycle and switches
MDIO_CFG between C22 and C45 mode as needed. It also skips the BMSR
workaround for "ethernet-phy-ieee802.3-c45" children and takes the bus
lock around unimac_mdio_clk_set() in resume.
> diff --git a/drivers/net/mdio/mdio-bcm-unimac.c b/drivers/net/mdio/mdio-bcm-unimac.c
> index f8e5c1811d96b..a79830566abb0 100644
> --- a/drivers/net/mdio/mdio-bcm-unimac.c
> +++ b/drivers/net/mdio/mdio-bcm-unimac.c
[ ... ]
> @@ -97,7 +103,53 @@ static int unimac_mdio_poll(void *wait_func_data)
[ ... ]
> +static int unimac_mdio_addr_c45(struct unimac_mdio_priv *priv,
> + int phy_id, int devad, int reg)
> +{
> + u32 cmd;
> + int ret;
> +
> + /* Prepare the addr c45 operation */
> + cmd = MDIO_ADDR_C45 | (phy_id << MDIO_PMD_SHIFT) |
> + unimac_mdio_c45_devad(devad) | (reg & MDIO_C45_REG_MASK);
> + unimac_mdio_writel(priv, cmd, MDIO_CMD);
> +
> + /* Start MDIO transaction */
> + unimac_mdio_start(priv);
> +
> + ret = priv->wait_func(priv->wait_func_data);
> + if (ret)
> + return ret;
> +
> + /* Some wait_func implementations (e.g.: bcmgenet_mii_wait()) return 0
> + * even when they timed out with the controller still busy. The data
> + * cycle must not be started before the ADDR cycle has completed, so
> + * make sure the controller is idle.
> + */
> + return unimac_mdio_poll(priv);
> +}
[ ... ]
> @@ -108,8 +160,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);
>
> /* Start MDIO transaction */
[Severity: Medium]
The comment in unimac_mdio_addr_c45() says bcmgenet_mii_wait() can
return 0 while START_BUSY is still set, so the ADDR cycle is followed by
unimac_mdio_poll(). Should the C45 data cycle get the same check?
bcmgenet_mii_wait() always returns 0:
drivers/net/ethernet/broadcom/genet/bcmmii.c:bcmgenet_mii_wait() {
wait_event_timeout(priv->wq,
!(bcmgenet_umac_readl(priv, UMAC_MDIO_CMD)
& MDIO_START_BUSY),
HZ / 100);
return 0;
}
With HZ=100 that timeout is a single jiffy, so it can expire before the
frame completes. At probe time there is also no MDIO IRQ to wake it.
After the data cycle, unimac_mdio_do_read() reads the result right away:
ret = priv->wait_func(priv->wait_func_data);
if (ret)
goto out;
cmd = unimac_mdio_readl(priv, MDIO_CMD);
...
ret = cmd & 0xffff;
For a C45 read, bits 15:0 of MDIO_CMD were just set to
(reg & MDIO_C45_REG_MASK). If the frame is still in flight, MDIO_READ_FAIL
is not valid yet.
Could the caller then get the MMD register number back as PHY data?
The C45 write path in unimac_mdio_do_write() has the same gap, because it
returns the wait_func() result directly. Could the next access then call
unimac_mdio_set_clause(), flip MDIO_CFG and write a new MDIO_CMD while the
previous C45 frame is still on the wire?
[ ... ]
> @@ -302,6 +401,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: Medium]
Can this add more than a second of probe delay for GENET when it has no
DT node, for example on ACPI?
Now that read_c45 is always set, __mdiobus_register() runs
mdiobus_scan_bus_c45() on every unmasked address that has no C22 device.
Without DT, bcmgenet_mii_register() sets ppd.phy_mask = ~0. The unimac
bus then gets bus->phy_mask = 0, so every address is scanned.
In that case wait_func is bcmgenet_mii_wait(). Its only waker is
bcmgenet_isr0() handling UMAC_IRQ_MDIO_EVENT, and that IRQ is not
requested until bcmgenet_open(). The bus is registered and scanned
earlier:
bcmgenet_probe()
bcmgenet_mii_init()
bcmgenet_mii_register()
platform_device_add()
unimac_mdio_probe()
of_mdiobus_register(bus, NULL)
__mdiobus_register()
mdiobus_scan_bus_c45()
get_phy_c45_ids()
unimac_mdio_read_c45()
So each MDIO frame sleeps for the full HZ/100. A C45 access is two frames
(ADDR plus data), and get_phy_c45_ids() does at least two C45 reads at an
empty address (MDIO_DEVS2 on MMD1, then on MMD0). That works out to about
31 x 4 x 10ms, roughly 1.2s per GENET instance. This comes on top of the
existing BMSR workaround and C22 scan.
If the controller does not flag READ_FAIL for C45 reads at empty
addresses, the devices-in-package loop walks MMDs 1..29 and the delay
grows a lot more.
The commit message only says:
This includes the platform device that GENET instantiates when it is
probed without a Device Tree node (e.g.: ACPI), which does not mask
any address.
Would it make sense to skip C45, or mask addresses, in the pdata/no-DT
case? If not, could the commit message at least mention the probe time
cost?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120051653.1433677-1-florian.fainelli%40broadcom.com
Technical Details
Message-ID:
<179549873890.3135.336400569504120899@kernel.org>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370018-linux-kernel-netdev=dewy.ruReferences:
<20261120051653.1433677-5-florian.fainelli@broadcom.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370018-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v4 4/4] net: mdio: mdio-bcm-unimac: Add Clause 45 support Date: Tue, 24 Nov 2026 05:38:58 +0000 Organization: Usenet Network Message-ID: <179549873890.3135.336400569504120899@kernel.org> References: <20261120051653.1433677-5-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="4061690"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:4Fdo9Rc7QK8SXVkLEgAMlZsk7eY= sha256:tYpwVaGsAo0u+fc0Xih4y+NkCSQDwZAfTDERrYwkWpo= sha1:Mw92J4c0MNuPfosCHaJ5VVmyumw= sha256:4ksnjTKsoVmgfo3Bya6RcEmRA03zBoBTuytQxfRxcWo= 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 426EC125DCF; Tue, 24 Nov 2026 08:39:25 +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 Q4uPYsK1XiEl; Tue, 24 Nov 2026 08:39:21 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-370018-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 78C6B125DCE; Tue, 24 Nov 2026 08:39:13 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 5FCB931AF8; Tue, 24 Nov 2026 05:39:07 +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=1795498741; b=y8O03nqcI43GyquvW94jjig47LyhdDtmFrqn57QF6K1w6X7ANiEDBcVASA/nzPj/m7D3 ZMzz3NN5N9QFCDrom7OmQ8k6OAwWkE2bi4O7H9ugSIB5SSy4uik+mMk/2eXWW0c3BfOKN Tcva2h13LXd+quiBEw7Mzauiw5njv/+4Pf0FSjQAUPM+wABrtsDM1mlQIC/uNi3sT5k9e 32f2g3Sul6U3Ldf/U1Qg8AjnRaU5Cm3LMKw8yVNDL7wr7vMMA76OisAY2PyCZJvmO4Txm lbxp5x27Sltw08wUlGaA/YEqjDaj44eDQVHbZ0iReZRUdcabrShSL68TemPshSchRKQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795498741; 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=sPjdcsWRMWGm7Iu02ZOoApvGOq1Znmpsgsg1uc8FTOo=; b=ttJC5I4B6jKsFUBdmx3XrGX/SvRu6TmBspcjH2MGNzBjhAKqo6YqJPOJrvxcN8qS9DQC j+v0TG5sBx4GGuGUAVPoZLI5k9JVAUDUTr5Ts8j0N6xrf2IzcAtrxBvmfoN9PzTTHtGrb ojbubVxPJIR2s2fzBIaCXGbph2IgBKcvLDboToGA6xz1VmF84VJ3kOrJw3fxmHqA/ctAh 0iyQ+Vc6YgHfaqwQtyRAC8dHpeIjZIFr7FOHUHSyuhAAeW5hEeJoJ0Qy2SeXstMZWdHbt tEMbKaRExbJYG+YW4+fEJE1oYSfVkluMZCj3QYf80KD1pGCaVtoc6wz0ZshSxJ+p26A== 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=RWuzF0au; 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 61A1A606A690; Tue, 24 Nov 2026 05:39:01 +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=RWuzF0au 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=1795498740; b=y76TCis40DXfaRO9Y94jjPNSLfq1/4YMTvUVG5bgdRxp1z/bKksknSy6Ao8PBaekuTcd aYf0m6OylXKTb+MFRvYHavCqyuEq8+ar+YRBUg55VuexLfywX57lML5zquwVOsCw0QdhL AoBfNd8Vmeo2pDeTsHMtJW88qPmt0+dKQO2T+riKdNYzkSvYsJHs8ytVh8JMldvaBiYwi JAIlmmU1UzBM5B2RoOUE1itYwTiIGPIDn/Wnd0FQd30gBsiIkux10GtlZ58PQq3XKic9V 8JIa8blg7v1bvN/a6oL/Y9SxqDOq4Su7ua+eCdurd5ZoCduIrvU0Ane8GxLKQuXJj0g== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795498740; 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=sPjdcsWRMWGm7Iu02ZOoApvGOq1Znmpsgsg1uc8FTOo=; b=mlrMG70aKPYPJAoEo8Iv2zEULPRwRor9AOrqNKYJ5LXldwkuQkq+/wmFOjFlTN5J6HhT feR90QVH2k4KbyDaOHTWo0GJV8FpaEaI8Oes+nPLIhtOHOyd5k/VY4GLHRKa192j67ccQ y+18D9GQCinNbbsu/Wr2XGMXhTDttsqTiQpgyCH8pPl9LR6uxaYCl0/E8Gc6giED2LJXV 6iHDLaw2/9x0fE0vfs0PpoWdHx0KPsrBDlYcuL4QHMEoI9VcjCbK6Id12PFlvXaa+XSFB 6KHJW5SRgSyAvCy89rVwfaGUIt6oYrWegRI+imtB/aL15hYlLPPfNyKFuWKaXwPjt5g== 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=RWuzF0au; 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 7D3F9606A33C; Tue, 24 Nov 2026 05:39:00 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50D1E1F000CA; Tue, 24 Nov 2026 05:38:59 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795498740; bh=sPjdcsWRMWGm7Iu02ZOoApvGOq1Znmpsgsg1uc8FTOo=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=RWuzF0auVxnG2ILJ4zLWZx14JF7ApAogZbq/4cJv/oi2K8nGBGOBNUR9cEjhJIKMF Q+zWyL+GoHbgj2LufnrU2iR/KaboPYqeaENyENsgV5hlteSi1lcAjDCsdYWoT+mU9p 9a4s3Cr7hQQMwGZSaCLWmlXZ6OHpwRy/jT4ZO4z21NKaPTTR8LcGHFM7X8QBd8FwUh YEB5YEu2LY+Mgk9FhvtTWPLTlG5hw3vGi/vxJLucfcdcvjMk2hJBoyRYJRUW7wBGyr O8udgI6BBc22Xh1TdJfyXS0r2DWJaRhqCbaj2pFotNRDWfq7fD+kjDiN8ITzas0sn2 S+8oJtHgDgstA== 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: <20261120051653.1433677-5-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