Skip to contentSkip to conversation

nvme-pci: simple suspend quirk for vmd devices

PATCH In review Keith Busch 3 participants 4 messages Feb 10, 2022 – Feb 16, 2022

Subsystems (3)
lore
Share & tools
lore

Keith Busch

author maintainer
#0 lore raw

PATCH 1/1 nvme-pci: simple suspend quirk for vmd devices

Bug reports from users tell us platfroms with vmd enabled regressed power when using nvme power management on s2idle. We can't get the StorageD3Enable property on such devices so the driver used the wrong suspend method. Add a simple suspend quirk for the domain since that is the safest option.

---
 drivers/nvme/host/pci.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/nvme/host/pci.c +6 -0
index 6a99ed680915..6fa66d5d924e 100644
@@ -3094,6 +3094,12 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		dev_info(&pdev->dev,
 			 "platform quirk: setting simple suspend\n");
 		quirks |= NVME_QUIRK_SIMPLE_SUSPEND;
+	} else if (pci_domain_nr(pdev->bus) > 0xffff) {
+		/*
+		 * ACPI device properties are not reliable within VMD domains,
+		 * so assume the worst.
+		 */
+		quirks |= NVME_QUIRK_SIMPLE_SUSPEND;
 	}
 
 	/*
Signature · 1 line
2.25.4
#1 lore raw

drivers/nvme/host/pci.c static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 3102

Quoted 6 lines · Keith Busch
drivers/nvme/host/pci.c +6 -0
+	} else if (pci_domain_nr(pdev->bus) > 0xffff) {
+		/*
+		 * ACPI device properties are not reliable within VMD domains,
+		 * so assume the worst.
+		 */
+		quirks |= NVME_QUIRK_SIMPLE_SUSPEND;

We'll need to communicate that from th vmd layer instead of hacking a check like this into NVMe..

#2 lore raw
In reply to Keith Busch
Quoted 8 lines · Keith Busch

Bug reports from users tell us platfroms with vmd enabled regressed power when using nvme power management on s2idle. We can't get the StorageD3Enable property on such devices so the driver used the wrong suspend method. Add a simple suspend quirk for the domain since that is the safest option.

Rafael, can you try this on the affected platform? (not for merge as-is)

arch/x86/pci/common.c +1 -0
index 9e1e6b8d88763..49f4e54da919d 100644
@@ -723,4 +723,5 @@ struct pci_dev *pci_real_dma_dev(struct pci_dev *dev)
 
 	return dev;
 }
+EXPORT_SYMBOL_GPL(pci_real_dma_dev);
 #endif
drivers/nvme/host/pci.c +1 -1
index 6a99ed6809158..6edc8c514cbc8 100644
@@ -3086,7 +3086,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	quirks |= check_vendor_combination_bug(pdev);
 
-	if (!noacpi && acpi_storage_d3(&pdev->dev)) {
+	if (!noacpi && acpi_storage_d3(&pci_real_dma_dev(pdev)->dev)) {
 		/*
 		 * Some systems use a bios work around to ask for D3 on
 		 * platforms that support kernel managed suspend.
#3 lore raw
Quoted 8 lines · Christoph Hellwig
Quoted 6 lines · Keith Busch

Bug reports from users tell us platfroms with vmd enabled regressed power when using nvme power management on s2idle. We can't get the StorageD3Enable property on such devices so the driver used the wrong suspend method. Add a simple suspend quirk for the domain since that is the safest option.

Quoted 5 lines
Quoted 2 lines

Rafael, can you try this on the affected platform? (not for merge as-is)

I can't really do that myself (no access to the system in question), but I've just asked the original reporter (CCed) to do it.

Quoted 24 lines
arch/x86/pci/common.c +1 -0
index 9e1e6b8d88763..49f4e54da919d 100644
@@ -723,4 +723,5 @@ struct pci_dev *pci_real_dma_dev(struct pci_dev *dev)
 
        return dev;
 }
+EXPORT_SYMBOL_GPL(pci_real_dma_dev);
 #endif
drivers/nvme/host/pci.c +1 -1
index 6a99ed6809158..6edc8c514cbc8 100644
@@ -3086,7 +3086,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
        quirks |= check_vendor_combination_bug(pdev);
 
-       if (!noacpi && acpi_storage_d3(&pdev->dev)) {
+       if (!noacpi && acpi_storage_d3(&pci_real_dma_dev(pdev)->dev)) {
                /*
                 * Some systems use a bios work around to ask for D3 on
                 * platforms that support kernel managed suspend.