diff options
author | Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> | 2013-09-03 18:41:27 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-09-04 14:55:34 -0400 |
commit | d2779e99468fd83ef1493c34f3803fec9aad8345 (patch) | |
tree | 4b240a6296af57e1340a68c37df65fd43ee861dc /drivers/net | |
parent | 3a1c756590633c0e86df606e5c618c190926a0df (diff) |
sh_eth: fix napi_{en|dis}able() calls racing against interrupts
While implementing NAPI for the driver, I overlooked the race conditions where
interrupt handler might have called napi_schedule_prep() before napi_enable()
was called or after napi_disable() was called. If RX interrupt happens, this
would cause the endless interrupts and messages like:
sh-eth eth0: ignoring interrupt, status 0x00040000, mask 0x01ff009f.
The interrupt wouldn't even be masked by the kernel eventually since the handler
would return IRQ_HANDLED all the time.
As a fix, move napi_enable() call before request_irq() call and napi_disable()
call after free_irq() call.
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/ethernet/renesas/sh_eth.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 1ccd5959c0bf..3426d32a1803 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c | |||
@@ -1857,11 +1857,13 @@ static int sh_eth_open(struct net_device *ndev) | |||
1857 | 1857 | ||
1858 | pm_runtime_get_sync(&mdp->pdev->dev); | 1858 | pm_runtime_get_sync(&mdp->pdev->dev); |
1859 | 1859 | ||
1860 | napi_enable(&mdp->napi); | ||
1861 | |||
1860 | ret = request_irq(ndev->irq, sh_eth_interrupt, | 1862 | ret = request_irq(ndev->irq, sh_eth_interrupt, |
1861 | mdp->cd->irq_flags, ndev->name, ndev); | 1863 | mdp->cd->irq_flags, ndev->name, ndev); |
1862 | if (ret) { | 1864 | if (ret) { |
1863 | dev_err(&ndev->dev, "Can not assign IRQ number\n"); | 1865 | dev_err(&ndev->dev, "Can not assign IRQ number\n"); |
1864 | return ret; | 1866 | goto out_napi_off; |
1865 | } | 1867 | } |
1866 | 1868 | ||
1867 | /* Descriptor set */ | 1869 | /* Descriptor set */ |
@@ -1879,12 +1881,12 @@ static int sh_eth_open(struct net_device *ndev) | |||
1879 | if (ret) | 1881 | if (ret) |
1880 | goto out_free_irq; | 1882 | goto out_free_irq; |
1881 | 1883 | ||
1882 | napi_enable(&mdp->napi); | ||
1883 | |||
1884 | return ret; | 1884 | return ret; |
1885 | 1885 | ||
1886 | out_free_irq: | 1886 | out_free_irq: |
1887 | free_irq(ndev->irq, ndev); | 1887 | free_irq(ndev->irq, ndev); |
1888 | out_napi_off: | ||
1889 | napi_disable(&mdp->napi); | ||
1888 | pm_runtime_put_sync(&mdp->pdev->dev); | 1890 | pm_runtime_put_sync(&mdp->pdev->dev); |
1889 | return ret; | 1891 | return ret; |
1890 | } | 1892 | } |
@@ -1976,8 +1978,6 @@ static int sh_eth_close(struct net_device *ndev) | |||
1976 | { | 1978 | { |
1977 | struct sh_eth_private *mdp = netdev_priv(ndev); | 1979 | struct sh_eth_private *mdp = netdev_priv(ndev); |
1978 | 1980 | ||
1979 | napi_disable(&mdp->napi); | ||
1980 | |||
1981 | netif_stop_queue(ndev); | 1981 | netif_stop_queue(ndev); |
1982 | 1982 | ||
1983 | /* Disable interrupts by clearing the interrupt mask. */ | 1983 | /* Disable interrupts by clearing the interrupt mask. */ |
@@ -1995,6 +1995,8 @@ static int sh_eth_close(struct net_device *ndev) | |||
1995 | 1995 | ||
1996 | free_irq(ndev->irq, ndev); | 1996 | free_irq(ndev->irq, ndev); |
1997 | 1997 | ||
1998 | napi_disable(&mdp->napi); | ||
1999 | |||
1998 | /* Free all the skbuffs in the Rx queue. */ | 2000 | /* Free all the skbuffs in the Rx queue. */ |
1999 | sh_eth_ring_free(ndev); | 2001 | sh_eth_ring_free(ndev); |
2000 | 2002 | ||