From: netdev-bot+sashiko@kernel.org
To: james.hilliard1@gmail.com
Cc: hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net,
edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
michael.chan@broadcom.com, hauke@hauke-m.de, andrew@lunn.ch,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 1/4] net: b44: keep phylib ioctls outside the spinlock
Date: Tue, 17 Nov 2026 09:15:52 +0000 [thread overview]
Message-ID: <179490695291.3136.15807458064775996761@kernel.org> (raw)
In-Reply-To: <20261113-submit-phy-mii-reset-v1-v1-1-02a55f352a91@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 1 · 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).
- [High] The fix is incomplete: b44 still makes sleeping phylib calls
while holding a spinlock with IRQs off.
- [Medium] The commit message says 'External PHY register accesses are
serialized by the MDIO bus mutex'.
--
net: b44: keep phylib ioctls outside the spinlock
With this patch, b44_ioctl() holds bp->lock only around
generic_mii_ioctl() for the internal PHY. The external PHY path now
calls phy_mii_ioctl() without the spinlock and relies on the MDIO bus
mutex for serialization.
> diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
> index f994636fbd5f1..e9f116dfaad99 100644
> --- a/drivers/net/ethernet/broadcom/b44.c
> +++ b/drivers/net/ethernet/broadcom/b44.c
> @@ -2126,14 +2126,14 @@ static int b44_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
> if (!netif_running(dev))
> goto out;
>
> - spin_lock_irq(&bp->lock);
[Severity: Medium]
The commit message says:
External PHY register accesses are serialized by the MDIO bus mutex, as
they already are when called from the PHY state machine.
Does that hold for b44? b44_mdio_read_phylib() and
b44_mdio_write_phylib() call __b44_readphy() and __b44_writephy(). Each
of those runs a multi-step sequence on Ethernet core registers:
drivers/net/ethernet/broadcom/b44.c:__b44_readphy() {
bw32(bp, B44_EMAC_ISTAT, EMAC_INT_MII);
bw32(bp, B44_MDIO_DATA, (MDIO_DATA_SB_START |
...
err = b44_wait_bit(bp, B44_EMAC_ISTAT, EMAC_INT_MII, 100, 0);
*val = br32(bp, B44_MDIO_DATA) & MDIO_DATA_DATA;
...
}
Two other paths touch the same hardware while holding only bp->lock,
without the mdio_lock:
b44_chip_reset() calls ssb_device_enable() and
ssb_pcicore_dev_irqvecs_enable(). On older SSB-PCI cores the second call
can switch the BAR0 window to the PCI core. b44_chip_reset() then
rewrites B44_MDIO_CTRL.
b44_setup_phy() calls b44_wap54g10_workaround() before the
B44_FLAG_EXTERNAL_PHY early return. That function does raw
__b44_readphy() and __b44_writephy() calls on PHY 0 and bypasses the
mii_bus.
Both paths can run without rtnl, from b44_tx_timeout() and from the RFO
and ISTAT_ERRORS recovery paths in b44_poll():
b44_tx_timeout()
spin_lock_irq(&bp->lock);
b44_halt(bp);
b44_init_rings(bp);
b44_init_hw(bp, B44_FULL_RESET);
Before this patch, the spin_lock_irq() in b44_ioctl() stopped a
SIOCGMIIREG or SIOCSMIIREG transaction from overlapping these paths.
Now the transaction runs under only rtnl and mdio_lock.
Can a TX timeout or NAPI error recovery interleave with the ioctl's MDIO
sequence? If so, the read could return a wrong value, b44_wait_bit()
could time out, or a SIOCSMIIREG write could be lost while
phy_mii_ioctl() still updates phydev->autoneg and advertising.
Also, ssb_pci_read32() checks bus->mapped_device and then calls
ioread32() with no lock in between. Could a concurrent window switch
send the MDIO register access to the PCI core's registers?
The PHY state machine already has this gap. This patch adds a path that
userspace can trigger. Would it make sense to serialize inside the b44
MDIO accessors instead, for example with a short
spin_lock_irqsave(&bp->lock) around the udelay-only sequence? That would
also mean dropping bp->lock in b44_set_link_ksettings().
> if (bp->flags & B44_FLAG_EXTERNAL_PHY) {
> BUG_ON(!dev->phydev);
> err = phy_mii_ioctl(dev->phydev, ifr, cmd);
[Severity: High]
Is this fix complete? On the external PHY path, b44_set_link_ksettings()
still calls into phylib with bp->lock held and interrupts disabled:
drivers/net/ethernet/broadcom/b44.c:b44_set_link_ksettings() {
...
if (bp->flags & B44_FLAG_EXTERNAL_PHY) {
BUG_ON(!dev->phydev);
spin_lock_irq(&bp->lock);
if (netif_running(dev))
b44_setup_phy(bp);
ret = phy_ethtool_ksettings_set(dev->phydev, cmd);
spin_unlock_irq(&bp->lock);
return ret;
}
...
}
Once its argument checks pass, phy_ethtool_ksettings_set() calls
mutex_lock(&phydev->lock). It then calls phy_trigger_machine() or
_phy_start_aneg(), and the aneg path does MDIO I/O under the bus
mdio_lock.
An ordinary "ethtool -s <dev> speed 100 duplex full autoneg off" on a
b44 with B44_FLAG_EXTERNAL_PHY gets here. ethtool does a get before the
set, and b44_get_link_ksettings() fills phy_address from
phy_ethtool_ksettings_get(), so the phy_address check passes.
Doesn't this hit the same sleeping-in-atomic problem that the commit
message describes for phy_mii_ioctl()?
If phydev->lock is contended, for example by phy_state_machine(), the
task would schedule with bp->lock held and interrupts off. Then
b44_interrupt() or b44_timer() on that CPU could spin on bp->lock
forever.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113-submit-phy-mii-reset-v1-v1-0-02a55f352a91%40gmail.com
next prev parent reply other threads:[~2026-11-17 9:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 8:48 [PATCH net 0/4] net: phy: restore driver state after userspace MII resets James Hilliard
2026-11-13 8:48 ` [PATCH net 1/4] net: b44: keep phylib ioctls outside the spinlock James Hilliard
2026-11-17 9:15 ` netdev-bot+sashiko [this message]
2026-11-13 8:48 ` [PATCH net 2/4] net: phy: propagate MII register write errors James Hilliard
2026-11-13 8:48 ` [PATCH net 3/4] net: phy: quiesce the state machine during MII resets James Hilliard
2026-11-17 9:15 ` netdev-bot+sashiko
2026-11-13 8:48 ` [PATCH net 4/4] net: phylink: reinitialize the PHY after an MII reset James Hilliard
2026-11-17 9:15 ` netdev-bot+sashiko
2026-11-13 8:53 ` [PATCH net 0/4] net: phy: restore driver state after userspace MII resets netdev-bot+sinfo
2026-11-13 9:28 ` James Hilliard
2026-11-13 13:33 ` Andrew Lunn
2026-11-13 16:39 ` James Hilliard
2026-11-13 17:50 ` Andrew Lunn
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=179490695291.3136.15807458064775996761@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hauke@hauke-m.de \
--cc=hkallweit1@gmail.com \
--cc=james.hilliard1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--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