Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: mmyangfl@gmail.com
Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org, shenjian15@huawei.com, shaojijie@huawei.com,
	devicetree@vger.kernel.org
Subject: Re: [PATCH net-next v3 1/5] net: hix5hd2_gmac: Use devm_ managed netdev and MDIO bus
Date: Wed, 25 Nov 2026 00:28:15 +0000	[thread overview]
Message-ID: <179556649591.3135.5859948318668585825@kernel.org> (raw)
In-Reply-To: <20261124002442.19414-2-mmyangfl@gmail.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] On a probe failure, the MDIO bus is now torn down after the MAC
  clocks are already off.

--

net: hix5hd2_gmac: Use devm_ managed netdev and MDIO bus

This commit switches hix5hd2_gmac to devm_alloc_etherdev(),
devm_mdiobus_alloc() and devm_of_mdiobus_register(). It drops the
manual free_netdev() and mdiobus_unregister()/mdiobus_free() calls from
the probe error path and from hix5hd2_dev_remove().

> diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
> index 12a5657653f85..d129aeceb641e 100644
> --- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
> +++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c

[ ... ]

> @@ -1189,21 +1189,21 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
>  	snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(&pdev->dev));
>  	priv->bus = bus;
>  
> -	ret = of_mdiobus_register(bus, node);
> +	ret = devm_of_mdiobus_register(dev, bus, node);
>  	if (ret)
> -		goto err_free_mdio;
> +		goto out_disable_clk;

[ ... ]

> @@ -1269,16 +1269,10 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
>  	hix5hd2_destroy_hw_desc_queue(priv);
>  out_phy_node:
>  	of_node_put(priv->phy_node);
> -err_mdiobus:
> -	mdiobus_unregister(bus);
> -err_free_mdio:
> -	mdiobus_free(bus);
>  out_disable_clk:
>  	clk_disable_unprepare(priv->mac_ifc_clk);
>  out_disable_mac_core_clk:
>  	clk_disable_unprepare(priv->mac_core_clk);
> -out_free_netdev:
> -	free_netdev(ndev);
>  
>  	return ret;
>  }

[Severity: Low]
Does this change when the MDIO bus is torn down, relative to the clocks,
if hix5hd2_dev_probe() fails?

Before this patch, a failure after of_mdiobus_register() ran
mdiobus_unregister() while mac_ifc_clk and mac_core_clk were still
enabled. Now the error path disables both clocks and returns. Devres then
runs devm_mdiobus_unregister() -> mdiobus_unregister() with the clocks
off.

These failures take that path:

- missing phy-mode or phy-handle
- platform_get_irq() errors, including -EPROBE_DEFER
- devm_request_irq() failure
- descriptor queue allocation failure
- register_netdev() failure

If the bus scan found a PHY and bound it to a driver, mdiobus_unregister()
calls phy_remove() through device_del(). phy_remove() can do MDIO I/O:

phy_remove()
    phy_leds_unregister()
        led_classdev_unregister()
            led_set_brightness(LED_OFF)
    phydev->drv->remove()

The LED_OFF write happens unless the DT sets retain-state-shutdown.

Those accesses go through hix5hd2_mdio_read() and hix5hd2_mdio_write().
Both poll the MAC register window in priv->base:

hix5hd2_mdio_wait_ready() {
    ...
	for (i = 0; readl_relaxed(base + MDIO_SINGLE_CMD) & MDIO_START; i++) {
		if (i == timeout)
			return -ETIMEDOUT;
		usleep_range(10, 20);
	}
    ...
}

With the MAC block unclocked, could these accesses time out (up to 10000
iterations per access)? Could they read a stale ready value and lose the
write, or stall the bus on some SoCs?

Before this patch, hix5hd2_dev_remove() already called
mdiobus_unregister() with the clocks off, because probe and ndo_stop
both disable them. The new ordering only affects the unwind after a
failed probe.

The same ordering is still there after the later patch in this series,
"net: hix5hd2_gmac: Support fixed-link". Its out_phy_node and
out_disable_clk labels disable the clocks while devres still holds the
registered bus.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124002442.19414-1-mmyangfl%40gmail.com

  reply	other threads:[~2026-11-25  0:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  0:24 [PATCH net-next v3 0/5] net: hix5hd2_gmac: Support fixed-link David Yang
2026-11-24  0:24 ` [PATCH net-next v3 1/5] net: hix5hd2_gmac: Use devm_ managed netdev and MDIO bus David Yang
2026-11-25  0:28   ` netdev-bot+sashiko [this message]
2026-11-24  0:24 ` [PATCH net-next v3 2/5] dt-bindings: net: hisilicon,hisi-gmac-v1: Add mdio bus child node David Yang
2026-11-24  0:24 ` [PATCH net-next v3 3/5] net: hix5hd2_gmac: Use mdio child node for MDIO bus if it exists David Yang
2026-11-25  0:28   ` netdev-bot+sashiko
2026-11-24  0:24 ` [PATCH net-next v3 4/5] dt-bindings: net: hisilicon,hisi-gmac-v1: Allow fixed-link David Yang
2026-11-25  0:28   ` netdev-bot+sashiko
2026-11-24  0:24 ` [PATCH net-next v3 5/5] net: hix5hd2_gmac: Support fixed-link David Yang
2026-11-25  0:28   ` 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=179556649591.3135.5859948318668585825@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=mmyangfl@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    --cc=shaojijie@huawei.com \
    --cc=shenjian15@huawei.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