When Intel AMT powers the host on shortly after a shutdown, CSME can still be driving the NIC while it hands it back to the host. The host's NIC_READY semaphore is free then, so iwl_pcie_prepare_card_hw() succeeds, but the MAC clock does not come up within the 25 ms that iwl_pcie_activate_nic() polls, and the probe fails for good: iwlwifi 0000:00:14.3: CSR_RESET = 0x11 iwlwifi 0000:00:14.3: probe with driver iwlwifi failed with error -110 CSME then keeps the device, and the following boots fail the same way until AMT's wireless is switched off and on again. At that point HW_IF_CONFIG reads 0x02080000 (ME_OWN and IAMT_UP set). If the SAP connection to CSME is up, or comes up within 5 seconds, continue as when CSME visibly owns the device at probe: drop the init-done request, set csme_own and let the op mode take the NVM from CSME and request the device over SAP before using it. Tested on an HP ZBook Firefly 14 G10 (AX211, CSME 16.1) with AMT's wireless enabled: without this change four of six AMT power-ons and resets left the host without Wi-Fi; with it, power-ons pressed as soon as AMT reported the host off came back on Wi-Fi 36-48 s later. Fixes: 2fd8aaaeb874 ("iwlwifi: pcie: try to grab NIC access early") Signed-off-by: Andrei Rusu de Castro --- .../net/wireless/intel/iwlwifi/pcie/trans.c | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c index 0f4e309fe32b..e95b52332cea 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c @@ -4182,6 +4182,40 @@ static void iwl_pcie_check_me_status(struct iwl_trans *trans) schedule_delayed_work(&trans_pcie->me_recheck_wk, HZ); } +/* + * CSME (Intel AMT) can still be driving the NIC while it hands the device + * over to the host, for example right after the host was powered on through + * AMT: the host gets the hardware semaphore, but the MAC does not wake. If + * the SAP connection to CSME is up, or comes up shortly, continue as when + * CSME visibly owns the device: the op mode gets the NVM from CSME and asks + * it for the device over SAP before using it. + */ +static bool iwl_pcie_csme_drives_nic(struct iwl_trans *trans) +{ + int t; + + for (t = 0; !iwl_mei_is_connected() && t < 5000; t += 100) + msleep(100); + + if (!iwl_mei_is_connected()) + return false; + + IWL_INFO(trans, + "Couldn't wake the NIC but SAP is connected, CSME owns it (HW_IF_CONFIG 0x%08x)\n", + iwl_trans_pcie_read32(trans, CSR_HW_IF_CONFIG_REG)); + + if (trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_BZ) + iwl_trans_clear_bit(trans, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_BZ_MAC_ACCESS_REQ | + CSR_GP_CNTRL_REG_FLAG_MAC_INIT); + else + iwl_trans_clear_bit(trans, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_INIT_DONE); + + trans->csme_own = true; + return true; +} + int _iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent, const struct iwl_mac_cfg *mac_cfg, u8 __iomem *hw_base, u32 hw_rev) @@ -4218,9 +4252,11 @@ int _iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent, ret = iwl_pcie_prepare_card_hw(iwl_trans); if (!ret) { ret = iwl_trans_activate_nic(iwl_trans); - if (ret) + if (ret && iwl_pcie_csme_drives_nic(iwl_trans)) { + ret = 0; + } else if (ret) { goto out_free_trans; - if (iwl_trans_grab_nic_access(iwl_trans)) { + } else if (iwl_trans_grab_nic_access(iwl_trans)) { get_crf_id(iwl_trans, &info, &hw_wfpm_id); /* all good */ iwl_trans_release_nic_access(iwl_trans); -- 2.55.0