Skip to contentSkip to conversation

wifi: iwlwifi: recover the device after it loses power in D3cold

PATCH In review Navon John Lukose 2 participants 6 messages Aug 29

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover wifi: iwlwifi: recover the device after it loses power in D3cold

On several Meteor Lake laptops the Intel BE200 does not survive a D3cold
transition: the platform's _PR3 power resource genuinely removes the M.2 module's rail, and the card does not restart when the rail and PERST# are restored. Config space reads 0xffffffff, the link never trains, and the device stays gone until a reboot.

iwlwifi already has everything needed to recover it. The platform-level device reset walks _PRR and evaluates _RST, and the vendor _DSM that arms it is already spoken. The problem is ordering: arming happens from the removal path, by which point the device no longer answers, and the _DSM is gated on the firmware reading the device's PCI ID back out of config space. So arming can never succeed at the one moment it matters.

Patch 1 arms it at probe, while the device still answers. Patch 2 asks for a product reset when the device is not on the bus after resume, instead of re-initialising hardware that is not there.

Analysis, register dumps and the discussion this came out of:

Tested on a Lenovo Yoga Pro 7 14IAH10 (BIOS QGCN35WW), BE200
SUBSYS_00F48086: the card dies in D3cold on every s2idle exactly as before, and recovers on its own in about 5s, repeatedly, with wifi both connected and idle at suspend time. With the reset skipped but everything else identical it stays absent, so the reset is what recovers it rather than the remove/rescan.

Caveats: one machine and one BIOS, discrete (!integrated) path only - I have no CNVi hardware, so the integrated arming mask is untested. Recovery costs ~4.3s of Sleep() inside the platform's _RST, which is firmware and not something we can shorten.

Tagged for stable: the PLDR path has never worked on platforms with this _DSM gate, and both changes are small and self-limiting - every _RST evaluation is already preceded by set_product_reset() setting the mode that reset wants, so arming at probe cannot alter the behaviour of any later reset.

Navon John Lukose (2):
wifi: iwlwifi: pcie: arm the product reset at probe
wifi: iwlwifi: pcie: request a product reset when the device is gone
after resume

 drivers/net/wireless/intel/iwlwifi/pcie/drv.c          | 12 ++++++++++++
 drivers/net/wireless/intel/iwlwifi/pcie/gen1_2/trans.c |  5 +++++
 2 files changed, 17 insertions(+)
#1 lore raw

PATCH 1/2 wifi: iwlwifi: pcie: arm the product reset at probe

The driver already implements the platform-level device reset (PLDR):
iwl_trans_pcie_call_reset() walks _PRR and evaluates _RST, and iwl_trans_pcie_set_product_reset() arms it over the vendor _DSM. But it is armed too late to ever help.

set_product_reset() is only called from iwl_trans_pcie_removal_wk(), i.e. once the device is already being torn down. On these platforms the _DSM dispatch is gated on the firmware reading the device's PCI ID back out of config space:

    Method (WIST) { Switch (ToInteger (VDID)) { Case (0x272B8086) {...} } }

If the device has lost power VDID reads 0xffffffff, WIST() returns 0, the _DSM never reaches the vendor functions and acpi_check_dsm() fails:

scheduling reset (mode=6)
ACPI _DSM not available (-19), cannot do product reset

So the reset stays disarmed, _RST falls back to a plain function-level reset and the device is unrecoverable in exactly the case PLDR exists for. Observed on Intel BE200 (8086:272b) on Meteor Lake laptops, where a D3cold transition removes the M.2 module's power rail and the card does not restart when the rail and PERST# are restored.

Arm it during probe instead, while the device still answers. The mode is sticky in the platform's namespace, so it is still set when the device later disappears. _RST is only evaluated when the driver actually asks for a reset, and a subsequent non-product reset re-runs the existing disarm path as before. On platforms with no such _DSM this is a no-op.

Fixes 9673c35486d4 ("wifi: iwlwifi: implement product reset for TOP errors")

---

drivers/net/wireless/intel/iwlwifi/pcie/gen1_2/trans.c +5 -0
@@ -4252,6 +4252,11 @@
 	iwl_trans_pcie_check_product_reset_status(pdev);
 	iwl_trans_pcie_check_product_reset_mode(pdev);
 
+	/* must be armed while the device still answers: the _DSM is gated on
+	 * reading its PCI ID out of config space
+	 */
+	iwl_trans_pcie_set_product_reset(pdev, true, mac_cfg->integrated);
+
 	/* set the things we know so far for the grab NIC access */
 	iwl_trans_set_info(iwl_trans, &info);
 
#4 lore raw

PATCH 2/2 wifi: iwlwifi: pcie: request a product reset when the device is gone after resume

In reply to Navon John Lukose

On platforms where D3cold removes the WiFi module's power rail, the device can come back from suspend completely absent from the bus: config space reads 0xffffffff and the downstream link never trains. _iwl_pci_resume() currently notices only a subset of this (scratch == ~0U, and only when the device was enabled), then "hopes for the best" by re-initialising over PCI, which cannot work - the hardware is not there. The result is several seconds of handshake timeouts and a bogus ADVANCED_SYSASSERT dump before giving up, and the device stays gone until reboot.

Check whether the device answers config cycles at all, and if not ask for a product reset, which power-cycles the module and re-enumerates it.

The check is deliberately placed before the STATUS_DEVICE_ENABLED block:
that block is skipped entirely when the device was idle or down at suspend time, which is a common case (e.g. the radio was switched off) and one where the device is just as dead.

Fixes 9673c35486d4 ("wifi: iwlwifi: implement product reset for TOP errors")

---

drivers/net/wireless/intel/iwlwifi/pcie/drv.c +12 -0
@@ -1232,6 +1232,18 @@
 	if (!trans->op_mode)
 		return 0;
 
+	/* Not answering config cycles: it fell off the bus and will not come
+	 * back from a PCI-level re-init. Deliberately checked before the
+	 * STATUS_DEVICE_ENABLED block below, which is skipped entirely if the
+	 * device was idle or down when we suspended.
+	 */
+	if (!pci_device_is_present(pdev)) {
+		IWL_ERR(trans,
+			"device is not on the bus after resume, requesting product reset\n");
+		iwl_trans_pcie_reset(trans, IWL_RESET_MODE_PROD_RESET);
+		return 0;
+	}
+
 	if (test_bit(STATUS_DEVICE_ENABLED, &trans->status)) {
 		/*
 		 * Scratch value was altered, this means the device was powered
#5 lore raw

Re: [PATCH wireless 2/2] wifi: iwlwifi: pcie: request a product reset when the device is gone after resume

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 18 lines

On platforms where D3cold removes the WiFi module's power rail, the device can come back from suspend completely absent from the bus: config space reads 0xffffffff and the downstream link never trains. _iwl_pci_resume() currently notices only a subset of this (scratch == ~0U, and only when the device was enabled), then "hopes for the best" by re-initialising over PCI, which cannot work - the hardware is not there. The result is several seconds of handshake timeouts and a bogus ADVANCED_SYSASSERT dump before giving up, and the device stays gone until reboot.

Check whether the device answers config cycles at all, and if not ask for a product reset, which power-cycles the module and re-enumerates it.

The check is deliberately placed before the STATUS_DEVICE_ENABLED block:
that block is skipped entirely when the device was idle or down at suspend time, which is a common case (e.g. the radio was switched off) and one where the device is just as dead.

Quoted 4 lines
Fixes 9673c35486d4 ("wifi: iwlwifi: implement product reset for TOP errors")

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#2 lore raw

Re: [PATCH wireless 1/2] wifi: iwlwifi: pcie: arm the product reset at probe

In reply to Navon John Lukose
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Silent disarm failure unintentionally upgrades a function reset to a product reset, causing an…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Silent disarm failure unintentionally upgrades a function reset to a product reset, causing an unhandled surprise removal of the Bluetooth device and bypassing ME protections.
- [Medium] Unconditional error log emitted during probe on platforms lacking the product reset _DSM.
--

commit 6aff245a17463ae76f40a95a671116d6cd174711
Author: Navon John Lukose <[email protected]>

wifi: iwlwifi: pcie: arm the product reset at probe

This patch arms the platform-level product reset via ACPI _DSM unconditionally during probe instead of device teardown. This is intended to fix recovery failures on laptops where the device loses power and cannot respond to the _DSM when the reset is requested later.

Quoted 5 lines

Arm it during probe instead, while the device still answers. The mode is sticky in the platform's namespace, so it is still set when the device later disappears. _RST is only evaluated when the driver actually asks for a reset, and a subsequent non-product reset re-runs the existing disarm path as before. On platforms with no such _DSM this is a no-op.

[Severity: Medium]
Will this actually be a no-op on platforms without the _DSM?

Looking at iwl_trans_pcie_set_product_reset(), if the _DSM fails and enable is true, it prints an error:

	if (IS_ERR(res)) {
		if (enable)
			IWL_ERR_DEV(&pdev->dev,
				    "ACPI _DSM not available (%d), cannot do product reset\n",
				    (int)PTR_ERR(res));
		return;
	}

Because this is now called unconditionally during probe with enable=true, won't this spam dmesg with an error on every boot for unsupported platforms?

drivers/net/wireless/intel/iwlwifi/pcie/gen1_2/trans.c int iwl_pci_gen1_2_probe(struct pci_dev *pdev, · line 4258

Quoted 12 lines
drivers/net/wireless/intel/iwlwifi/pcie/gen1_2/trans.c +4 -0
index 28b276c659526..a932e068cd0a5 100644
@@ -4252,6 +4252,11 @@ int iwl_pci_gen1_2_probe(struct pci_dev *pdev,
 	iwl_trans_pcie_check_product_reset_status(pdev);
 	iwl_trans_pcie_check_product_reset_mode(pdev);
 
+	/* must be armed while the device still answers: the _DSM is gated on
+	 * reading its PCI ID out of config space
+	 */
+	iwl_trans_pcie_set_product_reset(pdev, true, mac_cfg->integrated);

[Severity: High]
Does arming the sticky reset here unintentionally upgrade future function resets to product resets if the device is lost?

If the device falls off the bus (e.g. D3cold), the driver requests a reset. If Intel ME is present, iwl_trans_pcie_reset() forcibly downgrades a PROD_RESET to a FUNC_RESET.

When iwl_trans_pcie_removal_wk() later tries to disarm the reset:

	iwl_trans_pcie_set_product_reset(pdev,
					 removal->mode ==
						IWL_RESET_MODE_PROD_RESET,
					 removal->integrated);

The _DSM call will fail because the device is inaccessible. iwl_trans_pcie_set_product_reset() ignores this failure silently when enable=false.

Then the worker proceeds to call _RST:

	if (removal->mode >= IWL_RESET_MODE_FUNC_RESET)
		iwl_trans_pcie_call_reset(pdev);

Because the disarm failed, the sticky product reset armed here at probe is still active. Won't this cause the platform to execute an unexpected product reset, skipping the companion Bluetooth device teardown and bypassing ME protections?

Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/pcie/gen1_2/trans.c +1 -0
+
 	/* set the things we know so far for the grab NIC access */
 	iwl_trans_set_info(iwl_trans, &info);
 
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw

Re: [PATCH wireless 1/2] wifi: iwlwifi: pcie: arm the product reset at probe

Both findings are correct. Please drop this series; a v2 is coming.

On the first: arming at probe does leave the mode selected for the lifetime of the driver, and the disarm in iwl_trans_pcie_removal_wk() cannot be relied on to undo it, because it fails in exactly the case that matters - the DSM is gated on the platform reading the device's PCI ID out of config space, so it is unavailable once the device is off the bus, and set_product_reset() ignores that failure when disarming. _RST is not gated the same way: it reads the mode variable directly, so a stale selection does execute a full product reset, Bluetooth off/on included, with no BT teardown and with the ME downgrade bypassed.

I also need to retract something. The cover letter argued for stable on the grounds that "every _RST evaluation is already preceded by set_product_reset() setting the mode that reset wants, so arming at probe cannot alter the behaviour of any later reset". That is wrong. It holds only when the disarm succeeds, and the disarm cannot succeed on a device that is gone. The backport rationale as written does not stand.

On the second: yes, it logs IWL_ERR on every probe on any platform without this DSM, and the commit message's claim that it is a no-op there is wrong. The two neighbouring functions, iwl_trans_pcie_check_product_reset_mode() and _status(), already return silently in the same situation, so the asymmetry looks unintended - and it is what hid the failed disarm above.

v2 will instead select the mode from the suspend callback and clear it on resume, so it is only selected across the suspend window; guard the _RST call with pci_device_is_present(), which reads the same config register the platform's own gate does; and demote the log.

Unrelated, but found while checking this: iwl_pcie_recheck_me_status() reads CSR_HW_IF_CONFIG_REG without a liveness check, so on a device that is off the bus it sees 0xffffffff, concludes IAMT_UP is set, and marks ME present on a machine that has none - which then downgrades every later product reset. I will send that separately.

Patch 2/2 is substantively unchanged in v2.

Thanks for the review.

Navon