Created attachment 301750 [details] iwlwifi kernel log, options debug=1, card preparation failed after cold boot This issue exists at least since 2013-05-22 12:32, as has been reported downstream by a RedHat user: https://bugzilla.redhat.com/show_bug.cgi?id=966080. I have replicated it for the last 3-4 years on a Dell Latitude 7480, using many kernel versions, 4.x and 5.x. The problem is consistent across distribution and kernel flavors. Configuring the Intel AMT out-of-band management platform to use WiFi seems sufficient to cause a race-condition for the control of the PCIe WiFi network card, causing the WiFi card to not be initialized at boot. The problems occurs randomly (approximately 8 times over 10) when starting the computer from cold power-off or resuming for suspension. It only occurs if the computer has been suspended/powered-off for a sufficient amount of time (>15-20 seconds), probably the time needed for the Intel AMT system to rise its network stack and take control of the WiFi card. To get the card recognized and working again it's necessary to unload and reload the `iwlwifi` module several times. The part of the module `iwlwifi` involved seems to reside in the file `linux/drivers/net/wireless/intel/iwlwifi/pcie/trans.c`. In particular the functions `iwl_pcie_prepare_card_hw` and `iwl_pcie_set_hw_ready` are the ones called when the attempts to prepare the card fail. Apparently an attempt to fix this issue (or a similar one) has been made in commit https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=501fd9895c1d7d8161ed56698ae2fccb10ef14f5 (iwlwifi: pcie: try to get ownership several times, 2014-05-11, Reviewed-by: Johannes Berg <johannes.berg@intel.com>, Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>).
Created attachment 301751 [details] iwlwifi kernel log, options debug=1, card preparation succeded after module reload
Hi, can you try this: diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c index ce62929c36..e4868aa2f9 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c @@ -603,7 +603,6 @@ static int iwl_pcie_set_hw_ready(struct iwl_trans *trans) int iwl_pcie_prepare_card_hw(struct iwl_trans *trans) { int ret; - int t = 0; int iter; IWL_DEBUG_INFO(trans, "iwl_trans_prepare_card_hw enter\n"); @@ -620,6 +619,8 @@ int iwl_pcie_prepare_card_hw(struct iwl_trans *trans) usleep_range(1000, 2000); for (iter = 0; iter < 10; iter++) { + int t = 0; + /* If HW is not ready, prepare the conditions to check again */ iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_PREPARE);
Hi Emmanuel, I am currently using v5.15.60 and the patch seems indeed to make things better. I will need some more time to test extensively. In my first cold boot after patching the device got ready (automatically) in 12 seconds after the first attempt, at the iteration 7 over 10 (I modified the patch to print the iteration number in the debug kernel messages).
Created attachment 301758 [details] iwlwifi kernel log, options debug=1, proposed patch applied, card preparation succeded after reboot
After days of routinely using my laptop with the patched module, I can confirm that the proposed patch works and is stable. I monitored the iterations used at each start, and they reached a maximum of 8 (over 10 maximum allowed). Thanks to Emmanuel Grumbach for the rapid solution!
Great. Patch will be upstreamed throught the usual process. It may take time since we have a big backlog.