Commit ae9dfaca authored by Hirofumi Ogawa's avatar Hirofumi Ogawa Committed by Linus Torvalds

[netdrvr 8139cp] fix NAPI race

Andreas Happe <andreashappe@gmx.net> writes:
> my notebook (hp/compaq nx7000) still crashes when using 8139cp (runs
> rock solid with 8139too driver). The computer just locks up, there is no
> dmesg output. This has happened since I've got this laptop (around
> november '03).

It seems 8139cp.c has the race condition of rx_poll and interrupt.

NOTE, since I don't have this device, patch is untested. Sorry.
parent c23b8510
...@@ -615,8 +615,10 @@ static int cp_rx_poll (struct net_device *dev, int *budget) ...@@ -615,8 +615,10 @@ static int cp_rx_poll (struct net_device *dev, int *budget)
if (cpr16(IntrStatus) & cp_rx_intr_mask) if (cpr16(IntrStatus) & cp_rx_intr_mask)
goto rx_status_loop; goto rx_status_loop;
netif_rx_complete(dev); local_irq_disable();
cpw16_f(IntrMask, cp_intr_mask); cpw16_f(IntrMask, cp_intr_mask);
__netif_rx_complete(dev);
local_irq_enable();
return 0; /* done */ return 0; /* done */
} }
...@@ -643,6 +645,12 @@ cp_interrupt (int irq, void *dev_instance, struct pt_regs *regs) ...@@ -643,6 +645,12 @@ cp_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
spin_lock(&cp->lock); spin_lock(&cp->lock);
/* close possible race's with dev_close */
if (unlikely(!netif_running(dev))) {
cpw16(IntrMask, 0);
goto out;
}
if (status & (RxOK | RxErr | RxEmpty | RxFIFOOvr)) { if (status & (RxOK | RxErr | RxEmpty | RxFIFOOvr)) {
if (netif_rx_schedule_prep(dev)) { if (netif_rx_schedule_prep(dev)) {
cpw16_f(IntrMask, cp_norx_intr_mask); cpw16_f(IntrMask, cp_norx_intr_mask);
...@@ -664,7 +672,7 @@ cp_interrupt (int irq, void *dev_instance, struct pt_regs *regs) ...@@ -664,7 +672,7 @@ cp_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
/* TODO: reset hardware */ /* TODO: reset hardware */
} }
out:
spin_unlock(&cp->lock); spin_unlock(&cp->lock);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment