linux/arch/powerpc/sysdev
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
..
bestcomm removed unused #include <linux/version.h>'s 2008-08-23 12:14:12 -07:00
qe_lib powerpc/QE: move QE_GPIO Kconfig symbol into the platforms/Kconfig 2008-10-13 11:09:58 -05:00
6xx-suspend.S [POWERPC] Add 6xx-style HID0_SLEEP support. 2008-05-16 23:22:28 +10:00
axonram.c powerpc/axonram: Enable partitioning of the Axons DDR2 DIMMs 2008-07-22 10:39:31 +10:00
cpm1.c powerpc/cpm1: Fix race condition in CPM1 GPIO library. 2008-09-16 13:43:24 -05:00
cpm2.c cpm2: Rework baud rate generators configuration to support external clocks. 2008-07-28 08:47:45 -05:00
cpm2_pic.c powerpc: Fix irq_alloc_host() reference counting and callers 2008-06-09 13:51:16 +10:00
cpm2_pic.h [POWERPC] cpm2: CPM2 interrupt controller fix 2007-02-07 14:03:20 +11:00
cpm_common.c cpm2: Fix race condition in CPM2 GPIO library. 2008-08-21 00:15:54 -05:00
dart.h [POWERPC] Use 4kB iommu pages even on 64kB-page systems 2006-11-01 14:52:48 +11:00
dart_iommu.c powerpc/pseries: iommu enablement for CMO 2008-07-25 15:44:43 +10:00
dcr-low.S [POWERPC] Generic DCR infrastructure 2006-12-04 16:08:25 +11:00
dcr.c [POWERPC] 4xx: Fix compiler warning on DCR_NATIVE only builds 2008-05-29 07:06:56 -05:00
fsl_gtm.c powerpc/sysdev: implement FSL GTM support 2008-06-10 10:38:50 -05:00
fsl_lbc.c powerpc: fix fsl_upm nand driver modular build 2008-10-13 11:48:24 -05:00
fsl_msi.c powerpc: Convert the FSL MSI code to use msi_bitmap 2008-08-20 16:34:58 +10:00
fsl_msi.h powerpc: Convert the FSL MSI code to use msi_bitmap 2008-08-20 16:34:58 +10:00
fsl_pci.c powerpc/5121: Add PCI support. 2008-10-13 11:09:58 -05:00
fsl_pci.h powerpc: Move mpc83xx_add_bridge to fsl_pci.c 2008-07-16 17:57:35 -05:00
fsl_rio.c [RAPIDIO] fix current kernel-doc notation 2008-05-01 23:01:54 -05:00
fsl_soc.c gianfar: Fix race in TBI/SerDes configuration 2008-10-31 00:59:46 -04:00
fsl_soc.h powerpc: remove support for bootmem-allocated memory for the DIU driver 2008-10-13 11:09:59 -05:00
grackle.c [POWERPC] pci32: Add flags modifying the PCI code behaviour 2007-12-20 16:18:07 +11:00
i8259.c powerpc: Fix irq_alloc_host() reference counting and callers 2008-06-09 13:51:16 +10:00
indirect_pci.c powerpc/4xx: Workaround for PPC440EPx/GRx PCI_28 Errata 2008-06-17 19:01:38 -04:00
ipic.c powerpc/mpc83xx: Power Management support 2008-07-16 17:57:30 -05:00
ipic.h [POWERPC] ipic: ack only for edge interrupts 2007-12-12 01:53:07 -06:00
Kconfig powerpc: Move 8xxx GPIO Kconfig under the platform menu 2008-09-23 23:36:32 -05:00
Makefile powerpc/4xx: Add PowerPC 4xx GPIO driver 2008-10-17 13:33:44 -04:00
micropatch.c [POWERPC] CPM: Rename commproc to cpm1 and cpm2_common.c to cpm2.c 2008-01-28 08:31:05 -06:00
mmio_nvram.c [POWERPC] arch/powerpc/: Spelling fixes 2007-12-20 16:15:51 +11:00
mpc8xx_pic.c [POWERPC] arch/powerpc/sysdev: Add missing of_node_put 2008-02-06 22:06:59 +11:00
mpc8xx_pic.h [POWERPC] 8xx: mpc885ads pcmcia support 2007-07-10 00:33:51 -05:00
mpc8xxx_gpio.c powerpc: gpio driver for mpc8349/8572/8610 and compatible 2008-09-23 10:41:16 -05:00
mpic.c Merge commit 'origin/master' 2008-07-16 11:07:59 +10:00
mpic.h powerpc: Convert the MPIC MSI code to use msi_bitmap 2008-08-20 16:34:58 +10:00
mpic_msi.c powerpc: Convert the MPIC MSI code to use msi_bitmap 2008-08-20 16:34:58 +10:00
mpic_pasemi_msi.c powerpc: Convert the MPIC MSI code to use msi_bitmap 2008-08-20 16:34:58 +10:00
mpic_u3msi.c powerpc: Convert the MPIC MSI code to use msi_bitmap 2008-08-20 16:34:58 +10:00
msi_bitmap.c powerpc: Split-out common MSI bitmap logic into msi_bitmap.c 2008-08-20 16:34:57 +10:00
mv64x60.h [POWERPC] Add Marvell mv64x60 udbg putc/getc functions 2007-09-22 14:49:21 +10:00
mv64x60_dev.c mv643xx_eth: remove force_phy_addr field 2008-09-05 06:33:59 +02:00
mv64x60_pci.c [POWERPC] mv64x60: Fix FDT compatible names: mv64x60 => mv64360 2008-04-15 21:21:24 +10:00
mv64x60_pic.c [POWERPC] mv64x60: Fix FDT compatible names: mv64x60 => mv64360 2008-04-15 21:21:24 +10:00
mv64x60_udbg.c [POWERPC] Fix mv64x60 early console code to use cell-index property 2008-04-24 20:57:34 +10:00
of_rtc.c [POWERPC] Enable RTC for Ebony and Walnut (v2) 2008-01-25 07:07:26 -06:00
pmi.c [POWERPC] Clean out asm/of_{platform, device}.h from sysdev/ 2007-12-06 14:44:30 +11:00
ppc4xx_gpio.c powerpc/4xx: Add PowerPC 4xx GPIO driver 2008-10-17 13:33:44 -04:00
ppc4xx_pci.c Merge branch 'core-v28-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2008-10-16 15:17:40 -07:00
ppc4xx_pci.h [POWERPC] 4xx: Add 460EX PCIe support to 4xx pci driver 2008-03-26 07:19:16 -05:00
ppc4xx_soc.c [POWERPC] 4xx: Create common ppc4xx_reset_system() in ppc4xx_soc.c 2008-04-02 20:44:56 -05:00
rtc_cmos_setup.c powerpc: rtc_cmos_setup: assign interrupts only if there is i8259 PIC 2008-07-28 08:47:38 -05:00
tsi108_dev.c [POWERPC] Replace remaining __FUNCTION__ occurrences 2008-04-01 20:43:09 +11:00
tsi108_pci.c powerpc: Fix irq_alloc_host() reference counting and callers 2008-06-09 13:51:16 +10:00
uic.c powerpc: Fix irq_alloc_host() reference counting and callers 2008-06-09 13:51:16 +10:00
xilinx_intc.c [POWERPC] Xilinx: Fix compile warnings 2008-05-01 23:09:42 -05:00