kernel-ark/drivers
Trent Piepho c132419e56 gianfar: Fix race in TBI/SerDes configuration
The init_phy() function attaches to the PHY, then configures the
SerDes<->TBI link (in SGMII mode).  The TBI is on the MDIO bus with the PHY
(sort of) and is accessed via the gianfar's MDIO registers, using the
functions gfar_local_mdio_read/write(), which don't do any locking.

The previously attached PHY will start a work-queue on a timer, and
probably an irq handler as well, which will talk to the PHY and thus use
the MDIO bus.  This uses phy_read/write(), which have locking, but not
against the gfar_local_mdio versions.

The result is that PHY code will try to use the MDIO bus at the same time
as the SerDes setup code, corrupting the transfers.

Setting up the SerDes before attaching to the PHY will insure that there is
no race between the SerDes code and *our* PHY, but doesn't fix everything.
Typically the PHYs for all gianfar devices are on the same MDIO bus, which
is associated with the first gianfar device.  This means that the first
gianfar's SerDes code could corrupt the MDIO transfers for a different
gianfar's PHY.

The lock used by phy_read/write() is contained in the mii_bus structure,
which is pointed to by the PHY.  This is difficult to access from the
gianfar drivers, as there is no link between a gianfar device and the
mii_bus which shares the same MDIO registers.  As far as the device layer
and drivers are concerned they are two unrelated devices (which happen to
share registers).

Generally all gianfar devices' PHYs will be on the bus associated with the
first gianfar.  But this might not be the case, so simply locking the
gianfar's PHY's mii bus might not lock the mii bus that the SerDes setup
code is going to use.

We solve this by having the code that creates the gianfar platform device
look in the device tree for an mdio device that shares the gianfar's
registers.  If one is found the ID of its platform device is saved in the
gianfar's platform data.

A new function in the gianfar mii code, gfar_get_miibus(), can use the bus
ID to search through the platform devices for a gianfar_mdio device with
the right ID.  The platform device's driver data is the mii_bus structure,
which the SerDes setup code can use to lock the current bus.

Signed-off-by: Trent Piepho <tpiepho@freescale.com>
CC: Andy Fleming <afleming@freescale.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
2008-10-31 00:59:46 -04:00
..
accessibility braille_console: only register notifiers when the braille console is used 2008-10-02 15:53:13 -07:00
acpi ACPI suspend: build fix for ACPI_SLEEP=n && XEN_SAVE_RESTORE=y. 2008-10-25 04:07:13 -04:00
amba
ata libata: fix bug with non-ncq devices 2008-10-24 08:22:38 -07:00
atm Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6 2008-10-11 12:39:35 -07:00
auxdisplay
base memory_probe: fix wrong sysfs file attribute 2008-10-20 08:52:32 -07:00
block [PATCH] sanitize blkdev_get() and friends 2008-10-21 07:49:06 -04:00
bluetooth btsdio: free sk_buff with kfree_skb 2008-10-26 23:08:48 -07:00
cdrom [PATCH] switch viocd 2008-10-21 07:48:21 -04:00
char m68k: Disable Amiga serial console support if modular 2008-10-26 12:11:21 -07:00
clocksource Merge branches 'timers/clocksource', 'timers/hrtimers', 'timers/nohz', 'timers/ntp', 'timers/posixtimers' and 'timers/debug' into v28-timers-for-linus 2008-10-20 13:14:06 +02:00
connector
cpufreq [CPUFREQ] Fix BUG: using smp_processor_id() in preemptible code 2008-10-09 13:52:44 -04:00
cpuidle Merge branch 'v28-range-hrtimers-for-linus-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2008-10-23 10:53:02 -07:00
crypto
dca device create: misc: convert device_create_drvdata to device_create 2008-10-16 09:24:43 -07:00
dio
dma Merge branch 'i7300_idle' into release 2008-10-25 04:07:44 -04:00
edac edac cell: fix incorrect edac_mode 2008-10-20 08:52:40 -07:00
eisa
firewire firewire: fix ioctl() return code 2008-10-15 22:21:10 +02:00
firmware x86: sysfs: kill owner field from attribute 2008-10-20 08:52:42 -07:00
gpio mfd: twl4030-gpio driver 2008-10-22 01:19:39 +02:00
gpu Merge branch 'drm-next' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6 2008-10-23 10:18:40 -07:00
hid Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid 2008-10-26 16:34:14 -07:00
hwmon hwmon: (abituguru3) enable DMI probing feature on AW9D-MAX 2008-10-26 17:04:40 +01:00
i2c Merge branch 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6 2008-10-23 10:10:25 -07:00
ide arm ide breakage 2008-10-26 09:35:05 -07:00
idle i7300_idle: Cleanup based review comments 2008-10-24 12:55:14 -04:00
ieee1394 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6 2008-10-16 15:02:24 -07:00
infiniband Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband 2008-10-23 08:16:03 -07:00
input Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2008-10-26 16:40:59 -07:00
isdn device create: misc: convert device_create_drvdata to device_create 2008-10-16 09:24:43 -07:00
leds leds-hp-disk: fix build warning 2008-10-25 04:07:14 -04:00
lguest
macintosh device create: misc: convert device_create_drvdata to device_create 2008-10-16 09:24:43 -07:00
mca
md Merge branch 'for-linus' of git://neil.brown.name/md 2008-10-26 16:42:18 -07:00
media V4L/DVB (9336): cx88: always de-alloc frontends on fault condition 2008-10-21 14:32:12 -02:00
memstick [PATCH] switch memstick 2008-10-21 07:48:33 -04:00
message Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6 2008-10-23 13:02:03 -07:00
mfd mfd: Make WM8400 depend on I2C until SPI is submitted 2008-10-24 18:34:39 +02:00
misc intel_menlo: fix build warning 2008-10-23 00:43:47 -04:00
mmc [PATCH] switch mmc 2008-10-21 07:48:37 -04:00
mtd [PATCH] propagate mode through open_bdev_excl/close_bdev_excl 2008-10-21 07:49:00 -04:00
net gianfar: Fix race in TBI/SerDes configuration 2008-10-31 00:59:46 -04:00
nubus nubus: fix mis-indented statement 2008-10-16 11:21:30 -07:00
of Merge commit 'kumar/kumar-for-2.6.28' 2008-10-21 15:49:55 +11:00
oprofile Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile 2008-10-23 10:05:40 -07:00
parisc [PATCH] introduce fmode_t, do annotations 2008-10-21 07:47:06 -04:00
parport 8250: Oxford Semiconductor Devices 2008-10-23 09:31:09 -07:00
pci ACPI: Oops in ACPI with git latest 2008-10-25 04:07:14 -04:00
pcmcia Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm 2008-10-23 08:12:21 -07:00
pnp Merge branch 'linus' into test 2008-10-23 00:11:07 -04:00
power Merge git://git.infradead.org/battery-2.6 2008-10-20 09:44:30 -07:00
ps3 ps3: Add passthru support for non-audio streams 2008-10-20 08:05:15 +02:00
rapidio
regulator da903x: add regulator support for DA9030/DA9034 2008-10-13 21:51:57 +01:00
rtc Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6 2008-10-23 10:20:15 -07:00
s390 qeth: avoid skb_under_panic for malformatted inbound data 2008-10-27 14:49:00 -04:00
sbus
scsi Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6 2008-10-23 13:02:03 -07:00
serial 8250: Add more OxSemi devices 2008-10-23 09:35:18 -07:00
sh sh: Move the shared INTC code out to drivers/sh/ 2008-10-01 16:13:54 +09:00
sn
spi Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6 2008-10-16 12:40:26 -07:00
ssb Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6 2008-10-13 14:12:40 -07:00
staging staging: pcc_acpi: delete obsolete driver 2008-10-23 15:31:09 -04:00
tc
telephony phonedev: remove BKL 2008-10-20 08:52:36 -07:00
thermal
uio Merge branch 'bkl-removal' of git://git.lwn.net/linux-2.6 2008-10-20 13:42:14 -07:00
usb Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6 2008-10-23 10:09:50 -07:00
uwb uwb: wrong sizeof argument in mac address compare 2008-10-20 14:37:53 +01:00
video Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm 2008-10-23 16:06:49 -07:00
virtio
w1 x86: sysfs: kill owner field from attribute 2008-10-20 08:52:42 -07:00
watchdog watchdog: Fix warning 2008-10-23 09:19:47 -07:00
xen x86, um: ... and asm-x86 move 2008-10-22 22:55:20 -07:00
zorro
Kconfig Merge branch 'master' into for-upstream 2008-10-20 16:07:19 +01:00
Makefile Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/dvrabel/uwb 2008-10-26 16:35:46 -07:00