nvme-pci: add AMD PCIe quirk for NVMe simple suspend/resume
Subsystems (3)
v5 cover nvme-pci: add AMD PCIe quirk for NVMe simple suspend/resume
Those patch series can handle NVMe can't suspend to D3 during s2idle entry on some AMD platform. In this case, can be settld by assigning and passing a PCIe bus flag to the armed device which need NVMe shutdown opt in s2idle suspend and then use PCIe power setting to put the NVMe device to D3.
Prike Liang (2):
PCI: add AMD PCIe quirk for nvme shutdown opt
nvme-pci: add AMD PCIe quirk for simple suspend/resume
drivers/nvme/host/pci.c | 2 ++ drivers/pci/probe.c | 5 ++++- drivers/pci/quirks.c | 7 +++++++ include/linux/pci.h | 2 ++ 4 files changed, 15 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
PATCH v5 1/2 PCI: add AMD PCIe quirk for nvme shutdown opt
In the NVMe controller default suspend-resume seems only save/restore the NVMe link state by APST opt and the NVMe remains in D0 during this time. Then the NVMe device will be shutdown by SMU firmware in the s2idle entry and then will lost the NVMe power context during s2idle resume.Finally, the NVMe command queue request will be processed abnormally and result in access timeout.This issue can be settled by using PCIe power set with simple suspend-resume process path instead of APST get/set opt.
In this patch prepare a PCIe RC bus flag to identify the platform whether need the quirk.
---
Changes in v2:
Fix the patch format and check chip root complex DID instead of PCIe RP to avoid the storage device plugged in internal PCIe RP by USB adaptor.
Changes in v3:
According to Christoph Hellwig do NVME PCIe related identify opt better in PCIe quirk driver rather than in NVME module.
Changes in v4:
Split the fix to PCIe and NVMe part and then call the pci_dev_put() put the device reference count and finally refine the commit info.
Changes in v5:
According to Christoph Hellwig and Keith Busch better use a passthrough device(bus) gloable flag to identify the NVMe shutdown opt rather than look up the device BDF.
--- drivers/pci/probe.c | 5 ++++- drivers/pci/quirks.c | 7 +++++++ include/linux/pci.h | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-)
drivers/pci/probe.c +4 -1
@@ -558,10 +558,13 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)INIT_LIST_HEAD (&b->resources); b->max_bus_speed =PCI_SPEED_UNKNOWN ; b->cur_bus_speed =PCI_SPEED_UNKNOWN ; +if (parent) {#ifdef CONFIG_PCI_DOMAINS_GENERIC -if (parent) b->domain_nr = parent->domain_nr;#endif +if (parent->bus_flags &PCI_BUS_FLAGS_DISABLE_ON_S2I ) + b->bus_flags |=PCI_BUS_FLAGS_DISABLE_ON_S2I ; + }return b; }
drivers/pci/quirks.c +7 -0
@@ -312,6 +312,13 @@ static void quirk_nopciamd(struct pci_dev *dev) }DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_8151_0 , quirk_nopciamd); +static void quirk_amd_s2i_fixup (struct pci_dev *dev) +{ + dev->bus->bus_flags |=PCI_BUS_FLAGS_DISABLE_ON_S2I ; +pci_info (dev,"AMD simple suspend opt enabled\n" ); +} +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_AMD ,0x1630 , quirk_amd_s2i_fixup); +/* Triton requires workarounds to be used by the drivers */ static void quirk_triton (struct pci_dev *dev) {
include/linux/pci.h +2 -0
@@ -240,6 +240,8 @@ enum pci_bus_flags {PCI_BUS_FLAGS_NO_MMRBC = (__force pci_bus_flags_t )2 ,PCI_BUS_FLAGS_NO_AERSID = (__force pci_bus_flags_t )4 ,PCI_BUS_FLAGS_NO_EXTCFG = (__force pci_bus_flags_t )8 , +/* Driver must pci_disable_device() for suspend-to-idle */ + PCI_BUS_FLAGS_DISABLE_ON_S2I = (__force pci_bus_flags_t) 16, };/* Values from Link Status register, PCIe r3.1, sec 7.8.8 */
Signature · 1 line
2.7.4
RE: [PATCH v5 1/2] PCI: add AMD PCIe quirk for nvme shutdown opt
[AMD Public Use]
+ linux-pci for further review.
Thanks,
Quoted 102 lines
-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Thursday, April 22, 2021 9:19 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Deucher, Alexander <[email protected]>; S-k, Shyam-sundar <Shyam-sundar.S- [email protected]>; Liang, Prike <[email protected]>; Chaitanya Kulkarni <[email protected]>
Subject: [PATCH v5 1/2] PCI: add AMD PCIe quirk for nvme shutdown optIn the NVMe controller default suspend-resume seems only save/restore the NVMe link state by APST opt and the NVMe remains in D0 during this time. Then the NVMe device will be shutdown by SMU firmware in the s2idle entry and then will lost the NVMe power context during s2idle resume.Finally, the NVMe command queue request will be processed abnormally and result in access timeout.This issue can be settled by using PCIe power set with simple suspend-resume process path instead of APST get/set opt.
In this patch prepare a PCIe RC bus flag to identify the platform whether need the quirk.
Cc <[email protected]> # 5.10+Signed-off-by Prike Liang <[email protected]>Signed-off-by Shyam Sundar S K <[email protected]>[ck: split patches for nvme and pcie]Signed-off-by Chaitanya Kulkarni <[email protected]>Suggested-by Keith Busch <[email protected]>Acked-by Keith Busch <[email protected]>---
Changes in v2:
Fix the patch format and check chip root complex DID instead of PCIe RP to avoid the storage device plugged in internal PCIe RP by USB adaptor.Changes in v3:
According to Christoph Hellwig do NVME PCIe related identify opt better in PCIe quirk driver rather than in NVME module.Changes in v4:
Split the fix to PCIe and NVMe part and then call thepci_dev_put()put the device reference count and finally refine the commit info.Changes in v5:
According to Christoph Hellwig and Keith Busch better use a passthrough device(bus) gloable flag to identify the NVMe shutdown opt rather than look up the device BDF.--- drivers/pci/probe.c | 5 ++++- drivers/pci/quirks.c | 7 +++++++ include/linux/pci.h | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-)drivers/pci/probe.c index renamed from drivers/pci/probe.c +0
-0953f15a..34ba691e 100644
drivers/pci/probe.c +4
-1@@ -558,10 +558,13 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)INIT_LIST_HEAD (&b->resources); b->max_bus_speed =PCI_SPEED_UNKNOWN ; b->cur_bus_speed =PCI_SPEED_UNKNOWN ; +if (parent) {#ifdef CONFIG_PCI_DOMAINS_GENERIC -if (parent) b->domain_nr = parent->domain_nr;#endif +if (parent->bus_flags &PCI_BUS_FLAGS_DISABLE_ON_S2I ) +b->bus_flags |=PCI_BUS_FLAGS_DISABLE_ON_S2I ; +}return b; }drivers/pci/quirks.c index renamed from drivers/pci/quirks.c +0
-0653660e3..7c4bb8e 100644
drivers/pci/quirks.c +6
-0@@ -312,6 +312,13 @@ static void quirk_nopciamd(struct pci_dev *dev) }DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_8151_0 ,quirk_nopciamd); +static void quirk_amd_s2i_fixup (struct pci_dev *dev) { +dev->bus->bus_flags |=PCI_BUS_FLAGS_DISABLE_ON_S2I ; +pci_info (dev,"AMD simple suspend opt enabled\n" ); } +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_AMD ,0x1630 , +quirk_amd_s2i_fixup); + /* Triton requires workarounds to be used by the drivers */ static void
quirk_triton(struct pci_dev *dev){ diff --gita/include/linux/pci.hb/include/linux/pci.hindex 53f4904..dc65219 100644include/linux/pci.h +2
-1@@ -240,6 +240,8 @@ enum pci_bus_flags {PCI_BUS_FLAGS_NO_MMRBC = (__force pci_bus_flags_t )2 ,PCI_BUS_FLAGS_NO_AERSID = (__force pci_bus_flags_t )4 ,PCI_BUS_FLAGS_NO_EXTCFG = (__force pci_bus_flags_t )8 , +/* Driver must pci_disable_device() for suspend-to-idle */ +PCI_BUS_FLAGS_DISABLE_ON_S2I= (__force pci_bus_flags_t) 16, };/* Values from Link Status register, PCIe r3.1, sec 7.8.8 */ --2.7.4
RE: [PATCH v5 1/2] PCI: add AMD PCIe quirk for nvme shutdown opt
[AMD Public Use]
Ping... Could I get some comments or RB on this latest series.
Thanks,
Prike
Quoted 123 lines
-----Original Message-----
From: Liang, Prike
Sent: Thursday, May 6, 2021 11:08 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Bjorn Helgaas <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; S-k, Shyam-sundar <Shyam-sundar.S- [email protected]>; Chaitanya Kulkarni <[email protected]>; [email protected]
Subject: RE: [PATCH v5 1/2] PCI: add AMD PCIe quirk for nvme shutdown opt+ linux-pci for further review.
Thanks,
Quoted 12 lines
-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Thursday, April 22, 2021 9:19 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Deucher, Alexander <[email protected]>; S-k, Shyam-sundar <Shyam-sundar.S- [email protected]>; Liang, Prike <[email protected]>; Chaitanya Kulkarni <[email protected]>
Subject: [PATCH v5 1/2] PCI: add AMD PCIe quirk for nvme shutdown optQuoted 2 lines
In the NVMe controller default suspend-resume seems only save/restore the NVMe link state by APST opt and the NVMe remains in D0 during this
time.
Quoted 5 lines
Then the NVMe device will be shutdown by SMU firmware in the s2idle entry and then will lost the NVMe power context during s2idle resume.Finally, the NVMe command queue request will be processed abnormally and result in access timeout.This issue can be settled by using PCIe power set with simple suspend-resume process path instead of
APST get/set opt.
Quoted 87 lines
In this patch prepare a PCIe RC bus flag to identify the platform whether need the quirk.
Cc <[email protected]> # 5.10+Signed-off-by Prike Liang <[email protected]>Signed-off-by Shyam Sundar S K <[email protected]>[ck: split patches for nvme and pcie]Signed-off-by Chaitanya Kulkarni <[email protected]>Suggested-by Keith Busch <[email protected]>Acked-by Keith Busch <[email protected]>---
Changes in v2:
Fix the patch format and check chip root complex DID instead of PCIe RP to avoid the storage device plugged in internal PCIe RP by USB adaptor.Changes in v3:
According to Christoph Hellwig do NVME PCIe related identify opt better in PCIe quirk driver rather than in NVME module.Changes in v4:
Split the fix to PCIe and NVMe part and then call thepci_dev_put()put the device reference count and finally refine the commit info.Changes in v5:
According to Christoph Hellwig and Keith Busch better use a passthrough
device(bus) gloable flag to identify the NVMe shutdown opt rather than look up the device BDF.--- drivers/pci/probe.c | 5 ++++- drivers/pci/quirks.c | 7 +++++++ include/linux/pci.h | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-)drivers/pci/probe.c index renamed from drivers/pci/probe.c +0
-0953f15a..34ba691e 100644
drivers/pci/probe.c +0
-0@@ -558,10 +558,13 @@ static struct pci_bus *pci_alloc_bus(struct
pci_bus
*parent)INIT_LIST_HEAD(&b->resources); b->max_bus_speed = PCI_SPEED_UNKNOWN; b->cur_bus_speed = PCI_SPEED_UNKNOWN;drivers/pci/probe.c +4
-1+if (parent) {#ifdef CONFIG_PCI_DOMAINS_GENERIC -if (parent) b->domain_nr = parent->domain_nr;#endif +if (parent->bus_flags &PCI_BUS_FLAGS_DISABLE_ON_S2I ) + b->bus_flags |=PCI_BUS_FLAGS_DISABLE_ON_S2I ; + }return b; }drivers/pci/quirks.c index renamed from drivers/pci/quirks.c +0
-0653660e3..7c4bb8e 100644
drivers/pci/quirks.c +6
-0@@ -312,6 +312,13 @@ static void quirk_nopciamd(struct pci_dev *dev) }DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_8151_0 , quirk_nopciamd); +static void quirk_amd_s2i_fixup (struct pci_dev *dev) { + dev->bus->bus_flags |=PCI_BUS_FLAGS_DISABLE_ON_S2I ; +pci_info (dev,"AMD simple suspend opt enabled\n" ); } +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_AMD ,0x1630 , +quirk_amd_s2i_fixup); + /* Triton requires workarounds to be used by the drivers */ staticvoid
quirk_triton(struct pci_dev *dev){ diff --gita/include/linux/pci.hb/include/linux/pci.hindex 53f4904..dc65219 100644include/linux/pci.h +2
-1@@ -240,6 +240,8 @@ enum pci_bus_flags {PCI_BUS_FLAGS_NO_MMRBC = (__force pci_bus_flags_t )2 ,PCI_BUS_FLAGS_NO_AERSID = (__force pci_bus_flags_t )4 ,PCI_BUS_FLAGS_NO_EXTCFG = (__force pci_bus_flags_t )8 , +/* Driver must pci_disable_device() for suspend-to-idle */ + PCI_BUS_FLAGS_DISABLE_ON_S2I = (__force pci_bus_flags_t) 16, };/* Values from Link Status register, PCIe r3.1, sec 7.8.8 */ --2.7.4
PATCH v5 2/2 nvme-pci: add AMD PCIe quirk for simple suspend/resume
In reply to Prike LiangIn the NVMe controller default suspend-resume seems only save/restore the NVMe link state by APST opt and the NVMe remains in D0 during this time. Then the NVMe device will be shutdown by SMU firmware in the s2idle entry and then will lost the NVMe power context during s2idle resume.Finally, the NVMe command queue request will be processed abnormally and result in access timeout.This issue can be settled by using PCIe power set with simple suspend-resume process path instead of APST get/set opt.
This patch is updating the nvme_acpi_storage_d3() with previously added quirk.
---
Changes in v2:
Fix the patch format and check chip root complex DID instead of PCIe RP to avoid the storage device plugged in internal PCIe RP by USB adaptor.
Changes in v3:
According to Christoph Hellwig do NVME PCIe related identify opt better in PCIe quirk driver rather than in NVME module.
Changes in v4:
Split the fix to PCIe and NVMe part and then call the pci_dev_put() put the device reference count and finally refine the commit info.
Changes in v5:
According to Christoph Hellwig and Keith Busch better use a passthrough device(bus) gloable flag to identify the NVMe shutdown opt rather than look up the device BDF.
--- drivers/nvme/host/pci.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/nvme/host/pci.c +2 -0
@@ -2836,6 +2836,8 @@ static bool nvme_acpi_storage_d3(struct pci_dev *dev)acpi_status status;u8 val; +if (dev->bus->bus_flags &PCI_BUS_FLAGS_DISABLE_ON_S2I ) +return true;/* * Look for _DSD property specifying that the storage device on the port * must use D3 to support deep platform power savings during
Signature · 1 line
2.7.4
RE: [PATCH v5 2/2] nvme-pci: add AMD PCIe quirk for simple suspend/resume
[AMD Public Use]
+ linux-pci for further review.
Thanks,
Quoted 68 lines
-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Thursday, April 22, 2021 9:19 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Deucher, Alexander <[email protected]>; S-k, Shyam-sundar <Shyam-sundar.S- [email protected]>; Liang, Prike <[email protected]>; Chaitanya Kulkarni <[email protected]>
Subject: [PATCH v5 2/2] nvme-pci: add AMD PCIe quirk for simple suspend/resumeIn the NVMe controller default suspend-resume seems only save/restore the NVMe link state by APST opt and the NVMe remains in D0 during this time. Then the NVMe device will be shutdown by SMU firmware in the s2idle entry and then will lost the NVMe power context during s2idle resume.Finally, the NVMe command queue request will be processed abnormally and result in access timeout.This issue can be settled by using PCIe power set with simple suspend-resume process path instead of APST get/set opt.
This patch is updating the
nvme_acpi_storage_d3()with previously added quirk.Cc <[email protected]> # 5.10+Signed-off-by Prike Liang <[email protected]>Signed-off-by Shyam Sundar S K <[email protected]>[ck: split patches for nvme and pcie]Signed-off-by Chaitanya Kulkarni <[email protected]>Suggested-by Keith Busch <[email protected]>Acked-by Keith Busch <[email protected]>---
Changes in v2:
Fix the patch format and check chip root complex DID instead of PCIe RP to avoid the storage device plugged in internal PCIe RP by USB adaptor.Changes in v3:
According to Christoph Hellwig do NVME PCIe related identify opt better in PCIe quirk driver rather than in NVME module.Changes in v4:
Split the fix to PCIe and NVMe part and then call thepci_dev_put()put the device reference count and finally refine the commit info.Changes in v5:
According to Christoph Hellwig and Keith Busch better use a passthrough device(bus) gloable flag to identify the NVMe shutdown opt rather than look up the device BDF.--- drivers/nvme/host/pci.c | 2 ++ 1 file changed, 2 insertions(+)drivers/nvme/host/pci.c index renamed from drivers/nvme/host/pci.c +0
-06bad4d4..617256e 100644
drivers/nvme/host/pci.c +2
-0@@ -2836,6 +2836,8 @@ static bool nvme_acpi_storage_d3(struct pci_dev *dev)acpi_status status;u8 val; +if (dev->bus->bus_flags &PCI_BUS_FLAGS_DISABLE_ON_S2I ) +return true;/* * Look for _DSD property specifying that the storage device on the port
* must use D3 to support deep platform power savings during
--
2.7.4