Skip to contentSkip to conversation

PCI: Add D3cold reset quirk for devices with broken/missing FLR

PATCH In review Jose Ignacio Tornos Martinez 3 participants 4 messages May 7 – May 8 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: Add D3cold reset quirk for devices with broken/missing FLR

Some PCIe devices require D3cold power state transitions for proper firmware reset when used in VFIO passthrough scenarios, but lack Function Level Reset (FLR) capability or have incomplete FLR implementations that don't fully reset firmware state.

Known devices affected:
- Qualcomm ath11k WiFi (17cb:1103) - FLReset-, reset unreliable
- Qualcomm ath12k WiFi (17cb:1107) - FLReset-, reset always fails
- Qualcomm SDX62/SDX65 5G modems (17cb:0308) - FLReset-, never initialize in VMs
- MediaTek mt7925e WiFi (14c3:7925) - FLReset+ but broken, reset always fails

The problem manifests in two scenarios:

1. WiFi devices (ath11k, ath12k, mt7925e): Normal VM operation works fine, including clean shutdown/reboot. However, when the VM terminates uncleanly (crash, force-off), VFIO attempts to reset the device before it can be assigned to another VM. Because FLR is missing or broken, the reset fails and the device remains in an undefined state, preventing reuse.

2. Modem devices (SDX62/SDX65): Never successfully initialize even on first VM assignment due to lack of proper reset capability.

Add reset_device_d3cold() quirk that performs a simple D3cold->D0 power cycle when the device is bound to vfio-pci. This provides firmware reset capability for VM reset operations where standard PCI reset methods are insufficient.

The quirk only applies during VFIO passthrough - native drivers use their own reset mechanisms and will fall back to standard PCI reset methods by returning -ENOTTY.

---
 drivers/pci/quirks.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
drivers/pci/quirks.c +38 -0
index caaed1a01dc0..11d9a8b562e4 100644
@@ -4237,6 +4237,40 @@ static int reset_hinic_vf_dev(struct pci_dev *pdev, bool probe)
 	return 0;
 }
 
+/*
+ * Some devices need D3cold->D0 power cycle for proper firmware reset
+ * when used in VFIO passthrough. Some claim FLReset+ but it's incomplete,
+ * others lack FLR entirely, and standard reset methods don't fully reset
+ * firmware state. On bare metal with native drivers, we skip this and let
+ * the driver handle reset via standard methods.
+ */
+static int reset_device_d3cold(struct pci_dev *dev, bool probe)
+{
+	int ret;
+
+	if (probe)
+		return 0;
+
+	if (!dev->driver || strcmp(dev->driver->name, "vfio-pci") != 0)
+		return -ENOTTY;
+
+	/*
+	 * D3cold->D0 power cycle for firmware reset.
+	 * VFIO has already disabled interrupts and will handle state
+	 * save/restore, so we just do the power transition.
+	 */
+	ret = pci_set_power_state(dev, PCI_D3cold);
+	if (ret && ret != -EIO)
+		pci_warn(dev, "D3cold transition failed: %d\n", ret);
+
+	ret = pci_set_power_state(dev, PCI_D0);
+	if (ret && ret != -EIO)
+		pci_warn(dev, "D0 transition failed: %d\n", ret);
+
+	pci_info(dev, "D3cold reset completed\n");
+	return 0;
+}
+
 static const struct pci_dev_reset_methods pci_dev_reset_methods[] = {
 	{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82599_SFP_VF,
 		 reset_intel_82599_sfp_virtfn },
@@ -4252,6 +4286,10 @@ static const struct pci_dev_reset_methods pci_dev_reset_methods[] = {
 		reset_chelsio_generic_dev },
 	{ PCI_VENDOR_ID_HUAWEI, PCI_DEVICE_ID_HINIC_VF,
 		reset_hinic_vf_dev },
+	{ PCI_VENDOR_ID_QCOM, 0x1103, reset_device_d3cold },     /* Qualcomm ath11k WiFi */
+	{ PCI_VENDOR_ID_QCOM, 0x1107, reset_device_d3cold },     /* Qualcomm ath12k WiFi */
+	{ PCI_VENDOR_ID_QCOM, 0x0308, reset_device_d3cold },     /* Qualcomm SDX62/SDX65 5G modem */
+	{ PCI_VENDOR_ID_MEDIATEK, 0x7925, reset_device_d3cold }, /* MediaTek mt7925e WiFi */
 	{ 0 }
 };
 
Signature · 1 line
2.53.0
#1 lore raw
Quoted 52 lines · On Thu, 7 May 2026 16:29:16 +0200 Jose Ignacio Tornos Martinez…

Some PCIe devices require D3cold power state transitions for proper firmware reset when used in VFIO passthrough scenarios, but lack Function Level Reset (FLR) capability or have incomplete FLR implementations that don't fully reset firmware state.

Known devices affected:
- Qualcomm ath11k WiFi (17cb:1103) - FLReset-, reset unreliable
- Qualcomm ath12k WiFi (17cb:1107) - FLReset-, reset always fails
- Qualcomm SDX62/SDX65 5G modems (17cb:0308) - FLReset-, never initialize in VMs
- MediaTek mt7925e WiFi (14c3:7925) - FLReset+ but broken, reset always fails

The problem manifests in two scenarios:

1. WiFi devices (ath11k, ath12k, mt7925e): Normal VM operation works fine, including clean shutdown/reboot. However, when the VM terminates uncleanly (crash, force-off), VFIO attempts to reset the device before it can be assigned to another VM. Because FLR is missing or broken, the reset fails and the device remains in an undefined state, preventing reuse.

2. Modem devices (SDX62/SDX65): Never successfully initialize even on first VM assignment due to lack of proper reset capability.

Add reset_device_d3cold() quirk that performs a simple D3cold->D0 power cycle when the device is bound to vfio-pci. This provides firmware reset capability for VM reset operations where standard PCI reset methods are insufficient.

The quirk only applies during VFIO passthrough - native drivers use their own reset mechanisms and will fall back to standard PCI reset methods by returning -ENOTTY.

---
 drivers/pci/quirks.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
drivers/pci/quirks.c +5 -0
index caaed1a01dc0..11d9a8b562e4 100644
@@ -4237,6 +4237,40 @@ static int reset_hinic_vf_dev(struct pci_dev *pdev, bool probe)
 	return 0;
 }
 
+/*
+ * Some devices need D3cold->D0 power cycle for proper firmware reset
+ * when used in VFIO passthrough. Some claim FLReset+ but it's incomplete,
+ * others lack FLR entirely, and standard reset methods don't fully reset
+ * firmware state. On bare metal with native drivers, we skip this and let

drivers/pci/quirks.c static int reset_hinic_vf_dev(struct pci_dev *pdev, bool probe) · line 4254

Quoted 10 lines
drivers/pci/quirks.c +10 -0
+ * the driver handle reset via standard methods.
+ */
+static int reset_device_d3cold(struct pci_dev *dev, bool probe)
+{
+	int ret;
+
+	if (probe)
+		return 0;
+
+	if (!dev->driver || strcmp(dev->driver->name, "vfio-pci") != 0)

We should not have driver dependent reset behavior. If FLR is broken, add these devices to the list of devices using quirk_no_flr() and we'll fall back to another reset method. We also shouldn't be implementing a variant of pci_pm_reset(). PM reset can also be prioritized over FLR via the reset_methods sysfs attribute if the reset method really is tied to the usage. Thanks,

Alex

Quoted 33 lines
drivers/pci/quirks.c +23 -0
+		return -ENOTTY;
+
+	/*
+	 * D3cold->D0 power cycle for firmware reset.
+	 * VFIO has already disabled interrupts and will handle state
+	 * save/restore, so we just do the power transition.
+	 */
+	ret = pci_set_power_state(dev, PCI_D3cold);
+	if (ret && ret != -EIO)
+		pci_warn(dev, "D3cold transition failed: %d\n", ret);
+
+	ret = pci_set_power_state(dev, PCI_D0);
+	if (ret && ret != -EIO)
+		pci_warn(dev, "D0 transition failed: %d\n", ret);
+
+	pci_info(dev, "D3cold reset completed\n");
+	return 0;
+}
+
 static const struct pci_dev_reset_methods pci_dev_reset_methods[] = {
 	{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82599_SFP_VF,
 		 reset_intel_82599_sfp_virtfn },
@@ -4252,6 +4286,10 @@ static const struct pci_dev_reset_methods pci_dev_reset_methods[] = {
 		reset_chelsio_generic_dev },
 	{ PCI_VENDOR_ID_HUAWEI, PCI_DEVICE_ID_HINIC_VF,
 		reset_hinic_vf_dev },
+	{ PCI_VENDOR_ID_QCOM, 0x1103, reset_device_d3cold },     /* Qualcomm ath11k WiFi */
+	{ PCI_VENDOR_ID_QCOM, 0x1107, reset_device_d3cold },     /* Qualcomm ath12k WiFi */
+	{ PCI_VENDOR_ID_QCOM, 0x0308, reset_device_d3cold },     /* Qualcomm SDX62/SDX65 5G modem */
+	{ PCI_VENDOR_ID_MEDIATEK, 0x7925, reset_device_d3cold }, /* MediaTek mt7925e WiFi */
 	{ 0 }
 };
 
#2 lore raw

Hello Alex,

Quoted 6 lines

We should not have driver dependent reset behavior. If FLR is broken, add these devices to the list of devices using quirk_no_flr() and we'll fall back to another reset method. We also shouldn't be implementing a variant of pci_pm_reset(). PM reset can also be prioritized over FLR via the reset_methods sysfs attribute if the reset method really is tied to the usage. Thanks,

Thank you for your feedback and help

I tested quirk_no_flr() and it works perfectly for mt7925e. The related mt7922e device was already in that list so this was expected.

However, for the Qualcomm devices, that solution doesn't work and they need a different approach.

So, I will submit two independent patches for v2: one for mt7925e following your suggestion with quirk_no_flr(), and another for Qualcomm devices with a different proposal trying to follow the same idea.

Best regards
José Ignacio

#3 lore raw
In reply to Jose Ignacio Tornos Martinez
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [High] Unconditional success return masks D3cold transition failures and bypasses device reset. - [High]…

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] Unconditional success return masks D3cold transition failures and bypasses device reset.
- [High] Failure to disable broken FLR exposes native drivers to device hangs.
- [Medium] Hardcoding the 'vfio-pci' driver name violates architectural boundaries and breaks with modern VFIO variants.
- [Medium] Inconsistent probe logic causes pci_reset_supported() to falsely advertise reset capability. --

commit 2f9a723d1660924d07061cb5b2d479d4c40e48b5
Author: Jose Ignacio Tornos Martinez <[email protected]>

PCI: Add D3cold reset quirk for devices with broken/missing FLR

This commit adds a D3cold->D0 power cycle reset quirk for several PCIe devices lacking functional FLR when used in VFIO passthrough scenarios. It targets specific Qualcomm and MediaTek devices to ensure they are properly reset between VM assignments.

Quoted 3 lines
drivers/pci/quirks.c +0 -0

[ ... ]

drivers/pci/quirks.c static int reset_hinic_vf_dev(struct pci_dev *pdev, bool probe) · line 4255

Quoted 9 lines
drivers/pci/quirks.c +9 -0
+static int reset_device_d3cold(struct pci_dev *dev, bool probe)
+{
+	int ret;
+
+	if (probe)
+		return 0;
+
+	if (!dev->driver || strcmp(dev->driver->name, "vfio-pci") != 0)
+		return -ENOTTY;

Since the function unconditionally returns 0 when probe is true, but might return -ENOTTY later if the device is not bound to vfio-pci, won't this cause pci_reset_supported() to falsely advertise reset capability to upper layers like sysfs?

Is it safe to rely on a strict string comparison with vfio-pci? Modern VFIO setups often utilize variant drivers such as vfio-pci-core, mlx5_vfio_pci, or nvgrace-gpu-vfio-pci, which would fail this check.

Quoted 6 lines
drivers/pci/quirks.c +6 -0
+	/*
+	 * D3cold->D0 power cycle for firmware reset.
+	 * VFIO has already disabled interrupts and will handle state
+	 * save/restore, so we just do the power transition.
+	 */
+	ret = pci_set_power_state(dev, PCI_D3cold);

drivers/pci/quirks.c static int reset_hinic_vf_dev(struct pci_dev *pdev, bool probe) · line 4272

Quoted 10 lines
drivers/pci/quirks.c +10 -0
+	if (ret && ret != -EIO)
+		pci_warn(dev, "D3cold transition failed: %d\n", ret);
+
+	ret = pci_set_power_state(dev, PCI_D0);
+	if (ret && ret != -EIO)
+		pci_warn(dev, "D0 transition failed: %d\n", ret);
+
+	pci_info(dev, "D3cold reset completed\n");
+	return 0;
+}

Does unconditionally returning 0 here mask transition failures? If pci_set_power_state() fails and the device doesn't actually reach D3cold, VFIO might assign an un-reset device to the next VM.

Should the function verify that the target state was reached and propagate the error instead of proceeding?

Quoted 1 line

static const struct pci_dev_reset_methods pci_dev_reset_methods[] = {

[ ... ]

drivers/pci/quirks.c static const struct pci_dev_reset_methods pci_dev_reset_methods[] = { · line 4294

Quoted 8 lines
drivers/pci/quirks.c +4 -0
 	{ PCI_VENDOR_ID_HUAWEI, PCI_DEVICE_ID_HINIC_VF,
 		reset_hinic_vf_dev },
+	{ PCI_VENDOR_ID_QCOM, 0x1103, reset_device_d3cold },     /* Qualcomm ath11k WiFi */
+	{ PCI_VENDOR_ID_QCOM, 0x1107, reset_device_d3cold },     /* Qualcomm ath12k WiFi */
+	{ PCI_VENDOR_ID_QCOM, 0x0308, reset_device_d3cold },     /* Qualcomm SDX62/SDX65 5G modem */
+	{ PCI_VENDOR_ID_MEDIATEK, 0x7925, reset_device_d3cold }, /* MediaTek mt7925e WiFi */
 	{ 0 }
 };

The commit message notes that devices like the MediaTek mt7925e have an incomplete or broken FLR. Since this patch doesn't set PCI_DEV_FLAGS_NO_FLR_RESET, and reset_device_d3cold() returns -ENOTTY for native drivers, won't the PCI core fall back to using the explicitly broken FLR for native resets?

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