]> bbs.cooldavid.org Git - net-next-2.6.git/commit
net/mpc5200: Fix locking on fec_mpc52xx driver
authorAsier Llano <a.llano@ziv.es>
Wed, 9 Dec 2009 04:29:10 +0000 (20:29 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 9 Dec 2009 04:29:10 +0000 (20:29 -0800)
commit1e4e0767ecb1cf53a43343518c0e09ad7ee5e23a
treecccda01860fec5659a2c178284c2f57cbb755e16
parent4b860abf636fdd963731ae4ccafdd39ebcd5f962
net/mpc5200: Fix locking on fec_mpc52xx driver

Fix the locking scheme on the fec_mpc52xx driver.  This device can
receive IRQs from three sources; the FEC itself, the tx DMA, and the
rx DMA.  Mutual exclusion was handled by taking a spin_lock() in the
critical regions, but because the handlers are run with IRQs enabled,
spin_lock() is insufficient and the driver can end up interrupting
a critical region anyway from another IRQ.

Asier Llano discovered that this occurs when an error IRQ is raised
in the middle of handling rx irqs which resulted in an sk_buff memory
leak.

In addition, locking is spotty at best in the driver and inspection
revealed quite a few places with insufficient locking.

This patch is based on Asier's initial work, but reworks a number of
things so that locks are held for as short a time as possible, so
that spin_lock_irqsave() is used everywhere, and so the locks are
dropped when calling into the network stack (because the lock only
protects the hardware interface; not the network stack).

Boot tested on a lite5200 with an NFS root.  Has not been performance
tested.

Signed-off-by: Asier Llano <a.llano@ziv.es>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/fec_mpc52xx.c