Skip to content

Commit

Permalink
via-velocity: fix netif_receive_skb use in irq disabled section.
Browse files Browse the repository at this point in the history
2fdac01 ("via-velocity.c: update napi
implementation") overlooked an irq disabling spinlock when the Rx part
of the NAPI poll handler was converted from netif_rx to netif_receive_skb.

NAPI Rx processing can be taken out of the locked section with a pair of
napi_{disable / enable} since it only races with the MTU change function.

An heavier rework of the NAPI locking would be able to perform NAPI Tx
before Rx where I simply removed one of velocity_tx_srv calls.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1022733
Fixes: 2fdac01 (via-velocity.c: update napi implementation)
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Tested-by: Alex A. Schmidt <aaschmidt1@gmail.com>
Cc: Jamie Heilman <jamie@audible.transient.net>
Cc: Michele Baldessari <michele@acksyn.org>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
françois romieu authored and David S. Miller committed Nov 28, 2013
1 parent e63e60b commit bc9627e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions drivers/net/ethernet/via/via-velocity.c
Original file line number Diff line number Diff line change
Expand Up @@ -2172,16 +2172,13 @@ static int velocity_poll(struct napi_struct *napi, int budget)
unsigned int rx_done;
unsigned long flags;

spin_lock_irqsave(&vptr->lock, flags);
/*
* Do rx and tx twice for performance (taken from the VIA
* out-of-tree driver).
*/
rx_done = velocity_rx_srv(vptr, budget / 2);
velocity_tx_srv(vptr);
rx_done += velocity_rx_srv(vptr, budget - rx_done);
rx_done = velocity_rx_srv(vptr, budget);
spin_lock_irqsave(&vptr->lock, flags);
velocity_tx_srv(vptr);

/* If budget not fully consumed, exit the polling mode */
if (rx_done < budget) {
napi_complete(napi);
Expand Down Expand Up @@ -2342,6 +2339,8 @@ static int velocity_change_mtu(struct net_device *dev, int new_mtu)
if (ret < 0)
goto out_free_tmp_vptr_1;

napi_disable(&vptr->napi);

spin_lock_irqsave(&vptr->lock, flags);

netif_stop_queue(dev);
Expand All @@ -2362,6 +2361,8 @@ static int velocity_change_mtu(struct net_device *dev, int new_mtu)

velocity_give_many_rx_descs(vptr);

napi_enable(&vptr->napi);

mac_enable_int(vptr->mac_regs);
netif_start_queue(dev);

Expand Down

0 comments on commit bc9627e

Please sign in to comment.