* [PATCH net-next v2 1/2] net: sgi: ioc3-eth: request the IRQ in open, not probe [not found] <20261128154953.2664-1-kaloz@kernel.org> @ 2026-11-28 15:49 ` Imre Kaloz 2026-11-28 15:49 ` [PATCH net-next v2 2/2] net: sgi: ioc3-eth: do not wait for the link timer in ioc3_init Imre Kaloz 1 sibling, 0 replies; 3+ messages in thread From: Imre Kaloz @ 2026-11-28 15:49 UTC (permalink / raw) To: Thomas Bogendoerfer, netdev Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-mips, Sashiko, stable The shared IRQ is requested in probe before the rings, lock and timer its handler uses exist, and under devm it outlives free_netdev() on the error paths and in remove. Request it in ndo_open once the RX buffers exist and free it in ndo_stop before stopping the chip, because free_irq() waits for a running handler and ioc3_error() restarts the chip. Found by review; with DEBUG_SHIRQ, unbinding the driver without this change faults on freed memory. Tested on an SGI Fuel with DEBUG_SHIRQ and SLUB_DEBUG_ON: link down/up and driver unbind/rebind. Fixes: 0ce5ebd24d25 ("mfd: ioc3: Add driver for SGI IOC3 chip") Reported-by: Sashiko <sashiko-bot@kernel.org> Closes: https://lore.kernel.org/all/179473760071.2199510.16065103101920438822@kernel.org/ Closes: https://lore.kernel.org/all/179504054981.3136.8539477779059154181@kernel.org/ Cc: stable@vger.kernel.org Signed-off-by: Imre Kaloz <kaloz@kernel.org> --- drivers/net/ethernet/sgi/ioc3-eth.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/sgi/ioc3-eth.c b/drivers/net/ethernet/sgi/ioc3-eth.c index ee284a4f75ff..5023d05e7e38 100644 --- a/drivers/net/ethernet/sgi/ioc3-eth.c +++ b/drivers/net/ethernet/sgi/ioc3-eth.c @@ -781,6 +781,7 @@ static inline void ioc3_stop(struct ioc3_private *ip) static int ioc3_open(struct net_device *dev) { struct ioc3_private *ip = netdev_priv(dev); + int err; ip->ehar_h = 0; ip->ehar_l = 0; @@ -790,6 +791,13 @@ static int ioc3_open(struct net_device *dev) netdev_err(dev, "%s: rx buffer allocation failed\n", __func__); return -ENOMEM; } + err = request_irq(dev->irq, ioc3_interrupt, IRQF_SHARED, "ioc3-eth", + dev); + if (err) { + netdev_err(dev, "Can't get irq %d\n", dev->irq); + ioc3_free_rx_bufs(ip); + return err; + } ioc3_start(ip); ioc3_mii_start(ip); @@ -803,6 +811,9 @@ static int ioc3_close(struct net_device *dev) timer_delete_sync(&ip->ioc3_timer); + /* ioc3_error() restarts the chip, so free the IRQ before stopping it */ + free_irq(dev->irq, dev); + netif_stop_queue(dev); ioc3_stop(ip); @@ -870,13 +881,6 @@ static int ioc3eth_probe(struct platform_device *pdev) goto out_free; } - if (devm_request_irq(&pdev->dev, dev->irq, ioc3_interrupt, - IRQF_SHARED, "ioc3-eth", dev)) { - dev_err(&pdev->dev, "Can't get irq %d\n", dev->irq); - err = -ENODEV; - goto out_free; - } - spin_lock_init(&ip->ioc3_lock); timer_setup(&ip->ioc3_timer, ioc3_timer, 0); -- 2.47.3 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH net-next v2 2/2] net: sgi: ioc3-eth: do not wait for the link timer in ioc3_init [not found] <20261128154953.2664-1-kaloz@kernel.org> 2026-11-28 15:49 ` [PATCH net-next v2 1/2] net: sgi: ioc3-eth: request the IRQ in open, not probe Imre Kaloz @ 2026-11-28 15:49 ` Imre Kaloz 2026-12-04 4:30 ` willemb 1 sibling, 1 reply; 3+ messages in thread From: Imre Kaloz @ 2026-11-28 15:49 UTC (permalink / raw) To: Thomas Bogendoerfer, netdev Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-mips, Sashiko, stable ioc3_init() waits for the link timer with timer_delete_sync(), but it runs from ioc3_error() in hardirq context with ioc3_lock held, and from ioc3_timeout() under spin_lock_irq(). A callback interrupted on this CPU never finishes, and one on another CPU spins on ioc3_lock, which the waiter holds. Stop the timer in ioc3_open() instead and leave it running across resets, so the link poll no longer stops after the first error interrupt. Reproduced by injecting an IOC3 error interrupt from a kernel modification: without this change, timer_delete_sync() warns from hardirq context. Tested on an SGI Fuel with DEBUG_SHIRQ and SLUB_DEBUG_ON: link down/up, driver unbind/rebind and an injected error interrupt. Fixes: cfadbd298e8b ("[PATCH] Fix timer race") Reported-by: Sashiko <sashiko-bot@kernel.org> Closes: https://lore.kernel.org/all/179504054981.3136.8539477779059154181@kernel.org/ Cc: stable@vger.kernel.org Signed-off-by: Imre Kaloz <kaloz@kernel.org> --- drivers/net/ethernet/sgi/ioc3-eth.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/ethernet/sgi/ioc3-eth.c b/drivers/net/ethernet/sgi/ioc3-eth.c index 5023d05e7e38..0bb2e71befc8 100644 --- a/drivers/net/ethernet/sgi/ioc3-eth.c +++ b/drivers/net/ethernet/sgi/ioc3-eth.c @@ -718,8 +718,6 @@ static void ioc3_init(struct net_device *dev) struct ioc3_private *ip = netdev_priv(dev); struct ioc3_ethregs *regs = ip->regs; - timer_delete_sync(&ip->ioc3_timer); /* Kill if running */ - writel(EMCR_RST, ®s->emcr); /* Reset */ readl(®s->emcr); /* Flush WB */ udelay(4); /* Give it time ... */ @@ -786,6 +784,7 @@ static int ioc3_open(struct net_device *dev) ip->ehar_h = 0; ip->ehar_l = 0; + timer_delete_sync(&ip->ioc3_timer); ioc3_init(dev); if (ioc3_alloc_rx_bufs(dev)) { netdev_err(dev, "%s: rx buffer allocation failed\n", __func__); @@ -1131,7 +1130,6 @@ static void ioc3_timeout(struct net_device *dev, unsigned int txqueue) } ioc3_start(ip); ioc3_mii_init(ip); - ioc3_mii_start(ip); spin_unlock_irq(&ip->ioc3_lock); -- 2.47.3 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next v2 2/2] net: sgi: ioc3-eth: do not wait for the link timer in ioc3_init 2026-11-28 15:49 ` [PATCH net-next v2 2/2] net: sgi: ioc3-eth: do not wait for the link timer in ioc3_init Imre Kaloz @ 2026-12-04 4:30 ` willemb 0 siblings, 0 replies; 3+ messages in thread From: willemb @ 2026-12-04 4:30 UTC (permalink / raw) To: Imre Kaloz, Thomas Bogendoerfer, netdev Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-mips, Sashiko, stable Imre Kaloz wrote: > ioc3_init() waits for the link timer with timer_delete_sync(), but it > runs from ioc3_error() in hardirq context with ioc3_lock held, and from > ioc3_timeout() under spin_lock_irq(). A callback interrupted on this CPU > never finishes, and one on another CPU spins on ioc3_lock, which the > waiter holds. > Stop the timer in ioc3_open() instead and leave it running across > resets, so the link poll no longer stops after the first error > interrupt. > Reproduced by injecting an IOC3 error interrupt from a kernel > modification: without this change, timer_delete_sync() warns from > hardirq context. Tested on an SGI Fuel with DEBUG_SHIRQ and > SLUB_DEBUG_ON: link down/up, driver unbind/rebind and an injected > error interrupt. > Fixes: cfadbd298e8b ("[PATCH] Fix timer race") > Reported-by: Sashiko <sashiko-bot@kernel.org> > Closes: > https://lore.kernel.org/all/179504054981.3136.8539477779059154181@kernel.org/ > Cc: stable@vger.kernel.org > Signed-off-by: Imre Kaloz <kaloz@kernel.org> > --- > drivers/net/ethernet/sgi/ioc3-eth.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > diff --git a/drivers/net/ethernet/sgi/ioc3-eth.c > b/drivers/net/ethernet/sgi/ioc3-eth.c > index 5023d05e7e38..0bb2e71befc8 100644 > --- a/drivers/net/ethernet/sgi/ioc3-eth.c > +++ b/drivers/net/ethernet/sgi/ioc3-eth.c > @@ -718,8 +718,6 @@ static void ioc3_init(struct net_device *dev) > struct ioc3_private *ip = netdev_priv(dev); > struct ioc3_ethregs *regs = ip->regs; > - timer_delete_sync(&ip->ioc3_timer); /* Kill if running */ > - > writel(EMCR_RST, ®s->emcr); /* Reset */ > readl(®s->emcr); /* Flush WB */ > udelay(4); /* Give it time ... */ [severity: medium, confidence: high] Leaving ip->ioc3_timer running across resets introduces a bug when ioc3_alloc_rx_bufs() fails in ioc3_error() or ioc3_timeout(). Both error paths return early after ioc3_stop(), ioc3_free_rx_bufs(), and ioc3_init() have freed/unmapped all RX skbs and reset the chip, but ioc3_stop() only writes 0 to regs->emcr without clearing EMCR_TXDMAEN | EMCR_TXEN | EMCR_RXDMAEN | EMCR_RXEN from ip->emcr. Previously ioc3_init() stopped ioc3_timer before that failure return; now ioc3_timer() fires 1.2s later and ioc3_setup_duplex() executes writel(ip->emcr, ®s->emcr), turning RX/TX DMA back on against reset ring registers and freed buffers. Clearing EMCR_TXDMAEN | EMCR_TXEN | EMCR_RXDMAEN | EMCR_RXEN in ip->emcr inside ioc3_stop() (which already runs under ioc3_lock in both reset paths, while ioc3_start() unconditionally sets them again) prevents ioc3_setup_duplex()—even an already in-flight timer callback on another CPU—from re-enabling DMA on a stopped chip. [severity: low, confidence: high] On SMP systems, leaving ioc3_timer() running across ioc3_error() and ioc3_timeout() also allows ioc3_timer() -> mii_check_media() -> ioc3_mdio_read() (which does not hold ip->ioc3_lock) to race with ioc3_mii_init() (which holds ip->ioc3_lock) on regs->micr / regs->midr_r. (Missing ioc3_lock around mii_check_media() in ioc3_timer() is pre-existing against ethtool/ioctl, though this patch widens it to the reset paths.) > @@ -786,6 +784,7 @@ static int ioc3_open(struct net_device *dev) > ip->ehar_h = 0; > ip->ehar_l = 0; > + timer_delete_sync(&ip->ioc3_timer); > ioc3_init(dev); > if (ioc3_alloc_rx_bufs(dev)) { > netdev_err(dev, "%s: rx buffer allocation failed\n", __func__); > @@ -1131,7 +1130,6 @@ static void ioc3_timeout(struct net_device *dev, > unsigned int txqueue) > } > ioc3_start(ip); > ioc3_mii_init(ip); > - ioc3_mii_start(ip); > spin_unlock_irq(&ip->ioc3_lock); > -- > 2.47.3 ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-04 4:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20261128154953.2664-1-kaloz@kernel.org>
2026-11-28 15:49 ` [PATCH net-next v2 1/2] net: sgi: ioc3-eth: request the IRQ in open, not probe Imre Kaloz
2026-11-28 15:49 ` [PATCH net-next v2 2/2] net: sgi: ioc3-eth: do not wait for the link timer in ioc3_init Imre Kaloz
2026-12-04 4:30 ` willemb
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox