Skip to contentSkip to conversation

PCI: Extend D3hot delay for NVIDIA HDA controllers

RFC PATCH In review Alex Williamson 2 participants 6 messages Mar 28, 2023 – Apr 17, 2023 1 message not in the archive PCI

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 PCI: Extend D3hot delay for NVIDIA HDA controllers

Assignment of NVIDIA Ampere-based GPUs have seen a regression since the below referenced commit, where the reduced D3hot transition delay appears to introduce a small window where a D3hot->D0 transition followed by a bus reset can wedge the device. The entire device is subsequently unavailable, returning -1 on config space read and is unrecoverable without a host reset.

This has been observed with RTX A2000 and A5000 GPU and audio functions assigned to a Windows VM, where shutdown of the VM places the devices in D3hot prior to vfio-pci performing a bus reset when userspace releases the devices. The issue has roughly a 2-3% chance of occurring per shutdown.

Restoring the HDA controller d3hot_delay to the effective value before the below commit has been shown to resolve the issue.

I'm looking for input from NVIDIA whether this issue is unique to Ampere-based HDA controllers or should be assumed to linger in both older and newer controllers as well. Currently we've not been able to reproduce the issue other than on Ampere HDA controllers, however the implementation here includes all NVIDIA HDA controllers based on PCI vendor and device class.

If we were to limit the quirk to Ampere HDA controllers, I think that would include:

1aef GA102 High Definition Audio Controller
228b GA104 High Definition Audio Controller
228e GA106 High Definition Audio Controller

Cc Abhishek Sahu <[email protected]>
Cc Tarun Gupta <[email protected]>
Fixes 3e347969a577 ("PCI/PM: Reduce D3hot delay with usleep_range()")
---
 drivers/pci/quirks.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/pci/quirks.c +13 -0
index 44cab813bf95..f4e2a88729fd 100644
@@ -1939,6 +1939,19 @@ static void quirk_radeon_pm(struct pci_dev *dev)
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x6741, quirk_radeon_pm);
 
+/*
+ * NVIDIA Ampere-based HDA controllers can wedge the whole device if a bus
+ * reset is performed too soon after transition to D0, extend d3hot_delay
+ * to previous effective default for all NVIDIA HDA controllers.
+ */
+static void quirk_nvidia_hda_pm(struct pci_dev *dev)
+{
+	quirk_d3hot_delay(dev, 20);
+}
+DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
+			      PCI_CLASS_MULTIMEDIA_HD_AUDIO, 8,
+			      quirk_nvidia_hda_pm);
+
 /*
  * Ryzen5/7 XHCI controllers fail upon resume from runtime suspend or s2idle.
  * https://bugzilla.kernel.org/show_bug.cgi?id=205587
#1 lore raw

[+cc Sajid, author of 3e347969a577]

Quoted 6 lines · Alex Williamson

Assignment of NVIDIA Ampere-based GPUs have seen a regression since the below referenced commit, where the reduced D3hot transition delay appears to introduce a small window where a D3hot->D0 transition followed by a bus reset can wedge the device. The entire device is subsequently unavailable, returning -1 on config space read and is unrecoverable without a host reset.

Quoted 7 lines

This has been observed with RTX A2000 and A5000 GPU and audio functions assigned to a Windows VM, where shutdown of the VM places the devices in D3hot prior to vfio-pci performing a bus reset when userspace releases the devices. The issue has roughly a 2-3% chance of occurring per shutdown.

Restoring the HDA controller d3hot_delay to the effective value before the below commit has been shown to resolve the issue.

Interesting. This sounds like it was a hassle to track down. I guess we knew there was some risk in reducing those delays.

Did you by chance notice whether the actual delay when the device gets wedged is sufficient per spec?

If there's a case where the usleep_range() doesn't quite wait the spec-mandated time, we should adjust that in case we have the same problem with other devices.

Quoted 49 lines

I'm looking for input from NVIDIA whether this issue is unique to Ampere-based HDA controllers or should be assumed to linger in both older and newer controllers as well. Currently we've not been able to reproduce the issue other than on Ampere HDA controllers, however the implementation here includes all NVIDIA HDA controllers based on PCI vendor and device class.

If we were to limit the quirk to Ampere HDA controllers, I think that would include:

1aef GA102 High Definition Audio Controller
228b GA104 High Definition Audio Controller
228e GA106 High Definition Audio Controller

Cc Abhishek Sahu <[email protected]>
Cc Tarun Gupta <[email protected]>
Fixes 3e347969a577 ("PCI/PM: Reduce D3hot delay with usleep_range()")
---
 drivers/pci/quirks.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/pci/quirks.c +13 -0
index 44cab813bf95..f4e2a88729fd 100644
@@ -1939,6 +1939,19 @@ static void quirk_radeon_pm(struct pci_dev *dev)
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x6741, quirk_radeon_pm);
 
+/*
+ * NVIDIA Ampere-based HDA controllers can wedge the whole device if a bus
+ * reset is performed too soon after transition to D0, extend d3hot_delay
+ * to previous effective default for all NVIDIA HDA controllers.
+ */
+static void quirk_nvidia_hda_pm(struct pci_dev *dev)
+{
+	quirk_d3hot_delay(dev, 20);
+}
+DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
+			      PCI_CLASS_MULTIMEDIA_HD_AUDIO, 8,
+			      quirk_nvidia_hda_pm);
+
 /*
  * Ryzen5/7 XHCI controllers fail upon resume from runtime suspend or s2idle.
  * https://bugzilla.kernel.org/show_bug.cgi?id=205587
#2 lore raw
Quoted 20 lines · On Thu, 6 Apr 2023 16:50:49 -0500 Bjorn Helgaas <[email protected]> wrote:

[+cc Sajid, author of 3e347969a577]

Quoted 6 lines · Alex Williamson

Assignment of NVIDIA Ampere-based GPUs have seen a regression since the below referenced commit, where the reduced D3hot transition delay appears to introduce a small window where a D3hot->D0 transition followed by a bus reset can wedge the device. The entire device is subsequently unavailable, returning -1 on config space read and is unrecoverable without a host reset.

Quoted 7 lines

This has been observed with RTX A2000 and A5000 GPU and audio functions assigned to a Windows VM, where shutdown of the VM places the devices in D3hot prior to vfio-pci performing a bus reset when userspace releases the devices. The issue has roughly a 2-3% chance of occurring per shutdown.

Restoring the HDA controller d3hot_delay to the effective value before the below commit has been shown to resolve the issue.

Interesting. This sounds like it was a hassle to track down. I guess we knew there was some risk in reducing those delays.

Quoted 6 lines

Did you by chance notice whether the actual delay when the device gets wedged is sufficient per spec?

If there's a case where the usleep_range() doesn't quite wait the spec-mandated time, we should adjust that in case we have the same problem with other devices.

That would have been a good test, unfortunately I didn't check and don't currently have access to the system anymore. Perhaps this is something the NVIDIA folks can check as they're investigating the scope of affected hardware. Thanks,

Alex

Quoted 50 lines
Quoted 49 lines

I'm looking for input from NVIDIA whether this issue is unique to Ampere-based HDA controllers or should be assumed to linger in both older and newer controllers as well. Currently we've not been able to reproduce the issue other than on Ampere HDA controllers, however the implementation here includes all NVIDIA HDA controllers based on PCI vendor and device class.

If we were to limit the quirk to Ampere HDA controllers, I think that would include:

1aef GA102 High Definition Audio Controller
228b GA104 High Definition Audio Controller
228e GA106 High Definition Audio Controller

Cc Abhishek Sahu <[email protected]>
Cc Tarun Gupta <[email protected]>
Fixes 3e347969a577 ("PCI/PM: Reduce D3hot delay with usleep_range()")
---
 drivers/pci/quirks.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/pci/quirks.c +13 -0
index 44cab813bf95..f4e2a88729fd 100644
@@ -1939,6 +1939,19 @@ static void quirk_radeon_pm(struct pci_dev *dev)
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x6741, quirk_radeon_pm);
 
+/*
+ * NVIDIA Ampere-based HDA controllers can wedge the whole device if a bus
+ * reset is performed too soon after transition to D0, extend d3hot_delay
+ * to previous effective default for all NVIDIA HDA controllers.
+ */
+static void quirk_nvidia_hda_pm(struct pci_dev *dev)
+{
+	quirk_d3hot_delay(dev, 20);
+}
+DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
+			      PCI_CLASS_MULTIMEDIA_HD_AUDIO, 8,
+			      quirk_nvidia_hda_pm);
+
 /*
  * Ryzen5/7 XHCI controllers fail upon resume from runtime suspend or s2idle.
  * https://bugzilla.kernel.org/show_bug.cgi?id=205587

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 46 lines · On Thu, 13 Apr 2023 00:40:17 +0530 "Tarun Gupta (SW-GPU)"…
Quoted 31 lines · Alex Williamson

External email: Use caution opening links or attachments

Quoted 19 lines · On Thu, 6 Apr 2023 16:50:49 -0500 Bjorn Helgaas<[email protected]> wrote:

[+cc Sajid, author of 3e347969a577]

Quoted 6 lines · Alex Williamson

Assignment of NVIDIA Ampere-based GPUs have seen a regression since the below referenced commit, where the reduced D3hot transition delay appears to introduce a small window where a D3hot->D0 transition followed by a bus reset can wedge the device. The entire device is subsequently unavailable, returning -1 on config space read and is unrecoverable without a host reset.

Quoted 7 lines

This has been observed with RTX A2000 and A5000 GPU and audio functions assigned to a Windows VM, where shutdown of the VM places the devices in D3hot prior to vfio-pci performing a bus reset when userspace releases the devices. The issue has roughly a 2-3% chance of occurring per shutdown.

Restoring the HDA controller d3hot_delay to the effective value before the below commit has been shown to resolve the issue.

Interesting. This sounds like it was a hassle to track down. I guess we knew there was some risk in reducing those delays.

Quoted 6 lines

Did you by chance notice whether the actual delay when the device gets wedged is sufficient per spec?

If there's a case where the usleep_range() doesn't quite wait the spec-mandated time, we should adjust that in case we have the same problem with other devices.

Quoted 13 lines

That would have been a good test, unfortunately I didn't check and don't currently have access to the system anymore. Perhaps this is something the NVIDIA folks can check as they're investigating the scope of affected hardware. Thanks,

Alex

Quoted 6 lines
Quoted 6 lines

I'm looking for input from NVIDIA whether this issue is unique to Ampere-based HDA controllers or should be assumed to linger in both older and newer controllers as well. Currently we've not been able to reproduce the issue other than on Ampere HDA controllers, however the implementation here includes all NVIDIA HDA controllers based on PCI vendor and device class.

Quoted 6 lines

Hi, I believe it is safe to include this patch for all HDA controllers and not limit to only Ampere-based HDA controllers. This patch looks fine to me.

Haven't explicitly tested whether usleep_range() performs as mandated, but from our testing it doesn't seem to be the problem. On the same platform, the problem reproduces on certain GPU configs but doesn't reproduce on other.

Thanks, Tarun. Feel free to also send an explicit Acked-by: or
Reviewed-by: if you'd like.

Bjorn, I can resend this as a non-RFC if you prefer, the only change would be deleting "I'm looking for input..." through to the Cc:s. Thanks,

Alex

Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines

If we were to limit the quirk to Ampere HDA controllers, I think that would include:

1aef        GA102 High Definition Audio Controller
228b        GA104 High Definition Audio Controller
228e        GA106 High Definition Audio Controller
Cc Abhishek Sahu<[email protected]>
Cc Tarun Gupta<[email protected]>
Fixes 3e347969a577 ("PCI/PM: Reduce D3hot delay with usleep_range()")
---
  drivers/pci/quirks.c |   13 +++++++++++++
  1 file changed, 13 insertions(+)
drivers/pci/quirks.c +13 -0
index 44cab813bf95..f4e2a88729fd 100644
@@ -1939,6 +1939,19 @@ static void quirk_radeon_pm(struct pci_dev *dev)
  }
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x6741, quirk_radeon_pm);
 
+/*
+ * NVIDIA Ampere-based HDA controllers can wedge the whole device if a bus
+ * reset is performed too soon after transition to D0, extend d3hot_delay
+ * to previous effective default for all NVIDIA HDA controllers.
+ */
+static void quirk_nvidia_hda_pm(struct pci_dev *dev)
+{
+   quirk_d3hot_delay(dev, 20);
+}
+DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
+                         PCI_CLASS_MULTIMEDIA_HD_AUDIO, 8,
+                         quirk_nvidia_hda_pm);
+
  /*
   * Ryzen5/7 XHCI controllers fail upon resume from runtime suspend or s2idle.
   *https://bugzilla.kernel.org/show_bug.cgi?id=205587
#5 lore raw

PATCH 1/1 PCI: Extend D3hot delay for NVIDIA HDA controllers

In reply to Alex Williamson

Assignment of NVIDIA Ampere-based GPUs have seen a regression since the below referenced commit, where the reduced D3hot transition delay appears to introduce a small window where a D3hot->D0 transition followed by a bus reset can wedge the device. The entire device is subsequently unavailable, returning -1 on config space read and is unrecoverable without a host reset.

This has been observed with RTX A2000 and A5000 GPU and audio functions assigned to a Windows VM, where shutdown of the VM places the devices in D3hot prior to vfio-pci performing a bus reset when userspace releases the devices. The issue has roughly a 2-3% chance of occurring per shutdown.

Restoring the HDA controller d3hot_delay to the effective value before the below commit has been shown to resolve the issue. NVIDIA confirms this change should be safe for all of their HDA controllers.

Cc Abhishek Sahu <[email protected]>
Cc Tarun Gupta <[email protected]>
Fixes 3e347969a577 ("PCI/PM: Reduce D3hot delay with usleep_range()")

---

Unfortunately Tarun's reply with confirmation doesn't show up on lore, possibly due to html email, or else I'd provide that as a Link:.

 drivers/pci/quirks.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/pci/quirks.c +13 -0
index 44cab813bf95..f4e2a88729fd 100644
@@ -1939,6 +1939,19 @@ static void quirk_radeon_pm(struct pci_dev *dev)
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x6741, quirk_radeon_pm);
 
+/*
+ * NVIDIA Ampere-based HDA controllers can wedge the whole device if a bus
+ * reset is performed too soon after transition to D0, extend d3hot_delay
+ * to previous effective default for all NVIDIA HDA controllers.
+ */
+static void quirk_nvidia_hda_pm(struct pci_dev *dev)
+{
+	quirk_d3hot_delay(dev, 20);
+}
+DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
+			      PCI_CLASS_MULTIMEDIA_HD_AUDIO, 8,
+			      quirk_nvidia_hda_pm);
+
 /*
  * Ryzen5/7 XHCI controllers fail upon resume from runtime suspend or s2idle.
  * https://bugzilla.kernel.org/show_bug.cgi?id=205587
Signature · 1 line
2.39.2
#6 lore raw

[+cc Mika, Sathy, Lukas since they've been looking at similar delays]

Quoted 15 lines · Alex Williamson

Assignment of NVIDIA Ampere-based GPUs have seen a regression since the below referenced commit, where the reduced D3hot transition delay appears to introduce a small window where a D3hot->D0 transition followed by a bus reset can wedge the device. The entire device is subsequently unavailable, returning -1 on config space read and is unrecoverable without a host reset.

This has been observed with RTX A2000 and A5000 GPU and audio functions assigned to a Windows VM, where shutdown of the VM places the devices in D3hot prior to vfio-pci performing a bus reset when userspace releases the devices. The issue has roughly a 2-3% chance of occurring per shutdown.

Restoring the HDA controller d3hot_delay to the effective value before the below commit has been shown to resolve the issue. NVIDIA confirms this change should be safe for all of their HDA controllers.

Quoted 6 lines
Cc Abhishek Sahu <[email protected]>
Cc Tarun Gupta <[email protected]>
Fixes 3e347969a577 ("PCI/PM: Reduce D3hot delay with usleep_range()")

Applied to pci/reset for v6.4, thanks, Alex!

I guess there's no real risk here since we're waiting *longer*. It only makes NVIDIA GPU resets take longer.

Mika has some patches in flight that increase delays generically in some cases, but I think that applies to D3cold -> D0 transitions, which I don't *think* you're doing here.

Quoted 35 lines

---

Unfortunately Tarun's reply with confirmation doesn't show up on lore, possibly due to html email, or else I'd provide that as a Link:.

 drivers/pci/quirks.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/pci/quirks.c +13 -0
index 44cab813bf95..f4e2a88729fd 100644
@@ -1939,6 +1939,19 @@ static void quirk_radeon_pm(struct pci_dev *dev)
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x6741, quirk_radeon_pm);
 
+/*
+ * NVIDIA Ampere-based HDA controllers can wedge the whole device if a bus
+ * reset is performed too soon after transition to D0, extend d3hot_delay
+ * to previous effective default for all NVIDIA HDA controllers.
+ */
+static void quirk_nvidia_hda_pm(struct pci_dev *dev)
+{
+	quirk_d3hot_delay(dev, 20);
+}
+DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
+			      PCI_CLASS_MULTIMEDIA_HD_AUDIO, 8,
+			      quirk_nvidia_hda_pm);
+
 /*
  * Ryzen5/7 XHCI controllers fail upon resume from runtime suspend or s2idle.
  * https://bugzilla.kernel.org/show_bug.cgi?id=205587
Signature · 1 line
2.39.2