iwlwifi has been crashing a lot on me recently and it is driving me crazy because the only way to fix it is rebooting. The errors indicate that crash happens while NIC is waking up. I am currently using 5.4 kernel and i will see if updating the new version fixes it. At this point, I managed to produce the crash and test a workaround without rebooting.

The problem Link to heading

Starting with dmesg errors

[58632.320679] iwlwifi 0000:03:00.0: Failed to wake NIC for hcmd
[58632.320871] iwlwifi 0000:03:00.0: Error sending STATISTICS_CMD: enqueue_hcmd failed: -5
...
...
[58644.928522] ------------[ cut here ]------------
[58644.928537] Timeout waiting for hardware access (CSR_GP_CNTRL 0xffffffff)

The first error from iwl_finish_nic_init suggests it is happening while the card is coming out of sleep(suspend or whatever).

444 int iwl_finish_nic_init(struct iwl_trans *trans)
445 {
446     const struct iwl_cfg_trans_params *cfg_trans = trans->trans_cfg;
447     u32 poll_ready;
448     int err;

The error Timeout waiting for hardware access (CSR_GP_CNTRL 0xffffffff) suggests that hardware is not accessible anymore.

Based on this, I thought to try reseting the device and it worked like a charm.

echo "1" > /sys/bus/pci/devices/0000:03:00.0/reset

The workaround Link to heading

The workaround is removing the device and force pci scan. This way, the kernel will reset and probe the device again and iwlwifi will pick it up again.

sudo echo "1" > /sys/bus/pci/devices/0000:03:00.0/remove
sudo echo "1" > /sys/bus/pci/rescan

Looking at dmesg, the device is detected again and all is good.

[ 1880.826363] iwlwifi 0000:03:00.0: loaded firmware version 29.1654887522.0 op_mode iwlmvm
[ 1880.826473] iwlwifi 0000:03:00.0: Detected Intel(R) Dual Band Wireless AC 3165, REV=0x210

I think I will write a script in systemd service that detects the crash and remove/probe the device and fixes it.

Well, That was fun!