Re: JH7110 dwc MAC support

From: John F Carr <jfc_at_mit.edu>
Date: Mon, 17 Jun 2024 20:10:52 UTC

> On Jun 14, 2024, at 16:00, JMT Sihvola <jsihv@gmx.com> wrote:
> 
> John F Carr wrote:
>> Thanks.  I tried putting your driver on the main (15-CURRENT) branch.
>> It attaches but does not seem to put anything on the wire.
>> I will try building your 14-based branch next.
> 
> I use it with 15 branch myself. That github of mine is probably not in
> a coherent state. I recommend not using it for anything except
> for grabbing these network related files.
> 
>> Is it correct to see a total of four PHYs in the dmesg output below?
> 
> Yes, it is seen like that also on vendor's OS.
> 
> Probably some sort of error message should appear somewhere during
> the boot if it's not working.
> 
> One of the several things needed is the code for syscon pseudo device
> (starfive_syscon.c) that is used for the device memory access.
> It's already added to the mainline repository.
> 
> It may be challenging to get it working at this stage since things
> needed are a bit scattered now, but network codes will hopefully
> be added to CURRENT after a little while.
> 
> -jari s.

All is forgiven.  Almost all.  The main problem was the failure of the kernel to
set up network configuration to mount / over NFS.  With root on a memory
disk (load -t md_image) I can use ifconfig to set up the interface.
It at least passes a smoke test, reading files over NFS.

However, the driver has offended WITNESS by trying to hold "eqos lock"
and "Clock topology lock" at the same time.

# ifconfig
eqos0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=80008<VLAN_MTU,LINKSTATE>
	ether f2:00:73:a0:80:56
	media: Ethernet autoselect (none)
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
[...]
# ifconfig eqos0 192.168.5.2/30
eqos0: link state changed to DOWN
# lock order reversal: (sleepable after non-sleepable)
 1st 0xffffffc085227070 eqos lock (network driver, sleep mutex) @ /usr/home/15/src/sys/kern/kern_mutex.c:209
 2nd 0xffffffc000895940 Clock topology lock (Clock topology lock, sx) @ /usr/home/15/src/sys/dev/clk/clk.c:1208
lock order network driver -> Clock topology lock attempted at:
#0 0xffffffc0003730f6 at witness_checkorder+0x99e
#1 0xffffffc00031715e at _sx_xlock+0x58
#2 0xffffffc0000edd04 at clk_set_freq+0x44
#3 0xffffffc0005dfcd6 at if_eqos_starfive_set_speed+0x78
#4 0xffffffc0005b7018 at eqos_miibus_statchg+0x13e
#5 0xffffffc00010ff72 at miibus_statchg+0x50
#6 0xffffffc000110c86 at mii_phy_update+0x60
#7 0xffffffc00010e850 at mcommphy_service+0x20a
#8 0xffffffc00010f8ea at mii_tick+0x32
#9 0xffffffc0005b860c at eqos_tick+0x68
#10 0xffffffc000328948 at softclock_call_cc+0x106
#11 0xffffffc000329d8a at softclock_thread+0xaa
#12 0xffffffc0002cba34 at fork_exit+0x68
#13 0xffffffc0005d8eca at fork_trampoline+0xa
eqos0: link state changed to UP

[...]

# ifconfig eqos0
eqos0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500
options=80008<VLAN_MTU,LINKSTATE>
ether f2:00:73:a0:80:56
inet 192.168.5.2 netmask 0xfffffffc broadcast 192.168.5.3
media: Ethernet autoselect (1000baseT <full-duplex,master>)
status: active
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>