Vim2 ethernet problem with - mainline kernel

vim2 broken Ethernet for mainline kernel

NOTE: i have this problem on VIM2 only for all mainline kernels about 2 month
its very strange why nobody ask about this ? :wink:

test image with mainline kernel u can get there https://dl.khadas.com/Firmware/VIM2/Ubuntu/SD_USB/VIM2_Ubuntu-xfce-bionic_Linux-5.3-rc4_arm64_SD-USB_V20190830.7z

u can build last mainline but its have same situations

root@Khadas:~# uname -a
Linux Khadas 5.3.0-rc4 #0.7 SMP PREEMPT Fri Aug 30 12:50:08 CST 2019 aarch64 aarch64 aarch64 GNU/Linux

HOW can reproduce this problem

  1. bootup and login, check ethernet its works
root@Khadas:~# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.110  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::6e06:2d8b:b93e:9ccc  prefixlen 64  scopeid 0x20<link>
        ether be:10:1b:4a:3b:2c  txqueuelen 1000  (Ethernet)
        RX packets 5233  bytes 6585309 (6.5 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1126  bytes 83055 (83.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 22  

root@Khadas:~# ping 8.8.8.8 -c1
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=50 time=19.2 ms
  1. next step - after next simple commands Ethernet never come again ;(
ifdown eth0
ifup eth0

LOGS:

...
[   71.578058] meson8b-dwmac c9410000.ethernet: Failed to reset the dma
[   71.578835] meson8b-dwmac c9410000.ethernet eth0: stmmac_hw_setup: DMA engine initialization failed
[   71.587857] meson8b-dwmac c9410000.ethernet eth0: stmmac_open: Hw setup failed
RTNETLINK answers: Device or resource busy
Listening on LPF/eth0/be:10:1b:4a:3b:2c
Sending on   LPF/eth0/be:10:1b:4a:3b:2c
Sending on   Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3 (xid=0xab15472f)
send_packet: Network is down
dhclient.c:2438: Failed to send 300 byte long packet over eth0 interface.
receive_packet failed on eth0: Network is down
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7 (xid=0xab15472f)
send_packet: Network is down
dhclient.c:2438: Failed to send 300 byte long packet over eth0 interface.
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 13 (xid=0xab15472f)
send_packet: Network is down
dhclient.c:2438: Failed to send 300 byte long packet over eth0 interface.
^C

dmesg -c 

[   71.291332] meson8b-dwmac c9410000.ethernet eth0: phy link down rgmii/1Gbps/Full
[   71.291352] meson8b-dwmac c9410000.ethernet eth0: Link is Down
[   71.473224] meson8b-dwmac c9410000.ethernet eth0: PHY [0.2009087f:00] driver [RTL8211F Gigabit Ethernet]
[   71.473239] meson8b-dwmac c9410000.ethernet eth0: phy: setting supported 00,00000000,000062ff advertising 00,00000000,000062ff
[   71.578058] meson8b-dwmac c9410000.ethernet: Failed to reset the dma
[   71.578835] meson8b-dwmac c9410000.ethernet eth0: stmmac_hw_setup: DMA engine initialization failed
[   71.587857] meson8b-dwmac c9410000.ethernet eth0: stmmac_open: Hw setup failed

root@Khadas:~# mii-tool eth0
SIOCGMIIPHY on 'eth0' failed: Invalid argument

full-logs https://gist.github.com/hyphop/4499f3aed67cef3d949fbf7b00aed86b

Hi, wasn’t aware of this issue, could you share the issue on the Linux-amlogic mailing list so other people could check ?

Personally, I never experienced this issue… will have a run next week

@hyphop there is true mainline kernel, and then there’s various branches with lots of extra patches included (like mine). What kernel sources are you using?

for example this one: https://git.kernel.org/torvalds/t/linux-5.4-rc5.tar.gz

but u can use any previous ! its same
https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.3.7.tar.xz

if u know any workable mainline kernel source - plz share - i will happy to check it :wink:

hi @chewitt, :wink:

i have check libreelec image too!
and libreelec is no exception too! have same problems!!!

i think its common Ethernet problem for VIM2 and mainline linux
!!! poor Ethernet driver quality !!!
very interesting why nobody notice this issue ?! i now about this about 2 month already !

we can easy reproduce it

LibreELEC:/ $ uname -a
Linux LibreELEC 5.3.0-rc8 #1 SMP Wed Sep 11 11:52:50 MSK 2019 aarch64 GNU/Linux

LibreELEC:/ $ ping 8.8.8.8 -c1 && echo ok
ok

LibreELEC:/ $ dmesg -c >/dev/null

LibreELEC:/ $ ifconfig eth0 down

## after this ethernet never come again ;)
LibreELEC:/ $ ifconfig eth0 up
> ifconfig: ioctl 0x8914 failed: Device or resource busy

LibreELEC:/ $ dmesg -c
[  562.109408] meson8b-dwmac c9410000.ethernet eth0: PHY [0.2009087f:00] driver [RTL8211F Gigabit Ethernet]
[  562.109498] meson8b-dwmac c9410000.ethernet eth0: phy: setting supported 00,00000000,000062ff advertising 00,00000000,000062ff
[  562.224926] meson8b-dwmac c9410000.ethernet: Failed to reset the dma
[  562.225000] meson8b-dwmac c9410000.ethernet eth0: stmmac_hw_setup: DMA engine initialization failed
[  562.225053] meson8b-dwmac c9410000.ethernet eth0: stmmac_open: Hw setup failed

LibreELEC:/ # ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
ping: sendto: Network is unreachable

### well-done

similar here when going from mainline 5.3.1 to mainline 5.4.0
following appears on VIM2 serial console during boot for 5.4.0
(I run gentoo)

meson8b-dwmac c9410000.ethernet: Failed to reset the dma
meson8b-dwmac c9410000.ethernet eth0: stmmac_hw_setup: DMA engine initialization failed
meson8b-dwmac c9410000.ethernet eth0: stmmac_open: Hw setup failed

in .config I notice CONFIG_ARCH_HAS_DMA_MMAP_PGPROT disappeared from mainline 5.3.1 to mainline 5.4.0 and CONFIG_DMABUF_SELFTESTS appeared.

@hyphop : did you find a solution?

tnx for remind! i just forget publish it

this patch for any kernel 5.3.x or 5.4.x

just rebuild dtb

PS: u was a first who ask about this :wink:

1 Like

I don’t see this error on my current 5.4.x branch, but then I have backports from 5.5 added to the base upstream branch which may be the reason. Here’s my dmesg:

VIM2:~ # dmesg | grep dwmac
[    0.131651] meson8b-dwmac c9410000.ethernet: IRQ eth_wake_irq not found
[    0.132682] meson8b-dwmac c9410000.ethernet: IRQ eth_lpi not found
[    0.138856] meson8b-dwmac c9410000.ethernet: PTP uses main clock
[    0.138863] meson8b-dwmac c9410000.ethernet: no reset control found
[    0.139337] meson8b-dwmac c9410000.ethernet: User ID: 0x11, Synopsys ID: 0x37
[    0.139346] meson8b-dwmac c9410000.ethernet: 	DWMAC1000
[    0.139351] meson8b-dwmac c9410000.ethernet: DMA HW capability register supported
[    0.139355] meson8b-dwmac c9410000.ethernet: RX Checksum Offload Engine supported
[    0.139359] meson8b-dwmac c9410000.ethernet: COE Type 2
[    0.139362] meson8b-dwmac c9410000.ethernet: TX Checksum insertion supported
[    0.139366] meson8b-dwmac c9410000.ethernet: Wake-Up On Lan supported
[    0.139392] meson8b-dwmac c9410000.ethernet: Normal descriptors
[    0.139396] meson8b-dwmac c9410000.ethernet: Ring mode enabled
[    0.139400] meson8b-dwmac c9410000.ethernet: Enable RX Mitigation via HW Watchdog Timer
[    0.139406] meson8b-dwmac c9410000.ethernet: device MAC address 92:c7:b4:58:da:ba
[    5.644383] meson8b-dwmac c9410000.ethernet eth0: PHY [0.2009087f:00] driver [RTL8211F Gigabit Ethernet]
[    5.671721] meson8b-dwmac c9410000.ethernet eth0: No Safety Features support found
[    5.671748] meson8b-dwmac c9410000.ethernet eth0: PTP not supported by HW
[    5.671757] meson8b-dwmac c9410000.ethernet eth0: configuring for phy/rgmii link mode
[    9.284217] meson8b-dwmac c9410000.ethernet eth0: Link is Up - 1Gbps/Full - flow control off

Current WIP branch is here: https://github.com/chewitt/linux/commits/amlogic-5.4-integ and defconfig is here: https://github.com/chewitt/LibreELEC.tv/blob/amlogic-master/projects/Amlogic/linux/linux.aarch64.conf

plz run ifconfig eth0 down ; ifconfig eth0 up before show dmesg

Ahh, okay. Now I see the same error. Has this been reported to any mailing lists? … if not, why not?

yes ! sure reported! but i have found solution only 2-3 weeks ago!

everybody was noticed about this problem! @narmstrong , @chewitt , @numbqq
but nobody check it :wink: 3 month already ! :wink:

if u can push this patch for mainline plz do it
tnx for response

If you feel that patch is the solution you should submit it to the linux-amlogic mailing list so that it can be reviewed and, if accepted, included in the kernel (maybe even backported as a fix). Sending small patches like this upstream is not hard (I’m proof that even non-coding ‘developers’ can do it) and all developers on the Khadas staff need to learn the habit. Upstream contribution is good for the Khadas brand and reputation. Expecting others to do your work for you is not so positive.

3 Likes

thanks, I will try this evening and report result here.

@hyphop
Congratulations (and thanks again): your patch works
(for gentoo network scripts in my case).
I wonder though why mainline broke this in between 5.3 and 5.4
Is this a kernel regression or a day-1 dtb issue? And, is it vim2 specific?
Clearly some (different) eth related DMA code in between 5.3 and 5.4 gets (not) called.
I have a s905 minimx-g which has similar dtb section and will check if your patch is needed there as well.

DTS in mainline kernel - have many wrong or missed parts for VIM2 VIM3 VIM3L devices - we will try to push fixes to mainline

2 Likes

^ that’s the best words I heard from Khadas in some time :slight_smile:

@chewitt looks like u very kind man :wink:

u must understand mainline is mainline - sometimes difficult to control changes!

@chewitt i ready to bet your codes same have some bugs error and problems

1 Like

@hyphop

FYI: s905 minimx-g meson-gxbb-p200 needs your patch too

So I kind of wonder if some change in kernel affects all amlogic and/or if some gentoo specific aspects happen to help reveal something related.

Personally I feel kernel should not have broken working ethernet from 5.3 to 5.4

Have a nice day