Commit Graph

29 Commits (c39fae1416d59fd565606793f090cebe3720d50d)

Author SHA1 Message Date
Asier Llano 1e4e0767ec 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>
2009-12-08 20:29:10 -08:00
Joe Perches a0607fd3a2 drivers/net: request_irq - Remove unnecessary leading & from second arg
Not as fancy as coccinelle.  Checkpatch errors ignored.
Compile tested allyesconfig x86, not all files compiled.

grep -rPl --include=*.[ch] "\brequest_irq\s*\([^,\)]+,\s*\&" drivers/net | while read file ; do \
	perl -i -e 'local $/; while (<>) { s@(\brequest_irq\s*\([^,\)]+,\s*)\&@\1@g ; print ; }' $file ;\
done

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-11-18 23:29:17 -08:00
John Bonesio 37ccd92f55 net/fec_mpc52xx: Fix kernel panic on FEC error
The MDIO bus cannot be accessed at interrupt context, but on an FEC
error, the fec_mpc52xx driver reset function also tries to reset the
PHY.  Since the error is detected at IRQ context, and the PHY functions
try to sleep, the kernel ends up panicking.

Resetting the PHY on an FEC error isn't even necessary.  This patch
solves the problem by removing the PHY reset entirely.

Signed-off-by: John Bonesio <bones@secretlab.ca>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-10-14 15:10:19 -07:00
Dongdong Deng 4871953c0e drivers/net: fixed drivers that support netpoll use ndo_start_xmit()
The NETPOLL API requires that interrupts remain disabled in
netpoll_send_skb(). The use of "A functions set" in the NETPOLL API
callbacks causes the interrupts to get enabled and can lead to kernel
instability.

The solution is to use "B functions set" to prevent the irqs from
getting enabled while in netpoll_send_skb().

A functions set:
local_irq_disable()/local_irq_enable()
spin_lock_irq()/spin_unlock_irq()
spin_trylock_irq()/spin_unlock_irq()

B functions set:
local_irq_save()/local_irq_restore()
spin_lock_irqsave()/spin_unlock_irqrestore()
spin_trylock_irqsave()/spin_unlock_irqrestore()

Signed-off-by: Dongdong Deng <dongdong.deng@windriver.com>
Acked-by: Matt Mackall <mpm@selenic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-08-23 19:51:03 -07:00
Benjamin Herrenschmidt b71a107c66 Merge commit 'gcl/merge' into next
Manual merge of:
	drivers/net/fec_mpc52xx.c
2009-06-18 11:22:08 +10:00
Wolfgang Denk 87c441e54d powerpc/5xxx: Add common mpc5xxx_get_bus_frequency() function
So far, MPC512x used mpc512x_find_ips_freq() to get the bus frequency,
while MPC52xx used mpc52xx_find_ipb_freq().  Despite the different
clock names (IPS vs. IPB) the code was identical.

Use common code for both processor families.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2009-06-17 00:30:22 -06:00
Grant Likely ca816d9817 net: Rework mpc5200 fec driver to use of_mdio infrastructure.
The patch reworks the MPC5200 Fast Ethernet Controller (FEC) driver to
use the of_mdio infrastructure for registering PHY devices from data out
openfirmware device tree, and eliminates the assumption that the PHY
for the FEC is always attached to the FEC's own MDIO bus.  With this
patch, the FEC can use a PHY attached to any MDIO bus if it is described
in the device tree.

Tested on Freescale Lite5200b eval board

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-04-27 02:53:47 -07:00
Linus Torvalds ef8a97bbc9 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (54 commits)
  glge: remove unused #include <version.h>
  dnet: remove unused #include <version.h>
  tcp: miscounts due to tcp_fragment pcount reset
  tcp: add helper for counter tweaking due mid-wq change
  hso: fix for the 'invalid frame length' messages
  hso: fix for crash when unplugging the device
  fsl_pq_mdio: Fix compile failure
  fsl_pq_mdio: Revive UCC MDIO support
  ucc_geth: Pass proper device to DMA routines, otherwise oops happens
  i.MX31: Fixing cs89x0 network building to i.MX31ADS
  tc35815: Fix build error if NAPI enabled
  hso: add Vendor/Product ID's for new devices
  ucc_geth: Remove unused header
  gianfar: Remove unused header
  kaweth: Fix locking to be SMP-safe
  net: allow multiple dev per napi with GRO
  r8169: reset IntrStatus after chip reset
  ixgbe: Fix potential memory leak/driver panic issue while setting up Tx & Rx ring parameters
  ixgbe: fix ethtool -A|a behavior
  ixgbe: Patch to fix driver panic while freeing up tx & rx resources
  ...
2009-04-02 21:05:30 -07:00
Grant Likely 9404c82b5e net/fec_mpc52xx: Don't dereference phy_device if it is NULL
The FEC Ethernet device isn't always attached to a phy.  Be careful
not to dereference phy_device if it is NULL.  Also eliminates an
unnecessary extra function from the ioctl path.

Reported-by: Henk Stegeman <henk.stegeman@gmail.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-04-02 00:57:01 -07:00
Henk Stegeman d360009c10 net/fec_mpc52xx: Migrate to net_device_ops.
Since not using net_device_ops gets you shunned out the cool crowd,
this patch modifies the fec_mpc52xx Ethernet driver to provide the
management hooks via a struct net_device_ops.

Reported-by: Henk Stegeman <henk.stegeman@gmail.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-04-02 00:57:00 -07:00
Grant Likely 461cadbc62 net/fec_mpc52xx: fix BUG on missing dma_ops
The driver triggers a BUG_ON() when allocating DMA buffers because the
arch/powerpc dma_ops aren't in the net_device's struct device.  This
patch fixes the problem by using the parent of_device which does have
the correct dma_ops set.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Reviewed-by: Becky Bruce <beckyb@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-04-02 00:57:00 -07:00
Grant Likely 3b5ebf8e1a powerpc/5200: Stop using device_type and port-number properties
There is no reason for the PSC UART driver or the Ethernet driver
to require a device_type property.  The compatible value is sufficient
to uniquely identify the device.  Remove it from the driver.

The whole 'port-number' scheme for assigning numbers to PSC uarts was
always rather half baked and just adds complexity.  Remove it from the
driver.  After this patch is applied, PSC UART numbers are simply
assigned from the order they are found in the device tree (just like
all the other devices).  Userspace can query sysfs to determine what
ttyPSC number is assigned to each PSC instance.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Reviewed-by: Wolfram Sang <w.sang@pengutronix.de>
2009-02-03 12:30:25 -07:00
Kay Sievers fb28ad3590 net: struct device - replace bus_id with dev_name(), dev_set_name()
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-11-10 13:55:14 -08:00
David S. Miller babcda74e9 drivers/net: Kill now superfluous ->last_rx stores.
The generic packet receive code takes care of setting
netdev->last_rx when necessary, for the sake of the
bonding ARP monitor.

Drivers need not do it any more.

Some cases had to be skipped over because the drivers
were making use of the ->last_rx value themselves.

Signed-off-by: David S. Miller <davem@davemloft.net>
2008-11-03 21:11:17 -08:00
Jon Smirl bd28bdb18f [netdrvr] fec_mpc52xx: Implement polling, to make netconsole work.
Implement polling for 5200FEC to make netconsole work. Tested on
Phytec pcm030 and Efika.

Signed-off-by: Jon Smirl <jonsmirl@gmail.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
2008-10-22 07:26:49 -04:00
Anton Vorontsov c8f15686a4 netdev: bunch of drivers: avoid WARN at net/core/dev.c:1328
The drivers were touching net queue before it has been started, so
without this patch, the drivers will potentially WARN at
net/core/dev.c:1328.

I don't have the hardware for the drivers below, so this patch is
untested, and thus should be carefully peer reviewed.

tc35815.c
au1000_eth.c
bfin_mac.c
macb.c
^ The four drivers are using phylib, they're calling netif_start_queue()
in open() callback. So trivially remove netif_tx_schedule_all().
Phylib will handle netif_carrier_*().

cpmac.c
fec_mpc52xx.c
fs_enet/fs_enet-main.c
sh_eth.c
^ The same as above, but these were also needlessly calling
netif_carrier_*() functions. So removed queue calls and also remove
carrier calls, since phylib will handle it. fs_enet-main.c also didn't
call netif_start_queue() at open(), this is fixed now.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-07-22 15:41:24 -07:00
David S. Miller 263ba3204a netdev: Convert all drivers away from netif_schedule().
They logically all want to trigger a schedule for all device
TX queues.

Signed-off-by: David S. Miller <davem@davemloft.net>
2008-07-17 19:21:15 -07:00
Roel Kluin 8b9835108f fec_mpc52xx: MPC52xx_MESSAGES_DEFAULT: 2nd NETIF_MSG_IFDOWN => IFUP
Duplicate NETIF_MSG_IFDOWN, 2nd should be NETIF_MSG_IFUP

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Acked-by: Sylvain Munaut <tnt@246tNt.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
2008-06-11 22:24:42 -04:00
Grant Likely 80791be111 [POWERPC] mpc5200: Allow for fixed speed MII configurations
Various improvements for configuring the MPC5200 MII link from the
device tree:
* Look for 'current-speed' property for fixed speed MII links
* Look for 'fsl,7-wire-mode' property for boards using the 7 wire mode
* move definition of private data structure out of the header file

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Wolfgang Grandegger <wg@grandegger.com>
2008-05-01 11:05:58 -06:00
Sascha Hauer 8f3ba2dc81 [POWERPC] mpc5200: Fix FEC error handling on FIFO errors
The error handling for the mpc5200 fec interrupt is broken. The intended
behaviour is like this:

* If one of FEC_IEVENT_RFIFO_ERROR and FEC_IEVENT_XFIFO_ERROR happens,
  the datasheet says (MPC5200B User's Guide R1.2, p. 14-13): "When this
  occurs, software must ensure both the FIFO Controller and BestComm are
  soft-reset".

* On any other error (non-TFINT) interrupt, just issue a debug message.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2008-04-29 07:18:51 -06:00
David S. Miller 1e42198609 Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6 2008-04-17 23:56:30 -07:00
Andy Fleming 9d9326d3bc phy: Change mii_bus id field to a string
Having the id field be an int was making more complex bus topologies
excessively difficult.  For now, just convert it to a string, and
change all instances of "bus->id = val" to
snprintf(id, MII_BUS_ID_LEN, "%x", val).

Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
2008-04-16 20:09:35 -04:00
René Bürgel 8d813941b1 [POWERPC] Fix MPC5200 (not B!) device tree so FEC ethernet works
This gets the FEC ethernet driver working again on the lite5200
platform.

The FEC driver is also compatible with the MPC5200, not only with the
MPC5200B, so this adds a suitable entry to the driver's match list.
Furthermore this adds the settings for the PHY in the dts file for the
Lite5200.  Note, that this is not exactly the same as in the
Lite5200B, because the PHY is located at f0003000:01 for the 5200, and
at :00 for the 5200B.  This was tested on a Lite5200 and a Lite5200B,
both booted a kernel via tftp and mounted the root via nfs
successfully.

Signed-off-by: René Bürgel <r.buergel@unicontrol.de>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2008-04-03 22:11:12 +11:00
Grant Likely 66ffbe490b [POWERPC] mpc5200: normalize compatible property bindings
Update MPC5200 drivers to also look for compatible properties in the
form "fsl,mpc5200-*" to better conform to open firmware generic names
recommended practice as published here:

http://www.openfirmware.org/1275/practice/gnames/gnamv14a.html

This patch should *not* break compatibility with older device trees
which do not use the 'fsl,' prefix.  The drivers will still bind against
the older names also.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2008-01-26 15:26:01 -07:00
Al Viro cc154ac64a fec_mpc52xx: write in C...
If you need to find a difference between addresses of two
struct members, subtract offsetof() or cast addresses to
char * and subtract those if you prefer it that way.  Doing
that same with s/char */u32/, OTOH...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-12-22 22:53:07 -05:00
Jon Smirl 4c537e6371 Fix memory corruption in fec_mpc52xx
The mpc5200 fec driver is corrupting memory. This patch fixes two bugs
where the wrong skb was being referenced.

Signed-off-by: Jon Smirl <jonsmirl@gmail.com>
Acked-by: Domen Puncer <domen.puncer@telargo.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-12-04 14:53:14 -05:00
David Woodhouse 3d26e69533 SET_NETDEV_DEV() in fec_mpc52xx.c
This helps to allow the Fedora installer to use the built-in Ethernet on
the Efika for a network install.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-12-01 16:35:51 -05:00
Grant Likely 48d58459fe Fix region size check in mpc5200 FEC driver
Driver shouldn't complain if the register range is larger than what
it expects.  This works around failures with some device trees.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-11-01 16:04:45 -04:00
Domen Puncer 5d031e9e7e FEC - fast ethernet controller for mpc52xx
Driver for ethernet on mpc5200/mpc5200b SoCs (FEC).

Signed-off-by: Domen Puncer <domen.puncer@telargo.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-10-29 05:59:10 -04:00