All of lore.kernel.org
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: f.fainelli@gmail.com
Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, hkallweit1@gmail.com, linux@armlinux.org.uk,
	shaojijie@huawei.com, horms@kernel.org, runyu.xiao@seu.edu.cn,
	mmyangfl@gmail.com, hvr@gnu.org, danny.kukawka@bisect.de,
	mugunthanvnm@ti.com, sebastian.hesselbarth@gmail.com,
	linux-kernel@vger.kernel.org, manuel.lauss@gmail.com
Subject: Re: [PATCH net v3 03/10] net: au1000: disconnect the PHY before freeing the MDIO bus
Date: Fri, 20 Nov 2026 10:32:34 +0000	[thread overview]
Message-ID: <179517075464.3136.12005891937960917967@kernel.org> (raw)
In-Reply-To: <20261117193223.2795612-4-f.fainelli@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] The commit message of "net: au1000: disconnect the PHY before
  freeing the MDIO bus" partly misstates what the patch fixes, and…

--

net: au1000: disconnect the PHY before freeing the MDIO bus

This commit adds phy_disconnect() calls to the au1000_probe() error path
and to au1000_remove(), so that phy_connect() is balanced. It also makes
au1000_reset_mac_unlocked() skip MAC control register accesses when
mac_enabled is clear. It also resets the MAC in au1000_remove() after the
PHY and MDIO bus are torn down.

> Balance phy_connect() on probe failure and removal. Otherwise PHY
> interrupts, device references and the attachment to the freed netdev
> survive teardown.

[Severity: Low]
Can a PHY interrupt actually survive teardown in this driver?

mdiobus_alloc_size() sets every bus->irq[i] to PHY_POLL. au1000_probe()
only writes a real IRQ into mii_bus->irq[] when aup->phy_static_config is
set:

    if (aup->phy_static_config)
        if (aup->phy_irq && aup->phy_busid == aup->mac_id)
            aup->mii_bus->irq[aup->phy_addr] = aup->phy_irq;

In that same case, au1000_mii_probe() returns before it reaches
phy_connect():

    if (aup->phy_static_config) {
        ...
        if (aup->phy_addr)
            phydev = mdiobus_get_phy(aup->mii_bus, aup->phy_addr);
        else
            netdev_info(dev, "using PHY-less setup\n");
        return 0;
    }

That leaves dev->phydev NULL, so the new phy_disconnect() calls are
skipped.

On the dynamic search path, which is the only one that calls
phy_connect(), the PHY's irq is still PHY_POLL. That means no interrupt
is ever requested, and phy_disconnect() never reaches
phy_free_interrupt().

The device and module references taken in phy_attach_direct(), and the
attached_dev pointer to the freed netdev, do look like real leaks. Should
the "PHY interrupts" part be dropped from the message?

> PHY teardown can re-enable the MAC for MDIO even if the interface was
> never opened. Reset the MAC after PHY and MDIO bus teardown, before
> releasing descriptors and register mappings. Skip MAC control accesses
> when mac_enabled is clear, since stopping an already clock-gated MAC
> hangs MTX-1.

Would it help to say that the new mac_enabled check also fixes an
existing hang when register_netdev() fails in au1000_probe()?

Before this patch, the au1000_reset_mac() call just before
register_netdev() gated the MAC clock and cleared mac_enabled. If
register_netdev() then failed, the err_out path called
mdiobus_unregister(), which does no MDIO access, and then called
au1000_reset_mac() again:

au1000_probe()
  au1000_reset_mac(dev);        <- clock gated, mac_enabled = 0
  register_netdev(dev) fails
  goto err_out
    mdiobus_unregister()
    au1000_reset_mac(dev)
      au1000_hard_stop(dev)
        readl(&aup->mac->control)   <- MAC already clock-gated

According to the commit message, this access hangs MTX-1. The message
describes the PHY teardown case but not this change in the
register_netdev() failure path. Mentioning it would show backporters
which failure modes this patch fixes.

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

  reply	other threads:[~2026-11-20 10:32 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 19:32 [PATCH net v3 00/10] net: au1000: Bug fixes Florian Fainelli
2026-11-17 19:32 ` [PATCH net v3 01/10] net: au1000: recycle RX descriptors on allocation failure Florian Fainelli
2026-11-17 19:32 ` [PATCH net v3 02/10] net: au1000: clear all-multicast mode when restoring hash filtering Florian Fainelli
2026-11-17 19:32 ` [PATCH net v3 03/10] net: au1000: disconnect the PHY before freeing the MDIO bus Florian Fainelli
2026-11-20 10:32   ` netdev-bot+sashiko [this message]
2026-11-17 19:32 ` [PATCH net v3 04/10] net: au1000: report MDIO transaction timeouts Florian Fainelli
2026-11-17 19:32 ` [PATCH net v3 05/10] net: au1000: serialize TX completion with packet submission Florian Fainelli
2026-11-20 10:32   ` netdev-bot+sashiko
2026-11-17 19:32 ` [PATCH net v3 06/10] net: au1000: restore receive filtering before enabling RX Florian Fainelli
2026-11-17 19:32 ` [PATCH net v3 07/10] net: au1000: restore RX buffer addresses when restarting the MAC Florian Fainelli
2026-11-20 10:32   ` netdev-bot+sashiko
2026-11-17 19:32 ` [PATCH net v3 08/10] net: phy: smsc: wait for LAN83C183 power-down recovery Florian Fainelli
2026-11-20 10:32   ` netdev-bot+sashiko
2026-11-17 19:32 ` [PATCH net v3 09/10] net: au1000: keep the MAC stopped until the PHY link is ready Florian Fainelli
2026-11-20 10:32   ` netdev-bot+sashiko
2026-11-17 19:32 ` [PATCH net v3 10/10] net: au1000: reject frames larger than the TX bounce buffer Florian Fainelli
2026-11-17 19:38 ` [PATCH net v3 00/10] net: au1000: Bug fixes netdev-bot+sinfo
2026-11-17 21:54   ` 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=179517075464.3136.12005891937960917967@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=danny.kukawka@bisect.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=hvr@gnu.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=manuel.lauss@gmail.com \
    --cc=mmyangfl@gmail.com \
    --cc=mugunthanvnm@ti.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=runyu.xiao@seu.edu.cn \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=shaojijie@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.