Modify

Opened 5 years ago

#13413 new defect

Wrong PHY selected for ar231x_eth_mii with Marvell 88E6060 PHY

Reported by: Stanley.Pinchak@… Owned by: developers
Priority: high Milestone: Chaos Calmer 15.05
Component: packages Version: Trunk
Keywords: ar231x marvell 88e6060 WGT-624 PHY Cc:

Description

I was playing around with ramdisk based images of Barrier Breaker (r36370) on a WGT-624v2 and encountered a problem with the ar231x ethernet driver. Looking into the source code for ar231x.c it seems to makes sense as to why the wrong PHY is being selected. I was able to hard-code the correct address on the MII bus to check, but I don't know how to generalize this for others who may be suffering from having the wrong PHY selected.

First of all the serial output from (r36370), note the selection of Generic PHY at 10.39. Also please note the physical address of the two PHY's on the mdio bus near the end of the output:

[    0.000000] Linux version 3.8.8 (me@mybox) (gcc version 4.6.4 (OpenWrt3
[    0.000000] ar5312-gpio: registered 22 GPIOs                                 
[    0.000000] bootconsole [early0] enabled                                     
[    0.000000] CPU revision is: 0001800a (MIPS 4Kc)                             
[    0.000000] Determined physical RAM map:                                     
[    0.000000]  memory: 01000000 @ 00000000 (usable)                            
[    0.000000] Initrd not found or empty - disabling initrd                     
[    0.000000] Zone ranges:                                                     
[    0.000000]   Normal   [mem 0x00000000-0x00ffffff]                           
[    0.000000] Movable zone start for each node                                 
[    0.000000] Early memory node ranges                                         
[    0.000000]   node   0: [mem 0x00000000-0x00ffffff]                          
[    0.000000] Primary instruction cache 16kB, VIPT, 4-way, linesize 16 bytes.  
[    0.000000] Primary data cache 16kB, 4-way, VIPT, no aliases, linesize 16 bys
[    0.000000] Built 1 zonelists in Zone order, mobility grouping off.  Total p4
[    0.000000] Kernel command line:  console=ttyS0,9600 rootfstype=squashfs,jff2
[    0.000000] PID hash table entries: 64 (order: -4, 256 bytes)                
[    0.000000] Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)     
[    0.000000] Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)      
[    0.000000] __ex_table already sorted, skipping sort                         
[    0.000000] Memory: 12172k/16384k available (2000k kernel code, 4212k reserv)
[    0.000000] NR_IRQS:128                                                      
[    0.000000] console [ttyS0] enabled, bootconsole disabled                    
[    0.000000] console [ttyS0] enabled, bootconsole disabled                    
[    0.010000] Calibrating delay loop... 178.58 BogoMIPS (lpj=892928)           
[    0.110000] pid_max: default: 32768 minimum: 301                             
[    0.120000] Mount-cache hash table entries: 512                              
[    0.140000] NET: Registered protocol family 16                               
[    0.210000] bio: create slab <bio-0> at 0                                    
[    0.230000] Switching to clocksource MIPS                                    
[    0.260000] NET: Registered protocol family 2                                
[    0.310000] TCP established hash table entries: 512 (order: 0, 4096 bytes)   
[    0.400000] TCP bind hash table entries: 512 (order: -1, 2048 bytes)         
[    0.470000] TCP: Hash tables configured (established 512 bind 512)           
[    0.550000] TCP: reno registered                                             
[    0.590000] UDP hash table entries: 256 (order: 0, 4096 bytes)               
[    0.660000] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)          
[    0.730000] NET: Registered protocol family 1                                
[    8.650000] Radio config found at offset 0x10000(0x100)                      
[    8.740000] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORI.
[    8.860000] msgmni has been set to 23                                        
[    8.900000] io scheduler noop registered                                     
[    8.950000] io scheduler deadline registered (default)                       
[    9.020000] Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled         
[    9.110000] serial8250: ttyS0 at MMIO 0xbc000003 (irq = 37) is a 16550A      
[    9.210000] physmap platform flash device: 00800000 at 1e000000              
[    9.280000] physmap-flash.0: Found 1 x16 devices at 0x0 in 8-bit bank. Manuf9
[    9.400000] Amd/Fujitsu Extended Query Table at 0x0040                       
[    9.460000]   Amd/Fujitsu Extended Query version 1.0.                        
[    9.520000] number of CFI chips: 1                                           
[    9.570000] Searching for RedBoot partition table in physmap-flash.0 at offs0
[    9.680000] Searching for RedBoot partition table in physmap-flash.0 at offs0
[    9.800000] Searching for RedBoot partition table in physmap-flash.0 at offs0
[    9.920000] No RedBoot partition table detected in physmap-flash.0           
[   10.070000] eth0: Atheros AR231x: 00:09:5b:c9:be:2d, irq 4                   
[   10.340000] libphy: ar231x_eth_mii: probed                                   
[   10.390000] eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0:0a)  
[   10.480000] TCP: cubic registered                                            
[   10.520000] NET: Registered protocol family 17                               
[   10.580000] 8021q: 802.1Q VLAN Support v1.8                                  
[   10.650000] Freeing unused kernel memory: 1044k freed                        
- preinit -                                                                     
Press the [f] key and hit [enter] to enter failsafe mode                        
- regular preinit -                                                             
- init -                                                                        
                                                                                
Please press Enter to activate this console. [   17.340000] ip_tables: (C) 2000m
[   17.870000] nf_conntrack version 0.5.0 (206 buckets, 824 max)                
[   25.420000] device eth0.1 entered promiscuous mode                           
[   25.470000] device eth0 entered promiscuous mode                             
[   25.540000] br-lan: port 1(eth0.1) entered forwarding state                  
[   25.600000] br-lan: port 1(eth0.1) entered forwarding state                  
                                                                                
                                                                                
                                                                                
BusyBox v1.19.4 (2013-04-21 13:06:31 EDT) built-in shell (ash)                  
Enter 'help' for a list of built-in commands.                                   
                                                                                
  _______                     ________        __                                
 |       |.-----.-----.----[   27.600000] br-lan: port 1(eth0.1) entered forware
-.|  |  |  |.----.|  |_                                                         
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|                             
 |_______||   __|_____|__|__||________||__|  |____|                             
          |__| W I R E L E S S   F R E E D O M                                  
 -----------------------------------------------------                          
 BARRIER BREAKER (Bleeding Edge, r36370)                                        
 -----------------------------------------------------                          
  * 1/2 oz Galliano         Pour all ingredients into                           
  * 4 oz cold Coffee        an irish coffee mug filled                          
  * 1 1/2 oz Dark Rum       with crushed ice. Stir.                             
  * 2 tsp. Creme de Cacao                                                       
 -----------------------------------------------------                          
root@OpenWrt:/#  ping 192.168.1.2                                                
PING 192.168.1.2 (192.168.1.2): 56 data bytes                                   
^C                                                                              
--- 192.168.1.2 ping statistics ---                                             
23 packets transmitted, 0 packets received, 100% packet loss                    
root@OpenWrt:/# ls /sys/bus/mdio_bus/drivers/Marvell\ 88E6060/                  
0:10/   bind    uevent  unbind                                                  
root@OpenWrt:/# ls /sys/bus/mdio_bus/drivers/Generic\ PHY/                      
0:0a/   bind    uevent  unbind
root@OpenWrt:/# reboot                                                          
root@OpenWrt:/# [  215.830000] br-lan: port 1(eth0.1) entered disabled state    
[  215.960000] device eth0.1 left promiscuous mode                              
[  216.010000] device eth0 left promiscuous mode                                
[  216.060000] br-lan: port 1(eth0.1) entered disabled state                    
[  219.520000] Restarting system.                                               

After modifying the ar231x.c I was able to get the correct PHY selected for my board:

[    0.000000] Linux version 3.8.8 (me@mybox) (gcc version 4.6.4 (OpenWrt3
[    0.000000] ar5312-gpio: registered 22 GPIOs                                 
[    0.000000] bootconsole [early0] enabled                                     
[    0.000000] CPU revision is: 0001800a (MIPS 4Kc)                             
[    0.000000] Determined physical RAM map:                                     
[    0.000000]  memory: 01000000 @ 00000000 (usable)                            
[    0.000000] Initrd not found or empty - disabling initrd                     
[    0.000000] Zone ranges:                                                     
[    0.000000]   Normal   [mem 0x00000000-0x00ffffff]                           
[    0.000000] Movable zone start for each node                                 
[    0.000000] Early memory node ranges                                         
[    0.000000]   node   0: [mem 0x00000000-0x00ffffff]                          
[    0.000000] Primary instruction cache 16kB, VIPT, 4-way, linesize 16 bytes.  
[    0.000000] Primary data cache 16kB, 4-way, VIPT, no aliases, linesize 16 bys
[    0.000000] Built 1 zonelists in Zone order, mobility grouping off.  Total p4
[    0.000000] Kernel command line:  console=ttyS0,9600 rootfstype=squashfs,jff2
[    0.000000] PID hash table entries: 64 (order: -4, 256 bytes)                
[    0.000000] Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)     
[    0.000000] Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)      
[    0.000000] __ex_table already sorted, skipping sort                         
[    0.000000] Memory: 12172k/16384k available (2000k kernel code, 4212k reserv)
[    0.000000] NR_IRQS:128                                                      
[    0.000000] console [ttyS0] enabled, bootconsole disabled                    
[    0.000000] console [ttyS0] enabled, bootconsole disabled                    
[    0.010000] Calibrating delay loop... 178.58 BogoMIPS (lpj=892928)           
[    0.110000] pid_max: default: 32768 minimum: 301                             
[    0.120000] Mount-cache hash table entries: 512                              
[    0.140000] NET: Registered protocol family 16                               
[    0.210000] bio: create slab <bio-0> at 0                                    
[    0.230000] Switching to clocksource MIPS                                    
[    0.260000] NET: Registered protocol family 2                                
[    0.310000] TCP established hash table entries: 512 (order: 0, 4096 bytes)   
[    0.400000] TCP bind hash table entries: 512 (order: -1, 2048 bytes)         
[    0.470000] TCP: Hash tables configured (established 512 bind 512)           
[    0.550000] TCP: reno registered                                             
[    0.590000] UDP hash table entries: 256 (order: 0, 4096 bytes)               
[    0.660000] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)          
[    0.730000] NET: Registered protocol family 1                                
[    8.640000] Radio config found at offset 0x10000(0x100)                      
[    8.730000] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORI.
[    8.840000] msgmni has been set to 23                                        
[    8.890000] io scheduler noop registered                                     
[    8.940000] io scheduler deadline registered (default)                       
[    9.000000] Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled         
[    9.100000] serial8250: ttyS0 at MMIO 0xbc000003 (irq = 37) is a 16550A      
[    9.190000] physmap platform flash device: 00800000 at 1e000000              
[    9.270000] physmap-flash.0: Found 1 x16 devices at 0x0 in 8-bit bank. Manuf9
[    9.390000] Amd/Fujitsu Extended Query Table at 0x0040                       
[    9.450000]   Amd/Fujitsu Extended Query version 1.0.                        
[    9.510000] number of CFI chips: 1                                           
[    9.560000] Searching for RedBoot partition table in physmap-flash.0 at offs0
[    9.670000] Searching for RedBoot partition table in physmap-flash.0 at offs0
[    9.790000] Searching for RedBoot partition table in physmap-flash.0 at offs0
[    9.900000] No RedBoot partition table detected in physmap-flash.0           
[   10.060000] eth0: Atheros AR231x: 00:09:5b:c9:be:2d, irq 4                   
[   10.330000] libphy: ar231x_eth_mii: probed                                   
[   10.380000] eth0: Marvell 88E6060 PHY driver attached.                       
[   10.480000] eth0: attached PHY driver [Marvell 88E6060] (mii_bus:phy_addr=0:)
[   10.570000] TCP: cubic registered                                            
[   10.610000] NET: Registered protocol family 17                               
[   10.670000] 8021q: 802.1Q VLAN Support v1.8                                  
[   10.740000] Freeing unused kernel memory: 1044k freed                        
- preinit -                                                                     
Press the [f] key and hit [enter] to enter failsafe mode                        
- regular preinit -                                                             
- init -                                                                        
                                                                                
Please press Enter to activate this console. [   17.420000] ip_tables: (C) 2000m
[   17.950000] nf_conntrack version 0.5.0 (206 buckets, 824 max)                
                                                                                
                                                                                
                                                                                
BusyBox v1.19.4 (2013-04-21 13:06:31 EDT) built-in shell (ash)                  
Enter 'help' for a list of built-in commands.                                   
                                                                                
  _______                     ________        __                                
 |       |.-----.-----.-----.|  |  |  |.----.|  |_                              
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|                             
 |_______||   __|_____|__|__||________||__|  |____|                             
          |__| W I R E L E S S   F R E E D O M                                  
 -----------------------------------------------------                          
 BARRIER BREAKER (Bleeding Edge, r36370)                                        
 -----------------------------------------------------                          
  * 1/2 oz Galliano         Pour all ingredients into                           
  * 4 oz cold Coffee        an irish coffee mug filled                          
  * 1 1/2 oz Dark Rum       with crushed ice. Stir.                             
  * 2 tsp. Creme de Cacao                                                       
 -----------------------------------------------------                          
root@(none):/# ping 192.168.1.[   26.000000] device eth0.1 entered promiscuous e
[   26.070000] br-lan: port 1(eth0.1) entered forwarding state                  
[   26.130000] br-lan: port 1(eth0.1) entered forwarding state                  
2                                                                               
PING 192.168.1.2 (192.168.1.2): 56 data bytes                                   
64 bytes from 192.168.1.2: seq=0 ttl=64 time=2.889 ms                           
[   28.130000] br-lan: port 1(eth0.1) entered forwarding state                  
64 bytes from 192.168.1.2: seq=1 ttl=64 time=1.551 ms                           
64 bytes from 192.168.1.2: seq=2 ttl=64 time=1.447 ms                           
64 bytes from 192.168.1.2: seq=3 ttl=64 time=1.446 ms                           
^C                                                                              
--- 192.168.1.2 ping statistics ---                                             
4 packets transmitted, 4 packets received, 0% packet loss                       
round-trip min/avg/max = 1.446/1.833/2.889 ms                                   
root@OpenWrt:/# 

Here is the patch that I came up with to essentially hard-code ar231x_mdiobus_probe to look at the 0x10 physical address where the marvell PHY is located on the WGT-624 mdio bus. Blindly applying this patch to other ar231x based hardware will probably cause problems. Perhaps it would be possible to look at the PHY associated with the particular mdio physical addresses and choose the lowest address where the phydev->drv->name != "Generic PHY", falling back to the first instance of Generic PHY if necessary.

--- a/drivers/net/ethernet/ar231x/ar231x.c
+++ b/drivers/net/ethernet/ar231x/ar231x.c
@@ -1228,13 +1273,17 @@
        struct ar231x_private *const sp = netdev_priv(dev);
        struct phy_device *phydev = NULL;
        int phy_addr;
+       int i = 0;
 
        /* find the first (lowest address) PHY on the current MAC's MII bus */
        for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++)
                if (sp->mii_bus->phy_map[phy_addr]) {
                        phydev = sp->mii_bus->phy_map[phy_addr];
                        sp->phy = phy_addr;
-                       break; /* break out with first one found */
+                       if (i == 0x10) {
+                               break; /* break out with tenth one found */
+                       }
+                       i++;
                }
 
        if (!phydev) {

Here is a slightly more robust patch that should fall back to the present operation. I am a little confused about phy_id, so there may be a better way of checking if a phy is indeed a Generic PHY, phy_device.c indicates that for genphy_driver, phy_id = 0xffffffff, but looking at the phy_id in /sys/bus/mdio/0:*/ all of the "Generic PHY" devices on the bus before the marvell PHY had phy_id=0:

--- a/drivers/net/ethernet/ar231x/ar231x.c
+++ b/drivers/net/ethernet/ar231x/ar231x.c
@@ -1272,17 +1272,30 @@
 {
        struct ar231x_private *const sp = netdev_priv(dev);
        struct phy_device *phydev = NULL;
+       struct phy_device *gen_phydev = NULL;
        int phy_addr;
 
-       /* find the first (lowest address) PHY on the current MAC's MII bus */
-       for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++)
+       /* find the first PHY on the current MAC's MII bus */
+       for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) {
                if (sp->mii_bus->phy_map[phy_addr]) {
                        phydev = sp->mii_bus->phy_map[phy_addr];
-                       sp->phy = phy_addr;
-                       break; /* break out with first one found */
+                       if (phydev->phy_id == 0) {
+                               /* keep track of first Generic PHY */
+                               if (gen_phydev == NULL) {
+                                       gen_phydev = phydev;
+                               }
+                       } else {
+                               break; /* break if non-Generic PHY found */
+                       }
                }
+       }
 
-       if (!phydev) {
+       if (phydev) {
+               /* if phydev is a Generic PHY, use the first Generic PHY */
+               if (phydev->phy_id == 0)
+                       phydev = gen_phydev;
+               sp->phy = phy_addr;
+       } else {
                printk (KERN_ERR "ar231x: %s: no PHY found\n", dev->name);
                return -1;
        }

I have placed the priority at high due to the fact that the incorrect PHY selection breaks wired ethernet on the WGT-624v2, and perhaps on other atheros ar231x / marvell 88E6060 based hardware.

Attachments (0)

Change History (0)

Add Comment

Modify Ticket

Action
as new .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.