orangepi-xunlong / linux-orangepi

Other
200 stars 174 forks source link

uwe5622-unisocwifi: wait_for_completion() causes bugos system load #57

Open magicnat opened 11 months ago

magicnat commented 11 months ago

wait_for_completion puts the calling thread in the "uninterruptible sleep" state, making the kernel count the CPU utilization as 100%, leading to the bugos 1.0 system load.

Other reports of the same issue:

a quick dirty fix is to make the above wait interruptible by changing the tx_down implementation:

/* seam for tx_thread */
void tx_down(struct sprdwl_tx_msg *tx_msg)
{
    int ret;
    while (1) {
        ret = wait_for_completion_interruptible(&tx_msg->tx_completed);
        if (ret == -ERESTARTSYS) {
            continue;
        }

        return;
    }
}

this makes the thread "sleeps" properly when it waits:

% ps auxw | egrep '[S]PRDWL_TX_QUEUE'
root         375  0.0  0.0      0     0 ?        S<   08:27   0:00 [SPRDWL_TX_QUEUE]
% uptime
 09:16:34 up 49 min,  2 users,  load average: 0.00, 0.00, 0.00

~this also fix the spam of protocol 0000 is buggy, dev wlan0 message for me (similar report here and here). my suspection is that wait_for_completion somehow returned without the semaphore actually being completed, causing some bogus behavior down the line.~

the buggy protocol issue is more intermittent than I thought. the message reappeared after two hours of use. should be different issue.

rohoog commented 9 months ago

I had the same issue on 6.1.31 with opi zero 2w and was also experiencing wifi stability issues, sometimes freezing the whole system. I applied your patch and now the system load is normal, the system 'feels' more responsive when accessing through ssh from wifi and I haven't seen a lockup anymore.

rohoog commented 9 months ago

Although it seems a lot more stable, I still get errors on the wifi after a while. Dmesg contains:

[169232.347916] unisoc_wifi unisoc_wifi wlan0: sprdwl_report_connection sm_state (5), status: (2)!
[169232.347971] unisoc_wifi unisoc_wifi wlan0: sprdwl_report_connection SX551D9FAAA failed status code:1!
[169238.493047] sprdwl:sprdwl_fc_add_share_credit, 541, mode:1 closed, index:0, share it
jscxm commented 2 months ago

Although it seems a lot more stable, I still get errors on the wifi after a while. Dmesg contains:

[169232.347916] unisoc_wifi unisoc_wifi wlan0: sprdwl_report_connection sm_state (5), status: (2)!
[169232.347971] unisoc_wifi unisoc_wifi wlan0: sprdwl_report_connection SX551D9FAAA failed status code:1!
[169238.493047] sprdwl:sprdwl_fc_add_share_credit, 541, mode:1 closed, index:0, share it

Can you reconnect the wifi after disconnecting?

rohoog commented 2 months ago

No, the whole wifi device is inoperational in networkmanager. The only way to get it working again (apart from hard rebooting) is to hook a serial port, log in, unload the kernel modules and reload them and kicking networkmanager to re-enumerate the wifi adapters. I am considering to create a cron job that checks regularly if the wifi is still operational and if it isn't, do the unloading/reloading automatically. This is very ugly and will still cause a network interruption every now and then.

forose commented 2 months ago

No, the whole wifi device is inoperational in networkmanager. The only way to get it working again (apart from hard rebooting) is to hook a serial port, log in, unload the kernel modules and reload them and kicking networkmanager to re-enumerate the wifi adapters. I am considering to create a cron job that checks regularly if the wifi is still operational and if it isn't, do the unloading/reloading automatically. This is very ugly and will still cause a network interruption every now and then.

I have the save problem can you tell me how to reload

forose commented 2 months ago

No, the whole wifi device is inoperational in networkmanager. The only way to get it working again (apart from hard rebooting) is to hook a serial port, log in, unload the kernel modules and reload them and kicking networkmanager to re-enumerate the wifi adapters. I am considering to create a cron job that checks regularly if the wifi is still operational and if it isn't, do the unloading/reloading automatically. This is very ugly and will still cause a network interruption every now and then.

yes! thank you