Message ID | 20250121221519.392014-4-kuba@kernel.org (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | eth: fix calling napi_enable() in atomic context | expand |
On Tue, Jan 21, 2025 at 11:15 PM Jakub Kicinski <kuba@kernel.org> wrote: > > napi_enable() may sleep now, take netdev_lock() before np->lock. > > Fixes: 413f0271f396 ("net: protect NAPI enablement with netdev_lock()") > Reported-by: Dan Carpenter <dan.carpenter@linaro.org> > Link: https://lore.kernel.org/dcfd56bc-de32-4b11-9e19-d8bd1543745d@stanley.mountain > Signed-off-by: Jakub Kicinski <kuba@kernel.org> Thanks, Acked-by: Zhu Yanjun <zyjzyj2000@gmail.com> Zhu Yanjun > --- > CC: rain.1986.08.12@gmail.com > CC: zyjzyj2000@gmail.com > CC: kuniyu@amazon.com > CC: romieu@fr.zoreil.com > --- > drivers/net/ethernet/nvidia/forcedeth.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c > index b00df57f2ca3..499e5e39d513 100644 > --- a/drivers/net/ethernet/nvidia/forcedeth.c > +++ b/drivers/net/ethernet/nvidia/forcedeth.c > @@ -5562,6 +5562,7 @@ static int nv_open(struct net_device *dev) > /* ask for interrupts */ > nv_enable_hw_interrupts(dev, np->irqmask); > > + netdev_lock(dev); > spin_lock_irq(&np->lock); > writel(NVREG_MCASTADDRA_FORCE, base + NvRegMulticastAddrA); > writel(0, base + NvRegMulticastAddrB); > @@ -5580,7 +5581,7 @@ static int nv_open(struct net_device *dev) > ret = nv_update_linkspeed(dev); > nv_start_rxtx(dev); > netif_start_queue(dev); > - napi_enable(&np->napi); > + napi_enable_locked(&np->napi); > > if (ret) { > netif_carrier_on(dev); > @@ -5597,6 +5598,7 @@ static int nv_open(struct net_device *dev) > round_jiffies(jiffies + STATS_INTERVAL)); > > spin_unlock_irq(&np->lock); > + netdev_unlock(dev); > > /* If the loopback feature was set while the device was down, make sure > * that it's set correctly now. > -- > 2.48.1 >
On Tue, Jan 21, 2025 at 11:15 PM Jakub Kicinski <kuba@kernel.org> wrote: > > napi_enable() may sleep now, take netdev_lock() before np->lock. > > Fixes: 413f0271f396 ("net: protect NAPI enablement with netdev_lock()") > Reported-by: Dan Carpenter <dan.carpenter@linaro.org> > Link: https://lore.kernel.org/dcfd56bc-de32-4b11-9e19-d8bd1543745d@stanley.mountain > Signed-off-by: Jakub Kicinski <kuba@kernel.org> > --- Reviewed-by: Eric Dumazet <edumazet@google.com>
diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c index b00df57f2ca3..499e5e39d513 100644 --- a/drivers/net/ethernet/nvidia/forcedeth.c +++ b/drivers/net/ethernet/nvidia/forcedeth.c @@ -5562,6 +5562,7 @@ static int nv_open(struct net_device *dev) /* ask for interrupts */ nv_enable_hw_interrupts(dev, np->irqmask); + netdev_lock(dev); spin_lock_irq(&np->lock); writel(NVREG_MCASTADDRA_FORCE, base + NvRegMulticastAddrA); writel(0, base + NvRegMulticastAddrB); @@ -5580,7 +5581,7 @@ static int nv_open(struct net_device *dev) ret = nv_update_linkspeed(dev); nv_start_rxtx(dev); netif_start_queue(dev); - napi_enable(&np->napi); + napi_enable_locked(&np->napi); if (ret) { netif_carrier_on(dev); @@ -5597,6 +5598,7 @@ static int nv_open(struct net_device *dev) round_jiffies(jiffies + STATS_INTERVAL)); spin_unlock_irq(&np->lock); + netdev_unlock(dev); /* If the loopback feature was set while the device was down, make sure * that it's set correctly now.
napi_enable() may sleep now, take netdev_lock() before np->lock. Fixes: 413f0271f396 ("net: protect NAPI enablement with netdev_lock()") Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Link: https://lore.kernel.org/dcfd56bc-de32-4b11-9e19-d8bd1543745d@stanley.mountain Signed-off-by: Jakub Kicinski <kuba@kernel.org> --- CC: rain.1986.08.12@gmail.com CC: zyjzyj2000@gmail.com CC: kuniyu@amazon.com CC: romieu@fr.zoreil.com --- drivers/net/ethernet/nvidia/forcedeth.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)