net: ag71xx: disable napi interrupts during probe
Subsystems (3)
PATCH 1/1 net: ag71xx: disable napi interrupts during probe
From: Sven Eckelmann <[email protected]>
ag71xx_probe is registering ag71xx_interrupt as handler for gmac0/gmac1 interrupts. The handler is trying to use napi_schedule to handle the processing of packets. But the netif_napi_add for this device is called a lot later in ag71xx_probe.
It can therefore happen that a still running gmac0/gmac1 is triggering the interrupt handler with a bit from AG71XX_INT_POLL set in AG71XX_REG_INT_STATUS. The handler will then call napi_schedule and the napi code will crash the system because the ag->napi is not yet initialized.
The gmcc0/gmac1 must be brought in a state in which it doesn't signal a AG71XX_INT_POLL related status bits as interrupt before registering the interrupt handler. ag71xx_hw_start will take care of re-initializing the AG71XX_REG_INT_ENABLE.
--- drivers/net/ethernet/atheros/ag71xx.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/atheros/ag71xx.c +6 -0
@@ -1855,6 +1855,12 @@ static int ag71xx_probe(struct platform_device *pdev)if (!ag->mac_base)return -ENOMEM ; +/* ensure that HW is in manual polling mode before interrupts are +* activated. Otherwise ag71xx_interrupt might call napi_schedule +* before it is initialized by netif_napi_add. +*/ +ag71xx_int_disable (ag,AG71XX_INT_POLL ); + ndev->irq =platform_get_irq (pdev,0 ); err =devm_request_irq (&pdev->dev, ndev->irq, ag71xx_interrupt,0x0 ,dev_name (&pdev->dev), ndev);
Signature · 1 line
2.46.0
Quoted 13 lines · Rosen Penev
From: Sven Eckelmann <[email protected]>
ag71xx_probeis registeringag71xx_interruptas handler for gmac0/gmac1 interrupts. The handler is trying to usenapi_scheduleto handle the processing of packets. But thenetif_napi_addfor this device is called a lot later inag71xx_probe.It can therefore happen that a still running gmac0/gmac1 is triggering the interrupt handler with a bit from
AG71XX_INT_POLLset inAG71XX_REG_INT_STATUS. The handler will then callnapi_scheduleand the napi code will crash the system because theag->napiis not yet initialized.
Quoted 8 lines
The gmcc0/gmac1 must be brought in a state in which it doesn't signal a
AG71XX_INT_POLLrelated status bits as interrupt before registering the interrupt handler.ag71xx_hw_startwill take care of re-initializing theAG71XX_REG_INT_ENABLE.Signed-off-by Sven Eckelmann <[email protected]>Signed-off-by Rosen Penev <[email protected]>---
The description reads like a bug fix, so I would expect this to be targeted to net and have a Fixes tag indicating what commit introduced the issue, maybe:
The change seems reasonable to me otherwise.
Quoted 20 lines
drivers/net/ethernet/atheros/ag71xx.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/net/ethernet/atheros/ag71xx.c +6
-0@@ -1855,6 +1855,12 @@ static int ag71xx_probe(struct platform_device *pdev)if (!ag->mac_base)return -ENOMEM ; +/* ensure that HW is in manual polling mode before interrupts are +* activated. Otherwise ag71xx_interrupt might call napi_schedule +* before it is initialized by netif_napi_add. +*/ +ag71xx_int_disable (ag,AG71XX_INT_POLL ); + ndev->irq =platform_get_irq (pdev,0 ); err =devm_request_irq (&pdev->dev, ndev->irq, ag71xx_interrupt,0x0 ,dev_name (&pdev->dev), ndev);
Quoted 26 lines · Jacob Keller
Quoted 13 lines · Rosen Penev
From: Sven Eckelmann <[email protected]>
ag71xx_probeis registeringag71xx_interruptas handler for gmac0/gmac1 interrupts. The handler is trying to usenapi_scheduleto handle the processing of packets. But thenetif_napi_addfor this device is called a lot later inag71xx_probe.It can therefore happen that a still running gmac0/gmac1 is triggering the interrupt handler with a bit from
AG71XX_INT_POLLset inAG71XX_REG_INT_STATUS. The handler will then callnapi_scheduleand the napi code will crash the system because theag->napiis not yet initialized.Quoted 8 lines
The gmcc0/gmac1 must be brought in a state in which it doesn't signal a
AG71XX_INT_POLLrelated status bits as interrupt before registering the interrupt handler.ag71xx_hw_startwill take care of re-initializing theAG71XX_REG_INT_ENABLE.Signed-off-by Sven Eckelmann <[email protected]>Signed-off-by Rosen Penev <[email protected]>---
Quoted 7 lines
The description reads like a bug fix, so I would expect this to be targeted to net and have a Fixes tag indicating what commit introduced the issue, maybe:
Fixes d51b6ce441d3 ("net: ethernet: add ag71xx driver")The change seems reasonable to me otherwise.
OTOH there are currently no dual GMAC users upstream. Just single.
Quoted 21 lines
Quoted 21 lines
drivers/net/ethernet/atheros/ag71xx.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/net/ethernet/atheros/ag71xx.c +6
-0@@ -1855,6 +1855,12 @@ static int ag71xx_probe(struct platform_device *pdev)if (!ag->mac_base)return -ENOMEM ; +/* ensure that HW is in manual polling mode before interrupts are +* activated. Otherwise ag71xx_interrupt might call napi_schedule +* before it is initialized by netif_napi_add. +*/ +ag71xx_int_disable (ag,AG71XX_INT_POLL ); + ndev->irq =platform_get_irq (pdev,0 ); err =devm_request_irq (&pdev->dev, ndev->irq, ag71xx_interrupt,0x0 ,dev_name (&pdev->dev), ndev);
Quoted 38 lines
-----Original Message-----
From: Rosen Penev <[email protected]>
Sent: Thursday, August 29, 2024 10:47 AM
To: Keller, Jacob E <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH net-next] net: ag71xx: disable napi interrupts during probeQuoted 26 lines · Jacob Keller
Quoted 21 lines · Rosen Penev
From: Sven Eckelmann <[email protected]>
ag71xx_probeis registeringag71xx_interruptas handler for gmac0/gmac1 interrupts. The handler is trying to usenapi_scheduleto handle the processing of packets. But thenetif_napi_addfor this device is called a lot later inag71xx_probe.It can therefore happen that a still running gmac0/gmac1 is triggering the interrupt handler with a bit from
AG71XX_INT_POLLset inAG71XX_REG_INT_STATUS. The handler will then callnapi_scheduleand the napi code will crash the system because theag->napiis not yet initialized.The gmcc0/gmac1 must be brought in a state in which it doesn't signal a
AG71XX_INT_POLLrelated status bits as interrupt before registering the interrupt handler.ag71xx_hw_startwill take care of re-initializing theAG71XX_REG_INT_ENABLE.Signed-off-by Sven Eckelmann <[email protected]>Signed-off-by Rosen Penev <[email protected]>---
Quoted 9 lines
Quoted 7 lines
The description reads like a bug fix, so I would expect this to be targeted to net and have a Fixes tag indicating what commit introduced the issue, maybe:
Fixes d51b6ce441d3 ("net: ethernet: add ag71xx driver")The change seems reasonable to me otherwise.
OTOH there are currently no dual GMAC users upstream. Just single.
If that’s the case, updating the description to make that clear would help.