Low speed of wifi interface


I’ve found that wifi connection on my board is too slow.
I’ve measured it with iperf: 11.6 Mbits/sec
At the same time, test from Andorid phone and Windows machine connected to the same network shows ~90Mbits/sec.

Can it be fixed?
BTW, my router is configured to a “Mixed n/ac” mode for 5G band. If I turn it to “ac only” mode, the board cannot attach to it.

$ /sbin/iwconfig wlan0
wlan0     IEEE 802.11  ESSID:"xxxxxx"  
          Mode:Managed  Frequency:5.18 GHz  Access Point: 50:C7:BF:8C:18:C8   
          Bit Rate=150 Mb/s   Tx-Power=20 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
          Link Quality=63/70  Signal level=-47 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:1  Invalid misc:1   Missed beacon:0

Can anyone using Android on this board test wifi perfomance (preferably with iperf, but simple download speed over wifi network or another speed test could help)?

Perhaps the low speed is caused by the SDIO/MMC bandwidth.
Here is the output for the mmc1 where wl1837 is connected:

$ sudo cat /sys/kernel/debug/mmc1/ios
clock:		25000000 Hz
actual clock:	25000000 Hz
vdd:		7 (1.65 - 1.95 V)
bus mode:	2 (push-pull)
chip select:	0 (don't care)
power mode:	2 (on)
bus width:	0 (1 bits)
timing spec:	0 (legacy)
signal voltage:	0 (3.30 V)
driver type:	0 (driver type B)

I’ve found that the mmc host caps (/sys/kernel/debug/mmc1/caps) does not declare bus width, but the wl1837 chips seems supports 4 bits.
So, I would try to add bus-width = <0x4>; to the device tree (arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts).
The only question is how to patch, build and test this kernel (or dtb).

Continuing 4.19.5 kernel based Debian snapshot image release for HiKey960 here.
So far I’ve found that 4-bit mode typically hung on while uploading firmware to the wlan chip.
I have docker ethernet interface, wlan interface, bonding driver. NetworkManager is trying to initialize some interfaces on boot. Wlan interface is attempted first (based on its MAC), it is successfully inited (including downloading firmware). Then, wlan interface going down and wl18xx is de-inited. Soon after that another interface is inited. I have no idea what is that interface, its MAC is random. In this case, wlcore driver is trying to download firmware again and stuck. Here is the kernel stack (boot ran till login):
[<0>] __switch_to+0x94/0xd8
[<0>] mmc_wait_for_req_done+0x28/0x168
[<0>] mmc_wait_for_req+0x80/0xf0
[<0>] mmc_io_rw_extended+0x1b0/0x2c0
[<0>] sdio_io_rw_ext_helper+0x180/0x200
[<0>] sdio_memcpy_toio+0x20/0x28
[<0>] wl12xx_sdio_raw_write+0x108/0x1d0 [wlcore_sdio]
[<0>] wlcore_boot_upload_firmware+0x1cc/0x4b8 [wlcore]
[<0>] wl18xx_boot+0x7d4/0xc00 [wl18xx]
[<0>] wl1271_op_add_interface+0x844/0x9c8 [wlcore]
[<0>] drv_add_interface+0x34/0x88 [mac80211]
[<0>] ieee80211_do_open+0x220/0x800 [mac80211]
[<0>] ieee80211_open+0x48/0x60 [mac80211]
[<0>] __dev_open+0xe4/0x168
[<0>] __dev_change_flags+0x154/0x1b0
[<0>] dev_change_flags+0x20/0x60
[<0>] do_setlink+0x30c/0xbc0
[<0>] rtnl_newlink+0x340/0x6c8
[<0>] rtnetlink_rcv_msg+0x138/0x388
[<0>] netlink_rcv_skb+0x5c/0x128
[<0>] rtnetlink_rcv+0x14/0x20
[<0>] netlink_unicast+0x198/0x200
[<0>] netlink_sendmsg+0x2e4/0x360
[<0>] sock_sendmsg+0x18/0x30
[<0>] ___sys_sendmsg+0x28c/0x2c8
[<0>] __sys_sendmsg+0x6c/0xc8
[<0>] __arm64_sys_sendmsg+0x20/0x28
[<0>] el0_svc_common+0x60/0xe8
[<0>] el0_svc_handler+0x2c/0x80
[<0>] el0_svc+0x8/0xc
[<0>] 0xffffffffffffffff
I’ve tried to enable logging in wlcore_boot_upload_firmware (changed debug logs to info) and this seems fixed the issue. So, I assume it is some timing or race condition issue.
BTW, I’ve measured wifi bandwidth with iperf. It is ~3x of original speed (~50Mbps instead of ~17). Perhaps there should be tweaks needed in wl18xx configuration to reach 4x. Or maybe, the sdio clock maybe need to be increased to 50MHz.
I’m not actually sure that the issue is with wlcore/wx18xx drivers, pehaps SDIO driver have some issue. Refer the Console access without USB-TTY or network - boot hangs on if SD card is inserted into a slot. This issue is persist on my board.

If anyone have an idea what can I debug further to get the actual root cause - you’re welcome to comment.

Maybe you could try the android kernel instead: https://android.googlesource.com/kernel/hikey-linaro/+/refs/heads/android-hikey-linaro-4.19

This one seems to have 4-bit SDIO enabled: https://android.googlesource.com/kernel/hikey-linaro/+/refs/heads/android-hikey-linaro-4.19/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts#700