All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev-bot+sashiko@kernel.org
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 15:58:27 -0800	[thread overview]
Message-ID: <2ed2823f-298a-49e0-98d7-58545f09b304@gmail.com> (raw)
In-Reply-To: <179517075464.3136.12005891937960917967@kernel.org>

On 11/20/26 02:32, netdev-bot+sashiko@kernel.org wrote:
> 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.
> 

Agreed on both points. I have updated the commit message to remove the 
PHY-interrupt claim: the path that calls phy_connect() uses polling. The 
message now describes the leaked device/module references and the stale 
attached_dev pointer.

I also added the existing register_netdev() failure case. Probe gates 
the MAC clock before registration, and the error unwind resets it again. 
The mac_enabled guard prevents that second reset from accessing 
clock-gated MAC control registers if no intervening MDIO access has 
re-enabled the MAC.

This is a commit-message-only revision; the code is unchanged. The 
registration-failure path was verified by source inspection, not fault 
injection.

pw-bot: cr
-- 
Florian

  reply	other threads:[~2026-11-20 23:58 UTC|newest]

Thread overview: 23+ 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
2026-11-20 23:58     ` Florian Fainelli [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-21  0:06     ` Florian Fainelli
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-21  0:22     ` Florian Fainelli
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-21  0:25     ` Florian Fainelli
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-21  0:46     ` Florian Fainelli
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=2ed2823f-298a-49e0-98d7-58545f09b304@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=danny.kukawka@bisect.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --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-bot+sashiko@kernel.org \
    --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.