Subject: powerpc: net: gianfar ethernet broken on linux-3.10.29?

From: Émeric Vigier <[email-masked]>
Date: Tue, 25 Mar 2014 15:26:07 -0400 (EDT)

Hi guys,

I work on a Freescale MPC8347 custom board. I ported u-boot-v2014.01 on it. My config is attached.
I ported linux-3.2.52 (long-term). DTS is attached.

linux-3.2.52 being a bit old, I switched to linux-3.10.29 (long-term).
For linux-3.10.29, I use the same DTS.

linux-3.2.52
------------
Ethernet works on both u-boot and linux-3.2.52: i.e. I can ping, and use a rootfs over NFS.
I attached outputs from u-boot, ifconfig, mii-diag and ethtool utilities (mii-ethtool-ifconfig-3.2.52.txt).

linux-3.10.29
-------------
Ethernet is broken: i.e. I can up the link, it says 100/Full-duplex, but I cannot ping anybody.
When I ping the device from my PC, I get "RX interrupts" (eth0_g0_rx) but no "RX bytes".
Because I cannot use NFS, I mounted rootfs from a compressed initramfs.
I attached outputs from u-boot, ifconfig, mii-diag and ethtool utilities (mii-ethtool-ifconfig-3.10.29.txt).
mii-diag dumps the PHY registers. Only one register differs between the two kernels: 0x15
Datasheet says this register is reserved. I have no control over it.

After a week long of trials, I believe the PHY is fine. Problem might come from the gianfar driver.
Which has widely changed between 3.2 and 3.10: 51 patches.

  $ git log --oneline v3.2.52..v3.10.29 drivers/net/ethernet/freescale/gianfar.c | wc -l
  51

I have not "git bisect" the bug, fearing that I would struggle to build the resulting kernel due to
changes in net/ and the driver model.

Hardware 
--------
The architecture is as follows:

+----------------------+
|  MPC8347  +----------+
|           | gianfar  |
|           | ethernet |
|           | TSEC0    |
|           |          |
|           |   +------+      +-------------+
|           |   | MDIO | <--> | BCM5241 PHY |
|           |   |  MII |      | addr:0      |
|           |   +------+      +-------------+
|           +----------+
+----------------------+

MDIO is connected in MII: 4 TX, 4RX, COL, CRS, TXCLK, RXCLK, MDIO, MDC.
Auto-negotiation is disabled by hardware (pull-ups), speed is fixed to 100Mbps and full-duplex.
The PHY lies at address 0.
MDIO link is fine: I can read/write registers on the PHY.

I made several trials, list is not exhaustive:
- switch to Generic PHY driver
- switch to Broadcom BCM5241 PHY driver
- fixed-link = <0 1 100 0 0> in DTS
- stub tbi-phy node in DTS
- stub ethernet1 node (TSEC1) in DTS
- reset the PHY with mii-diag
- remove the interrupt attribute in DTS

I made it work on linux-3.10.29 once, only 3/4 min after bootup. But I couldn't catch why...

Do you guys see what could be wrong in my config?
Or what has changed in linux-3.{4,6,8,10} that could break my ethernet?

thanks,
Emeric