public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 0/2] Revise some PCI _DSM method implement
@ 2025-06-05  6:58 Zhou Shengqing
  2025-06-05  6:58 ` [PATCH v6 1/2] PCI/ACPI: Add rev 2 check for PRESERVE_BOOT_CONFIG function Zhou Shengqing
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Zhou Shengqing @ 2025-06-05  6:58 UTC (permalink / raw)
  To: Rafael J. Wysocki, Bjorn Helgaas
  Cc: Len Brown, linux-acpi, linux-pci, linux-kernel, zhoushengqing

[1/2]PCI/ACPI: Add rev 2 check for PRESERVE_BOOT_CONFIG function
[2/2]PCI/ACPI: Add acpi_check_dsm() for PCI _DSM definitions

 drivers/pci/pci-acpi.c | 58 ++++++++++++++++++++++++++++++++----------
 1 file changed, 44 insertions(+), 14 deletions(-)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v6 1/2] PCI/ACPI: Add rev 2 check for PRESERVE_BOOT_CONFIG function
  2025-06-05  6:58 [PATCH v6 0/2] Revise some PCI _DSM method implement Zhou Shengqing
@ 2025-06-05  6:58 ` Zhou Shengqing
  2025-06-05  6:58 ` [PATCH v6 2/2] PCI/ACPI: Add acpi_check_dsm() for PCI _DSM definitions Zhou Shengqing
  2026-01-07 21:47 ` [PATCH v6 0/2] Revise some PCI _DSM method implement Mario Limonciello
  2 siblings, 0 replies; 4+ messages in thread
From: Zhou Shengqing @ 2025-06-05  6:58 UTC (permalink / raw)
  To: Rafael J. Wysocki, Bjorn Helgaas
  Cc: Len Brown, linux-acpi, linux-pci, linux-kernel, zhoushengqing

Per PCI Firmware Specification Revision 3.3 Table 4-7 _DSM Definitions
for PCI. Preserve PCI Boot Configuration Initial Revision ID changed to 2.

So add rev2 check and add acpi_check_dsm() for DSM_PCI_PRESERVE_BOOT_CONFIG.

Signed-off-by: Zhou Shengqing <zhoushengqing@ttyinfo.com>
---
v6:follow Rafael advice, revise code style(use for-loop to check revision).
v5:follow Bjorn advice, add acpi_check_dsm for PCI _DSM.
v4:Initialize *obj to NULL.
v3:try revision id 1 first, then try revision id 2.
v2:add Fixes tag.

Fixes: 9d7d5db8e78e ("PCI: Move PRESERVE_BOOT_CONFIG _DSM evaluation to pci_re")
---
 drivers/pci/pci-acpi.c | 42 ++++++++++++++++++++++++++++++------------
 1 file changed, 30 insertions(+), 12 deletions(-)

diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index b78e0e417324..c49abd03daf0 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -122,22 +122,40 @@ phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle)
 
 bool pci_acpi_preserve_config(struct pci_host_bridge *host_bridge)
 {
-	if (ACPI_HANDLE(&host_bridge->dev)) {
-		union acpi_object *obj;
+	bool rc = false;
+	u64 rev;
+	union acpi_object *obj;
+
+	if (!ACPI_HANDLE(&host_bridge->dev))
+		return false;
+
+	/*
+	 * Evaluate the "PCI Boot Configuration" _DSM Function.  If it
+	 * exists and returns 0, we must preserve any PCI resource
+	 * assignments made by firmware for this host bridge.
+	 *
+	 * Per PCI Firmware r3.2, released Jan 26, 2015,
+	 * DSM_PCI_PRESERVE_BOOT_CONFIG Revision ID is 1. But PCI Firmware r3.3,
+	 * released Jan 20, 2021, changed sec 4.6.5 to say
+	 * "lowest valid Revision ID value: 2". So check rev 1 first, then rev 2.
+	 */
+	for (rev = 1; rev <= 2; rev++) {
+		if (!acpi_check_dsm(ACPI_HANDLE(&host_bridge->dev),
+					&pci_acpi_dsm_guid, rev, BIT(DSM_PCI_PRESERVE_BOOT_CONFIG)))
+			continue;
 
-		/*
-		 * Evaluate the "PCI Boot Configuration" _DSM Function.  If it
-		 * exists and returns 0, we must preserve any PCI resource
-		 * assignments made by firmware for this host bridge.
-		 */
 		obj = acpi_evaluate_dsm_typed(ACPI_HANDLE(&host_bridge->dev),
-					      &pci_acpi_dsm_guid,
-					      1, DSM_PCI_PRESERVE_BOOT_CONFIG,
-					      NULL, ACPI_TYPE_INTEGER);
+						&pci_acpi_dsm_guid, rev,
+						DSM_PCI_PRESERVE_BOOT_CONFIG,
+						NULL, ACPI_TYPE_INTEGER);
 		if (obj && obj->integer.value == 0)
-			return true;
+			rc = true;
+
 		ACPI_FREE(obj);
-	}
+
+		if (rc)
+			return true;
+ 	}
 
 	return false;
 }
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v6 2/2] PCI/ACPI: Add acpi_check_dsm() for PCI _DSM definitions
  2025-06-05  6:58 [PATCH v6 0/2] Revise some PCI _DSM method implement Zhou Shengqing
  2025-06-05  6:58 ` [PATCH v6 1/2] PCI/ACPI: Add rev 2 check for PRESERVE_BOOT_CONFIG function Zhou Shengqing
@ 2025-06-05  6:58 ` Zhou Shengqing
  2026-01-07 21:47 ` [PATCH v6 0/2] Revise some PCI _DSM method implement Mario Limonciello
  2 siblings, 0 replies; 4+ messages in thread
From: Zhou Shengqing @ 2025-06-05  6:58 UTC (permalink / raw)
  To: Rafael J. Wysocki, Bjorn Helgaas
  Cc: Len Brown, linux-acpi, linux-pci, linux-kernel, zhoushengqing

Add acpi_check_dsm() for DSM_PCI_POWER_ON_RESET_DELAY and
DSM_PCI_DEVICE_READINESS_DURATIONS.

Signed-off-by: Zhou Shengqing <zhoushengqing@ttyinfo.com>
---
 drivers/pci/pci-acpi.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index c49abd03daf0..e3680448b6a1 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -1240,6 +1240,7 @@ bool acpi_pci_need_resume(struct pci_dev *dev)
 
 void acpi_pci_add_bus(struct pci_bus *bus)
 {
+	u64 rev;
 	union acpi_object *obj;
 	struct pci_host_bridge *bridge;
 
@@ -1256,7 +1257,12 @@ void acpi_pci_add_bus(struct pci_bus *bus)
 	if (!pci_is_root_bus(bus))
 		return;
 
-	obj = acpi_evaluate_dsm_typed(ACPI_HANDLE(bus->bridge), &pci_acpi_dsm_guid, 3,
+	rev = 3;
+	if (!acpi_check_dsm(ACPI_HANDLE(bus->bridge), &pci_acpi_dsm_guid, rev,
+			BIT(DSM_PCI_POWER_ON_RESET_DELAY)))
+		return;
+
+	obj = acpi_evaluate_dsm_typed(ACPI_HANDLE(bus->bridge), &pci_acpi_dsm_guid, rev,
 				      DSM_PCI_POWER_ON_RESET_DELAY, NULL, ACPI_TYPE_INTEGER);
 	if (!obj)
 		return;
@@ -1412,12 +1418,18 @@ static void pci_acpi_optimize_delay(struct pci_dev *pdev,
 {
 	struct pci_host_bridge *bridge = pci_find_host_bridge(pdev->bus);
 	int value;
+	u64 rev;
 	union acpi_object *obj, *elements;
 
 	if (bridge->ignore_reset_delay)
 		pdev->d3cold_delay = 0;
 
-	obj = acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, 3,
+	rev = 3;
+	if (!acpi_check_dsm(handle, &pci_acpi_dsm_guid, rev,
+				BIT(DSM_PCI_DEVICE_READINESS_DURATIONS)))
+		return;
+
+	obj = acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, rev,
 				      DSM_PCI_DEVICE_READINESS_DURATIONS, NULL,
 				      ACPI_TYPE_PACKAGE);
 	if (!obj)
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v6 0/2] Revise some PCI _DSM method implement
  2025-06-05  6:58 [PATCH v6 0/2] Revise some PCI _DSM method implement Zhou Shengqing
  2025-06-05  6:58 ` [PATCH v6 1/2] PCI/ACPI: Add rev 2 check for PRESERVE_BOOT_CONFIG function Zhou Shengqing
  2025-06-05  6:58 ` [PATCH v6 2/2] PCI/ACPI: Add acpi_check_dsm() for PCI _DSM definitions Zhou Shengqing
@ 2026-01-07 21:47 ` Mario Limonciello
  2 siblings, 0 replies; 4+ messages in thread
From: Mario Limonciello @ 2026-01-07 21:47 UTC (permalink / raw)
  To: Zhou Shengqing, Rafael J. Wysocki, Bjorn Helgaas
  Cc: Len Brown, linux-acpi, linux-pci, linux-kernel

On 6/5/25 1:58 AM, Zhou Shengqing wrote:
> [1/2]PCI/ACPI: Add rev 2 check for PRESERVE_BOOT_CONFIG function
> [2/2]PCI/ACPI: Add acpi_check_dsm() for PCI _DSM definitions
> 
>   drivers/pci/pci-acpi.c | 58 ++++++++++++++++++++++++++++++++----------
>   1 file changed, 44 insertions(+), 14 deletions(-)

Did this series get overlooked?  I was talking to someone about this 
_DSM and noticed it on lore.  It looks reasonable to me.

The only thing that jumped out to me that I would say is that the tag

Fixes: 9d7d5db8e78e ("PCI: Move PRESERVE_BOOT_CONFIG _DSM evaluation to 
pci_re")

Shouldn't be below the cutlist, it should be above it.  If there are no 
other concerns maybe Bjorn can just fix that while committing though.

Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-01-07 21:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-05  6:58 [PATCH v6 0/2] Revise some PCI _DSM method implement Zhou Shengqing
2025-06-05  6:58 ` [PATCH v6 1/2] PCI/ACPI: Add rev 2 check for PRESERVE_BOOT_CONFIG function Zhou Shengqing
2025-06-05  6:58 ` [PATCH v6 2/2] PCI/ACPI: Add acpi_check_dsm() for PCI _DSM definitions Zhou Shengqing
2026-01-07 21:47 ` [PATCH v6 0/2] Revise some PCI _DSM method implement Mario Limonciello

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox