[BPI-R2] Porting 2nd gmac to 4.19


(Frank W.) #1

Hi,

i tried porting 2nd gmac from 4.14 to 4.19.

for compare here is the version for 4.14:

it compiles without errors, boots without crash/oops, but it still does not work…i only see eth0 and eth1, but none of the external (USER-) ports in “ip a”

also nothing obviously in dmesg

root@bpi-r2-ubuntu:~# dmesg | grep -i 'dsa\|net'                                                                                                                                   
[    0.195904] NET: Registered protocol family 16                                                                                                                                  
[    0.468627] NET: Registered protocol family 2                                                                                                                                   
[    0.513491] NET: Registered protocol family 1                                                                                                                                   
[    1.068059] drivers/net/ethernet/mediatek/mtk_eth_soc.c:mtk_mdio_init[413]0 237bf14f                                                                                            
[    1.075784] mtk_soc_eth 1b100000.ethernet: generated random MAC address 5e:32:b8:eb:72:9b                                                                                       
[    1.084466] mtk_soc_eth 1b100000.ethernet: connected mac 0 to PHY at fixed-0:00 [uid=00000000, driver=Generic PHY]                                                              
[    1.095246] mtk_soc_eth 1b100000.ethernet eth0: mediatek frame engine at 0xe14c0000, irq 228                                                                                    
[    1.103682] mtk_soc_eth 1b100000.ethernet: generated random MAC address 12:a6:6c:0e:bd:20                                                                                       
[    1.112250] mtk_soc_eth 1b100000.ethernet: connected mac 1 to PHY at fixed-0:01 [uid=00000000, driver=Generic PHY]                                                              
[    1.122983] mtk_soc_eth 1b100000.ethernet eth1: mediatek frame engine at 0xe14c0000, irq 228                                                                                    
[    1.489242] NET: Registered protocol family 17
[    3.678471] NET: Registered protocol family 10

i also wrote to john crispin he will look over it…but maybe anyone here see’s the problem. main challenge was that dsa2.c changes too much for 4.15 (not only functionnames or parameters changed). here i’m unsure if i included new code in right context…

some documentation i used:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/net/dsa/dsa2.c?h=v4.19-rc2

dsa_cpu_parse

net: dsa: setup and teardown ports (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/net/dsa/dsa2.c?h=v4.19-rc2&id=1d27732f411d57f0168af30be2adb504b8b7749d)

port_apply=> setup

port_unapply => teardown

net: dsa: setup and teardown ports https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/net/dsa/dsa2.c?h=v4.19-rc2&id=1d27732f411d57f0168af30be2adb504b8b7749d

dsa_ds_parse => dsa_tree_setup_default_cpu

net: dsa: setup and teardown default CPU port https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/net/dsa/dsa2.c?h=v4.19-rc2&id=f070464cf000131928b2c3fd592efd1946610eea


(Frank W.) #2

Can anybody help here? I got answer from john crispin that he had not enough time to look over it yet


(Frank W.) #3

seems that i got it working with some help of a DSA-Maintainer :slight_smile:

branch is currently based on rc1 but i will import changes to 4.19 if i removed unnecessary stuff (started with printks) and changed mt7530_probe back to mdio_device (platform_device should not be used because it will be dropped in future, but i need to know how to link to mdio-node)

all interfaces are visible, wan is bound to eth1 and lan-ports to eth0…quick-tested wan and lan0 via ping. i can also deactivate the corresponding cpu-port (eth1 for wan or eth0 for lan0) to disable ping…so routing seems correct.

wonder why this is not used

it gets overridden dsa_tree_setup_switches => dsa_port_setup => dsa_user_parse

sets ds->ports[index].upstream = cpu_port_index;

but dp->cpu_dp is not changed again as far as i see, but in slave.c master is changed from cpu_dp.master to ports[x].ethernet so only this seems to be used and cpu_dp ignored

int dsa_slave_create(struct dsa_port *port)
...
	//struct net_device *master = cpu_dp->master;
	struct net_device *master = ds->ports[port->upstream].ethernet;
...

seems to work…hope anybody will test it too

i currently try to move back to mdio-device because the way with platform-device and phandle-linking should not be used anymore

argh…mt7530_probe gets not called again, but diff (dts+mt7530.c) looks good for me

mt7530.diff (9,4 KB)

seems that is caused by size-cells/adress-cells/reg-property in switch-node…changed it and now probe gets called :tada:


(Frank W.) #4

had also removed clock-patch and in_atomic (with kernel-hacking) in 4.20-gmac for testing (try to get it mainline)

it seems that it does not have any effect

root@bpi-r2:~# iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size:  128 KByte (default)
------------------------------------------------------------
[  4] local 192.168.0.42 port 5001 connected with 192.168.0.21 port 39930
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0-10.0 sec   920 MBytes   771 Mbits/sec
^Croot@bpi-r2:~# iperf -c 192.168.0.21
------------------------------------------------------------
Client connecting to 192.168.0.21, TCP port 5001
TCP window size: 43.8 KByte (default)
------------------------------------------------------------
[  3] local 192.168.0.42 port 59860 connected with 192.168.0.21 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.09 GBytes   940 Mbits/sec
root@bpi-r2:~# ifdown wan
[ 1445.764386] mt7530 mdio-bus:00 wan: Link is Down
root@bpi-r2:~# [ 1456.498533] mt7530 mdio-bus:00 lan0: Link is Up - 1Gbps/Full f
[ 1456.505837] IPv6: ADDRCONF(NETDEV_CHANGE): lan0: link becomes ready

root@bpi-r2:~# ip addr add 192.168.0.15/24 dev lan0                            
root@bpi-r2:~# uname -a
Linux bpi-r2 4.20.0-rc1-bpi-r2-gmac #237 SMP Thu Nov 29 10:06:38 CET 2018 armv7x
root@bpi-r2:~# iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size:  128 KByte (default)
------------------------------------------------------------
[  4] local 192.168.0.15 port 5001 connected with 192.168.0.21 port 54590
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0-10.0 sec   861 MBytes   721 Mbits/sec
root@bpi-r2:~# iperf -c 192.168.0.21
------------------------------------------------------------
Client connecting to 192.168.0.21, TCP port 5001
TCP window size: 43.8 KByte (default)
------------------------------------------------------------
[  3] local 192.168.0.15 port 44502 connected with 192.168.0.21 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.10 GBytes   943 Mbits/sec

(Frank W.) #5

seems i have made an error somewhere:

root@bpi-r2:~# iperf -c 192.168.0.21
------------------------------------------------------------
Client connecting to 192.168.0.21, TCP port 5001
TCP window size: 43.8 KByte (default)
------------------------------------------------------------
[  3] local 192.168.0.15 port 35150 connected with 192.168.0.21 port 5001
[  102.243908] ------------[ cut here ]------------
[  102.248532] WARNING: CPU: 0 PID: 0 at net/sched/sch_generic.c:461 dev_watchdog+0x278/0x27c
[  102.256768] NETDEV WATCHDOG: eth1 (mtk_soc_eth): transmit queue 0 timed out
[  102.263691] Modules linked in: mtk_thermal thermal_sys mt6577_auxadc spi_mt65xx pwm_mediatek mtk_pmic_keys nvmem_mtk_efuse ip_tabless
[  102.276356] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.19.4-bpi-r2-testing #231
[  102.283703] Hardware name: Mediatek Cortex-A7 (Device Tree)
[  102.289259] [<c0114ca0>] (unwind_backtrace) from [<c010e9cc>] (show_stack+0x20/0x24)
[  102.296947] [<c010e9cc>] (show_stack) from [<c0bbcff4>] (dump_stack+0x94/0xa8)
[  102.304117] [<c0bbcff4>] (dump_stack) from [<c01283c0>] (__warn+0xf0/0x108)
[  102.311027] [<c01283c0>] (__warn) from [<c0128430>] (warn_slowpath_fmt+0x58/0x74)
[  102.318455] [<c0128430>] (warn_slowpath_fmt) from [<c096b95c>] (dev_watchdog+0x278/0x27c)
[  102.326574] [<c096b95c>] (dev_watchdog) from [<c01a9008>] (call_timer_fn+0x4c/0x194)
[  102.334261] [<c01a9008>] (call_timer_fn) from [<c01a9240>] (expire_timers+0xf0/0x16c)
[  102.342031] [<c01a9240>] (expire_timers) from [<c01a95a8>] (run_timer_softirq+0xf4/0x1ec)
[  102.350146] [<c01a95a8>] (run_timer_softirq) from [<c01023f8>] (__do_softirq+0x148/0x3b4)
[  102.358265] [<c01023f8>] (__do_softirq) from [<c012f188>] (irq_exit+0xdc/0x11c)
[  102.365521] [<c012f188>] (irq_exit) from [<c018b1f8>] (__handle_domain_irq+0x70/0xc4)
[  102.373291] [<c018b1f8>] (__handle_domain_irq) from [<c0102268>] (gic_handle_irq+0x5c/0xa0)
[  102.381577] [<c0102268>] (gic_handle_irq) from [<c0101a0c>] (__irq_svc+0x6c/0x90)
[  102.388997] Exception stack(0xc1201ed8 to 0xc1201f20)
[  102.394006] 1ec0:                                                       00000000 00154614
[  102.402121] 1ee0: df59e408 c0121760 ffffe000 c1204c70 c1204cb8 00000001 00000001 c12b8023
[  102.410234] 1f00: c0e51ee4 c1201f34 c1201f38 c1201f28 c010a9f8 c010a9fc 60050013 ffffffff
[  102.418351] [<c0101a0c>] (__irq_svc) from [<c010a9fc>] (arch_cpu_idle+0x48/0x4c)
[  102.425695] [<c010a9fc>] (arch_cpu_idle) from [<c0bd8cd8>] (default_idle_call+0x30/0x3c)
[  102.433726] [<c0bd8cd8>] (default_idle_call) from [<c015cafc>] (do_idle+0xf4/0x164)
[  102.441326] [<c015cafc>] (do_idle) from [<c015ce2c>] (cpu_startup_entry+0x28/0x2c)
[  102.448839] [<c015ce2c>] (cpu_startup_entry) from [<c0bd26ec>] (rest_init+0xc0/0xc4)
[  102.456525] [<c0bd26ec>] (rest_init) from [<c1100ff8>] (start_kernel+0x46c/0x49c)
[  102.463982] ---[ end trace 18e53bf3e74400e7 ]---
[  102.468585] mtk_soc_eth 1b100000.ethernet eth1: transmit timed out
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.04 GBytes   897 Mbits/sec

happens after i made a iperf (client) over wan, set wan down, add ip to lan0 an make iperf again

root@bpi-r2:~# iperf -c 192.168.0.21
------------------------------------------------------------
Client connecting to 192.168.0.21, TCP port 5001
TCP window size: 43.8 KByte (default)
------------------------------------------------------------
[  3] local 192.168.0.42 port 36400 connected with 192.168.0.21 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.09 GBytes   940 Mbits/sec
root@bpi-r2:~# ifdown wan
[   65.668446] mt7530 mdio-bus:00 wan: Link is Down
root@bpi-r2:~# ip addr add 192.168.0.15/24 dev lan0                                                                                     
root@bpi-r2:~# [   86.884496] mt7530 mdio-bus:00 lan0: Link is Up - 1Gbps/Full - flow control off
[   86.891791] IPv6: ADDRCONF(NETDEV_CHANGE): lan0: link becomes ready

root@bpi-r2:~# 
root@bpi-r2:~# iperf -c 192.168.0.21

kernel:

root@bpi-r2:~# uname -a
Linux bpi-r2 4.19.4-bpi-r2-testing #231 SMP Tue Nov 27 18:58:30 CET 2018 armv7l GNU/Linux

reproducable with 4.19, 4.20 but not 4.14 so it seems i made i mistake while porting

sometimes it happens after trying wan again (mtk_soc_eth 1b100000.ethernet eth0: transmit timed out)…tried also with reverted in_atomic and clock-patch (no change)


(Frank W.) #6

it seems that some of the ethernet-Patches causes this crash and that they are not needed (as i thought). I applied the patch-series (cherry-picked from 4.20-gmac_test_dsa_only) i’ve posted to mainline-kernel to 4.19…

after testing with 4.20 and now applied to (new) 4.19-gmac and tested again…seems to work without problems

here my tests (iperf over wan,lan0,wan again and lan0 again):

log
root@bpi-r2:~# uname -r
4.19.10-bpi-r2-gmac
root@bpi-r2:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 9a:da:30:8e:aa:52 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 5e:06:08:25:eb:ef brd ff:ff:ff:ff:ff:ff
4: wan@eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 5e:06:08:25:eb:ef brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.11/24 brd 192.168.0.255 scope global wan
       valid_lft forever preferred_lft forever
5: lan0@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 9a:da:30:8e:aa:52 brd ff:ff:ff:ff:ff:ff
6: lan1@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 9a:da:30:8e:aa:52 brd ff:ff:ff:ff:ff:ff
7: lan2@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 9a:da:30:8e:aa:52 brd ff:ff:ff:ff:ff:ff
8: lan3@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state LOWERLAYERDOWN group default qlen 1000
    link/ether 9a:da:30:8e:aa:52 brd ff:ff:ff:ff:ff:ff
9: wan.60@wan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 5e:06:08:25:eb:ef brd ff:ff:ff:ff:ff:ff
    inet 192.168.60.1/24 brd 192.168.60.255 scope global wan.60
       valid_lft forever preferred_lft forever
10: lxcbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether 8e:c6:30:ed:4c:43 brd ff:ff:ff:ff:ff:ff
    inet 10.0.3.1/24 brd 10.0.3.255 scope global lxcbr0
       valid_lft forever preferred_lft forever
root@bpi-r2:~# iperf -c 192.168.0.21
------------------------------------------------------------
Client connecting to 192.168.0.21, TCP port 5001
TCP window size: 43.8 KByte (default)
------------------------------------------------------------
[  3] local 192.168.0.11 port 36498 connected with 192.168.0.21 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.09 GBytes   940 Mbits/sec
root@bpi-r2:~# ip link set wan down
[  129.232523] mt7530 mdio-bus:00 wan: Link is Down
root@bpi-r2:~# ip addr add 192.168.0.19/24 dev lan0
root@bpi-r2:~# ip link set lan0 up
[  144.462925] mt7530 mdio-bus:00 lan0: configuring for phy/gmii link mode
root@bpi-r2:~# [  150.717531] mt7530 mdio-bus:00 lan0: Link is Up - 1Gbps/Full - flow control off

root@bpi-r2:~# 
root@bpi-r2:~# iperf -c 192.168.0.21
------------------------------------------------------------
Client connecting to 192.168.0.21, TCP port 5001
TCP window size: 43.8 KByte (default)
------------------------------------------------------------
[  3] local 192.168.0.19 port 38498 connected with 192.168.0.21 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.10 GBytes   942 Mbits/sec
root@bpi-r2:~# ip link set lan0 down                                                                                                            
[  233.152510] mt7530 mdio-bus:00 lan0: Link is Down
root@bpi-r2:~# 
root@bpi-r2:~# 
root@bpi-r2:~# 
root@bpi-r2:~# ip link set wan up
[  289.553227] mt7530 mdio-bus:00 wan: configuring for phy/gmii link mode
root@bpi-r2:~# [  292.717522] mt7530 mdio-bus:00 wan: Link is Up - 1Gbps/Full - flow control off

root@bpi-r2:~# iperf -c 192.168.0.21
------------------------------------------------------------
Client connecting to 192.168.0.21, TCP port 5001
TCP window size: 43.8 KByte (default)
------------------------------------------------------------
[  3] local 192.168.0.11 port 36502 connected with 192.168.0.21 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.09 GBytes   940 Mbits/sec
root@bpi-r2:~# ip link set wan down
[  318.692540] mt7530 mdio-bus:00 wan: Link is Down
root@bpi-r2:~# 
root@bpi-r2:~# ip link set lan0 up
[  352.022970] mt7530 mdio-bus:00 lan0: configuring for phy/gmii link mode
root@bpi-r2:~# [  355.117526] mt7530 mdio-bus:00 lan0: Link is Up - 1Gbps/Full - flow control off

root@bpi-r2:~# iperf -c 192.168.0.21
------------------------------------------------------------
Client connecting to 192.168.0.21, TCP port 5001
TCP window size: 43.8 KByte (default)
------------------------------------------------------------
[  3] local 192.168.0.19 port 38502 connected with 192.168.0.21 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.10 GBytes   942 Mbits/sec
root@bpi-r2:~#

i hope here are some users to test…


(Frank W.) #7

fixed crash if cpu-option is not set and want to post it to mainline, but mails got currently blocked on infradead (same as hdmi). contacted postmaster

if anybody here want to try it here is the actual patchset:

contacted andrew and florian how to get further to bring it mainline (they want to avoid dts-option and prefer bridge by user)