mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] wifi: iwlwifi: keep Wi-Fi when Intel AMT powers the host on
@ 2026-11-16 16:40 Andrei Rusu de Castro
  2026-11-16 16:41 ` [PATCH 1/2] wifi: iwlwifi: pcie: use the CSME path when the NIC cannot be woken at probe Andrei Rusu de Castro
  2026-11-16 16:41 ` [PATCH 2/2] wifi: iwlwifi: mvm: take the NVM from CSME when it takes the device back Andrei Rusu de Castro
  0 siblings, 2 replies; 3+ messages in thread
From: Andrei Rusu de Castro @ 2026-11-16 16:40 UTC (permalink / raw)
  To: Miri Korenblit
  Cc: Johannes Berg, Emmanuel Grumbach, Luca Coelho, Kalle Valo,
	Ayala Beker, linux-wireless, linux-kernel

With IWLMEI enabled and AMT's wireless enabled, the host can come up
without Wi-Fi after AMT powers it on: CSME is still handing the NIC back
to the host while iwlwifi probes. On an HP ZBook Firefly 14 G10 (AX211,
CSME 16.1) this happened in two ways:

 - the NIC cannot be woken at probe while CSME still drives it, and the
   probe fails with -110 for good (patch 1);
 - ownership moves back to CSME between the end of the probe and the
   op mode's start, which then fails with -EBUSY (patch 2).

In both cases the SAP connection to CSME is up, so the host can take the
NVM from CSME and request the NIC over SAP, as it does when CSME visibly
owns the NIC at probe.

The series applies to iwlwifi-next. IWLMEI depends on BROKEN; it builds
with CONFIG_WERROR only together with [1], and binds only with [2]:

[1] https://lore.kernel.org/r/20261116-iwlmei-nvm-const-0c16d1de@empyreal.works
[2] https://lore.kernel.org/r/20261116-mei-cl-dma-parent-60802f47@empyreal.works

Tested with both patches on that machine. The failure in patch 1 hit four
of six AMT power-ons and resets before it; with it, AMT power-ons came back
on Wi-Fi 36-48 s after Power on. The race in patch 2 was seen once in seven
AMT power-ons with patch 1 applied (after about 20 minutes off) and did not
recur in the three power-ons since (after 0 s, 2 and 33 minutes off), so its
fallback has not yet run on hardware.

Andrei Rusu de Castro (2):
  wifi: iwlwifi: pcie: use the CSME path when the NIC cannot be woken at
    probe
  wifi: iwlwifi: mvm: take the NVM from CSME when it takes the device
    back

 drivers/net/wireless/intel/iwlwifi/mvm/ops.c  | 13 ++++++
 .../net/wireless/intel/iwlwifi/pcie/trans.c   | 40 ++++++++++++++++++-
 2 files changed, 51 insertions(+), 2 deletions(-)

-- 
2.55.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] wifi: iwlwifi: pcie: use the CSME path when the NIC cannot be woken at probe
  2026-11-16 16:40 [PATCH 0/2] wifi: iwlwifi: keep Wi-Fi when Intel AMT powers the host on Andrei Rusu de Castro
@ 2026-11-16 16:41 ` Andrei Rusu de Castro
  2026-11-16 16:41 ` [PATCH 2/2] wifi: iwlwifi: mvm: take the NVM from CSME when it takes the device back Andrei Rusu de Castro
  1 sibling, 0 replies; 3+ messages in thread
From: Andrei Rusu de Castro @ 2026-11-16 16:41 UTC (permalink / raw)
  To: Miri Korenblit
  Cc: Johannes Berg, Emmanuel Grumbach, Luca Coelho, Kalle Valo,
	Ayala Beker, linux-wireless, linux-kernel

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 <arc@empyreal.works>
---
 .../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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] wifi: iwlwifi: mvm: take the NVM from CSME when it takes the device back
  2026-11-16 16:40 [PATCH 0/2] wifi: iwlwifi: keep Wi-Fi when Intel AMT powers the host on Andrei Rusu de Castro
  2026-11-16 16:41 ` [PATCH 1/2] wifi: iwlwifi: pcie: use the CSME path when the NIC cannot be woken at probe Andrei Rusu de Castro
@ 2026-11-16 16:41 ` Andrei Rusu de Castro
  1 sibling, 0 replies; 3+ messages in thread
From: Andrei Rusu de Castro @ 2026-11-16 16:41 UTC (permalink / raw)
  To: Miri Korenblit
  Cc: Johannes Berg, Emmanuel Grumbach, Luca Coelho, Kalle Valo,
	Ayala Beker, linux-wireless, linux-kernel

Right after Intel AMT powered the host on, ownership of the device can
still move between CSME and the host. The last iwl_pcie_prepare_card_hw()
of the probe may get the device, clearing csme_own, and CSME take it back
before iwl_mvm_start_get_nvm() starts it. iwl_trans_start_hw() then fails
with -EBUSY after setting csme_own again:

  iwlwifi 0000:00:14.3: SAP not supported for this NIC family
  iwlwifi 0000:00:14.3: Error while preparing HW: -16

and the op mode never comes up, so the host has no Wi-Fi until it is
rebooted. HW_IF_CONFIG read 0x10080000 at probe in that case (IAMT_UP
without ME_OWN).

When starting the device fails with -EBUSY and csme_own is set, take the
NVM from CSME, as when CSME owned the device at probe; the device itself
is then requested over SAP when the interface comes up.

Fixes: 6d19a5eba5cd ("iwlwifi: integrate with iwlmei")
Signed-off-by: Andrei Rusu de Castro <arc@empyreal.works>
---
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
index 183251457361..7818453db4d4 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
@@ -822,9 +822,12 @@ static const struct iwl_fw_runtime_ops iwl_mvm_fwrt_ops = {
 static int iwl_mvm_start_get_nvm(struct iwl_mvm *mvm)
 {
 	struct iwl_trans *trans = mvm->trans;
+	bool tried_csme = false;
 	int ret;
 
+get_nvm_from_csme:
 	if (trans->csme_own) {
+		tried_csme = true;
 		if (WARN(!mvm->mei_registered,
 			 "csme is owner, but we aren't registered to iwlmei\n"))
 			goto get_nvm_from_fw;
@@ -859,6 +862,16 @@ static int iwl_mvm_start_get_nvm(struct iwl_mvm *mvm)
 		mutex_unlock(&mvm->mutex);
 		wiphy_unlock(mvm->hw->wiphy);
 		rtnl_unlock();
+		/*
+		 * Right after CSME (Intel AMT) powered the host on, ownership
+		 * can still move between CSME and the host: the probe's last
+		 * check may get the device and CSME take it back before we
+		 * start it. Then the device is busy and csme_own is set again,
+		 * so take the NVM from CSME, as when CSME owned it at probe,
+		 * and get the device over SAP when the interface comes up.
+		 */
+		if (ret == -EBUSY && trans->csme_own && !tried_csme)
+			goto get_nvm_from_csme;
 		return ret;
 	}
 
-- 
2.55.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-16 16:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 16:40 [PATCH 0/2] wifi: iwlwifi: keep Wi-Fi when Intel AMT powers the host on Andrei Rusu de Castro
2026-11-16 16:41 ` [PATCH 1/2] wifi: iwlwifi: pcie: use the CSME path when the NIC cannot be woken at probe Andrei Rusu de Castro
2026-11-16 16:41 ` [PATCH 2/2] wifi: iwlwifi: mvm: take the NVM from CSME when it takes the device back Andrei Rusu de Castro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®