From: netdev-bot+sashiko@kernel.org
To: florian.fainelli@broadcom.com
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 v4 4/4] net: mdio: mdio-bcm-unimac: Add Clause 45 support
Date: Tue, 24 Nov 2026 05:38:58 +0000 [thread overview]
Message-ID: <179549873890.3135.336400569504120899@kernel.org> (raw)
In-Reply-To: <20261120051653.1433677-5-florian.fainelli@broadcom.com>
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
next prev parent reply other threads:[~2026-11-24 5:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 5:16 [PATCH net-next v4 0/4] net: mdio: Clause 45 support for mdio-bcm-unimac Florian Fainelli
2026-11-20 5:16 ` [PATCH net-next v4 1/4] net: phy: Map C45 probe read errors to -ENODEV during bus scan Florian Fainelli
2026-11-24 5:38 ` netdev-bot+sashiko
2026-11-20 5:16 ` [PATCH net-next v4 2/4] net: mdio: mdio-bcm-unimac: Define MDIO_OP_SHIFT Florian Fainelli
2026-11-20 5:16 ` [PATCH net-next v4 3/4] net: mdio: mdio-bcm-unimac: Poll for completion at 1us granularity Florian Fainelli
2026-11-20 5:16 ` [PATCH net-next v4 4/4] net: mdio: mdio-bcm-unimac: Add Clause 45 support Florian Fainelli
2026-11-24 5:38 ` netdev-bot+sashiko [this message]
2026-11-20 8:30 ` [PATCH net-next v4 0/4] net: mdio: Clause 45 support for mdio-bcm-unimac Nicolai Buchwitz
2026-11-20 17:50 ` Florian Fainelli
-- strict thread matches above, loose matches on Subject: below --
2026-11-19 0:59 Florian Fainelli
2026-11-19 0:59 ` [PATCH net-next v4 4/4] net: mdio: mdio-bcm-unimac: Add Clause 45 support Florian Fainelli
2026-11-20 5:38 ` netdev-bot+sashiko
2026-11-20 19:10 ` 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=179549873890.3135.336400569504120899@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=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@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®