Skip to contentSkip to conversation

VRAM Self Refresh

PATCH In review Anshuman Gupta 6 participants 46 messages Apr 1, 2025 – May 29, 2025

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover VRAM Self Refresh

This revision has fixed the below review comment on RFC[1] series.

PCIe ACPI Patches:
- Break the _DSM {10, 11} Patch for different _DSM Method "D3cold Aux Power Limit", "PERST# Assertion Delay" (Bjorn Helgaas)
- Remove the Battlemage-specific language from commit log and Document that this implementation does not track and aggregate requests from all child devices `below the Downstream Port. (Bjorn Helgaas)
- Add Rev 3.3 along with Section in commit log.
- Address cosmetic review comment.
- Added a notifier block.

Xe Pacthes:
- %s/VRAM_/VRAM_SR/
(Rodrigo)
- %s/d3cold.allowed/d3cold.target_state
(Rodrigo)
- Add has_vrsr flag and refactor pci_acpi_aux_power_setup. (Rodrigo)
- Reorder the xe_d3_state enum.
(Karthik)
- Use default VGA gpu to enable VRSR.

VRAM Self Refresh

This revision has fixed the below review cpmment on RFC[1] series.

PCIe ACPI Patches:
- Break the _DSM {10, 11} Patch for different _DSM Method "D3cold Aux Power Limit", "PERST# Assertion Delay" (Bjorn Helgaas)
- Remove the Battlemage-specific language from commit log and Document that this implementation does not track and aggregate requests from all child devices `below the Downstream Port. (Bjorn Helgaas)
- Add Rev 3.3 along with Section in commit log.
- Address cosmetic review comment.
- Added a notifier block.

Xe Patches:
- %s/VRAM_/VRAM_SR/
(Rodrigo)
- %s/d3cold.allowed/d3cold.target_state
(Rodrigo)
- Add has_vrsr flag and refactor pci_acpi_aux_power_setup. (Rodrigo)
- Reorder the xe_d3_state enum.
(Karthik)
- Use default VGA gpu to enable VRSR.

[1] https://patchwork.freedesktop.org/series/145342/

Anshuman Gupta (8):
PCI/ACPI: Add D3cold Aux Power Limit_DSM method PCI/ACPI: Add PERST# Assertion Delay _DSM method PCI/ACPI: Add aux power grant notifier drm/xe/vrsr: Detect VRSR Capability drm/xe: Add PCIe ACPI Aux Power notifier drm/xe/vrsr: Refactor d3cold.allowed to a enum drm/xe/pm: D3Cold target state drm/xe/vrsr: Enable VRSR

Badal Nilawar (4):
drm/xe/vrsr: Introduce flag has_vrsr drm/xe/vrsr: Initialize VRSR feature drm/xe/vrsr: Enable VRSR on default VGA boot device drm/xe/vrsr: Introduce a debugfs node named vrsr_capable

 drivers/gpu/drm/xe/display/xe_display.c |  28 ++-
 drivers/gpu/drm/xe/display/xe_display.h |   2 +
 drivers/gpu/drm/xe/regs/xe_regs.h       |   3 +
 drivers/gpu/drm/xe/xe_debugfs.c         |  20 ++
 drivers/gpu/drm/xe/xe_device_types.h    |  15 +-
 drivers/gpu/drm/xe/xe_pci.c             |  13 +-
 drivers/gpu/drm/xe/xe_pcode_api.h       |   8 +
 drivers/gpu/drm/xe/xe_pm.c              | 236 ++++++++++++++++++++++--
 drivers/gpu/drm/xe/xe_pm.h              |   9 +-
 drivers/pci/pci-acpi.c                  | 159 ++++++++++++++++
 include/linux/pci-acpi.h                |  26 +++
 11 files changed, 490 insertions(+), 29 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/12 PCI/ACPI: Add D3cold Aux Power Limit_DSM method

Implement _DSM method 10 and _DSM Method 11 as per PCI firmware specs section 4.6.10 Rev 3.3.

Note that this implementation assumes only a single device below the Downstream Port will request for Aux Power Limit under a given Root Port because it does not track and aggregate requests from all child devices below the Downstream Port as required by Section 4.6.10 Rev 3.3.

One possible mitigation would be only allowing only first PCIe Non-Bridge Endpoint Function 0 driver to call_DSM method 10.

---
 drivers/pci/pci-acpi.c   | 78 ++++++++++++++++++++++++++++++++++++++++
 include/linux/pci-acpi.h |  6 ++++
 2 files changed, 84 insertions(+)
drivers/pci/pci-acpi.c +78 -0
index af370628e583..ebd49e43457e 100644
@@ -1421,6 +1421,84 @@ static void pci_acpi_optimize_delay(struct pci_dev *pdev,
 	ACPI_FREE(obj);
 }
 
+/**
+ * pci_acpi_request_d3cold_aux_power - Request D3cold aux power via ACPI DSM
+ * @dev: PCI device instance
+ * @requested_power: Requested auxiliary power in milliwatts
+ *
+ * This function sends a request to the host BIOS via ACPI _DSM Function 10
+ * to grant the required D3Cold Auxiliary power for the specified PCI device.
+ * It evaluates the _DSM (Device Specific Method) to request the Auxiliary
+ * power and handles the response accordingly.
+ *
+ * This function shall be only called by 1st non-bridge Endpoint driver
+ * on Function 0. For a Multi-Function Device, the driver for Function 0 is
+ * required to report an aggregate power requirement covering all
+ * functions contained within the device.
+ *
+ * Return: Returns 0 on success and errno on failure.
+ */
+int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
+{
+	union acpi_object in_obj = {
+		.integer.type = ACPI_TYPE_INTEGER,
+		.integer.value = requested_power,
+	};
+
+	union acpi_object *out_obj;
+	acpi_handle handle;
+	int result, ret = -EINVAL;
+
+	if (!dev || !ACPI_HANDLE(&dev->dev))
+		return -EINVAL;
+
+	handle = ACPI_HANDLE(&dev->dev);
+
+	out_obj = acpi_evaluate_dsm_typed(handle,
+					  &pci_acpi_dsm_guid,
+					  4,
+					  DSM_PCI_D3COLD_AUX_POWER_LIMIT,
+					  &in_obj,
+					  ACPI_TYPE_INTEGER);
+	if (!out_obj)
+		return -EINVAL;
+
+	result = out_obj->integer.value;
+
+	switch (result) {
+	case 0x0:
+		dev_dbg(&dev->dev, "D3cold Aux Power %umW request denied\n",
+			requested_power);
+		break;
+	case 0x1:
+		dev_info(&dev->dev, "D3cold Aux Power request granted: %umW\n",
+			 requested_power);
+		ret = 0;
+		break;
+	case 0x2:
+		dev_info(&dev->dev, "D3cold Aux Power: Main power won't be removed\n");
+		ret = -EBUSY;
+		break;
+	default:
+		if (result >= 0x11 && result <= 0x1F) {
+			int retry_interval = result & 0xF;
+
+			dev_warn(&dev->dev, "D3cold Aux Power request needs retry."
+				 "Interval: %d seconds.\n", retry_interval);
+			msleep(retry_interval * 1000);
+			ret = -EAGAIN;
+		} else {
+			dev_err(&dev->dev, "D3cold Aux Power: Reserved or "
+				"unsupported response: 0x%x.\n", result);
+		}
+		break;
+	}
+
+	ACPI_FREE(out_obj);
+	return ret;
+}
+EXPORT_SYMBOL(pci_acpi_request_d3cold_aux_power);
+
 static void pci_acpi_set_external_facing(struct pci_dev *dev)
 {
 	u8 val;
include/linux/pci-acpi.h +6 -0
index 078225b514d4..dbc4b0ed433c 100644
@@ -121,6 +121,7 @@ extern const guid_t pci_acpi_dsm_guid;
 #define DSM_PCI_DEVICE_NAME			0x07
 #define DSM_PCI_POWER_ON_RESET_DELAY		0x08
 #define DSM_PCI_DEVICE_READINESS_DURATIONS	0x09
+#define DSM_PCI_D3COLD_AUX_POWER_LIMIT		0x0A
 
 #ifdef CONFIG_PCIE_EDR
 void pci_acpi_add_edr_notifier(struct pci_dev *pdev);
@@ -132,10 +133,15 @@ static inline void pci_acpi_remove_edr_notifier(struct pci_dev *pdev) { }
 
 int pci_acpi_set_companion_lookup_hook(struct acpi_device *(*func)(struct pci_dev *));
 void pci_acpi_clear_companion_lookup_hook(void);
+int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power);
 
 #else	/* CONFIG_ACPI */
 static inline void acpi_pci_add_bus(struct pci_bus *bus) { }
 static inline void acpi_pci_remove_bus(struct pci_bus *bus) { }
+int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
+{
+	return -EOPNOTSUPP;
+}
 #endif	/* CONFIG_ACPI */
 
 #endif	/* _PCI_ACPI_H_ */
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH 01/12] PCI/ACPI: Add D3cold Aux Power Limit_DSM method

Quoted 2 lines · Anshuman Gupta

Implement _DSM method 10 and _DSM Method 11 as per PCI firmware specs section 4.6.10 Rev 3.3.

Thanks for splitting this into two patches. But I think now this only implements function 10 (0x0a), so this sentence needs to be updated.

I would write this consistently as "0x0a" or "0Ah" to match the spec description. I don't think the spec ever uses "10".

Quoted 31 lines

Note that this implementation assumes only a single device below the Downstream Port will request for Aux Power Limit under a given Root Port because it does not track and aggregate requests from all child devices below the Downstream Port as required by Section 4.6.10 Rev 3.3.

One possible mitigation would be only allowing only first PCIe Non-Bridge Endpoint Function 0 driver to call_DSM method 10.

---
 drivers/pci/pci-acpi.c   | 78 ++++++++++++++++++++++++++++++++++++++++
 include/linux/pci-acpi.h |  6 ++++
 2 files changed, 84 insertions(+)
drivers/pci/pci-acpi.c +6 -0
index af370628e583..ebd49e43457e 100644
@@ -1421,6 +1421,84 @@ static void pci_acpi_optimize_delay(struct pci_dev *pdev,
 	ACPI_FREE(obj);
 }
 
+/**
+ * pci_acpi_request_d3cold_aux_power - Request D3cold aux power via ACPI DSM
+ * @dev: PCI device instance
+ * @requested_power: Requested auxiliary power in milliwatts
+ *
+ * This function sends a request to the host BIOS via ACPI _DSM Function 10

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1439

Quoted 10 lines
drivers/pci/pci-acpi.c +10 -0
+ * to grant the required D3Cold Auxiliary power for the specified PCI device.
+ * It evaluates the _DSM (Device Specific Method) to request the Auxiliary
+ * power and handles the response accordingly.
+ *
+ * This function shall be only called by 1st non-bridge Endpoint driver
+ * on Function 0. For a Multi-Function Device, the driver for Function 0 is
+ * required to report an aggregate power requirement covering all
+ * functions contained within the device.
+ *
+ * Return: Returns 0 on success and errno on failure.

Write all this in imperative mood, e.g.,

Request auxiliary power while device is in D3cold ...

Return 0 on success ...

Quoted 6 lines
drivers/pci/pci-acpi.c +6 -0
+ */
+int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
+{
+	union acpi_object in_obj = {
+		.integer.type = ACPI_TYPE_INTEGER,
+		.integer.value = requested_power,

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1455

Quoted 10 lines
drivers/pci/pci-acpi.c +10 -0
+	};
+
+	union acpi_object *out_obj;
+	acpi_handle handle;
+	int result, ret = -EINVAL;
+
+	if (!dev || !ACPI_HANDLE(&dev->dev))
+		return -EINVAL;
+
+	handle = ACPI_HANDLE(&dev->dev);

This needs an acpi_check_dsm() call to find out whether the platform supports DSM_PCI_D3COLD_AUX_POWER_LIMIT.

We have several _DSM calls that *should* do this, but unfortunately they don't do it yet, so they're not good examples to copy.

Quoted 5 lines
drivers/pci/pci-acpi.c +5 -0
+	out_obj = acpi_evaluate_dsm_typed(handle,
+					  &pci_acpi_dsm_guid,
+					  4,
+					  DSM_PCI_D3COLD_AUX_POWER_LIMIT,
+					  &in_obj,

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1471

Quoted 10 lines
drivers/pci/pci-acpi.c +10 -0
+					  ACPI_TYPE_INTEGER);
+	if (!out_obj)
+		return -EINVAL;
+
+	result = out_obj->integer.value;
+
+	switch (result) {
+	case 0x0:
+		dev_dbg(&dev->dev, "D3cold Aux Power %umW request denied\n",
+			requested_power);

Use pci_dbg(dev), pci_info(dev), etc.

Quoted 7 lines
drivers/pci/pci-acpi.c +7 -0
+		break;
+	case 0x1:
+		dev_info(&dev->dev, "D3cold Aux Power request granted: %umW\n",
+			 requested_power);
+		ret = 0;
+		break;
+	case 0x2:

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1488

Quoted 10 lines
drivers/pci/pci-acpi.c +10 -0
+		dev_info(&dev->dev, "D3cold Aux Power: Main power won't be removed\n");
+		ret = -EBUSY;
+		break;
+	default:
+		if (result >= 0x11 && result <= 0x1F) {
+			int retry_interval = result & 0xF;
+
+			dev_warn(&dev->dev, "D3cold Aux Power request needs retry."
+				 "Interval: %d seconds.\n", retry_interval);
+			msleep(retry_interval * 1000);

It doesn't seem right to me to do this sleep internally because it means this interface might take up to 15 seconds to return, and the caller has no idea what is happening during that time.

This seems like it should be done in the driver, which can decide *whether* it wants to sleep, and if it does sleep, it may give a nice indication to the user.

Of course, that would mean returning some kind of retry interval information to the caller.

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1492

Quoted 4 lines
drivers/pci/pci-acpi.c +4 -0
+			ret = -EAGAIN;
+		} else {
+			dev_err(&dev->dev, "D3cold Aux Power: Reserved or "
+				"unsupported response: 0x%x.\n", result);

Drop periods at end of messages.

Quoted 8 lines
drivers/pci/pci-acpi.c +8 -0
+		}
+		break;
+	}
+
+	ACPI_FREE(out_obj);
+	return ret;
+}
+EXPORT_SYMBOL(pci_acpi_request_d3cold_aux_power);
#3 lore raw

Re: [PATCH 01/12] PCI/ACPI: Add D3cold Aux Power Limit_DSM method

Quoted 16 lines · Bjorn Helgaas
Quoted 2 lines · Anshuman Gupta

Implement _DSM method 10 and _DSM Method 11 as per PCI firmware specs section 4.6.10 Rev 3.3.

Thanks for splitting this into two patches. But I think now this only implements function 10 (0x0a), so this sentence needs to be updated.

I would write this consistently as "0x0a" or "0Ah" to match the spec description. I don't think the spec ever uses "10".

Quoted 5 lines

Note that this implementation assumes only a single device below the Downstream Port will request for Aux Power Limit under a given Root Port because it does not track and aggregate requests from all child devices below the Downstream Port as required by Section 4.6.10 Rev 3.3.

Why is it regarded as compliant, then?

Request aggregation is a known problem that has been addressed for a couple of times (at least) in the kernel. Why is it too hard to address it here?

Quoted 2 lines
Quoted 2 lines

One possible mitigation would be only allowing only first PCIe Non-Bridge Endpoint Function 0 driver to call_DSM method 10.

What about topologies where there is a switch with multiple downstream ports below the Root Port?

Quoted 17 lines
Quoted 17 lines
---
 drivers/pci/pci-acpi.c   | 78 ++++++++++++++++++++++++++++++++++++++++
 include/linux/pci-acpi.h |  6 ++++
 2 files changed, 84 insertions(+)
drivers/pci/pci-acpi.c +0 -0
index af370628e583..ebd49e43457e 100644
@@ -1421,6 +1421,84 @@ static void pci_acpi_optimize_delay(struct pci_dev *pdev,
      ACPI_FREE(obj);
 }
 
Quoted 4 lines

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1427

Quoted 4 lines
drivers/pci/pci-acpi.c +4 -0
+/**
+ * pci_acpi_request_d3cold_aux_power - Request D3cold aux power via ACPI DSM
+ * @dev: PCI device instance
+ * @requested_power: Requested auxiliary power in milliwatts

How's the caller supposed to find out what value to use here?

Quoted 19 lines

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1439

Quoted 12 lines
drivers/pci/pci-acpi.c +12 -0
+ *
+ * This function sends a request to the host BIOS via ACPI _DSM Function 10
+ * to grant the required D3Cold Auxiliary power for the specified PCI device.
+ * It evaluates the _DSM (Device Specific Method) to request the Auxiliary
+ * power and handles the response accordingly.
+ *
+ * This function shall be only called by 1st non-bridge Endpoint driver
+ * on Function 0. For a Multi-Function Device, the driver for Function 0 is
+ * required to report an aggregate power requirement covering all
+ * functions contained within the device.
+ *
+ * Return: Returns 0 on success and errno on failure.

Write all this in imperative mood, e.g.,

Request auxiliary power while device is in D3cold ...

Return 0 on success ...

Quoted 16 lines
Quoted 6 lines
drivers/pci/pci-acpi.c +6 -0
+ */
+int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
+{
+     union acpi_object in_obj = {
+             .integer.type = ACPI_TYPE_INTEGER,
+             .integer.value = requested_power,

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1455

Quoted 10 lines
drivers/pci/pci-acpi.c +10 -0
+     };
+
+     union acpi_object *out_obj;
+     acpi_handle handle;
+     int result, ret = -EINVAL;
+
+     if (!dev || !ACPI_HANDLE(&dev->dev))
+             return -EINVAL;
+
+     handle = ACPI_HANDLE(&dev->dev);

Well, ACPI_HANDLE() is not a simple macro, so I'd rather avoid using it twice in a row for the same device.

What about

if (!dev)

        return -EINVAL;

handle = ACPI_HANDLE(&dev->dev);
if (!handle)

        return -EINVAL;
Quoted 3 lines

This needs an acpi_check_dsm() call to find out whether the platform supports DSM_PCI_D3COLD_AUX_POWER_LIMIT.

Absolutely.

Quoted 2 lines

We have several _DSM calls that *should* do this, but unfortunately they don't do it yet, so they're not good examples to copy.

Right.

Quoted 36 lines
Quoted 5 lines
drivers/pci/pci-acpi.c +5 -0
+     out_obj = acpi_evaluate_dsm_typed(handle,
+                                       &pci_acpi_dsm_guid,
+                                       4,
+                                       DSM_PCI_D3COLD_AUX_POWER_LIMIT,
+                                       &in_obj,

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1471

Quoted 10 lines
drivers/pci/pci-acpi.c +10 -0
+                                       ACPI_TYPE_INTEGER);
+     if (!out_obj)
+             return -EINVAL;
+
+     result = out_obj->integer.value;
+
+     switch (result) {
+     case 0x0:
+             dev_dbg(&dev->dev, "D3cold Aux Power %umW request denied\n",
+                     requested_power);

Use pci_dbg(dev), pci_info(dev), etc.

Quoted 7 lines
drivers/pci/pci-acpi.c +7 -0
+             break;
+     case 0x1:
+             dev_info(&dev->dev, "D3cold Aux Power request granted: %umW\n",
+                      requested_power);
+             ret = 0;
+             break;
+     case 0x2:

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1488

Quoted 10 lines
drivers/pci/pci-acpi.c +10 -0
+             dev_info(&dev->dev, "D3cold Aux Power: Main power won't be removed\n");
+             ret = -EBUSY;
+             break;
+     default:
+             if (result >= 0x11 && result <= 0x1F) {
+                     int retry_interval = result & 0xF;
+
+                     dev_warn(&dev->dev, "D3cold Aux Power request needs retry."
+                              "Interval: %d seconds.\n", retry_interval);
+                     msleep(retry_interval * 1000);
Quoted 3 lines

It doesn't seem right to me to do this sleep internally because it means this interface might take up to 15 seconds to return, and the caller has no idea what is happening during that time.

I entirely agree here.

If this is going to happen during system suspend, sleeping for seconds is a total no-go.

Quoted 3 lines

This seems like it should be done in the driver, which can decide *whether* it wants to sleep, and if it does sleep, it may give a nice indication to the user.

So during a system suspend in progress, this is rather hard to achieve.

I'd say that if the request is not granted right away, it is a failure and we don't use D3cold.

Quoted 18 lines

Of course, that would mean returning some kind of retry interval information to the caller.

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1492

Quoted 4 lines
drivers/pci/pci-acpi.c +4 -0
+                     ret = -EAGAIN;
+             } else {
+                     dev_err(&dev->dev, "D3cold Aux Power: Reserved or "
+                             "unsupported response: 0x%x.\n", result);

Drop periods at end of messages.

Quoted 8 lines
drivers/pci/pci-acpi.c +8 -0
+             }
+             break;
+     }
+
+     ACPI_FREE(out_obj);
+     return ret;
+}
+EXPORT_SYMBOL(pci_acpi_request_d3cold_aux_power);
#4 lore raw

RE: [PATCH 01/12] PCI/ACPI: Add D3cold Aux Power Limit_DSM method

In reply to Bjorn Helgaas
Quoted 17 lines

-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: Tuesday, April 1, 2025 11:56 PM
To: Gupta, Anshuman <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; De Marchi, Lucas <[email protected]>; Vivi, Rodrigo <[email protected]>; Nilawar, Badal <[email protected]>; Gupta, Varun <[email protected]>; [email protected]; Shankar, Uma <[email protected]>
Subject: Re: [PATCH 01/12] PCI/ACPI: Add D3cold Aux Power Limit_DSM method

Quoted 1 line · Anshuman Gupta

Implement _DSM method 10 and _DSM Method 11 as per PCI firmware

Quoted 8 lines

specs

Quoted 1 line

section 4.6.10 Rev 3.3.

Thanks for splitting this into two patches. But I think now this only implements function 10 (0x0a), so this sentence needs to be updated.

I would write this consistently as "0x0a" or "0Ah" to match the spec description. I don't think the spec ever uses "10".

Thanks for Review, will fix the commit log.

Quoted 52 lines
Quoted 7 lines

Note that this implementation assumes only a single device below the Downstream Port will request for Aux Power Limit under a given Root Port because it does not track and aggregate requests from all child devices below the Downstream Port as required by Section 4.6.10 Rev 3.3.

Quoted 8 lines

One possible mitigation would be only allowing only first PCIe Non-Bridge Endpoint Function 0 driver to call_DSM method 10.

---
 drivers/pci/pci-acpi.c   | 78

++++++++++++++++++++++++++++++++++++++++

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct

Quoted 8 lines
 include/linux/pci-acpi.h |  6 ++++
 2 files changed, 84 insertions(+)
drivers/pci/pci-acpi.c index renamed from drivers/pci/pci-acpi.c +0 -0

af370628e583..ebd49e43457e 100644

drivers/pci/pci-acpi.c +0 -0
@@ -1421,6 +1421,84 @@ static void pci_acpi_optimize_delay(struct

pci_dev *pdev,

Quoted 14 lines
drivers/pci/pci-acpi.c +11 -0
 	ACPI_FREE(obj);
 }
 
+/**
+ * pci_acpi_request_d3cold_aux_power - Request D3cold aux power via
+ACPI DSM
+ * @dev: PCI device instance
+ * @requested_power: Requested auxiliary power in milliwatts
+ *
+ * This function sends a request to the host BIOS via ACPI _DSM
+Function 10
+ * to grant the required D3Cold Auxiliary power for the specified PCI device.
+ * It evaluates the _DSM (Device Specific Method) to request the
+Auxiliary

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1439

Quoted 10 lines
drivers/pci/pci-acpi.c +10 -0
+ * power and handles the response accordingly.
+ *
+ * This function shall be only called by 1st non-bridge Endpoint
+driver
+ * on Function 0. For a Multi-Function Device, the driver for
+Function 0 is
+ * required to report an aggregate power requirement covering all
+ * functions contained within the device.
+ *
+ * Return: Returns 0 on success and errno on failure.

Write all this in imperative mood, e.g.,

Quoted 1 line

Request auxiliary power while device is in D3cold ...

Will address this in V2.

Quoted 23 lines

Return 0 on success ...

Quoted 6 lines
drivers/pci/pci-acpi.c +6 -0
+ */
+int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32
+requested_power) {
+	union acpi_object in_obj = {
+		.integer.type = ACPI_TYPE_INTEGER,
+		.integer.value = requested_power,

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1455

Quoted 10 lines
drivers/pci/pci-acpi.c +10 -0
+	};
+
+	union acpi_object *out_obj;
+	acpi_handle handle;
+	int result, ret = -EINVAL;
+
+	if (!dev || !ACPI_HANDLE(&dev->dev))
+		return -EINVAL;
+
+	handle = ACPI_HANDLE(&dev->dev);

This needs an acpi_check_dsm() call to find out whether the platform supports DSM_PCI_D3COLD_AUX_POWER_LIMIT.

Quoted 2 lines

We have several _DSM calls that *should* do this, but unfortunately they don't do it yet, so they're not good examples to copy.

Thanks for comment, I would like to understand what shall be the Rev used to invoke this ?
acpi_check_dsm(handle, guid, 4 , DSM_PCI_D3COLD_AUX_POWER_LIMIT).

TBH I am not able to understand the discussion about Rev 4 in the next patch. I hope it is ok to use 4 as constant here for Revision ID.

Quoted 17 lines

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1465

Quoted 5 lines
drivers/pci/pci-acpi.c +4 -0
+	out_obj = acpi_evaluate_dsm_typed(handle,
+					  &pci_acpi_dsm_guid,
+					  4,
+

DSM_PCI_D3COLD_AUX_POWER_LIMIT,

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev,

Quoted 10 lines
drivers/pci/pci-acpi.c +10 -0
+					  &in_obj,
+					  ACPI_TYPE_INTEGER);
+	if (!out_obj)
+		return -EINVAL;
+
+	result = out_obj->integer.value;
+
+	switch (result) {
+	case 0x0:
+		dev_dbg(&dev->dev, "D3cold Aux Power %umW request

denied\n",

Quoted 3 lines

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct · line 1475

Quoted 1 line
drivers/pci/pci-acpi.c +1 -0
+			requested_power);

Use pci_dbg(dev), pci_info(dev), etc.

Will change all dev_{dbg, err, info} with pci_{dbg, err, info}.

Quoted 26 lines

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev,

Quoted 4 lines
drivers/pci/pci-acpi.c +3 -0
+		break;
+	case 0x1:
+		dev_info(&dev->dev, "D3cold Aux Power request granted:

%umW\n",

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev,

Quoted 5 lines
drivers/pci/pci-acpi.c +5 -0
+			 requested_power);
+		ret = 0;
+		break;
+	case 0x2:
+		dev_info(&dev->dev, "D3cold Aux Power: Main power won't

be removed\n");

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev,

Quoted 7 lines
drivers/pci/pci-acpi.c +7 -0
+		ret = -EBUSY;
+		break;
+	default:
+		if (result >= 0x11 && result <= 0x1F) {
+			int retry_interval = result & 0xF;
+
+			dev_warn(&dev->dev, "D3cold Aux Power request

needs retry."

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1488

Quoted 2 lines
drivers/pci/pci-acpi.c +2 -0
+				 "Interval: %d seconds.\n", retry_interval);
+			msleep(retry_interval * 1000);

It doesn't seem right to me to do this sleep internally because it means this interface might take up to 15 seconds to return, and the caller has no idea what is happening during that time.

Quoted 6 lines

This seems like it should be done in the driver, which can decide *whether* it wants to sleep, and if it does sleep, it may give a nice indication to the user.

Of course, that would mean returning some kind of retry interval information to the caller.

Sure will modify the function to return a output which will have the retry delay.

Quoted 7 lines

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1492

Quoted 5 lines
drivers/pci/pci-acpi.c +4 -0
+			ret = -EAGAIN;
+		} else {
+			dev_err(&dev->dev, "D3cold Aux Power: Reserved or "
+				"unsupported response: 0x%x.\n", result);

Drop periods at end of messages.

Will fix it.

Thanks,
Anshuman

Quoted 9 lines
Quoted 9 lines
drivers/pci/pci-acpi.c +8 -0
+		}
+		break;
+	}
+
+	ACPI_FREE(out_obj);
+	return ret;
+}
+EXPORT_SYMBOL(pci_acpi_request_d3cold_aux_power);
#5 lore raw

PATCH 2/12 PCI/ACPI: Add PERST# Assertion Delay _DSM method

In reply to Anshuman Gupta

Implement _DSM Method 11 as per PCI firmware specs section 4.6.11 Rev 3.3.

---
 drivers/pci/pci-acpi.c   | 53 ++++++++++++++++++++++++++++++++++++++++
 include/linux/pci-acpi.h |  7 ++++++
 2 files changed, 60 insertions(+)
drivers/pci/pci-acpi.c +53 -0
index ebd49e43457e..04149f037664 100644
@@ -1499,6 +1499,59 @@ int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
 }
 EXPORT_SYMBOL(pci_acpi_request_d3cold_aux_power);
 
+/**
+ * pci_acpi_add_perst_assertion_delay - Request PERST# delay via ACPI DSM
+ * @dev: PCI device instance
+ * @delay_us: Requested delay_us
+ *
+ * This function sends a request to the host BIOS via ACPI _DSM to grant the
+ * required PERST# delay for the specified PCI device. It evaluates the _DSM
+ * to request the PERST# delay and handles the response accordingly.
+ *
+ * Return: returns 0 on success and errno on failure.
+ */
+int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
+{
+	union acpi_object in_obj = {
+		.integer.type = ACPI_TYPE_INTEGER,
+		.integer.value = delay_us,
+	};
+
+	union acpi_object *out_obj;
+	acpi_handle handle;
+	int result, ret = -EINVAL;
+
+	if (!dev || !ACPI_HANDLE(&dev->dev))
+		return -EINVAL;
+
+	handle = ACPI_HANDLE(&dev->dev);
+
+	out_obj = acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, 4,
+					  DSM_PCI_PERST_ASSERTION_DELAY,
+					  &in_obj, ACPI_TYPE_INTEGER);
+	if (!out_obj)
+		return -EINVAL;
+
+	result = out_obj->integer.value;
+
+	if (result == delay_us) {
+		dev_info(&dev->dev, "PERST# Assertion Delay set to"
+			 "%u microseconds\n", delay_us);
+		ret = 0;
+	} else if (result == 0) {
+		dev_warn(&dev->dev, "PERST# Assertion Delay request failed,"
+			 "no previous valid request\n");
+	} else {
+		dev_warn(&dev->dev,
+			 "PERST# Assertion Delay request failed"
+			 "Previous valid delay: %u microseconds\n", result);
+	}
+
+	ACPI_FREE(out_obj);
+	return ret;
+}
+EXPORT_SYMBOL(pci_acpi_add_perst_assertion_delay);
+
 static void pci_acpi_set_external_facing(struct pci_dev *dev)
 {
 	u8 val;
include/linux/pci-acpi.h +7 -0
index dbc4b0ed433c..4b7373f91a9a 100644
@@ -122,6 +122,7 @@ extern const guid_t pci_acpi_dsm_guid;
 #define DSM_PCI_POWER_ON_RESET_DELAY		0x08
 #define DSM_PCI_DEVICE_READINESS_DURATIONS	0x09
 #define DSM_PCI_D3COLD_AUX_POWER_LIMIT		0x0A
+#define DSM_PCI_PERST_ASSERTION_DELAY		0x0B
 
 #ifdef CONFIG_PCIE_EDR
 void pci_acpi_add_edr_notifier(struct pci_dev *pdev);
@@ -134,6 +135,7 @@ static inline void pci_acpi_remove_edr_notifier(struct pci_dev *pdev) { }
 int pci_acpi_set_companion_lookup_hook(struct acpi_device *(*func)(struct pci_dev *));
 void pci_acpi_clear_companion_lookup_hook(void);
 int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power);
+int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us);
 
 #else	/* CONFIG_ACPI */
 static inline void acpi_pci_add_bus(struct pci_bus *bus) { }
@@ -142,6 +144,11 @@ int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
 {
 	return -EOPNOTSUPP;
 }
+
+int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
+{
+	return -EOPNOTSUPP;
+}
 #endif	/* CONFIG_ACPI */
 
 #endif	/* _PCI_ACPI_H_ */
Signature · 1 line
2.43.0
#6 lore raw

Re: [PATCH 02/12] PCI/ACPI: Add PERST# Assertion Delay _DSM method

Quoted 2 lines · Anshuman Gupta

Implement _DSM Method 11 as per PCI firmware specs section 4.6.11 Rev 3.3.

"PCI Firmware r3.3, sec 4.6.11" so the citation is major to minor.

"0xb" or "0Bh" to match spec usage.

Quoted 30 lines
---
 drivers/pci/pci-acpi.c   | 53 ++++++++++++++++++++++++++++++++++++++++
 include/linux/pci-acpi.h |  7 ++++++
 2 files changed, 60 insertions(+)
drivers/pci/pci-acpi.c +16 -0
index ebd49e43457e..04149f037664 100644
@@ -1499,6 +1499,59 @@ int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
 }
 EXPORT_SYMBOL(pci_acpi_request_d3cold_aux_power);
 
+/**
+ * pci_acpi_add_perst_assertion_delay - Request PERST# delay via ACPI DSM
+ * @dev: PCI device instance
+ * @delay_us: Requested delay_us
+ *
+ * This function sends a request to the host BIOS via ACPI _DSM to grant the
+ * required PERST# delay for the specified PCI device. It evaluates the _DSM
+ * to request the PERST# delay and handles the response accordingly.
+ *
+ * Return: returns 0 on success and errno on failure.
+ */
+int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
+{
+	union acpi_object in_obj = {
+		.integer.type = ACPI_TYPE_INTEGER,
+		.integer.value = delay_us,

drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power) · line 1527

Quoted 10 lines
drivers/pci/pci-acpi.c +10 -0
+	};
+
+	union acpi_object *out_obj;
+	acpi_handle handle;
+	int result, ret = -EINVAL;
+
+	if (!dev || !ACPI_HANDLE(&dev->dev))
+		return -EINVAL;
+
+	handle = ACPI_HANDLE(&dev->dev);

acpi_check_dsm().

drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power) · line 1539

Quoted 11 lines
drivers/pci/pci-acpi.c +11 -0
+	out_obj = acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, 4,
+					  DSM_PCI_PERST_ASSERTION_DELAY,
+					  &in_obj, ACPI_TYPE_INTEGER);
+	if (!out_obj)
+		return -EINVAL;
+
+	result = out_obj->integer.value;
+
+	if (result == delay_us) {
+		dev_info(&dev->dev, "PERST# Assertion Delay set to"
+			 "%u microseconds\n", delay_us);

pci_info().

Join these into a single string, even though they won't fit in a line without wrapping. This is to make them easier to grep for when a user reports seeing the message. (Do this on the previous patch too, where I forgot to mention it.)

Quoted 14 lines
drivers/pci/pci-acpi.c +14 -0
+		ret = 0;
+	} else if (result == 0) {
+		dev_warn(&dev->dev, "PERST# Assertion Delay request failed,"
+			 "no previous valid request\n");
+	} else {
+		dev_warn(&dev->dev,
+			 "PERST# Assertion Delay request failed"
+			 "Previous valid delay: %u microseconds\n", result);
+	}
+
+	ACPI_FREE(out_obj);
+	return ret;
+}
+EXPORT_SYMBOL(pci_acpi_add_perst_assertion_delay);
#7 lore raw

RE: [PATCH 02/12] PCI/ACPI: Add PERST# Assertion Delay _DSM method

Quoted 15 lines

-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: Wednesday, April 2, 2025 12:01 AM
To: Gupta, Anshuman <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; De Marchi, Lucas <[email protected]>; Vivi, Rodrigo <[email protected]>; Nilawar, Badal <[email protected]>; Gupta, Varun <[email protected]>; [email protected]; Shankar, Uma <[email protected]>
Subject: Re: [PATCH 02/12] PCI/ACPI: Add PERST# Assertion Delay _DSM method

Quoted 7 lines
Quoted 2 lines · Anshuman Gupta

Implement _DSM Method 11 as per PCI firmware specs section 4.6.11 Rev 3.3.

"PCI Firmware r3.3, sec 4.6.11" so the citation is major to minor.

"0xb" or "0Bh" to match spec usage.

Thanks for review,
will fix it.

Quoted 39 lines
Quoted 4 lines
---
 drivers/pci/pci-acpi.c   | 53

++++++++++++++++++++++++++++++++++++++++

Quoted 34 lines
 include/linux/pci-acpi.h |  7 ++++++
 2 files changed, 60 insertions(+)
drivers/pci/pci-acpi.c index renamed from drivers/pci/pci-acpi.c +0 -0

ebd49e43457e..04149f037664 100644

drivers/pci/pci-acpi.c +23 -0
@@ -1499,6 +1499,59 @@ int pci_acpi_request_d3cold_aux_power(struct
 pci_dev *dev, u32 requested_power)  }
 EXPORT_SYMBOL(pci_acpi_request_d3cold_aux_power);
 
+/**
+ * pci_acpi_add_perst_assertion_delay - Request PERST# delay via ACPI
+DSM
+ * @dev: PCI device instance
+ * @delay_us: Requested delay_us
+ *
+ * This function sends a request to the host BIOS via ACPI _DSM to
+grant the
+ * required PERST# delay for the specified PCI device. It evaluates
+the _DSM
+ * to request the PERST# delay and handles the response accordingly.
+ *
+ * Return: returns 0 on success and errno on failure.
+ */
+int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32
+delay_us) {
+	union acpi_object in_obj = {
+		.integer.type = ACPI_TYPE_INTEGER,
+		.integer.value = delay_us,
+	};
+
+	union acpi_object *out_obj;
+	acpi_handle handle;
Quoted 8 lines

drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power) · line 1527

Quoted 6 lines
drivers/pci/pci-acpi.c +6 -0
+	int result, ret = -EINVAL;
+
+	if (!dev || !ACPI_HANDLE(&dev->dev))
+		return -EINVAL;
+
+	handle = ACPI_HANDLE(&dev->dev);

acpi_check_dsm().

Will fix it same as patch1

Quoted 15 lines

drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power) · line 1539

Quoted 12 lines
drivers/pci/pci-acpi.c +11 -0
+	out_obj = acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, 4,
+					  DSM_PCI_PERST_ASSERTION_DELAY,
+					  &in_obj, ACPI_TYPE_INTEGER);
+	if (!out_obj)
+		return -EINVAL;
+
+	result = out_obj->integer.value;
+
+	if (result == delay_us) {
+		dev_info(&dev->dev, "PERST# Assertion Delay set to"
+			 "%u microseconds\n", delay_us);

pci_info().

Quoted 4 lines

Join these into a single string, even though they won't fit in a line without wrapping. This is to make them easier to grep for when a user reports seeing the message. (Do this on the previous patch too, where I forgot to mention it.)

there was comment in RFC to warp the line with in 80. Will join the string.
Thanks,
Anshuman

Quoted 16 lines

drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)

Quoted 4 lines
drivers/pci/pci-acpi.c +3 -0
+		ret = 0;
+	} else if (result == 0) {
+		dev_warn(&dev->dev, "PERST# Assertion Delay request

failed,"

Quoted 11 lines
drivers/pci/pci-acpi.c +11 -0
+			 "no previous valid request\n");
+	} else {
+		dev_warn(&dev->dev,
+			 "PERST# Assertion Delay request failed"
+			 "Previous valid delay: %u microseconds\n", result);
+	}
+
+	ACPI_FREE(out_obj);
+	return ret;
+}
+EXPORT_SYMBOL(pci_acpi_add_perst_assertion_delay);
#8 lore raw

Re: [PATCH 02/12] PCI/ACPI: Add PERST# Assertion Delay _DSM method

In reply to Anshuman Gupta
Quoted 5 lines · Anshuman Gupta

Implement _DSM Method 11 as per PCI firmware specs section 4.6.11 Rev 3.3.

I have basically the same comments as for the previous patch (in addition to Bjorn's comments).

Quoted 10 lines
---
 drivers/pci/pci-acpi.c   | 53 ++++++++++++++++++++++++++++++++++++++++
 include/linux/pci-acpi.h |  7 ++++++
 2 files changed, 60 insertions(+)
drivers/pci/pci-acpi.c +0 -0
index ebd49e43457e..04149f037664 100644

drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power) · line 1505

Quoted 7 lines
drivers/pci/pci-acpi.c +4 -0
@@ -1499,6 +1499,59 @@ int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
 }
 EXPORT_SYMBOL(pci_acpi_request_d3cold_aux_power);
 
+/**
+ * pci_acpi_add_perst_assertion_delay - Request PERST# delay via ACPI DSM
+ * @dev: PCI device instance
+ * @delay_us: Requested delay_us

How's the caller supposed to find out what value to use here?

Quoted 12 lines
drivers/pci/pci-acpi.c +12 -0
+ *
+ * This function sends a request to the host BIOS via ACPI _DSM to grant the
+ * required PERST# delay for the specified PCI device. It evaluates the _DSM
+ * to request the PERST# delay and handles the response accordingly.
+ *
+ * Return: returns 0 on success and errno on failure.
+ */
+int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
+{
+       union acpi_object in_obj = {
+               .integer.type = ACPI_TYPE_INTEGER,
+               .integer.value = delay_us,

drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power) · line 1527

Quoted 10 lines
drivers/pci/pci-acpi.c +10 -0
+       };
+
+       union acpi_object *out_obj;
+       acpi_handle handle;
+       int result, ret = -EINVAL;
+
+       if (!dev || !ACPI_HANDLE(&dev->dev))
+               return -EINVAL;
+
+       handle = ACPI_HANDLE(&dev->dev);

Please use ACPI_HANDLE() once.

drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power) · line 1529

Quoted 2 lines
drivers/pci/pci-acpi.c +2 -0
+
+       out_obj = acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, 4,

This is something I haven't noticed in the previous patch, but also applies to it.

Why is rev 4 of the interface hard-coded here?

Quoted 14 lines
drivers/pci/pci-acpi.c +14 -0
+                                         DSM_PCI_PERST_ASSERTION_DELAY,
+                                         &in_obj, ACPI_TYPE_INTEGER);
+       if (!out_obj)
+               return -EINVAL;
+
+       result = out_obj->integer.value;
+
+       if (result == delay_us) {
+               dev_info(&dev->dev, "PERST# Assertion Delay set to"
+                        "%u microseconds\n", delay_us);
+               ret = 0;
+       } else if (result == 0) {
+               dev_warn(&dev->dev, "PERST# Assertion Delay request failed,"
+                        "no previous valid request\n");

drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power) · line 1553

Quoted 10 lines
drivers/pci/pci-acpi.c +10 -0
+       } else {
+               dev_warn(&dev->dev,
+                        "PERST# Assertion Delay request failed"
+                        "Previous valid delay: %u microseconds\n", result);
+       }
+
+       ACPI_FREE(out_obj);
+       return ret;
+}
+EXPORT_SYMBOL(pci_acpi_add_perst_assertion_delay);

EXPORT_SYMBOL_GPL()?

Quoted 37 lines
drivers/pci/pci-acpi.c +1 -0
+
 static void pci_acpi_set_external_facing(struct pci_dev *dev)
 {
        u8 val;
include/linux/pci-acpi.h +7 -1
index dbc4b0ed433c..4b7373f91a9a 100644
@@ -122,6 +122,7 @@ extern const guid_t pci_acpi_dsm_guid;
 #define DSM_PCI_POWER_ON_RESET_DELAY           0x08
 #define DSM_PCI_DEVICE_READINESS_DURATIONS     0x09
 #define DSM_PCI_D3COLD_AUX_POWER_LIMIT         0x0A
+#define DSM_PCI_PERST_ASSERTION_DELAY          0x0B
 
 #ifdef CONFIG_PCIE_EDR
 void pci_acpi_add_edr_notifier(struct pci_dev *pdev);
@@ -134,6 +135,7 @@ static inline void pci_acpi_remove_edr_notifier(struct pci_dev *pdev) { }
 int pci_acpi_set_companion_lookup_hook(struct acpi_device *(*func)(struct pci_dev *));
 void pci_acpi_clear_companion_lookup_hook(void);
 int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power);
+int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us);
 
 #else  /* CONFIG_ACPI */
 static inline void acpi_pci_add_bus(struct pci_bus *bus) { }
@@ -142,6 +144,11 @@ int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
 {
        return -EOPNOTSUPP;
 }
+
+int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
+{
+       return -EOPNOTSUPP;
+}
 #endif /* CONFIG_ACPI */
 
 #endif /* _PCI_ACPI_H_ */
--
#9 lore raw

Re: [PATCH 02/12] PCI/ACPI: Add PERST# Assertion Delay _DSM method

Quoted 26 lines · Rafael J. Wysocki
Quoted 11 lines · Anshuman Gupta

Implement _DSM Method 11 as per PCI firmware specs section 4.6.11 Rev 3.3.

drivers/pci/pci-acpi.c +7 -0
+int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
+{
+       union acpi_object in_obj = {
+               .integer.type = ACPI_TYPE_INTEGER,
+               .integer.value = delay_us,
+       };
+

drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power) · line 1529

Quoted 10 lines
drivers/pci/pci-acpi.c +10 -0
+       union acpi_object *out_obj;
+       acpi_handle handle;
+       int result, ret = -EINVAL;
+
+       if (!dev || !ACPI_HANDLE(&dev->dev))
+               return -EINVAL;
+
+       handle = ACPI_HANDLE(&dev->dev);
+
+       out_obj = acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, 4,

This is something I haven't noticed in the previous patch, but also applies to it.

Quoted 1 line

Why is rev 4 of the interface hard-coded here?

Thanks for asking this because it's related to the whole _DSM revision question that I don't understand.

If we didn't use rev 4 here, what should we use? The PCI Firmware spec, r3.3, sec 4.6.11, documents this interface and says "lowest valid Revision ID value is 4", so that's the source of the 4.

My argument is that the spec documents rev 4, the kernel code was tested with rev 4, so what would be the benefit of using a different revision here?

Quoted 2 lines
Quoted 2 lines
drivers/pci/pci-acpi.c +2 -0
+                                         DSM_PCI_PERST_ASSERTION_DELAY,
+                                         &in_obj, ACPI_TYPE_INTEGER);
#10 lore raw

Re: [PATCH 02/12] PCI/ACPI: Add PERST# Assertion Delay _DSM method

Quoted 28 lines · Bjorn Helgaas
Quoted 26 lines · Rafael J. Wysocki
Quoted 11 lines · Anshuman Gupta

Implement _DSM Method 11 as per PCI firmware specs section 4.6.11 Rev 3.3.

drivers/pci/pci-acpi.c +7 -0
+int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
+{
+       union acpi_object in_obj = {
+               .integer.type = ACPI_TYPE_INTEGER,
+               .integer.value = delay_us,
+       };
+

drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power) · line 1529

Quoted 10 lines
drivers/pci/pci-acpi.c +10 -0
+       union acpi_object *out_obj;
+       acpi_handle handle;
+       int result, ret = -EINVAL;
+
+       if (!dev || !ACPI_HANDLE(&dev->dev))
+               return -EINVAL;
+
+       handle = ACPI_HANDLE(&dev->dev);
+
+       out_obj = acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, 4,

This is something I haven't noticed in the previous patch, but also applies to it.

Quoted 8 lines
Quoted 1 line

Why is rev 4 of the interface hard-coded here?

Thanks for asking this because it's related to the whole _DSM revision question that I don't understand.

If we didn't use rev 4 here, what should we use? The PCI Firmware spec, r3.3, sec 4.6.11, documents this interface and says "lowest valid Revision ID value is 4", so that's the source of the 4.

Well, the "lowest vaild Revision ID" does not generally mean the "only valid Revision ID".

Quoted 3 lines

My argument is that the spec documents rev 4, the kernel code was tested with rev 4, so what would be the benefit of using a different revision here?

I'm talking about using a symbol to represent the number 4, not about possibly using a different number, along the lines of using, say, ACPI_FADT_LOW_POWER_S0 instead of putting BIT(21) directly into the code.

The value is not likely to change, but using a symbol for representing it has merit (it can be meaningfully used in searches, it can be documented etc.).

Now, I'm not sure how likely it is for the PCI Firmware spec to bump up the revision of this interface (I suppose that it will do so if a new function is defined), but even if it does so, the kernel will have to check both the new revision and rev 4 anyway, in case the firmware doesn't know about the new revision.

#11 lore raw

Re: [PATCH 02/12] PCI/ACPI: Add PERST# Assertion Delay _DSM method

Quoted 33 lines · Rafael J. Wysocki
Quoted 32 lines · Bjorn Helgaas
Quoted 26 lines · Rafael J. Wysocki
Quoted 11 lines · Anshuman Gupta

Implement _DSM Method 11 as per PCI firmware specs section 4.6.11 Rev 3.3.

drivers/pci/pci-acpi.c +7 -0
+int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
+{
+       union acpi_object in_obj = {
+               .integer.type = ACPI_TYPE_INTEGER,
+               .integer.value = delay_us,
+       };
+

drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power) · line 1529

Quoted 10 lines
drivers/pci/pci-acpi.c +10 -0
+       union acpi_object *out_obj;
+       acpi_handle handle;
+       int result, ret = -EINVAL;
+
+       if (!dev || !ACPI_HANDLE(&dev->dev))
+               return -EINVAL;
+
+       handle = ACPI_HANDLE(&dev->dev);
+
+       out_obj = acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, 4,

This is something I haven't noticed in the previous patch, but also applies to it.

Quoted 1 line

Why is rev 4 of the interface hard-coded here?

Thanks for asking this because it's related to the whole _DSM revision question that I don't understand.

Quoted 6 lines
Quoted 3 lines

If we didn't use rev 4 here, what should we use? The PCI Firmware spec, r3.3, sec 4.6.11, documents this interface and says "lowest valid Revision ID value is 4", so that's the source of the 4.

Well, the "lowest valid Revision ID" does not generally mean the "only valid Revision ID".

True, but why should the kernel change from using the tested revision ID to some other revision ID? What would be the benefit of using rev 5?

PCI Firmware r3.3 does contain a statement that "OSPM must invoke all Functions other than Function 0 with the same Revision ID value," but IMO that was a mistake, and we just approved an ECR to remove it.

Quoted 4 lines
Quoted 3 lines

My argument is that the spec documents rev 4, the kernel code was tested with rev 4, so what would be the benefit of using a different revision here?

Quoted 8 lines

I'm talking about using a symbol to represent the number 4, not about possibly using a different number, along the lines of using, say, ACPI_FADT_LOW_POWER_S0 instead of putting BIT(21) directly into the code.

The value is not likely to change, but using a symbol for representing it has merit (it can be meaningfully used in searches, it can be documented etc.).

DSM_PCI_PERST_ASSERTION_DELAY (the function number) is a great thing to search for. I doubt a symbol for "4" would really add anything. At least in PCI, changes to a particular _DSM function are relatively rare.

Quoted 5 lines

Now, I'm not sure how likely it is for the PCI Firmware spec to bump up the revision of this interface (I suppose that it will do so if a new function is defined), but even if it does so, the kernel will have to check both the new revision and rev 4 anyway, in case the firmware doesn't know about the new revision.

I guess the reason the OS would check both rev 5 and rev 4 would be that a new platform might implement DSM_PCI_PERST_ASSERTION_DELAY only at rev 5? I think this would be a real mistake in terms of implementing something to the spec.

The spec documents DSM_PCI_PERST_ASSERTION_DELAY rev 4. Some platforms implemented and tested DSM_PCI_PERST_ASSERTION_DELAY rev 4. Linux added and tested support for DSM_PCI_PERST_ASSERTION_DELAY rev
4. I propose new platforms should also implement and test DSM_PCI_PERST_ASSERTION_DELAY rev 4.

If a new platform implements only DSM_PCI_PERST_ASSERTION_DELAY rev 5, there is no actual documentation for that rev other than the spec assertion that "rev 5 must support all functions defined by previous revs of the UUID." IMO this is nonsense. The platform might have no need to implement all the functions defined for the UUID.

Even if the platform makes all its functions valid for "the lowest valid Revision ID" through the "current Revision ID", there's nothing other than the spec assertion to guarantee that they all behave the same. And dealing with multiple revisions that are "supposed" to be the same just makes work and risk for the OS.

Bjorn

#12 lore raw

Re: [PATCH 02/12] PCI/ACPI: Add PERST# Assertion Delay _DSM method

Quoted 39 lines · Bjorn Helgaas
Quoted 37 lines · Rafael J. Wysocki
Quoted 35 lines · Bjorn Helgaas
Quoted 26 lines · Rafael J. Wysocki
Quoted 11 lines · Anshuman Gupta

Implement _DSM Method 11 as per PCI firmware specs section 4.6.11 Rev 3.3.

drivers/pci/pci-acpi.c +7 -0
+int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
+{
+       union acpi_object in_obj = {
+               .integer.type = ACPI_TYPE_INTEGER,
+               .integer.value = delay_us,
+       };
+

drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power) · line 1529

Quoted 10 lines
drivers/pci/pci-acpi.c +10 -0
+       union acpi_object *out_obj;
+       acpi_handle handle;
+       int result, ret = -EINVAL;
+
+       if (!dev || !ACPI_HANDLE(&dev->dev))
+               return -EINVAL;
+
+       handle = ACPI_HANDLE(&dev->dev);
+
+       out_obj = acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, 4,

This is something I haven't noticed in the previous patch, but also applies to it.

Quoted 1 line

Why is rev 4 of the interface hard-coded here?

Thanks for asking this because it's related to the whole _DSM revision question that I don't understand.

If we didn't use rev 4 here, what should we use? The PCI Firmware spec, r3.3, sec 4.6.11, documents this interface and says "lowest valid Revision ID value is 4", so that's the source of the 4.

Quoted 6 lines
Quoted 2 lines

Well, the "lowest valid Revision ID" does not generally mean the "only valid Revision ID".

True, but why should the kernel change from using the tested revision ID to some other revision ID? What would be the benefit of using rev 5?

TBH I'm not exactly buying the "tested revision ID" concept because what does it really mean?

If a given _DSM interface has been tested on one platform, does it necessarily mean that it will work on all of the other platforms implementing it?

Quoted 28 lines

PCI Firmware r3.3 does contain a statement that "OSPM must invoke all Functions other than Function 0 with the same Revision ID value," but IMO that was a mistake, and we just approved an ECR to remove it.

Quoted 4 lines
Quoted 3 lines

My argument is that the spec documents rev 4, the kernel code was tested with rev 4, so what would be the benefit of using a different revision here?

Quoted 8 lines

I'm talking about using a symbol to represent the number 4, not about possibly using a different number, along the lines of using, say, ACPI_FADT_LOW_POWER_S0 instead of putting BIT(21) directly into the code.

The value is not likely to change, but using a symbol for representing it has merit (it can be meaningfully used in searches, it can be documented etc.).

DSM_PCI_PERST_ASSERTION_DELAY (the function number) is a great thing to search for. I doubt a symbol for "4" would really add anything. At least in PCI, changes to a particular _DSM function are relatively rare.

Quoted 5 lines

Now, I'm not sure how likely it is for the PCI Firmware spec to bump up the revision of this interface (I suppose that it will do so if a new function is defined), but even if it does so, the kernel will have to check both the new revision and rev 4 anyway, in case the firmware doesn't know about the new revision.

Quoted 4 lines

I guess the reason the OS would check both rev 5 and rev 4 would be that a new platform might implement DSM_PCI_PERST_ASSERTION_DELAY only at rev 5? I think this would be a real mistake in terms of implementing something to the spec.

This is a real possibility, however, because there's nothing to prevent this kind of spec interpretation.

I didn't mean this, though.

Say the kernel wants to use a function that is only defined at rev 5. It will invoke function 0 at rev 5 to see if this function is available, but then it may as well see if the other functions it wants to use are available at rev 5 because it will get this information from the same _DSM call. If the platform firmware responds that they all are implemented, why won't the kernel use them all at rev 5?

Quoted 11 lines

The spec documents DSM_PCI_PERST_ASSERTION_DELAY rev 4. Some platforms implemented and tested DSM_PCI_PERST_ASSERTION_DELAY rev 4. Linux added and tested support for DSM_PCI_PERST_ASSERTION_DELAY rev
4. I propose new platforms should also implement and test DSM_PCI_PERST_ASSERTION_DELAY rev 4.

If a new platform implements only DSM_PCI_PERST_ASSERTION_DELAY rev 5, there is no actual documentation for that rev other than the spec assertion that "rev 5 must support all functions defined by previous revs of the UUID." IMO this is nonsense. The platform might have no need to implement all the functions defined for the UUID.

Sure. That's why function 0 should always be used.

Quoted 5 lines

Even if the platform makes all its functions valid for "the lowest valid Revision ID" through the "current Revision ID", there's nothing other than the spec assertion to guarantee that they all behave the same. And dealing with multiple revisions that are "supposed" to be the same just makes work and risk for the OS.

You seem to be questioning the interface versioning at large by saying that there is no real guarantee of backwards compatibility between consecutive interface revisions on the same platform.

Presumably, though, the interface is adhering to some specification which defines the behavior of the functions (and the set of available functions in the first place) for all of the valid revisions of it. The OS and the platform firmware both follow the same spec and so they should be mutually compatible. If this particular spec defines rev 5 to be an exact superset of rev 4, there is no reason to expect anything else.

#13 lore raw

Re: [PATCH 02/12] PCI/ACPI: Add PERST# Assertion Delay _DSM method

Quoted 46 lines · Rafael J. Wysocki
Quoted 38 lines · Bjorn Helgaas
Quoted 37 lines · Rafael J. Wysocki
Quoted 35 lines · Bjorn Helgaas
Quoted 26 lines · Rafael J. Wysocki
Quoted 11 lines · Anshuman Gupta

Implement _DSM Method 11 as per PCI firmware specs section 4.6.11 Rev 3.3.

drivers/pci/pci-acpi.c +7 -0
+int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
+{
+       union acpi_object in_obj = {
+               .integer.type = ACPI_TYPE_INTEGER,
+               .integer.value = delay_us,
+       };
+

drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power) · line 1529

Quoted 10 lines
drivers/pci/pci-acpi.c +10 -0
+       union acpi_object *out_obj;
+       acpi_handle handle;
+       int result, ret = -EINVAL;
+
+       if (!dev || !ACPI_HANDLE(&dev->dev))
+               return -EINVAL;
+
+       handle = ACPI_HANDLE(&dev->dev);
+
+       out_obj = acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, 4,

This is something I haven't noticed in the previous patch, but also applies to it.

Quoted 1 line

Why is rev 4 of the interface hard-coded here?

Thanks for asking this because it's related to the whole _DSM revision question that I don't understand.

If we didn't use rev 4 here, what should we use? The PCI Firmware spec, r3.3, sec 4.6.11, documents this interface and says "lowest valid Revision ID value is 4", so that's the source of the 4.

Quoted 6 lines
Quoted 2 lines

Well, the "lowest valid Revision ID" does not generally mean the "only valid Revision ID".

True, but why should the kernel change from using the tested revision ID to some other revision ID? What would be the benefit of using rev 5?

Quoted 6 lines

TBH I'm not exactly buying the "tested revision ID" concept because what does it really mean?

If a given _DSM interface has been tested on one platform, does it necessarily mean that it will work on all of the other platforms implementing it?

No, all we can say is that this OS rev 4 code works on the platforms we've tested. Other platforms might have their own defects.

My point is that this OS code was written to the rev 4 spec and has been tested, and we shouldn't change the code or the revision it uses unless we're fixing something.

Quoted 17 lines
Quoted 11 lines
Quoted 6 lines

Now, I'm not sure how likely it is for the PCI Firmware spec to bump up the revision of this interface (I suppose that it will do so if a new function is defined), but even if it does so, the kernel will have to check both the new revision and rev 4 anyway, in case the firmware doesn't know about the new revision.

I guess the reason the OS would check both rev 5 and rev 4 would be that a new platform might implement DSM_PCI_PERST_ASSERTION_DELAY only at rev 5? I think this would be a real mistake in terms of implementing something to the spec.

This is a real possibility, however, because there's nothing to prevent this kind of spec interpretation.

I didn't mean this, though.

Quoted 7 lines

Say the kernel wants to use a function that is only defined at rev
5. It will invoke function 0 at rev 5 to see if this function is available, but then it may as well see if the other functions it wants to use are available at rev 5 because it will get this information from the same _DSM call. If the platform firmware responds that they all are implemented, why won't the kernel use them all at rev 5?

This is an unnecessary change, since the OS tested its rev 4 code and now we're saying the OS should use rev 5 instead, which the OS did not test. The reason rev 5 exists at all is probably that some completely unrelated new function was added, and somebody decided it should be rev 5.

I guess function 0 *could* have been defined to answer "yes/no" about whether a single (function, revision) is implemented. Then we probably wouldn't be having this conversation.

But we do get an entire bitmask of implemented functions back from function 0, which allows the possibility of using the same revision for all the functions. I suppose we could have a boot-time function that calls function 0 with rev 0, 1, 2, ..., until it gets an empty bitmask, and saves the highest rev with a non-empty mask.

In PCI we don't do that; instead, we call acpi_check_dsm() before every acpi_evaluate_dsm(). The main reason is that I don't think it's safe to change the function X rev just because function Y was added later with a higher revision.

Quoted 7 lines
Quoted 7 lines

The spec documents DSM_PCI_PERST_ASSERTION_DELAY rev 4. Some platforms implemented and tested DSM_PCI_PERST_ASSERTION_DELAY rev
4. Linux added and tested support for DSM_PCI_PERST_ASSERTION_DELAY rev 4. I propose new platforms should also implement and test DSM_PCI_PERST_ASSERTION_DELAY rev 4.

Quoted 8 lines
Quoted 6 lines

If a new platform implements only DSM_PCI_PERST_ASSERTION_DELAY rev 5, there is no actual documentation for that rev other than the spec assertion that "rev 5 must support all functions defined by previous revs of the UUID." IMO this is nonsense. The platform might have no need to implement all the functions defined for the UUID.

Sure. That's why function 0 should always be used.

Yes. But the requirement that rev 5 must support all functions ever previously documented for the UUID still makes no sense to me. I don't think there's any requirement that a platform implement ALL of the documented PCI functions.

Maybe the intent is that this only applies to a given platform, i.e., that new firmware for that platform must continue to support all functions and revisions that were ever supported on that platform? That seems obvious to me and hardly worth mentioning.

Quoted 9 lines
Quoted 5 lines

Even if the platform makes all its functions valid for "the lowest valid Revision ID" through the "current Revision ID", there's nothing other than the spec assertion to guarantee that they all behave the same. And dealing with multiple revisions that are "supposed" to be the same just makes work and risk for the OS.

You seem to be questioning the interface versioning at large by saying that there is no real guarantee of backwards compatibility between consecutive interface revisions on the same platform.

That's exactly what I'm saying, although I think problems are more likely across different platforms. There's the requirement in the spec, but that's just words on a page. There's no way to enforce or validate it.

Quoted 7 lines

Presumably, though, the interface is adhering to some specification which defines the behavior of the functions (and the set of available functions in the first place) for all of the valid revisions of it. The OS and the platform firmware both follow the same spec and so they should be mutually compatible. If this particular spec defines rev 5 to be an exact superset of rev 4, there is no reason to expect anything else.

I don't *expect* rev 5 to be different. But as a user of it, why would I change working, tested code that is not broken?

The PCI DPC function 0xc is an example where rev 5 (per ECN) and rev 6 (per r3.3) are not compatible.

If the OS implemented rev 5, then learns via function 0 that function 0xc is also supported at rev 6, and starts using the same OS code with rev 6, the OS is broken.

Bjorn

#14 lore raw

Re: [PATCH 02/12] PCI/ACPI: Add PERST# Assertion Delay _DSM method

Quoted 55 lines · Bjorn Helgaas
Quoted 46 lines · Rafael J. Wysocki
Quoted 38 lines · Bjorn Helgaas
Quoted 37 lines · Rafael J. Wysocki
Quoted 35 lines · Bjorn Helgaas
Quoted 26 lines · Rafael J. Wysocki
Quoted 11 lines · Anshuman Gupta

Implement _DSM Method 11 as per PCI firmware specs section 4.6.11 Rev 3.3.

(quoted diff) +7 -0
+int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
+{
+       union acpi_object in_obj = {
+               .integer.type = ACPI_TYPE_INTEGER,
+               .integer.value = delay_us,
+       };
+

Review

Quoted 10 lines
(quoted diff) +10 -0
+       union acpi_object *out_obj;
+       acpi_handle handle;
+       int result, ret = -EINVAL;
+
+       if (!dev || !ACPI_HANDLE(&dev->dev))
+               return -EINVAL;
+
+       handle = ACPI_HANDLE(&dev->dev);
+
+       out_obj = acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, 4,

This is something I haven't noticed in the previous patch, but also applies to it.

Quoted 1 line

Why is rev 4 of the interface hard-coded here?

Thanks for asking this because it's related to the whole _DSM revision question that I don't understand.

If we didn't use rev 4 here, what should we use? The PCI Firmware spec, r3.3, sec 4.6.11, documents this interface and says "lowest valid Revision ID value is 4", so that's the source of the 4.

Quoted 6 lines
Quoted 2 lines

Well, the "lowest valid Revision ID" does not generally mean the "only valid Revision ID".

True, but why should the kernel change from using the tested revision ID to some other revision ID? What would be the benefit of using rev 5?

Quoted 6 lines

TBH I'm not exactly buying the "tested revision ID" concept because what does it really mean?

If a given _DSM interface has been tested on one platform, does it necessarily mean that it will work on all of the other platforms implementing it?

Quoted 6 lines

No, all we can say is that this OS rev 4 code works on the platforms we've tested. Other platforms might have their own defects.

My point is that this OS code was written to the rev 4 spec and has been tested, and we shouldn't change the code or the revision it uses unless we're fixing something.

Well, if the spec says "rev 5 is the same as rev 4 except for function Y which is new in rev 5", then arguably the same OS code is also compliant with rev 5 (it will not use function Y, but that's fine).

If the platform firmware follows the same spec, then the rev 5 implementation in it can be expected to work exactly as its rev 4 implementation either.

I see no problem with using rev 5 instead of rev 4 in that case and nn new platforms, rev 5 is just as risky as rev 4.

Quoted 25 lines
Quoted 17 lines
Quoted 11 lines
Quoted 6 lines

Now, I'm not sure how likely it is for the PCI Firmware spec to bump up the revision of this interface (I suppose that it will do so if a new function is defined), but even if it does so, the kernel will have to check both the new revision and rev 4 anyway, in case the firmware doesn't know about the new revision.

I guess the reason the OS would check both rev 5 and rev 4 would be that a new platform might implement DSM_PCI_PERST_ASSERTION_DELAY only at rev 5? I think this would be a real mistake in terms of implementing something to the spec.

This is a real possibility, however, because there's nothing to prevent this kind of spec interpretation.

I didn't mean this, though.

Quoted 7 lines

Say the kernel wants to use a function that is only defined at rev
5. It will invoke function 0 at rev 5 to see if this function is available, but then it may as well see if the other functions it wants to use are available at rev 5 because it will get this information from the same _DSM call. If the platform firmware responds that they all are implemented, why won't the kernel use them all at rev 5?

Quoted 3 lines

This is an unnecessary change, since the OS tested its rev 4 code and now we're saying the OS should use rev 5 instead, which the OS did not test.

Yes, it did. It is the same code, as per the above.

Quoted 14 lines

The reason rev 5 exists at all is probably that some completely unrelated new function was added, and somebody decided it should be rev 5.

I guess function 0 *could* have been defined to answer "yes/no" about whether a single (function, revision) is implemented. Then we probably wouldn't be having this conversation.

But we do get an entire bitmask of implemented functions back from function 0, which allows the possibility of using the same revision for all the functions. I suppose we could have a boot-time function that calls function 0 with rev 0, 1, 2, ..., until it gets an empty bitmask, and saves the highest rev with a non-empty mask.

Quoted 4 lines

In PCI we don't do that; instead, we call acpi_check_dsm() before every acpi_evaluate_dsm(). The main reason is that I don't think it's safe to change the function X rev just because function Y was added later with a higher revision.

So what if there is a platform that only implements revisions greater than X?

Presumably, there is another OS targeted by this platform that only uses revisions X+1 and forward.

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines

The spec documents DSM_PCI_PERST_ASSERTION_DELAY rev 4. Some platforms implemented and tested DSM_PCI_PERST_ASSERTION_DELAY rev
4. Linux added and tested support for DSM_PCI_PERST_ASSERTION_DELAY rev 4. I propose new platforms should also implement and test DSM_PCI_PERST_ASSERTION_DELAY rev 4.

If a new platform implements only DSM_PCI_PERST_ASSERTION_DELAY rev 5, there is no actual documentation for that rev other than the spec assertion that "rev 5 must support all functions defined by previous revs of the UUID." IMO this is nonsense. The platform might have no need to implement all the functions defined for the UUID.

Quoted 6 lines
Quoted 1 line

Sure. That's why function 0 should always be used.

Yes. But the requirement that rev 5 must support all functions ever previously documented for the UUID still makes no sense to me. I don't think there's any requirement that a platform implement ALL of the documented PCI functions.

I think that there is some confusion in the spec language that seems to be conflating platforms with interface definitions.

It ostensibly wants the definitions of subsequent revisions of the same interface to be consistent with each other, which is not a bad thing in principle IMV, but at the same time it ostensibly allows platforms to choose which functions to implement, and it doesn't say anything about the expected behavior when the OS attempts to use a function that is not implemented for a given rev.

You are right that the backward compatibility language in the _DSM definition is not enforceable, but it can be regarded as a guidance:
Do not change the interface that you have once defined arbitrarily between revisions. After all, if you don't like this guidance, you can just allocate a new UUID and define a new interface based on it.

Anyway, I'm not the author of this piece of the specification, so I don't really know the original intent, and it is not sufficiently clear.

Quoted 31 lines

Maybe the intent is that this only applies to a given platform, i.e., that new firmware for that platform must continue to support all functions and revisions that were ever supported on that platform? That seems obvious to me and hardly worth mentioning.

Quoted 9 lines
Quoted 5 lines

Even if the platform makes all its functions valid for "the lowest valid Revision ID" through the "current Revision ID", there's nothing other than the spec assertion to guarantee that they all behave the same. And dealing with multiple revisions that are "supposed" to be the same just makes work and risk for the OS.

You seem to be questioning the interface versioning at large by saying that there is no real guarantee of backwards compatibility between consecutive interface revisions on the same platform.

That's exactly what I'm saying, although I think problems are more likely across different platforms. There's the requirement in the spec, but that's just words on a page. There's no way to enforce or validate it.

Quoted 7 lines

Presumably, though, the interface is adhering to some specification which defines the behavior of the functions (and the set of available functions in the first place) for all of the valid revisions of it. The OS and the platform firmware both follow the same spec and so they should be mutually compatible. If this particular spec defines rev 5 to be an exact superset of rev 4, there is no reason to expect anything else.

I don't *expect* rev 5 to be different. But as a user of it, why would I change working, tested code that is not broken?

Quoted 6 lines

The PCI DPC function 0xc is an example where rev 5 (per ECN) and rev 6 (per r3.3) are not compatible.

If the OS implemented rev 5, then learns via function 0 that function 0xc is also supported at rev 6, and starts using the same OS code with rev 6, the OS is broken.

Yes, in this case the backward compatibility language in the _DSM definition is obviously not followed.

#15 lore raw

Re: [PATCH 02/12] PCI/ACPI: Add PERST# Assertion Delay _DSM method

Quoted 8 lines · Rafael J. Wysocki
Quoted 6 lines · Bjorn Helgaas

I don't *expect* rev 5 to be different. But as a user of it, why would I change working, tested code that is not broken?

The PCI DPC function 0xc is an example where rev 5 (per ECN) and rev 6 (per r3.3) are not compatible.

Quoted 6 lines
Quoted 3 lines

If the OS implemented rev 5, then learns via function 0 that function 0xc is also supported at rev 6, and starts using the same OS code with rev 6, the OS is broken.

Yes, in this case the backward compatibility language in the _DSM definition is obviously not followed.

Rev 5 in the ECN isn't compatible with rev 6 in the PCI FW r3.3 spec, so it doesn't follow the ACPI compatibility requirement. And this is documented in PCI FW, which says "Fn 0xC was added with rev 5 (see ECN for rev 5 details); here is how rev 6 works."

An OS implemented to the ECN doesn't know that rev 6 is different from rev 5; it assumes they're the same because ACPI says we can assume that, and PCI FW r3.3 even says the OS should use the same rev for all functions. If OS adds support for rev 6 of a some other function, it is supposed to use rev 6 of Fn 0xC, which doesn't work as the OS expects.

I guess one could argue that "OS didn't add rev 6 support for anything until PCI FW r3.3 added a function at rev 6, r3.3 did mention the difference between Fn 0xC rev 5 and 6, and OS should have looked at all the already-implemented unrelated functions for possible changes between rev 5 and rev 6."

I think that causes unnecessary changes in unrelated code. The OS can avoid the problem by *always* using Fn 0xC rev 5, regardless of what rev it uses for other functions.

Of course, the OS can include support for multiple revs, e.g., it could add support for Fn 0xC rev 6 and use that when available. And it could retain support for Fn 0xC rev 5 and use that if rev 6 isn't available.

Bjorn

#16 lore raw

Re: [PATCH 02/12] PCI/ACPI: Add PERST# Assertion Delay _DSM method

Quoted 22 lines · Bjorn Helgaas
Quoted 8 lines · Rafael J. Wysocki
Quoted 6 lines · Bjorn Helgaas

I don't *expect* rev 5 to be different. But as a user of it, why would I change working, tested code that is not broken?

The PCI DPC function 0xc is an example where rev 5 (per ECN) and rev 6 (per r3.3) are not compatible.

Quoted 6 lines
Quoted 3 lines

If the OS implemented rev 5, then learns via function 0 that function 0xc is also supported at rev 6, and starts using the same OS code with rev 6, the OS is broken.

Yes, in this case the backward compatibility language in the _DSM definition is obviously not followed.

Rev 5 in the ECN isn't compatible with rev 6 in the PCI FW r3.3 spec, so it doesn't follow the ACPI compatibility requirement. And this is documented in PCI FW, which says "Fn 0xC was added with rev 5 (see ECN for rev 5 details); here is how rev 6 works."

Quoted 4 lines

An OS implemented to the ECN doesn't know that rev 6 is different from rev 5; it assumes they're the same because ACPI says we can assume that, and PCI FW r3.3 even says the OS should use the same rev for all functions.

OK (and this is important because PCI FW r3.3 is the spec defining the interface)

Quoted 2 lines

If OS adds support for rev 6 of a some other function, it is supposed to use rev 6 of Fn 0xC, which doesn't work as the OS expects.

IMV with respect to _DSM, the spec that has defined the interface (PCI FW r3.3) takes precedence over the ACPI spec regardless of what the latter is saying. In this case ACPI provides a framework the interface can be based on, but the actual interface is not defined by it.

Also, I think that the OS should use rev 6 if it is supported by the firmware (for all functions) and it should literally follow the definition of rev 6.

If rev 6 is not supported (or some functions needed by the OS are not implemented by the firmware), it should fall back to rev 5 and in this case it should literally follow the definition of rev 5.

And so on.

Quoted 5 lines

I guess one could argue that "OS didn't add rev 6 support for anything until PCI FW r3.3 added a function at rev 6, r3.3 did mention the difference between Fn 0xC rev 5 and 6, and OS should have looked at all the already-implemented unrelated functions for possible changes between rev 5 and rev 6."

Yes, it should.

Quoted 3 lines

I think that causes unnecessary changes in unrelated code. The OS can avoid the problem by *always* using Fn 0xC rev 5, regardless of what rev it uses for other functions.

What if the functions on the firmware side depend on each other interfally and the firmware gets confused if revisions are mixed up on the OS side?

Since PCI FW r3.3 says that the OS should use the same rev for all functions, that's what it should do because the firmware may reasonably assume that it will.

Quoted 4 lines

Of course, the OS can include support for multiple revs, e.g., it could add support for Fn 0xC rev 6 and use that when available. And it could retain support for Fn 0xC rev 5 and use that if rev 6 isn't available.

That's what I mean basically.

In practice, the OS needs to assume that the firmware may not implement a certain rev and so it needs to support other revisions anyway.

#17 lore raw

Re: [PATCH 02/12] PCI/ACPI: Add PERST# Assertion Delay _DSM method

Quoted 40 lines · Rafael J. Wysocki
Quoted 21 lines · Bjorn Helgaas
Quoted 8 lines · Rafael J. Wysocki
Quoted 6 lines · Bjorn Helgaas

I don't *expect* rev 5 to be different. But as a user of it, why would I change working, tested code that is not broken?

The PCI DPC function 0xc is an example where rev 5 (per ECN) and rev 6 (per r3.3) are not compatible.

Quoted 6 lines
Quoted 3 lines

If the OS implemented rev 5, then learns via function 0 that function 0xc is also supported at rev 6, and starts using the same OS code with rev 6, the OS is broken.

Yes, in this case the backward compatibility language in the _DSM definition is obviously not followed.

Rev 5 in the ECN isn't compatible with rev 6 in the PCI FW r3.3 spec, so it doesn't follow the ACPI compatibility requirement. And this is documented in PCI FW, which says "Fn 0xC was added with rev 5 (see ECN for rev 5 details); here is how rev 6 works."

Quoted 4 lines

An OS implemented to the ECN doesn't know that rev 6 is different from rev 5; it assumes they're the same because ACPI says we can assume that, and PCI FW r3.3 even says the OS should use the same rev for all functions.

OK (and this is important because PCI FW r3.3 is the spec defining the interface)

Quoted 3 lines

If OS adds support for rev 6 of a some other function, it is supposed to use rev 6 of Fn 0xC, which doesn't work as the OS expects.

IMV with respect to _DSM, the spec that has defined the interface (PCI FW r3.3) takes precedence over the ACPI spec regardless of what the latter is saying. In this case ACPI provides a framework the interface can be based on, but the actual interface is not defined by it.

Quoted 3 lines

Also, I think that the OS should use rev 6 if it is supported by the firmware (for all functions) and it should literally follow the definition of rev 6.

I think you interpret rev 6 as a global revision of the platform, i.e., the platform supports rev 6 for every function it implements in this UUID (which is clearly the intent of the ACPI ASL example).

I suggest that it would be better to interpret the revision individually for each function because it removes the backwards compatibility assumption and reduces the testing burden.

Most functions would be specified and implemented with rev 0, and would never have a rev 1. There would only be a rev 1 of a function if we made a non backwards compatible change to it.

Any other functions would be untouched, and they would still only support rev 0, not rev 1.

Quoted 7 lines
Quoted 5 lines

I guess one could argue that "OS didn't add rev 6 support for anything until PCI FW r3.3 added a function at rev 6, r3.3 did mention the difference between Fn 0xC rev 5 and 6, and OS should have looked at all the already-implemented unrelated functions for possible changes between rev 5 and rev 6."

Yes, it should.

I don't think it's reasonable to require the person adding support for Fn 0xE rev 6 (TLP Processing Hints) to go back and add Fn 0xC rev 6 (Downstream Port Containment) at the same time.

Assuming that "rev X works the same as rev X-1 and therefore rev X doesn't need to be tested" seems unwise to me. But even if we normally rely on that assumption, in this case Fn 0xC rev 5 and rev 6 are different, so we'd be adding new code that would require testing on every platform that supports rev 6 of any function.

Quoted 3 lines

What if the functions on the firmware side depend on each other interfally and the firmware gets confused if revisions are mixed up on the OS side?

In such a case, the backwards compatibility assumption doesn't apply to those functions, so the spec would have to document multiple revisions of them, and IMO that's the natural place to document a requirement to use the same revision for the set.

Bjorn

#18 lore raw

Re: [PATCH 02/12] PCI/ACPI: Add PERST# Assertion Delay _DSM method

Quoted 42 lines · Bjorn Helgaas
Quoted 40 lines · Rafael J. Wysocki
Quoted 21 lines · Bjorn Helgaas
Quoted 8 lines · Rafael J. Wysocki
Quoted 6 lines · Bjorn Helgaas

I don't *expect* rev 5 to be different. But as a user of it, why would I change working, tested code that is not broken?

The PCI DPC function 0xc is an example where rev 5 (per ECN) and rev 6 (per r3.3) are not compatible.

Quoted 6 lines
Quoted 3 lines

If the OS implemented rev 5, then learns via function 0 that function 0xc is also supported at rev 6, and starts using the same OS code with rev 6, the OS is broken.

Yes, in this case the backward compatibility language in the _DSM definition is obviously not followed.

Rev 5 in the ECN isn't compatible with rev 6 in the PCI FW r3.3 spec, so it doesn't follow the ACPI compatibility requirement. And this is documented in PCI FW, which says "Fn 0xC was added with rev 5 (see ECN for rev 5 details); here is how rev 6 works."

Quoted 4 lines

An OS implemented to the ECN doesn't know that rev 6 is different from rev 5; it assumes they're the same because ACPI says we can assume that, and PCI FW r3.3 even says the OS should use the same rev for all functions.

OK (and this is important because PCI FW r3.3 is the spec defining the interface)

Quoted 3 lines

If OS adds support for rev 6 of a some other function, it is supposed to use rev 6 of Fn 0xC, which doesn't work as the OS expects.

IMV with respect to _DSM, the spec that has defined the interface (PCI FW r3.3) takes precedence over the ACPI spec regardless of what the latter is saying. In this case ACPI provides a framework the interface can be based on, but the actual interface is not defined by it.

Quoted 7 lines
Quoted 3 lines

Also, I think that the OS should use rev 6 if it is supported by the firmware (for all functions) and it should literally follow the definition of rev 6.

I think you interpret rev 6 as a global revision of the platform, i.e., the platform supports rev 6 for every function it implements in this UUID (which is clearly the intent of the ACPI ASL example).

Yes, I do.

Quoted 10 lines

I suggest that it would be better to interpret the revision individually for each function because it removes the backwards compatibility assumption and reduces the testing burden.

Most functions would be specified and implemented with rev 0, and would never have a rev 1. There would only be a rev 1 of a function if we made a non backwards compatible change to it.

Any other functions would be untouched, and they would still only support rev 0, not rev 1.

I think that it would just be confusing because both the OS and the firmware would now have to remember which function is defined at which revision.

Also the industry practice in this respect has been different so far, AFAICS.

And PCI FW r3.3 wants the OS to use the same rev for all functions which doesn't leave too much room for interpretation.

Quoted 11 lines
Quoted 7 lines
Quoted 5 lines

I guess one could argue that "OS didn't add rev 6 support for anything until PCI FW r3.3 added a function at rev 6, r3.3 did mention the difference between Fn 0xC rev 5 and 6, and OS should have looked at all the already-implemented unrelated functions for possible changes between rev 5 and rev 6."

Yes, it should.

I don't think it's reasonable to require the person adding support for Fn 0xE rev 6 (TLP Processing Hints) to go back and add Fn 0xC rev 6 (Downstream Port Containment) at the same time.

Well, if you know that the function is supposed to work the same in the new rev, it only is a matter of changing the rev passed to acpi_evaluate_dsm*().

Quoted 2 lines

Assuming that "rev X works the same as rev X-1 and therefore rev X doesn't need to be tested" seems unwise to me.

So say you've only changed the rev passed to acpi_evaluate_dsm*() as per the above. The only reason why it may not work is when there is a bug in the firmware.

Now, suppose that you don't change anything and stick to rev X-1, but there is a new version of the firmware that contains a bug in the given _DSM implementation. Same thing.

I get the "only the tested code is trustable" argument, but its applicability here is naturally limited.

Quoted 3 lines

But even if we normally rely on that assumption, in this case Fn 0xC rev 5 and rev 6 are different, so we'd be adding new code that would require testing on every platform that supports rev 6 of any function.

Unfortunately, as far as OS-firmware interfaces are concerned, you need to trust the other end to do the right thing because you cannot test all of the possible combinations.

Quoted 8 lines
Quoted 3 lines

What if the functions on the firmware side depend on each other interfally and the firmware gets confused if revisions are mixed up on the OS side?

In such a case, the backwards compatibility assumption doesn't apply to those functions, so the spec would have to document multiple revisions of them, and IMO that's the natural place to document a requirement to use the same revision for the set.

I'm not talking about the definition of the interface, but about dependencies at the implementation level.

Given the PCI FW r3.3 provisions, firmware may assume that the OS will use the same rev for all functions and it may depend on that.

#19 lore raw

PATCH 3/12 PCI/ACPI: Add aux power grant notifier

In reply to Anshuman Gupta

Adding a notifier to notify all PCIe child devices about the block main power removal. It is needed because theoretically multiple PCIe Endpoint devices on same Root Port can request for AUX power and _DSM method can return with 80000000h signifies that the hierarchy connected via the slot cannot support main power removal when in D3Cold. This may disrupt functionality of other child device.

Let's notify all PCIe devices requested Aux power resource and Let PCIe End Point driver handle it in its callback.

---
 drivers/pci/pci-acpi.c   | 34 +++++++++++++++++++++++++++++++---
 include/linux/pci-acpi.h | 13 +++++++++++++
 2 files changed, 44 insertions(+), 3 deletions(-)
drivers/pci/pci-acpi.c +31 -3
index 04149f037664..d1ca1649e6e8 100644
@@ -1421,6 +1421,32 @@ static void pci_acpi_optimize_delay(struct pci_dev *pdev,
 	ACPI_FREE(obj);
 }
 
+static BLOCKING_NOTIFIER_HEAD(pci_acpi_aux_power_notify_list);
+
+/**
+ * pci_acpi_register_aux_power_notifier - Register driver notifier
+ * @nb: notifier block
+ *
+ * This function shall be called by PCIe End Point device requested the Aux
+ * power resource in order to handle the any scenario gracefully when other
+ * child PCIe devices Aux power request returns with No main power removal.
+ * PCIe devices which register this notifier shall handle No main power
+ * removal scenario accordingly.
+ *
+ * Return: Returns 0 on success and errno on failure.
+ */
+int pci_acpi_register_aux_power_notifier(struct notifier_block *nb)
+{
+	return blocking_notifier_chain_register(&pci_acpi_aux_power_notify_list, nb);
+}
+EXPORT_SYMBOL_GPL(pci_acpi_register_aux_power_notifier);
+
+void pci_acpi_unregister_aux_power_notifier(struct notifier_block *nb)
+{
+	blocking_notifier_chain_unregister(&pci_acpi_aux_power_notify_list, nb);
+}
+EXPORT_SYMBOL_GPL(pci_acpi_unregister_aux_power_notifier);
+
 /**
  * pci_acpi_request_d3cold_aux_power - Request D3cold aux power via ACPI DSM
  * @dev: PCI device instance
@@ -1466,17 +1492,19 @@ int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
 	result = out_obj->integer.value;
 
 	switch (result) {
-	case 0x0:
+	case ACPI_AUX_PW_DENIED:
 		dev_dbg(&dev->dev, "D3cold Aux Power %umW request denied\n",
 			requested_power);
 		break;
-	case 0x1:
+	case ACPI_AUX_PW_GRANTED:
 		dev_info(&dev->dev, "D3cold Aux Power request granted: %umW\n",
 			 requested_power);
 		ret = 0;
 		break;
-	case 0x2:
+	case ACPI_NO_MAIN_PW_REMOVAL:
 		dev_info(&dev->dev, "D3cold Aux Power: Main power won't be removed\n");
+		blocking_notifier_call_chain(&pci_acpi_aux_power_notify_list,
+					     ACPI_NO_MAIN_PW_REMOVAL, dev);
 		ret = -EBUSY;
 		break;
 	default:
include/linux/pci-acpi.h +13 -0
index 4b7373f91a9a..793b979af98b 100644
@@ -124,6 +124,10 @@ extern const guid_t pci_acpi_dsm_guid;
 #define DSM_PCI_D3COLD_AUX_POWER_LIMIT		0x0A
 #define DSM_PCI_PERST_ASSERTION_DELAY		0x0B
 
+#define ACPI_AUX_PW_DENIED			0x0
+#define ACPI_AUX_PW_GRANTED			0x1
+#define ACPI_NO_MAIN_PW_REMOVAL			0x2
+
 #ifdef CONFIG_PCIE_EDR
 void pci_acpi_add_edr_notifier(struct pci_dev *pdev);
 void pci_acpi_remove_edr_notifier(struct pci_dev *pdev);
@@ -134,12 +138,21 @@ static inline void pci_acpi_remove_edr_notifier(struct pci_dev *pdev) { }
 
 int pci_acpi_set_companion_lookup_hook(struct acpi_device *(*func)(struct pci_dev *));
 void pci_acpi_clear_companion_lookup_hook(void);
+int pci_acpi_register_aux_power_notifier(struct notifier_block *nb);
+void pci_acpi_unregister_aux_power_notifier(struct notifier_block *nb);
 int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power);
 int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us);
 
 #else	/* CONFIG_ACPI */
 static inline void acpi_pci_add_bus(struct pci_bus *bus) { }
 static inline void acpi_pci_remove_bus(struct pci_bus *bus) { }
+int pci_acpi_register_aux_power_notifier(struct notifier_block *nb)
+{
+	return -EOPNOTSUPP;
+}
+
+void pci_acpi_unregister_aux_power_notifier(struct notifier_block *nb) { }
+
 int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
 {
 	return -EOPNOTSUPP;
Signature · 1 line
2.43.0
#20 lore raw

Re: [PATCH 03/12] PCI/ACPI: Add aux power grant notifier

Quoted 6 lines · Anshuman Gupta

Adding a notifier to notify all PCIe child devices about the block main power removal. It is needed because theoretically multiple PCIe Endpoint devices on same Root Port can request for AUX power and _DSM method can return with 80000000h signifies that the hierarchy connected via the slot cannot support main power removal when in D3Cold.

I wish the spec used different language here. "D3cold" *means* "main power is removed" (PCIe r6.0, sec 5.3.1.4.2), so it doesn't make sense to say that "the slot cannot support main power removal when in D3cold". If a device is in D3cold, its main power has been removed by definition.

I suppose the spec is trying to say if the driver has called this _DSM with 80000000h, it means the platform must not remove main power from the device while the system is in S0? Is that what you think it means?

The 2h return value description says it "indicates that the platform will not remove main power from the slot while the system is in S0," so I guess that must be it.

In this series, pci_acpi_aux_power_setup() only supplies a 16-bit aux_pwr_limit value, so the driver cannot *request* that the platform not remove main power.

So I guess the only scenario where the _DSM returns 80000000h is when the platform itself or other devices prevent the removal of main power. And the point of the notifier is to tell devices that their main power will never be removed while the system is in S0. Is that right?

Quoted 1 line

This may disrupt functionality of other child device.

What sort of disruption could happen? I would think that if the _DSM returns 80000000h, it just means the device will not have main power removed, so it won't see that power state transition. The only "disruption" would be that we're using more power.

Quoted 2 lines

Let's notify all PCIe devices requested Aux power resource and Let PCIe End Point driver handle it in its callback.

Wrap to fill 75 columns.

s/Adding/Add/
s/Let's notify/Notify/
s/and Let/and let/
s/End Point/Endpoint/ (several places here and below)

Quoted 15 lines
---
 drivers/pci/pci-acpi.c   | 34 +++++++++++++++++++++++++++++++---
 include/linux/pci-acpi.h | 13 +++++++++++++
 2 files changed, 44 insertions(+), 3 deletions(-)
drivers/pci/pci-acpi.c +1 -0
index 04149f037664..d1ca1649e6e8 100644
@@ -1421,6 +1421,32 @@ static void pci_acpi_optimize_delay(struct pci_dev *pdev,
 	ACPI_FREE(obj);
 }
 
+static BLOCKING_NOTIFIER_HEAD(pci_acpi_aux_power_notify_list);

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1434

Quoted 10 lines
drivers/pci/pci-acpi.c +10 -0
+
+/**
+ * pci_acpi_register_aux_power_notifier - Register driver notifier
+ * @nb: notifier block
+ *
+ * This function shall be called by PCIe End Point device requested the Aux
+ * power resource in order to handle the any scenario gracefully when other
+ * child PCIe devices Aux power request returns with No main power removal.
+ * PCIe devices which register this notifier shall handle No main power
+ * removal scenario accordingly.

This would actually be called by the *driver* (not by the device).

Reword in imperative mood if possible.

Quoted 19 lines
drivers/pci/pci-acpi.c +15 -0
+ *
+ * Return: Returns 0 on success and errno on failure.
+ */
+int pci_acpi_register_aux_power_notifier(struct notifier_block *nb)
+{
+	return blocking_notifier_chain_register(&pci_acpi_aux_power_notify_list, nb);
+}
+EXPORT_SYMBOL_GPL(pci_acpi_register_aux_power_notifier);
+
+void pci_acpi_unregister_aux_power_notifier(struct notifier_block *nb)
+{
+	blocking_notifier_chain_unregister(&pci_acpi_aux_power_notify_list, nb);
+}
+EXPORT_SYMBOL_GPL(pci_acpi_unregister_aux_power_notifier);
+
 /**
  * pci_acpi_request_d3cold_aux_power - Request D3cold aux power via ACPI DSM
  * @dev: PCI device instance

drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power) · line 1495

Quoted 5 lines
drivers/pci/pci-acpi.c +1 -1
@@ -1466,17 +1492,19 @@ int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
 	result = out_obj->integer.value;
 
 	switch (result) {
-	case 0x0:
+	case ACPI_AUX_PW_DENIED:

Add these constants in the patch that adds the _DSM. Then this patch will be just notifier-related code.

Quoted 57 lines
drivers/pci/pci-acpi.c +4 -2
 		dev_dbg(&dev->dev, "D3cold Aux Power %umW request denied\n",
 			requested_power);
 		break;
-	case 0x1:
+	case ACPI_AUX_PW_GRANTED:
 		dev_info(&dev->dev, "D3cold Aux Power request granted: %umW\n",
 			 requested_power);
 		ret = 0;
 		break;
-	case 0x2:
+	case ACPI_NO_MAIN_PW_REMOVAL:
 		dev_info(&dev->dev, "D3cold Aux Power: Main power won't be removed\n");
+		blocking_notifier_call_chain(&pci_acpi_aux_power_notify_list,
+					     ACPI_NO_MAIN_PW_REMOVAL, dev);
 		ret = -EBUSY;
 		break;
 	default:
include/linux/pci-acpi.h +13 -0
index 4b7373f91a9a..793b979af98b 100644
@@ -124,6 +124,10 @@ extern const guid_t pci_acpi_dsm_guid;
 #define DSM_PCI_D3COLD_AUX_POWER_LIMIT		0x0A
 #define DSM_PCI_PERST_ASSERTION_DELAY		0x0B
 
+#define ACPI_AUX_PW_DENIED			0x0
+#define ACPI_AUX_PW_GRANTED			0x1
+#define ACPI_NO_MAIN_PW_REMOVAL			0x2
+
 #ifdef CONFIG_PCIE_EDR
 void pci_acpi_add_edr_notifier(struct pci_dev *pdev);
 void pci_acpi_remove_edr_notifier(struct pci_dev *pdev);
@@ -134,12 +138,21 @@ static inline void pci_acpi_remove_edr_notifier(struct pci_dev *pdev) { }
 
 int pci_acpi_set_companion_lookup_hook(struct acpi_device *(*func)(struct pci_dev *));
 void pci_acpi_clear_companion_lookup_hook(void);
+int pci_acpi_register_aux_power_notifier(struct notifier_block *nb);
+void pci_acpi_unregister_aux_power_notifier(struct notifier_block *nb);
 int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power);
 int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us);
 
 #else	/* CONFIG_ACPI */
 static inline void acpi_pci_add_bus(struct pci_bus *bus) { }
 static inline void acpi_pci_remove_bus(struct pci_bus *bus) { }
+int pci_acpi_register_aux_power_notifier(struct notifier_block *nb)
+{
+	return -EOPNOTSUPP;
+}
+
+void pci_acpi_unregister_aux_power_notifier(struct notifier_block *nb) { }
+
 int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
 {
 	return -EOPNOTSUPP;
Signature · 1 line
2.43.0
#21 lore raw

Re: [PATCH 03/12] PCI/ACPI: Add aux power grant notifier

Quoted 65 lines · Bjorn Helgaas
Quoted 6 lines · Anshuman Gupta

Adding a notifier to notify all PCIe child devices about the block main power removal. It is needed because theoretically multiple PCIe Endpoint devices on same Root Port can request for AUX power and _DSM method can return with 80000000h signifies that the hierarchy connected via the slot cannot support main power removal when in D3Cold.

I wish the spec used different language here. "D3cold" *means* "main power is removed" (PCIe r6.0, sec 5.3.1.4.2), so it doesn't make sense to say that "the slot cannot support main power removal when in D3cold". If a device is in D3cold, its main power has been removed by definition.

I suppose the spec is trying to say if the driver has called this _DSM with 80000000h, it means the platform must not remove main power from the device while the system is in S0? Is that what you think it means?

The 2h return value description says it "indicates that the platform will not remove main power from the slot while the system is in S0," so I guess that must be it.

In this series, pci_acpi_aux_power_setup() only supplies a 16-bit aux_pwr_limit value, so the driver cannot *request* that the platform not remove main power.

So I guess the only scenario where the _DSM returns 80000000h is when the platform itself or other devices prevent the removal of main power. And the point of the notifier is to tell devices that their main power will never be removed while the system is in S0. Is that right?

Quoted 1 line

This may disrupt functionality of other child device.

What sort of disruption could happen? I would think that if the _DSM returns 80000000h, it just means the device will not have main power removed, so it won't see that power state transition. The only "disruption" would be that we're using more power.

Quoted 2 lines

Let's notify all PCIe devices requested Aux power resource and Let PCIe End Point driver handle it in its callback.

Wrap to fill 75 columns.

s/Adding/Add/
s/Let's notify/Notify/
s/and Let/and let/
s/End Point/Endpoint/ (several places here and below)

Quoted 14 lines
---
 drivers/pci/pci-acpi.c   | 34 +++++++++++++++++++++++++++++++---
 include/linux/pci-acpi.h | 13 +++++++++++++
 2 files changed, 44 insertions(+), 3 deletions(-)
drivers/pci/pci-acpi.c +0 -0
index 04149f037664..d1ca1649e6e8 100644
@@ -1421,6 +1421,32 @@ static void pci_acpi_optimize_delay(struct pci_dev *pdev,
      ACPI_FREE(obj);
 }
 
Quoted 13 lines

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1434

Quoted 11 lines
drivers/pci/pci-acpi.c +11 -0
+static BLOCKING_NOTIFIER_HEAD(pci_acpi_aux_power_notify_list);
+
+/**
+ * pci_acpi_register_aux_power_notifier - Register driver notifier
+ * @nb: notifier block
+ *
+ * This function shall be called by PCIe End Point device requested the Aux
+ * power resource in order to handle the any scenario gracefully when other
+ * child PCIe devices Aux power request returns with No main power removal.
+ * PCIe devices which register this notifier shall handle No main power
+ * removal scenario accordingly.

This would actually be called by the *driver* (not by the device).

Apart from this, there seems to be a design issue here because it won't notify every driver that has requested the Aux power, just the ones that have also registered notifiers.

So this appears to be an opt-in from getting notifications on Aux power request rejection responses to requests from other drivers requesting Aux power for the same Root Port, but the changelog of the first patch already claimed that the aggregation of requests was not supported. So if only one driver will be allowed to request the Aux power for the given Root Port, why would the notifiers be necessary after all?

#22 lore raw

RE: [PATCH 03/12] PCI/ACPI: Add aux power grant notifier

Quoted 82 lines

-----Original Message-----
From: Rafael J. Wysocki <[email protected]>
Sent: Wednesday, April 2, 2025 4:54 PM
To: Bjorn Helgaas <[email protected]>; Gupta, Anshuman <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; De Marchi, Lucas <[email protected]>; Vivi, Rodrigo <[email protected]>; Nilawar, Badal <[email protected]>; Gupta, Varun <[email protected]>; [email protected]; Shankar, Uma <[email protected]>
Subject: Re: [PATCH 03/12] PCI/ACPI: Add aux power grant notifier

Quoted 57 lines · Bjorn Helgaas
Quoted 6 lines · Anshuman Gupta

Adding a notifier to notify all PCIe child devices about the block main power removal. It is needed because theoretically multiple PCIe Endpoint devices on same Root Port can request for AUX power and _DSM method can return with 80000000h signifies that the hierarchy connected via the slot cannot support main power removal when in D3Cold.

I wish the spec used different language here. "D3cold" *means* "main power is removed" (PCIe r6.0, sec 5.3.1.4.2), so it doesn't make sense to say that "the slot cannot support main power removal when in D3cold". If a device is in D3cold, its main power has been removed by definition.

I suppose the spec is trying to say if the driver has called this _DSM with 80000000h, it means the platform must not remove main power from the device while the system is in S0? Is that what you think it means?

The 2h return value description says it "indicates that the platform will not remove main power from the slot while the system is in S0," so I guess that must be it.

In this series, pci_acpi_aux_power_setup() only supplies a 16-bit aux_pwr_limit value, so the driver cannot *request* that the platform not remove main power.

So I guess the only scenario where the _DSM returns 80000000h is when the platform itself or other devices prevent the removal of main power. And the point of the notifier is to tell devices that their main power will never be removed while the system is in S0. Is that right?

Quoted 1 line

This may disrupt functionality of other child device.

What sort of disruption could happen? I would think that if the _DSM returns 80000000h, it just means the device will not have main power removed, so it won't see that power state transition. The only "disruption" would be that we're using more power.

Quoted 2 lines

Let's notify all PCIe devices requested Aux power resource and Let PCIe End Point driver handle it in its callback.

Wrap to fill 75 columns.

s/Adding/Add/
s/Let's notify/Notify/
s/and Let/and let/
s/End Point/Endpoint/ (several places here and below)

Quoted 6 lines
---
 drivers/pci/pci-acpi.c   | 34 +++++++++++++++++++++++++++++++---
 include/linux/pci-acpi.h | 13 +++++++++++++
 2 files changed, 44 insertions(+), 3 deletions(-)
Quoted 5 lines

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct

Quoted 5 lines
drivers/pci/pci-acpi.c index renamed from drivers/pci/pci-acpi.c +0 -0

04149f037664..d1ca1649e6e8 100644

drivers/pci/pci-acpi.c +0 -0
@@ -1421,6 +1421,32 @@ static void pci_acpi_optimize_delay(struct

pci_dev *pdev,

Quoted 3 lines
Quoted 3 lines
drivers/pci/pci-acpi.c +0 -0
      ACPI_FREE(obj);
 }
 
Quoted 18 lines
Quoted 11 lines

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev,

Quoted 11 lines
drivers/pci/pci-acpi.c +11 -0
+static BLOCKING_NOTIFIER_HEAD(pci_acpi_aux_power_notify_list);
+
+/**
+ * pci_acpi_register_aux_power_notifier - Register driver notifier
+ * @nb: notifier block
+ *
+ * This function shall be called by PCIe End Point device requested
+the Aux
+ * power resource in order to handle the any scenario gracefully
+when other
+ * child PCIe devices Aux power request returns with No main power

removal.

Quoted 5 lines

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct · line 1437

Quoted 3 lines
drivers/pci/pci-acpi.c +3 -0
+ * PCIe devices which register this notifier shall handle No main
+power
+ * removal scenario accordingly.

This would actually be called by the *driver* (not by the device).

Hi Rafael,
Thanks for review.

Quoted 3 lines

Apart from this, there seems to be a design issue here because it won't notify every driver that has requested the Aux power, just the ones that have also registered notifiers.

IMHO that is what intended, if any device has functional impact in our case it is INTEL GPU has functional impact if other PCIe device's (on same root port) Aux Power request returns with 0x2. We need to handle such case to handle it gracefully.

Quoted 7 lines

So this appears to be an opt-in from getting notifications on Aux power request rejection responses to requests from other drivers requesting Aux power for the same Root Port, but the changelog of the first patch already claimed that the aggregation of requests was not supported. So if only one driver will be allowed to request the Aux power for the given Root Port, why would the notifiers be necessary after all?

Please guide us, if we remove the above limitation from the commit log. Then do we have any design issue with notifier approach ? Thanks,
Anshuman.

#23 lore raw

Re: [PATCH 03/12] PCI/ACPI: Add aux power grant notifier

Quoted 115 lines · Anshuman
Quoted 81 lines

-----Original Message-----
From: Rafael J. Wysocki <[email protected]>
Sent: Wednesday, April 2, 2025 4:54 PM
To: Bjorn Helgaas <[email protected]>; Gupta, Anshuman <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; De Marchi, Lucas <[email protected]>; Vivi, Rodrigo <[email protected]>; Nilawar, Badal <[email protected]>; Gupta, Varun <[email protected]>; [email protected]; Shankar, Uma <[email protected]>
Subject: Re: [PATCH 03/12] PCI/ACPI: Add aux power grant notifier

Quoted 57 lines · Bjorn Helgaas
Quoted 6 lines · Anshuman Gupta

Adding a notifier to notify all PCIe child devices about the block main power removal. It is needed because theoretically multiple PCIe Endpoint devices on same Root Port can request for AUX power and _DSM method can return with 80000000h signifies that the hierarchy connected via the slot cannot support main power removal when in D3Cold.

I wish the spec used different language here. "D3cold" *means* "main power is removed" (PCIe r6.0, sec 5.3.1.4.2), so it doesn't make sense to say that "the slot cannot support main power removal when in D3cold". If a device is in D3cold, its main power has been removed by definition.

I suppose the spec is trying to say if the driver has called this _DSM with 80000000h, it means the platform must not remove main power from the device while the system is in S0? Is that what you think it means?

The 2h return value description says it "indicates that the platform will not remove main power from the slot while the system is in S0," so I guess that must be it.

In this series, pci_acpi_aux_power_setup() only supplies a 16-bit aux_pwr_limit value, so the driver cannot *request* that the platform not remove main power.

So I guess the only scenario where the _DSM returns 80000000h is when the platform itself or other devices prevent the removal of main power. And the point of the notifier is to tell devices that their main power will never be removed while the system is in S0. Is that right?

Quoted 1 line

This may disrupt functionality of other child device.

What sort of disruption could happen? I would think that if the _DSM returns 80000000h, it just means the device will not have main power removed, so it won't see that power state transition. The only "disruption" would be that we're using more power.

Quoted 2 lines

Let's notify all PCIe devices requested Aux power resource and Let PCIe End Point driver handle it in its callback.

Wrap to fill 75 columns.

s/Adding/Add/
s/Let's notify/Notify/
s/and Let/and let/
s/End Point/Endpoint/ (several places here and below)

Quoted 6 lines
---
 drivers/pci/pci-acpi.c   | 34 +++++++++++++++++++++++++++++++---
 include/linux/pci-acpi.h | 13 +++++++++++++
 2 files changed, 44 insertions(+), 3 deletions(-)
Quoted 5 lines

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct

Quoted 5 lines
drivers/pci/pci-acpi.c index renamed from drivers/pci/pci-acpi.c +0 -0

04149f037664..d1ca1649e6e8 100644

drivers/pci/pci-acpi.c +0 -0
@@ -1421,6 +1421,32 @@ static void pci_acpi_optimize_delay(struct

pci_dev *pdev,

Quoted 3 lines
Quoted 3 lines
drivers/pci/pci-acpi.c +0 -0
      ACPI_FREE(obj);
 }
 
Quoted 18 lines
Quoted 11 lines

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev,

Quoted 11 lines
drivers/pci/pci-acpi.c +11 -0
+static BLOCKING_NOTIFIER_HEAD(pci_acpi_aux_power_notify_list);
+
+/**
+ * pci_acpi_register_aux_power_notifier - Register driver notifier
+ * @nb: notifier block
+ *
+ * This function shall be called by PCIe End Point device requested
+the Aux
+ * power resource in order to handle the any scenario gracefully
+when other
+ * child PCIe devices Aux power request returns with No main power

removal.

Quoted 5 lines

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct · line 1437

Quoted 3 lines
drivers/pci/pci-acpi.c +3 -0
+ * PCIe devices which register this notifier shall handle No main
+power
+ * removal scenario accordingly.

This would actually be called by the *driver* (not by the device).

Hi Rafael,
Thanks for review.

Quoted 3 lines

Apart from this, there seems to be a design issue here because it won't notify every driver that has requested the Aux power, just the ones that have also registered notifiers.

IMHO that is what intended, if any device has functional impact in our case it is INTEL GPU has functional impact if other PCIe device's (on same root port) Aux Power request returns with 0x2. We need to handle such case to handle it gracefully.

Quoted 8 lines

So this appears to be an opt-in from getting notifications on Aux power request rejection responses to requests from other drivers requesting Aux power for the same Root Port, but the changelog of the first patch already claimed that the aggregation of requests was not supported. So if only one driver will be allowed to request the Aux power for the given Root Port, why would the notifiers be necessary after all?

Quoted 2 lines

Please guide us, if we remove the above limitation from the commit log. Then do we have any design issue with notifier approach ?

Exactly like I said: If you only allow one driver to use the _DSM to request the Aux power from a given Root Port, it will have all of the information and does not need to be notified about any changes. Since no one else is allowed to use this interface for that Root Port, no one else will need a notifier either. For this to work, you need some mechanism allowing drivers to claim the interface so no one else can use it (on a per Root Port basis) which is currently missing AFAICS. I think that this is the option you want to pursue.

OTOH, if you want to allow multiple drivers to use this interface for the same Root Port, you need to aggregate the requests (as required by the spec IIUC) in the first place, or else the users can override each other's request. In that case you'll likely need a notification mechanism of some sort to let the requesters know whether or not the Aux power will be provided, but maybe that can be done through a callback associated with a request.

The second option is genuinely more complicated because all of the devices requesting the Aux power from the same Root Port cannot be suspended independently in that case, so until there is a clear real-world use case for it, my recommendation would be to go for the first option.

But the first option means exclusive access and so no need for notifiers and such.

#24 lore raw

RE: [PATCH 03/12] PCI/ACPI: Add aux power grant notifier

Quoted 144 lines

-----Original Message-----
From: Rafael J. Wysocki <[email protected]>
Sent: Thursday, April 3, 2025 7:04 PM
To: Gupta, Anshuman <[email protected]>
Cc: Rafael J. Wysocki <[email protected]>; Bjorn Helgaas <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; De Marchi, Lucas <[email protected]>; Vivi, Rodrigo <[email protected]>; Nilawar, Badal <[email protected]>; Gupta, Varun <[email protected]>; [email protected]; Shankar, Uma <[email protected]>
Subject: Re: [PATCH 03/12] PCI/ACPI: Add aux power grant notifier

Quoted 16 lines · Anshuman
Quoted 16 lines

-----Original Message-----
From: Rafael J. Wysocki <[email protected]>
Sent: Wednesday, April 2, 2025 4:54 PM
To: Bjorn Helgaas <[email protected]>; Gupta, Anshuman <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; De Marchi, Lucas <[email protected]>; Vivi, Rodrigo <[email protected]>; Nilawar, Badal <[email protected]>; Gupta, Varun <[email protected]>; [email protected]; Shankar, Uma <[email protected]>
Subject: Re: [PATCH 03/12] PCI/ACPI: Add aux power grant notifier

On Tue, Apr 1, 2025 at 10:13 PM Bjorn Helgaas <[email protected]>

Quoted 15 lines · wrote:
Quoted 15 lines
Quoted 15 lines · Anshuman Gupta
Quoted 6 lines

Adding a notifier to notify all PCIe child devices about the block main power removal. It is needed because theoretically multiple PCIe Endpoint devices on same Root Port can request for AUX power and _DSM method can return with 80000000h signifies that the hierarchy connected via the slot cannot support main power removal when in D3Cold.

I wish the spec used different language here. "D3cold" *means* "main power is removed" (PCIe r6.0, sec 5.3.1.4.2), so it doesn't make sense to say that "the slot cannot support main power removal when in D3cold". If a device is in D3cold, its main power has been removed by definition.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

I suppose the spec is trying to say if the driver has called this _DSM with 80000000h, it means the platform must not remove main power from the device while the system is in S0? Is that what you think it means?

The 2h return value description says it "indicates that the platform will not remove main power from the slot while the system is in

S0,"

Quoted 66 lines
Quoted 46 lines
Quoted 35 lines

so I guess that must be it.

In this series, pci_acpi_aux_power_setup() only supplies a 16-bit aux_pwr_limit value, so the driver cannot *request* that the platform not remove main power.

So I guess the only scenario where the _DSM returns 80000000h is when the platform itself or other devices prevent the removal of main power. And the point of the notifier is to tell devices that their main power will never be removed while the system is in S0. Is that right?

Quoted 1 line

This may disrupt functionality of other child device.

What sort of disruption could happen? I would think that if the _DSM returns 80000000h, it just means the device will not have main power removed, so it won't see that power state transition. The only "disruption" would be that we're using more power.

Quoted 2 lines

Let's notify all PCIe devices requested Aux power resource and Let PCIe End Point driver handle it in its callback.

Wrap to fill 75 columns.

s/Adding/Add/
s/Let's notify/Notify/
s/and Let/and let/
s/End Point/Endpoint/ (several places here and below)

Quoted 6 lines
---
 drivers/pci/pci-acpi.c   | 34 +++++++++++++++++++++++++++++++---
 include/linux/pci-acpi.h | 13 +++++++++++++
 2 files changed, 44 insertions(+), 3 deletions(-)
Quoted 7 lines
Quoted 7 lines
drivers/pci/pci-acpi.c +0 -0

index
04149f037664..d1ca1649e6e8 100644

drivers/pci/pci-acpi.c +0 -0
@@ -1421,6 +1421,32 @@ static void

pci_acpi_optimize_delay(struct

pci_dev *pdev,

Quoted 3 lines
Quoted 3 lines
      ACPI_FREE(obj);

}

Quoted 20 lines
Quoted 5 lines
Quoted 5 lines
drivers/pci/pci-acpi.c +5 -0
+static BLOCKING_NOTIFIER_HEAD(pci_acpi_aux_power_notify_list);
+
+/**
+ * pci_acpi_register_aux_power_notifier - Register driver
+notifier
Quoted 8 lines

drivers/pci/pci-acpi.c

Quoted 8 lines

+ * @nb: notifier block
+ *
+ * This function shall be called by PCIe End Point device

drivers/pci/pci-acpi.c +5 -0
+requested the Aux
+ * power resource in order to handle the any scenario
+gracefully when other
+ * child PCIe devices Aux power request returns with No main
+power

removal.

Quoted 5 lines
Quoted 3 lines

+ * PCIe devices which register this notifier shall handle No +main power
+ * removal scenario accordingly.

This would actually be called by the *driver* (not by the device).

Quoted 8 lines

Hi Rafael,
Thanks for review.

Quoted 3 lines

Apart from this, there seems to be a design issue here because it won't notify every driver that has requested the Aux power, just the ones that have also registered notifiers.

IMHO that is what intended, if any device has functional impact in our case it is INTEL GPU has functional impact if other PCIe device's (on same root port) Aux Power request returns with 0x2. We need to handle

such case to handle it gracefully.

Quoted 7 lines
Quoted 7 lines

So this appears to be an opt-in from getting notifications on Aux power request rejection responses to requests from other drivers requesting Aux power for the same Root Port, but the changelog of the first patch already claimed that the aggregation of requests was not supported. So if only one driver will be allowed to request the Aux power for the given Root Port, why would the notifiers be necessary

after all?

Quoted 3 lines
Quoted 1 line

Please guide us, if we remove the above limitation from the commit log. Then do we have any design issue with notifier approach ?

Quoted 7 lines

Exactly like I said: If you only allow one driver to use the _DSM to request the Aux power from a given Root Port, it will have all of the information and does not need to be notified about any changes. Since no one else is allowed to use this interface for that Root Port, no one else will need a notifier either. For this to work, you need some mechanism allowing drivers to claim the interface so no one else can use it (on a per Root Port basis) which is currently missing AFAICS.

IMHO such kind of mechanism will require to add Root Port specific data structure to claim the interface. But real problem is the criteria to claim the interface.
Is first PCIe Non-Bridge Endpoint Function 0 driver can be criteria to claim the Interface. Or first come and first serve approach ?

Quoted 2 lines

I think that this is the option you want to pursue.

We will prefer to stick with this option, if it can guaranty that XeKMD will the only driver allowed to request Aux power to enable VRSR.

Quoted 3 lines

OTOH, if you want to allow multiple drivers to use this interface for the same Root Port, you need to aggregate the requests (as required by the spec IIUC) in the first place, or else the users can override each other's request. In that case

INHO how Linux Kernel will aggregate the Aux Power request, without knowing the total Aux power budget. AFAIU aggregated Aux power request without knowledge of total power budget can also be denied by BIOS[1].
Therefore how aggregation can be useful ?

[1]As per r3.3 Section 4.6.10
Platform Firmware Budgeting of Aux Power Availability:
Platform firmware must not grant more power than what is available within the system. For example, a board may be designed with four CEM slots (one x16 slot, one x4 slot, and two x1 slots). The board may implement a power delivery circuit capable of supplying 2 W of power for the 3.3 Vaux rail supplying all 4 slots. The 3.3 Vaux pins on each CEM slot can supply 1 W each. Platform firmware may use the retry mechanism to prioritize requests from devices in preferred slots in the following manner:

-> Requests from a device in the highest priority slot (e.g., x16) are granted immediately, if available.

-> Requests from devices in lower priority slots (e.g., x2, x1) are initially rejected, with a retry interval inversely proportional to the slot priority. For instance, if the x2 slot is higher priority than the x1 slots, so the retry interval for the x2 slot may be 4 seconds, and the x1 slots may be 8 and 10 seconds.

->As requests are granted, the granted values are subtracted from the available budget.
Retried requests are granted based on the remaining power budget or denied if insufficient
power budget is available. Another retry is not permitted.

-> When there is insufficient power budget for a request, firmware may choose to keep main power on and return no power removal (2h).

Thanks,
Anshuman.

Quoted 8 lines

you'll likely need a notification mechanism of some sort to let the requesters know whether or not the Aux power will be provided, but maybe that can be done through a callback associated with a request.

The second option is genuinely more complicated because all of the devices requesting the Aux power from the same Root Port cannot be suspended independently in that case, so until there is a clear real-world use case for it, my recommendation would be to go for the first option.

Multiple devices under same root ports requesting Aux Power is a theoretical use case.

Quoted 3 lines

But the first option means exclusive access and so no need for notifiers and such.

#25 lore raw

Re: [PATCH 03/12] PCI/ACPI: Add aux power grant notifier

Quoted 151 lines · Anshuman
Quoted 143 lines

-----Original Message-----
From: Rafael J. Wysocki <[email protected]>
Sent: Thursday, April 3, 2025 7:04 PM
To: Gupta, Anshuman <[email protected]>
Cc: Rafael J. Wysocki <[email protected]>; Bjorn Helgaas <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; De Marchi, Lucas <[email protected]>; Vivi, Rodrigo <[email protected]>; Nilawar, Badal <[email protected]>; Gupta, Varun <[email protected]>; [email protected]; Shankar, Uma <[email protected]>
Subject: Re: [PATCH 03/12] PCI/ACPI: Add aux power grant notifier

Quoted 16 lines · Anshuman
Quoted 16 lines

-----Original Message-----
From: Rafael J. Wysocki <[email protected]>
Sent: Wednesday, April 2, 2025 4:54 PM
To: Bjorn Helgaas <[email protected]>; Gupta, Anshuman <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; De Marchi, Lucas <[email protected]>; Vivi, Rodrigo <[email protected]>; Nilawar, Badal <[email protected]>; Gupta, Varun <[email protected]>; [email protected]; Shankar, Uma <[email protected]>
Subject: Re: [PATCH 03/12] PCI/ACPI: Add aux power grant notifier

On Tue, Apr 1, 2025 at 10:13 PM Bjorn Helgaas <[email protected]>

Quoted 15 lines · wrote:
Quoted 15 lines
Quoted 15 lines · Anshuman Gupta
Quoted 6 lines

Adding a notifier to notify all PCIe child devices about the block main power removal. It is needed because theoretically multiple PCIe Endpoint devices on same Root Port can request for AUX power and _DSM method can return with 80000000h signifies that the hierarchy connected via the slot cannot support main power removal when in D3Cold.

I wish the spec used different language here. "D3cold" *means* "main power is removed" (PCIe r6.0, sec 5.3.1.4.2), so it doesn't make sense to say that "the slot cannot support main power removal when in D3cold". If a device is in D3cold, its main power has been removed by definition.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

I suppose the spec is trying to say if the driver has called this _DSM with 80000000h, it means the platform must not remove main power from the device while the system is in S0? Is that what you think it means?

The 2h return value description says it "indicates that the platform will not remove main power from the slot while the system is in

S0,"

Quoted 66 lines
Quoted 46 lines
Quoted 35 lines

so I guess that must be it.

In this series, pci_acpi_aux_power_setup() only supplies a 16-bit aux_pwr_limit value, so the driver cannot *request* that the platform not remove main power.

So I guess the only scenario where the _DSM returns 80000000h is when the platform itself or other devices prevent the removal of main power. And the point of the notifier is to tell devices that their main power will never be removed while the system is in S0. Is that right?

Quoted 1 line

This may disrupt functionality of other child device.

What sort of disruption could happen? I would think that if the _DSM returns 80000000h, it just means the device will not have main power removed, so it won't see that power state transition. The only "disruption" would be that we're using more power.

Quoted 2 lines

Let's notify all PCIe devices requested Aux power resource and Let PCIe End Point driver handle it in its callback.

Wrap to fill 75 columns.

s/Adding/Add/
s/Let's notify/Notify/
s/and Let/and let/
s/End Point/Endpoint/ (several places here and below)

Quoted 6 lines
---
 drivers/pci/pci-acpi.c   | 34 +++++++++++++++++++++++++++++++---
 include/linux/pci-acpi.h | 13 +++++++++++++
 2 files changed, 44 insertions(+), 3 deletions(-)
Quoted 7 lines
Quoted 7 lines
drivers/pci/pci-acpi.c +0 -0

index
04149f037664..d1ca1649e6e8 100644

drivers/pci/pci-acpi.c +0 -0
@@ -1421,6 +1421,32 @@ static void

pci_acpi_optimize_delay(struct

pci_dev *pdev,

Quoted 3 lines
Quoted 3 lines
      ACPI_FREE(obj);

}

Quoted 20 lines
Quoted 5 lines
Quoted 5 lines
drivers/pci/pci-acpi.c +5 -0
+static BLOCKING_NOTIFIER_HEAD(pci_acpi_aux_power_notify_list);
+
+/**
+ * pci_acpi_register_aux_power_notifier - Register driver
+notifier
Quoted 8 lines

drivers/pci/pci-acpi.c

Quoted 8 lines

+ * @nb: notifier block
+ *
+ * This function shall be called by PCIe End Point device

drivers/pci/pci-acpi.c +5 -0
+requested the Aux
+ * power resource in order to handle the any scenario
+gracefully when other
+ * child PCIe devices Aux power request returns with No main
+power

removal.

Quoted 5 lines
Quoted 3 lines

+ * PCIe devices which register this notifier shall handle No +main power
+ * removal scenario accordingly.

This would actually be called by the *driver* (not by the device).

Quoted 8 lines

Hi Rafael,
Thanks for review.

Quoted 3 lines

Apart from this, there seems to be a design issue here because it won't notify every driver that has requested the Aux power, just the ones that have also registered notifiers.

IMHO that is what intended, if any device has functional impact in our case it is INTEL GPU has functional impact if other PCIe device's (on same root port) Aux Power request returns with 0x2. We need to handle

such case to handle it gracefully.

Quoted 7 lines
Quoted 7 lines

So this appears to be an opt-in from getting notifications on Aux power request rejection responses to requests from other drivers requesting Aux power for the same Root Port, but the changelog of the first patch already claimed that the aggregation of requests was not supported. So if only one driver will be allowed to request the Aux power for the given Root Port, why would the notifiers be necessary

after all?

Quoted 3 lines
Quoted 1 line

Please guide us, if we remove the above limitation from the commit log. Then do we have any design issue with notifier approach ?

Quoted 7 lines

Exactly like I said: If you only allow one driver to use the _DSM to request the Aux power from a given Root Port, it will have all of the information and does not need to be notified about any changes. Since no one else is allowed to use this interface for that Root Port, no one else will need a notifier either. For this to work, you need some mechanism allowing drivers to claim the interface so no one else can use it (on a per Root Port basis) which is currently missing AFAICS.

Quoted 4 lines

IMHO such kind of mechanism will require to add Root Port specific data structure to claim the interface. But real problem is the criteria to claim the interface.
Is first PCIe Non-Bridge Endpoint Function 0 driver can be criteria to claim the Interface. Or first come and first serve approach ?

IMV, the first PCIe Non-Bridge Endpoint Function 0 driver approach would be sort of fragile and cumbersome to enforce.

First come, first serve is much simpler and should be sufficient for now AFAICS.

Quoted 5 lines
Quoted 2 lines

I think that this is the option you want to pursue.

We will prefer to stick with this option, if it can guaranty that XeKMD will the only driver allowed to request Aux power to enable VRSR.

Quoted 8 lines
Quoted 3 lines

OTOH, if you want to allow multiple drivers to use this interface for the same Root Port, you need to aggregate the requests (as required by the spec IIUC) in the first place, or else the users can override each other's request. In that case

INHO how Linux Kernel will aggregate the Aux Power request, without knowing the total Aux power budget. AFAIU aggregated Aux power request without knowledge of total power budget can also be denied by BIOS[1].
Therefore how aggregation can be useful ?

Say two drivers request the Aux power from the same Root Port and each of them passes a limit sufficient for its device. Without aggregation, what guarantees that the last limit passed will be sufficient for both devices?

Also see the spec provision regarding retries below.

Quoted 17 lines

[1]As per r3.3 Section 4.6.10
Platform Firmware Budgeting of Aux Power Availability:
Platform firmware must not grant more power than what is available within the system. For example, a board may be designed with four CEM slots (one x16 slot, one x4 slot, and two x1 slots). The board may implement a power delivery circuit capable of supplying 2 W of power for the 3.3 Vaux rail supplying all 4 slots. The 3.3 Vaux pins on each CEM slot can supply 1 W each. Platform firmware may use the retry mechanism to prioritize requests from devices in preferred slots in the following manner:

-> Requests from a device in the highest priority slot (e.g., x16) are granted immediately, if available.

-> Requests from devices in lower priority slots (e.g., x2, x1) are initially rejected, with a retry interval inversely proportional to the slot priority. For instance, if the x2 slot is higher priority than the x1 slots, so the retry interval for the x2 slot may be 4 seconds, and the x1 slots may be 8 and 10 seconds.

Quoted 6 lines

->As requests are granted, the granted values are subtracted from the available budget.
Retried requests are granted based on the remaining power budget or denied if insufficient
power budget is available. Another retry is not permitted.

-> When there is insufficient power budget for a request, firmware may choose to keep main power on and return no power removal (2h).

This means that the platform firmware is supposed to do its own aggregation, but at the system (board) level, not at the Root Port level.

The algorithm is described above and my understanding of it is that once a request has been granted, it cannot be retracted later. Also it appears to assume a 1:1 correspondence between PCIe slots and Root Ports.

The guys who haven't been granted their requests at once may be asked to try again later and there may not be enough Aux power for the last guys at all, so they will not get it and they will stay on the main power. And again, this appears to be at the Root Port granularity.

#26 lore raw

RE: [PATCH 03/12] PCI/ACPI: Add aux power grant notifier

/snip

Quoted 12 lines
Quoted 8 lines
Quoted 8 lines

Exactly like I said: If you only allow one driver to use the _DSM to request the Aux power from a given Root Port, it will have all of the information and does not need to be notified about any changes. Since no one else is allowed to use this interface for that Root Port, no one else will need a notifier either. For this to work, you need some mechanism allowing drivers to claim the interface so no one else can use it (on a per Root Port basis) which is currently missing

AFAICS.

Quoted 3 lines

IMHO such kind of mechanism will require to add Root Port specific data structure to claim the interface. But real problem is the criteria to claim

Quoted 8 lines

the interface.

Quoted 2 lines

Is first PCIe Non-Bridge Endpoint Function 0 driver can be criteria to claim the Interface. Or first come and first serve approach ?

IMV, the first PCIe Non-Bridge Endpoint Function 0 driver approach would be sort of fragile and cumbersome to enforce.

First come, first serve is much simpler and should be sufficient for now AFAICS.

We are enabling VRSR only for default vga boot device.
As it needed only GPU driving the display for better user experience. Can we use same logic vga_default_device() to claim the interface under root port. That will simplify the criteria to claim the interface.

Quoted 11 lines
Quoted 11 lines
Quoted 3 lines

I think that this is the option you want to pursue.

We will prefer to stick with this option, if it can guaranty that XeKMD will the only driver allowed to request Aux power to enable VRSR.

Quoted 4 lines

OTOH, if you want to allow multiple drivers to use this interface for the same Root Port, you need to aggregate the requests (as required by the spec IIUC) in the first place, or else the users can override each other's request. In that case

Quoted 8 lines
Quoted 4 lines

INHO how Linux Kernel will aggregate the Aux Power request, without knowing the total Aux power budget. AFAIU aggregated Aux power request without knowledge of total power budget can also be denied by BIOS[1]. Therefore how aggregation can be useful ?

Say two drivers request the Aux power from the same Root Port and each of them passes a limit sufficient for its device. Without aggregation, what guarantees that the last limit passed will be sufficient for both devices?

Thanks for explaining this.

Quoted 38 lines

Also see the spec provision regarding retries below.

Quoted 6 lines

[1]As per r3.3 Section 4.6.10
Platform Firmware Budgeting of Aux Power Availability:
Platform firmware must not grant more power than what is available within the system. For example, a board may be designed with four CEM slots (one x16 slot, one x4 slot, and two x1 slots). The board may implement a power delivery circuit capable of supplying 2 W of power for the

3.3 Vaux rail supplying all 4 slots. The 3.3 Vaux pins on each CEM slot can supply 1 W each.

Quoted 7 lines

Platform firmware may use the retry mechanism to prioritize requests from devices in preferred slots in the following manner:

-> Requests from a device in the highest priority slot (e.g., x16) are -> granted immediately, if
available.

Quoted 8 lines

-> Requests from devices in lower priority slots (e.g., x2, x1) are -> initially rejected, with a retry
interval inversely proportional to the slot priority. For instance, if the x2 slot is higher priority than the x1 slots, so the retry interval for the x2 slot may be 4 seconds, and the x1 slots may be 8 and 10 seconds.

->As requests are granted, the granted values are subtracted from the

available budget.

Quoted 2 lines

Retried requests are granted based on the remaining power budget or
denied if insufficient power budget is available. Another retry is not

permitted.

Quoted 4 lines

-> When there is insufficient power budget for a request, firmware may -> choose to keep main
power on and return no power removal (2h).

This means that the platform firmware is supposed to do its own aggregation, but at the system (board) level, not at the Root Port level.

Quoted 8 lines

The algorithm is described above and my understanding of it is that once a request has been granted, it cannot be retracted later. Also it appears to assume a 1:1 correspondence between PCIe slots and Root Ports.

The guys who haven't been granted their requests at once may be asked to try again later and there may not be enough Aux power for the last guys at all, so they will not get it and they will stay on the main power. And again, this appears to be at the Root Port granularity.

Thanks for explanation.
Thanks,
Anshuman

#27 lore raw

Re: [PATCH 03/12] PCI/ACPI: Add aux power grant notifier

Quoted 21 lines · Anshuman

/snip

Quoted 19 lines
Quoted 8 lines
Quoted 8 lines

Exactly like I said: If you only allow one driver to use the _DSM to request the Aux power from a given Root Port, it will have all of the information and does not need to be notified about any changes. Since no one else is allowed to use this interface for that Root Port, no one else will need a notifier either. For this to work, you need some mechanism allowing drivers to claim the interface so no one else can use it (on a per Root Port basis) which is currently missing

AFAICS.

Quoted 3 lines

IMHO such kind of mechanism will require to add Root Port specific data structure to claim the interface. But real problem is the criteria to claim

the interface.

Quoted 2 lines

Is first PCIe Non-Bridge Endpoint Function 0 driver can be criteria to claim the Interface. Or first come and first serve approach ?

IMV, the first PCIe Non-Bridge Endpoint Function 0 driver approach would be sort of fragile and cumbersome to enforce.

Quoted 6 lines
Quoted 1 line

First come, first serve is much simpler and should be sufficient for now AFAICS.

We are enabling VRSR only for default vga boot device.
As it needed only GPU driving the display for better user experience. Can we use same logic vga_default_device() to claim the interface under root port. That will simplify the criteria to claim the interface.

Basically, you need to prevent somebody else from running DSM_PCI_D3COLD_AUX_POWER_LIMIT concurrently for the given Root Port and store the information that it has been run already.

Personally, I'd add aux_power_limit to struct acpi_device_power and I'd use a static mutex in pci_acpi_request_d3cold_aux_power() along the lines of:

1. Acquire the mutex.
2. If power.aux_power_limit is set for the ACPI companion of pci_dev, release the mutex and bail out.
3. Evaluate DSM_PCI_D3COLD_AUX_POWER_LIMIT and if it fails, release the mutex and bail out.
4. Set power.aux_power_limit for the ACPI companion of pci_dev to the requested value.
5. Release the mutex.

Of course, this would only allow it to be set once per kernel boot, so in order to handle hibernation properly, the same Aux power limit would need to be requested again automatically on Root Port restore.

#28 lore raw

Re: [PATCH 03/12] PCI/ACPI: Add aux power grant notifier

Quoted 40 lines · Rafael J. Wysocki
Quoted 14 lines · Anshuman

/snip

Quoted 13 lines
Quoted 7 lines
Quoted 7 lines

Exactly like I said: If you only allow one driver to use the _DSM to request the Aux power from a given Root Port, it will have all of the information and does not need to be notified about any changes. Since no one else is allowed to use this interface for that Root Port, no one else will need a notifier either. For this to work, you need some mechanism allowing drivers to claim the interface so no one else can use it (on a per Root Port basis) which is currently missing

AFAICS.

Quoted 2 lines

IMHO such kind of mechanism will require to add Root Port specific data structure to claim the interface. But real problem is the criteria to claim

the interface.

Quoted 2 lines

Is first PCIe Non-Bridge Endpoint Function 0 driver can be criteria to claim the Interface. Or first come and first serve approach ?

Quoted 8 lines
Quoted 4 lines

IMV, the first PCIe Non-Bridge Endpoint Function 0 driver approach would be sort of fragile and cumbersome to enforce.

First come, first serve is much simpler and should be sufficient for now AFAICS.

We are enabling VRSR only for default vga boot device.
As it needed only GPU driving the display for better user experience. Can we use same logic vga_default_device() to claim the interface under root port. That will simplify the criteria to claim the interface.

Basically, you need to prevent somebody else from running DSM_PCI_D3COLD_AUX_POWER_LIMIT concurrently for the given Root Port and store the information that it has been run already.

Personally, I'd add aux_power_limit to struct acpi_device_power and I'd use a static mutex in pci_acpi_request_d3cold_aux_power() along the lines of:

1. Acquire the mutex.
2. If power.aux_power_limit is set for the ACPI companion of pci_dev, release the mutex and bail out.
3. Evaluate DSM_PCI_D3COLD_AUX_POWER_LIMIT and if it fails, release the mutex and bail out.
4. Set power.aux_power_limit for the ACPI companion of pci_dev to the requested value.
5. Release the mutex.

Quoted 3 lines

Of course, this would only allow it to be set once per kernel boot, so in order to handle hibernation properly, the same Aux power limit would need to be requested again automatically on Root Port restore.

 I've incorporated the above suggestion in v4 patch [v4,02/11] PCI/ACPI: Per root port allow one Aux power limit request - Patchwork <https://patchwork.freedesktop.org/patch/656187/?series=145342&rev=4> , except for the Aux power re-request after hibernation exit, as we didn't observe any issues with VRSR post hibernation.

Regards,
Badal

#29 lore raw

RE: [PATCH 03/12] PCI/ACPI: Add aux power grant notifier

In reply to Bjorn Helgaas
Quoted 22 lines

-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: Wednesday, April 2, 2025 1:44 AM
To: Gupta, Anshuman <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; De Marchi, Lucas <[email protected]>; Vivi, Rodrigo <[email protected]>; Nilawar, Badal <[email protected]>; Gupta, Varun <[email protected]>; [email protected]; Shankar, Uma <[email protected]>
Subject: Re: [PATCH 03/12] PCI/ACPI: Add aux power grant notifier

Quoted 6 lines · Anshuman Gupta

Adding a notifier to notify all PCIe child devices about the block main power removal. It is needed because theoretically multiple PCIe Endpoint devices on same Root Port can request for AUX power and _DSM method can return with 80000000h signifies that the hierarchy connected via the slot cannot support main power removal when in D3Cold.

Quoted 8 lines

I wish the spec used different language here. "D3cold" *means* "main power is removed" (PCIe r6.0, sec 5.3.1.4.2), so it doesn't make sense to say that "the slot cannot support main power removal when in D3cold". If a device is in D3cold, its main power has been removed by definition.

I suppose the spec is trying to say if the driver has called this _DSM with 80000000h, it means the platform must not remove main power from the device while the system is in S0? Is that what you think it means?

Thanks for review.
what I understand here, S0 term essentially means here PCIe Runtime PM or s2idle (both refers system is S0 state). AFAIU during both Runtime PM and s2ilde path Root Port can transition to D3Cold if it support _PR3.
I observed Root Port either have D0 or D3Cold state. /sys/bus/pci0/devices/$root_port_bdf/firmware_node/real_power_state

Driver can disable the D3cold by pci_d3cold_disable(), so I wonder there is no use case driver calling _DSM 0xa with 80000000h.
PCIe specs shall be simplified by removal of value 80000000h from _DSM 0xa Arg.

Quoted 8 lines

The 2h return value description says it "indicates that the platform will not remove main power from the slot while the system is in S0,"
so I guess that must be it.

In this series, pci_acpi_aux_power_setup() only supplies a 16-bit aux_pwr_limit value, so the driver cannot *request* that the platform not remove main power.

Yeah but that value Xe driver received from GPU firmware.

Quoted 5 lines

So I guess the only scenario where the _DSM returns 80000000h is when the platform itself or other devices prevent the removal of main power. And the point of the notifier is to tell devices that their main power will never be removed while the system is in S0. Is that right?

Yes the notifier will safeguard against the use case if some other PCIe device calls _DSM 0xa with Arg3 Value of 80000000h or its request return with 0x2h.

Quoted 7 lines
Quoted 2 lines

This may disrupt functionality of other child device.

What sort of disruption could happen? I would think that if the _DSM returns 80000000h, it just means the device will not have main power removed, so it won't see that power state transition. The only "disruption" would be that we're using more power.

Let's say during Xe Driver initialization BIOS firmware grants the Xe driver Aux power request successfully.
Xe driver will prepare to transition D3Cold state with VRAM Self Refresh. VRAM Self Refresh relies on vram shall derive power from Aux power. But later at any point if some other PCIe device under same root port Calls _DSM either with 080000000h or _DSM returns with 02h, will Block the main power removal. But Xe driver is unaware of it can still program the VRAM Self Refresh and that make VRAM to derive power from Aux and that will disrupt the GPU VRAM as there is no switch to Aux Power.
Thanks,
Anshuman

Quoted 141 lines
Quoted 3 lines

Let's notify all PCIe devices requested Aux power resource and Let PCIe End Point driver handle it in its callback.

Wrap to fill 75 columns.

s/Adding/Add/
s/Let's notify/Notify/
s/and Let/and let/
s/End Point/Endpoint/ (several places here and below)

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct

Quoted 11 lines
---
 drivers/pci/pci-acpi.c   | 34 +++++++++++++++++++++++++++++++---
 include/linux/pci-acpi.h | 13 +++++++++++++
 2 files changed, 44 insertions(+), 3 deletions(-)
drivers/pci/pci-acpi.c index renamed from drivers/pci/pci-acpi.c +0 -0

04149f037664..d1ca1649e6e8 100644

drivers/pci/pci-acpi.c +0 -0
@@ -1421,6 +1421,32 @@ static void pci_acpi_optimize_delay(struct

pci_dev *pdev,

Quoted 4 lines
drivers/pci/pci-acpi.c +1 -0
 	ACPI_FREE(obj);
 }
 
+static BLOCKING_NOTIFIER_HEAD(pci_acpi_aux_power_notify_list);

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev,

Quoted 10 lines
drivers/pci/pci-acpi.c +10 -0
+
+/**
+ * pci_acpi_register_aux_power_notifier - Register driver notifier
+ * @nb: notifier block
+ *
+ * This function shall be called by PCIe End Point device requested
+the Aux
+ * power resource in order to handle the any scenario gracefully when
+other
+ * child PCIe devices Aux power request returns with No main power

removal.

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct · line 1437

Quoted 3 lines
drivers/pci/pci-acpi.c +3 -0
+ * PCIe devices which register this notifier shall handle No main
+power
+ * removal scenario accordingly.

This would actually be called by the *driver* (not by the device).

Reword in imperative mood if possible.

Quoted 5 lines
drivers/pci/pci-acpi.c +5 -0
+ *
+ * Return: Returns 0 on success and errno on failure.
+ */
+int pci_acpi_register_aux_power_notifier(struct notifier_block *nb) {
+	return

drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct · line 1452

Quoted 10 lines
drivers/pci/pci-acpi.c +8 -0
+blocking_notifier_chain_register(&pci_acpi_aux_power_notify_list,
+nb); } EXPORT_SYMBOL_GPL(pci_acpi_register_aux_power_notifier);
+
+void pci_acpi_unregister_aux_power_notifier(struct notifier_block
+*nb) {
+	blocking_notifier_chain_unregister(&pci_acpi_aux_power_notify_list,
+nb); } EXPORT_SYMBOL_GPL(pci_acpi_unregister_aux_power_notifier);
+
 /**
  * pci_acpi_request_d3cold_aux_power - Request D3cold aux power via

ACPI DSM

drivers/pci/pci-acpi.c int

Quoted 2 lines
drivers/pci/pci-acpi.c +0 -0
  * @dev: PCI device instance
@@ -1466,17 +1492,19 @@ int

pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)

drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power) · line 1495

Quoted 5 lines
drivers/pci/pci-acpi.c +1 -1
 	result = out_obj->integer.value;
 
 	switch (result) {
-	case 0x0:
+	case ACPI_AUX_PW_DENIED:

Add these constants in the patch that adds the _DSM. Then this patch will be just notifier-related code.

drivers/pci/pci-acpi.c int · line 1496

Quoted 1 line
drivers/pci/pci-acpi.c +0 -0
 		dev_dbg(&dev->dev, "D3cold Aux Power %umW request

denied\n",

drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)

Quoted 5 lines
drivers/pci/pci-acpi.c +1 -1
 			requested_power);
 		break;
-	case 0x1:
+	case ACPI_AUX_PW_GRANTED:
 		dev_info(&dev->dev, "D3cold Aux Power request granted:

%umW\n",

drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)

Quoted 6 lines
drivers/pci/pci-acpi.c +1 -1
 			 requested_power);
 		ret = 0;
 		break;
-	case 0x2:
+	case ACPI_NO_MAIN_PW_REMOVAL:
 		dev_info(&dev->dev, "D3cold Aux Power: Main power won't

be

drivers/pci/pci-acpi.c int · line 1508

Quoted 3 lines
drivers/pci/pci-acpi.c +2 -0
 removed\n");
+		blocking_notifier_call_chain(&pci_acpi_aux_power_notify_list,
+					     ACPI_NO_MAIN_PW_REMOVAL,

dev);

Quoted 47 lines
drivers/pci/pci-acpi.c +0 -0
 		ret = -EBUSY;
 		break;
drivers/pci/pci-acpi.c +0 -0
 	default:
include/linux/pci-acpi.h index renamed from include/linux/pci-acpi.h +0 -0

4b7373f91a9a..793b979af98b 100644

include/linux/pci-acpi.h +4 -0
@@ -124,6 +124,10 @@ extern const guid_t pci_acpi_dsm_guid;
 #define DSM_PCI_D3COLD_AUX_POWER_LIMIT		0x0A
 #define DSM_PCI_PERST_ASSERTION_DELAY		0x0B
 
+#define ACPI_AUX_PW_DENIED			0x0
+#define ACPI_AUX_PW_GRANTED			0x1
+#define ACPI_NO_MAIN_PW_REMOVAL			0x2
+
 #ifdef CONFIG_PCIE_EDR
 void pci_acpi_add_edr_notifier(struct pci_dev *pdev);  void

pci_acpi_remove_edr_notifier(struct pci_dev *pdev); @@ -134,12 +138,21 @@ static inline void pci_acpi_remove_edr_notifier(struct pci_dev *pdev) { }

int pci_acpi_set_companion_lookup_hook(struct acpi_device
*(*func)(struct pci_dev *)); void pci_acpi_clear_companion_lookup_hook(void);

include/linux/pci-acpi.h +3 -0
+int pci_acpi_register_aux_power_notifier(struct notifier_block *nb);
+void pci_acpi_unregister_aux_power_notifier(struct notifier_block
+*nb);
 int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32

requested_power); int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us);

#else /* CONFIG_ACPI */
static inline void acpi_pci_add_bus(struct pci_bus *bus) { } static
inline void acpi_pci_remove_bus(struct pci_bus *bus) { }

include/linux/pci-acpi.h +7 -0
+int pci_acpi_register_aux_power_notifier(struct notifier_block *nb) {
+	return -EOPNOTSUPP;
+}
+
+void pci_acpi_unregister_aux_power_notifier(struct notifier_block
+*nb) { }
+
 int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32

requested_power) {
return -EOPNOTSUPP;
--
2.43.0

#30 lore raw

Re: [PATCH 03/12] PCI/ACPI: Add aux power grant notifier

Quoted 58 lines · Anshuman
Quoted 21 lines

-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: Wednesday, April 2, 2025 1:44 AM
To: Gupta, Anshuman <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; De Marchi, Lucas <[email protected]>; Vivi, Rodrigo <[email protected]>; Nilawar, Badal <[email protected]>; Gupta, Varun <[email protected]>; [email protected]; Shankar, Uma <[email protected]>
Subject: Re: [PATCH 03/12] PCI/ACPI: Add aux power grant notifier

Quoted 6 lines · Anshuman Gupta

Adding a notifier to notify all PCIe child devices about the block main power removal. It is needed because theoretically multiple PCIe Endpoint devices on same Root Port can request for AUX power and _DSM method can return with 80000000h signifies that the hierarchy connected via the slot cannot support main power removal when in D3Cold.

Quoted 8 lines

I wish the spec used different language here. "D3cold" *means* "main power is removed" (PCIe r6.0, sec 5.3.1.4.2), so it doesn't make sense to say that "the slot cannot support main power removal when in D3cold". If a device is in D3cold, its main power has been removed by definition.

I suppose the spec is trying to say if the driver has called this _DSM with 80000000h, it means the platform must not remove main power from the device while the system is in S0? Is that what you think it means?

Thanks for review.
what I understand here, S0 term essentially means here PCIe Runtime PM or s2idle (both refers system is S0 state). AFAIU during both Runtime PM and s2ilde path Root Port can transition to D3Cold if it support _PR3.
I observed Root Port either have D0 or D3Cold state. /sys/bus/pci0/devices/$root_port_bdf/firmware_node/real_power_state

Driver can disable the D3cold by pci_d3cold_disable(), so I wonder there is no use case driver calling _DSM 0xa with 80000000h.
PCIe specs shall be simplified by removal of value 80000000h from _DSM 0xa Arg.

Quoted 8 lines

The 2h return value description says it "indicates that the platform will not remove main power from the slot while the system is in S0,"
so I guess that must be it.

In this series, pci_acpi_aux_power_setup() only supplies a 16-bit aux_pwr_limit value, so the driver cannot *request* that the platform not remove main power.

Yeah but that value Xe driver received from GPU firmware.

Quoted 5 lines

So I guess the only scenario where the _DSM returns 80000000h is when the platform itself or other devices prevent the removal of main power. And the point of the notifier is to tell devices that their main power will never be removed while the system is in S0. Is that right?

Yes the notifier will safeguard against the use case if some other PCIe device calls _DSM 0xa with Arg3 Value of 80000000h or its request return with 0x2h.

Quoted 3 lines
Quoted 2 lines

This may disrupt functionality of other child device.

Quoted 7 lines
Quoted 4 lines

What sort of disruption could happen? I would think that if the _DSM returns 80000000h, it just means the device will not have main power removed, so it won't see that power state transition. The only "disruption" would be that we're using more power.

Let's say during Xe Driver initialization BIOS firmware grants the Xe driver Aux power request successfully.

Slightly OT, but if you do it at init time, you also need to do it after hibernation because the original ini-time request may not survive it.

Quoted 5 lines

Xe driver will prepare to transition D3Cold state with VRAM Self Refresh. VRAM Self Refresh relies on vram shall derive power from Aux power. But later at any point if some other PCIe device under same root port Calls _DSM either with 080000000h or _DSM returns with 02h, will Block the main power removal.

As I said in the previous message, this cannot happen if only one driver at a time is allowed to request the Aux power on a given Root Port.

If multiple drivers are allowed to do it, aggregation of requests is necessary.

Quoted 3 lines

But Xe driver is unaware of it can still
program the VRAM Self Refresh and that make VRAM to derive power from Aux and that will disrupt the GPU VRAM as there is no switch to Aux

This is a rather unfortunate and counter-intuitive design decision IMV. If the main power is still there, I'd expect the VRAM Self Refresh to use it instead of the Aux power.

#31 lore raw

PATCH 4/12 drm/xe/vrsr: Introduce flag has_vrsr

In reply to Anshuman Gupta

From: Badal Nilawar <[email protected]>

Introduce flag has_vrsr to determine if platform supports VRSR feature

---
 drivers/gpu/drm/xe/xe_device_types.h | 2 ++
 drivers/gpu/drm/xe/xe_pci.c          | 3 +++
 2 files changed, 5 insertions(+)
drivers/gpu/drm/xe/xe_device_types.h +2 -0
index c54adebfe518..b8ccf729f7c0 100644
@@ -334,6 +334,8 @@ struct xe_device {
 		u8 has_sriov:1;
 		/** @info.has_usm: Device has unified shared memory support */
 		u8 has_usm:1;
+		/** @info.has_vrsr: Has capability to enter into VRAM self refresh */
+		u8 has_vrsr:1;
 		/** @info.is_dgfx: is discrete device */
 		u8 is_dgfx:1;
 		/**
drivers/gpu/drm/xe/xe_pci.c +3 -0
index 772b6c81672c..70d4827f5821 100644
@@ -68,6 +68,7 @@ struct xe_device_desc {
 	u8 has_llc:1;
 	u8 has_pxp:1;
 	u8 has_sriov:1;
+	u8 has_vrsr:1;
 	u8 skip_guc_pc:1;
 	u8 skip_mtcfg:1;
 	u8 skip_pcode:1;
@@ -343,6 +344,7 @@ static const struct xe_device_desc bmg_desc = {
 	.dma_mask_size = 46,
 	.has_display = true,
 	.has_fan_control = true,
+	.has_vrsr = true,
 	.has_heci_cscfi = 1,
 };
 
@@ -589,6 +591,7 @@ static int xe_info_init_early(struct xe_device *xe,
 	xe->info.has_llc = desc->has_llc;
 	xe->info.has_pxp = desc->has_pxp;
 	xe->info.has_sriov = desc->has_sriov;
+	xe->info.has_vrsr = desc->has_vrsr;
 	xe->info.skip_guc_pc = desc->skip_guc_pc;
 	xe->info.skip_mtcfg = desc->skip_mtcfg;
 	xe->info.skip_pcode = desc->skip_pcode;
Signature · 1 line
2.43.0
#32 lore raw

PATCH 5/12 drm/xe/vrsr: Detect VRSR Capability

In reply to Anshuman Gupta

Detect VRAM Self Refresh(vrsr) Capability.

---
 drivers/gpu/drm/xe/regs/xe_regs.h    |  3 +++
 drivers/gpu/drm/xe/xe_device_types.h |  4 ++++
 drivers/gpu/drm/xe/xe_pm.c           | 27 +++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)
drivers/gpu/drm/xe/regs/xe_regs.h +3 -0
index 3abb17d2ca33..4db486fb310a 100644
@@ -53,6 +53,9 @@
 #define MTL_MPE_FREQUENCY			XE_REG(0x13802c)
 #define   MTL_RPE_MASK				REG_GENMASK(8, 0)
 
+#define VRAM_SR_CAPABILITY                         XE_REG(0x138144)
+#define   VRAM_SR_SUPPORTED                        REG_BIT(0)
+
 #define VF_CAP_REG				XE_REG(0x1901f8, XE_REG_OPTION_VF)
 #define   VF_CAP				REG_BIT(0)
 
drivers/gpu/drm/xe/xe_device_types.h +4 -0
index b8ccf729f7c0..219800092b8d 100644
@@ -498,6 +498,9 @@ struct xe_device {
 		/** @d3cold.allowed: Indicates if d3cold is a valid device state */
 		bool allowed;
 
+		/** @d3cold.vrsr_capable: Indicates if d3cold VRAM Self Refresh is supported */
+		bool vrsr_capable;
+
 		/**
 		 * @d3cold.vram_threshold:
 		 *
@@ -508,6 +511,7 @@ struct xe_device {
 		 * Default threshold value is 300mb.
 		 */
 		u32 vram_threshold;
+
 		/** @d3cold.lock: protect vram_threshold */
 		struct mutex lock;
 	} d3cold;
drivers/gpu/drm/xe/xe_pm.c +27 -0
index a7ddf45db886..c96be409de49 100644
@@ -17,12 +17,15 @@
 #include "xe_bo_evict.h"
 #include "xe_device.h"
 #include "xe_device_sysfs.h"
+#include "xe_force_wake.h"
 #include "xe_ggtt.h"
 #include "xe_gt.h"
 #include "xe_guc.h"
 #include "xe_irq.h"
+#include "xe_mmio.h"
 #include "xe_pcode.h"
 #include "xe_pxp.h"
+#include "regs/xe_regs.h"
 #include "xe_trace.h"
 #include "xe_wa.h"
 
@@ -236,6 +239,28 @@ static bool xe_pm_pci_d3cold_capable(struct xe_device *xe)
 	return true;
 }
 
+static bool xe_pm_vrsr_capable(struct xe_device *xe)
+{
+	struct xe_mmio *mmio = xe_root_tile_mmio(xe);
+	unsigned int fw_ref;
+	struct xe_gt *gt;
+	u32 val;
+
+	gt = xe_root_mmio_gt(xe);
+
+	if (!xe->info.probe_display)
+		return false;
+
+	fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
+	if (!fw_ref)
+		return false;
+
+	val = xe_mmio_read32(mmio, VRAM_SR_CAPABILITY);
+	xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL);
+
+	return val & VRAM_SR_SUPPORTED;
+}
+
 static void xe_pm_runtime_init(struct xe_device *xe)
 {
 	struct device *dev = xe->drm.dev;
@@ -310,6 +335,8 @@ int xe_pm_init(struct xe_device *xe)
 		err = xe_pm_set_vram_threshold(xe, vram_threshold);
 		if (err)
 			return err;
+
+		xe->d3cold.vrsr_capable = xe_pm_vrsr_capable(xe);
 	}
 
 	xe_pm_runtime_init(xe);
Signature · 1 line
2.43.0
#33 lore raw

PATCH 6/12 drm/xe/vrsr: Initialize VRSR feature

In reply to Anshuman Gupta

From: Badal Nilawar <[email protected]>

Initialize VRSR feature by requesting Auxilary Power and PERST# assertion delay. Include an API to enable VRSR feature.

---
 drivers/gpu/drm/xe/xe_device_types.h |  1 +
 drivers/gpu/drm/xe/xe_pcode_api.h    |  8 +++
 drivers/gpu/drm/xe/xe_pm.c           | 92 +++++++++++++++++++++++++++-
 drivers/gpu/drm/xe/xe_pm.h           |  1 +
 4 files changed, 101 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_device_types.h +1 -0
index 219800092b8d..fd9dea207580 100644
@@ -7,6 +7,7 @@
 #define _XE_DEVICE_TYPES_H_
 
 #include <linux/pci.h>
+#include <linux/pci-acpi.h>
 
 #include <drm/drm_device.h>
 #include <drm/drm_file.h>
drivers/gpu/drm/xe/xe_pcode_api.h +8 -0
index e622ae17f08d..cffdf52495f9 100644
@@ -42,6 +42,14 @@
 #define	    POWER_SETUP_I1_SHIFT		6	/* 10.6 fixed point format */
 #define	    POWER_SETUP_I1_DATA_MASK		REG_GENMASK(15, 0)
 
+#define	  PCODE_D3_VRAM_SELF_REFRESH	0x71
+#define	    PCODE_D3_VRSR_SC_DISABLE	0x0
+#define	    PCODE_D3_VRSR_SC_ENABLE	0x1
+#define     PCODE_D3_VRSR_SC_AUX_PL_AND_PERST_DELAY	0x2
+#define     PCODE_D3_VRSR_PERST_SHIFT	16
+#define	    POWER_D3_VRSR_PSERST_MASK	REG_GENMASK(31, 16)
+#define	    POWER_D3_VRSR_AUX_PL_MASK	REG_GENMASK(15, 0)
+
 #define   PCODE_FREQUENCY_CONFIG		0x6e
 /* Frequency Config Sub Commands (param1) */
 #define     PCODE_MBOX_FC_SC_READ_FUSED_P0	0x0
drivers/gpu/drm/xe/xe_pm.c +91 -1

110 lines not on this page · raw message

drivers/gpu/drm/xe/xe_pm.h +1 -0
index 998d1ed64556..2b5df31db4c4 100644
@@ -35,4 +35,5 @@ bool xe_rpm_reclaim_safe(const struct xe_device *xe);
 struct task_struct *xe_pm_read_callback_task(struct xe_device *xe);
 int xe_pm_module_init(void);
 
+int xe_pm_vrsr_enable(struct xe_device *xe, bool enable);
 #endif
Signature · 1 line
2.43.0
#34 lore raw

Re: [PATCH 06/12] drm/xe/vrsr: Initialize VRSR feature

Quoted 4 lines · Anshuman Gupta

From: Badal Nilawar <[email protected]>

Initialize VRSR feature by requesting Auxilary Power and PERST# assertion delay. Include an API to enable VRSR feature.

s/Auxilary/Auxiliary/

I would include the name of the API directly.

Quoted 1 line

+#define PCODE_D3_VRSR_PERST_SHIFT 16

PCODE_D3_VRSR_PERST_SHIFT is not used by this series; maybe omit it?

Quoted 1 line

+#define POWER_D3_VRSR_PSERST_MASK REG_GENMASK(31, 16)

s/PSERST/PERST/ (looks like a typo?)

drivers/gpu/drm/xe/xe_pm.c static bool xe_pm_vrsr_capable(struct xe_device *xe) · line 305

Quoted 5 lines
drivers/gpu/drm/xe/xe_pm.c +5 -0
+static void xe_pm_vrsr_init(struct xe_device *xe)
+{
+	int ret;
+
+	/* Check if platform support d3cold vrsr */

Nicer to consistently capitalize as "VRSR" in comments, commit logs, and messages.

Similar with "D3cold" ("D3cold" is used ~100 times in the tree, "D3Cold" ~20, mostly in xe).

drivers/gpu/drm/xe/xe_pm.c static bool xe_pm_vrsr_capable(struct xe_device *xe) · line 318

Quoted 13 lines
drivers/gpu/drm/xe/xe_pm.c +13 -0
+	if (!xe->info.has_vrsr)
+		return;
+
+	if (!xe_pm_vrsr_capable(xe))
+		return;
+
+	/*
+	 * If the VRSR initialization fails, the device will proceed with the regular
+	 * D3 Cold flow
+	 */
+	ret = pci_acpi_aux_power_setup(xe);
+	if (ret) {
+		drm_info(&xe->drm, "VRSR capable %s\n", "No");

Kinda weird to use %s when the text is a known constant.

drivers/gpu/drm/xe/xe_pm.c static bool xe_pm_vrsr_capable(struct xe_device *xe) · line 323

Quoted 5 lines
drivers/gpu/drm/xe/xe_pm.c +5 -0
+		return;
+	}
+
+	xe->d3cold.vrsr_capable = true;
+	drm_info(&xe->drm, "VRSR capable %s\n", "Yes");

Same.

Quoted 1 line

+}

#35 lore raw

RE: [PATCH 06/12] drm/xe/vrsr: Initialize VRSR feature

Quoted 61 lines

-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: Wednesday, April 2, 2025 1:27 AM
To: Gupta, Anshuman <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; De Marchi, Lucas <[email protected]>; Vivi, Rodrigo <[email protected]>; Nilawar, Badal <[email protected]>; Gupta, Varun <[email protected]>; [email protected]; Shankar, Uma <[email protected]>
Subject: Re: [PATCH 06/12] drm/xe/vrsr: Initialize VRSR feature

Quoted 4 lines · Anshuman Gupta

From: Badal Nilawar <[email protected]>

Initialize VRSR feature by requesting Auxilary Power and PERST# assertion delay. Include an API to enable VRSR feature.

s/Auxilary/Auxiliary/

I would include the name of the API directly.

Quoted 1 line

+#define PCODE_D3_VRSR_PERST_SHIFT 16

PCODE_D3_VRSR_PERST_SHIFT is not used by this series; maybe omit it?

Quoted 1 line

+#define POWER_D3_VRSR_PSERST_MASK REG_GENMASK(31,

16)

s/PSERST/PERST/ (looks like a typo?)

drivers/gpu/drm/xe/xe_pm.c static bool xe_pm_vrsr_capable(struct xe_device *xe) · line 305

Quoted 5 lines
drivers/gpu/drm/xe/xe_pm.c +5 -0
+static void xe_pm_vrsr_init(struct xe_device *xe)
+{
+	int ret;
+
+	/* Check if platform support d3cold vrsr */

Nicer to consistently capitalize as "VRSR" in comments, commit logs, and messages.

Similar with "D3cold" ("D3cold" is used ~100 times in the tree, "D3Cold" ~20, mostly in xe).

drivers/gpu/drm/xe/xe_pm.c static bool xe_pm_vrsr_capable(struct xe_device *xe) · line 318

Quoted 13 lines
drivers/gpu/drm/xe/xe_pm.c +13 -0
+	if (!xe->info.has_vrsr)
+		return;
+
+	if (!xe_pm_vrsr_capable(xe))
+		return;
+
+	/*
+	 * If the VRSR initialization fails, the device will proceed with the regular
+	 * D3 Cold flow
+	 */
+	ret = pci_acpi_aux_power_setup(xe);
+	if (ret) {
+		drm_info(&xe->drm, "VRSR capable %s\n", "No");

Kinda weird to use %s when the text is a known constant.

Quoted 7 lines

drivers/gpu/drm/xe/xe_pm.c static bool xe_pm_vrsr_capable(struct xe_device *xe) · line 323

Quoted 5 lines
drivers/gpu/drm/xe/xe_pm.c +5 -0
+		return;
+	}
+
+	xe->d3cold.vrsr_capable = true;
+	drm_info(&xe->drm, "VRSR capable %s\n", "Yes");

Same.

Thanks for review comment, will address these in v2. Thanks,
Anshuman.

Quoted 2 lines
Quoted 2 lines

+}

#36 lore raw

PATCH 7/12 drm/xe/vrsr: Enable VRSR on default VGA boot device

In reply to Anshuman Gupta

From: Badal Nilawar <[email protected]>

The VRSR feature is to enhance the display screen refresh experience when the device exits from the D3Cold state. Therefore, apply the VRSR feature to the default VGA boot device and when a display is connected.

---
 drivers/gpu/drm/xe/display/xe_display.c | 22 ++++++++++++++++++++++
 drivers/gpu/drm/xe/display/xe_display.h |  2 ++
 drivers/gpu/drm/xe/xe_pm.c              |  5 +++++
 3 files changed, 29 insertions(+)
drivers/gpu/drm/xe/display/xe_display.c +22 -0
index 23937ed3b33d..a7a50f48f1c5 100644
@@ -88,6 +88,28 @@ static void display_destroy(struct drm_device *dev, void *dummy)
 	destroy_workqueue(xe->display.hotplug.dp_wq);
 }
 
+bool xe_display_connected(struct xe_device *xe)
+{
+	struct drm_connector *list_connector;
+	struct drm_connector_list_iter iter;
+	bool ret = false;
+
+	mutex_lock(&xe->drm.mode_config.mutex);
+	drm_connector_list_iter_begin(&xe->drm, &iter);
+
+	drm_for_each_connector_iter(list_connector, &iter) {
+		if (list_connector->status == connector_status_connected) {
+			ret = true;
+			break;
+		}
+	}
+
+	drm_connector_list_iter_end(&iter);
+	mutex_unlock(&xe->drm.mode_config.mutex);
+
+	return ret;
+}
+
 /**
  * xe_display_create - create display struct
  * @xe: XE device instance
drivers/gpu/drm/xe/display/xe_display.h +2 -0
index 46e14f8dee28..a432790d6d34 100644
@@ -39,6 +39,7 @@ void xe_display_pm_resume(struct xe_device *xe);
 void xe_display_pm_runtime_suspend(struct xe_device *xe);
 void xe_display_pm_runtime_suspend_late(struct xe_device *xe);
 void xe_display_pm_runtime_resume(struct xe_device *xe);
+bool xe_display_connected(struct xe_device *xe);
 
 #else
 
@@ -71,5 +72,6 @@ static inline void xe_display_pm_runtime_suspend(struct xe_device *xe) {}
 static inline void xe_display_pm_runtime_suspend_late(struct xe_device *xe) {}
 static inline void xe_display_pm_runtime_resume(struct xe_device *xe) {}
 
+static inline bool xe_display_connected(struct xe_device *xe) {}
 #endif /* CONFIG_DRM_XE_DISPLAY */
 #endif /* _XE_DISPLAY_H_ */
drivers/gpu/drm/xe/xe_pm.c +5 -0
index abb5099475cb..364b937e0ded 100644
@@ -8,6 +8,7 @@
 #include <linux/fault-inject.h>
 #include <linux/pm_runtime.h>
 #include <linux/suspend.h>
+#include <linux/vgaarb.h>
 
 #include <drm/drm_managed.h>
 #include <drm/ttm/ttm_placement.h>
@@ -300,6 +301,7 @@ static int pci_acpi_aux_power_setup(struct xe_device *xe)
 
 static void xe_pm_vrsr_init(struct xe_device *xe)
 {
+	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
 	int ret;
 
 	/* Check if platform support d3cold vrsr */
@@ -309,6 +311,9 @@ static void xe_pm_vrsr_init(struct xe_device *xe)
 	if (!xe_pm_vrsr_capable(xe))
 		return;
 
+	if (pdev != vga_default_device() || !xe_display_connected(xe))
+		return;
+
 	/*
 	 * If the VRSR initialization fails, the device will proceed with the regular
 	 * D3 Cold flow
Signature · 1 line
2.43.0
#37 lore raw

PATCH 8/12 drm/xe: Add PCIe ACPI Aux Power notifier

In reply to Anshuman Gupta

Register PCIe ACPI notifier block and mark vrsr_capable false in the notifier callback. This will ensure that BMG GPU does not explode if any other PCIe child device (under same Root Port) aux power request returns with No main power removal.

---
 drivers/gpu/drm/xe/xe_device_types.h |  3 ++
 drivers/gpu/drm/xe/xe_pm.c           | 41 ++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)
drivers/gpu/drm/xe/xe_device_types.h +3 -0
index fd9dea207580..9aacd5af7d0f 100644
@@ -517,6 +517,9 @@ struct xe_device {
 		struct mutex lock;
 	} d3cold;
 
+	/** @nb: PCI ACPI Aux power notifier */
+	struct notifier_block nb;
+
 	/** @pmt: Support the PMT driver callback interface */
 	struct {
 		/** @pmt.lock: protect access for telemetry data */
drivers/gpu/drm/xe/xe_pm.c +41 -0

53 lines not on this page · raw message

Signature · 1 line
2.43.0
#38 lore raw

PATCH 9/12 drm/xe/vrsr: Refactor d3cold.allowed to a enum

In reply to Anshuman Gupta

Add xe_d3_state enum to add support for VRAM Self Refresh d3cold state.

---
 drivers/gpu/drm/xe/display/xe_display.c |  6 +++---
 drivers/gpu/drm/xe/xe_device_types.h    |  5 +++--
 drivers/gpu/drm/xe/xe_pci.c             |  6 +++---
 drivers/gpu/drm/xe/xe_pm.c              | 16 ++++++++--------
 drivers/gpu/drm/xe/xe_pm.h              |  8 +++++++-
 5 files changed, 24 insertions(+), 17 deletions(-)
drivers/gpu/drm/xe/display/xe_display.c +3 -3
index a7a50f48f1c5..7877c2d61618 100644
@@ -433,7 +433,7 @@ void xe_display_pm_runtime_suspend(struct xe_device *xe)
 	if (!xe->info.probe_display)
 		return;
 
-	if (xe->d3cold.allowed) {
+	if (xe->d3cold.target_state) {
 		xe_display_enable_d3cold(xe);
 		return;
 	}
@@ -459,7 +459,7 @@ void xe_display_pm_runtime_suspend_late(struct xe_device *xe)
 	if (!xe->info.probe_display)
 		return;
 
-	if (xe->d3cold.allowed)
+	if (xe->d3cold.target_state)
 		xe_display_pm_suspend_late(xe);
 
 	/*
@@ -537,7 +537,7 @@ void xe_display_pm_runtime_resume(struct xe_device *xe)
 	if (!xe->info.probe_display)
 		return;
 
-	if (xe->d3cold.allowed) {
+	if (xe->d3cold.target_state) {
 		xe_display_disable_d3cold(xe);
 		return;
 	}
drivers/gpu/drm/xe/xe_device_types.h +3 -2
index 9aacd5af7d0f..9d97f2c84c33 100644
@@ -20,6 +20,7 @@
 #include "xe_memirq_types.h"
 #include "xe_oa_types.h"
 #include "xe_platform_types.h"
+#include "xe_pm.h"
 #include "xe_pmu_types.h"
 #include "xe_pt_types.h"
 #include "xe_sriov_types.h"
@@ -496,8 +497,8 @@ struct xe_device {
 		/** @d3cold.capable: Indicates if root port is d3cold capable */
 		bool capable;
 
-		/** @d3cold.allowed: Indicates if d3cold is a valid device state */
-		bool allowed;
+		/** @d3cold.target_state: Indicates d3cold target state */
+		enum xe_d3_state target_state;
 
 		/** @d3cold.vrsr_capable: Indicates if d3cold VRAM Self Refresh is supported */
 		bool vrsr_capable;
drivers/gpu/drm/xe/xe_pci.c +3 -3
index 70d4827f5821..fa2d43395129 100644
@@ -976,7 +976,7 @@ static int xe_pci_runtime_suspend(struct device *dev)
 
 	pci_save_state(pdev);
 
-	if (xe->d3cold.allowed) {
+	if (xe->d3cold.target_state) {
 		d3cold_toggle(pdev, D3COLD_ENABLE);
 		pci_disable_device(pdev);
 		pci_ignore_hotplug(pdev);
@@ -1001,7 +1001,7 @@ static int xe_pci_runtime_resume(struct device *dev)
 
 	pci_restore_state(pdev);
 
-	if (xe->d3cold.allowed) {
+	if (xe->d3cold.target_state) {
 		err = pci_enable_device(pdev);
 		if (err)
 			return err;
@@ -1017,7 +1017,7 @@ static int xe_pci_runtime_idle(struct device *dev)
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct xe_device *xe = pdev_to_xe_device(pdev);
 
-	xe_pm_d3cold_allowed_toggle(xe);
+	xe_pm_d3cold_target_state_toggle(xe);
 
 	return 0;
 }
drivers/gpu/drm/xe/xe_pm.c +8 -8
index ea93923d6671..d4149a2eace7 100644
@@ -585,7 +585,7 @@ int xe_pm_runtime_suspend(struct xe_device *xe)
 
 	xe_display_pm_runtime_suspend(xe);
 
-	if (xe->d3cold.allowed) {
+	if (xe->d3cold.target_state) {
 		err = xe_bo_evict_all(xe);
 		if (err)
 			goto out_resume;
@@ -632,7 +632,7 @@ int xe_pm_runtime_resume(struct xe_device *xe)
 
 	xe_rpm_lockmap_acquire(xe);
 
-	if (xe->d3cold.allowed) {
+	if (xe->d3cold.target_state) {
 		err = xe_pcode_ready(xe, true);
 		if (err)
 			goto out;
@@ -655,7 +655,7 @@ int xe_pm_runtime_resume(struct xe_device *xe)
 
 	xe_display_pm_runtime_resume(xe);
 
-	if (xe->d3cold.allowed) {
+	if (xe->d3cold.target_state) {
 		err = xe_bo_restore_user(xe);
 		if (err)
 			goto out;
@@ -897,13 +897,13 @@ int xe_pm_set_vram_threshold(struct xe_device *xe, u32 threshold)
 }
 
 /**
- * xe_pm_d3cold_allowed_toggle - Check conditions to toggle d3cold.allowed
+ * xe_pm_d3cold_target_state_toggle - Check conditions to toggle target_state
  * @xe: xe device instance
  *
  * To be called during runtime_pm idle callback.
  * Check for all the D3Cold conditions ahead of runtime suspend.
  */
-void xe_pm_d3cold_allowed_toggle(struct xe_device *xe)
+void xe_pm_d3cold_target_state_toggle(struct xe_device *xe)
 {
 	struct ttm_resource_manager *man;
 	u32 total_vram_used_mb = 0;
@@ -911,7 +911,7 @@ void xe_pm_d3cold_allowed_toggle(struct xe_device *xe)
 	int i;
 
 	if (!xe->d3cold.capable) {
-		xe->d3cold.allowed = false;
+		xe->d3cold.target_state = XE_D3HOT;
 		return;
 	}
 
@@ -926,9 +926,9 @@ void xe_pm_d3cold_allowed_toggle(struct xe_device *xe)
 	mutex_lock(&xe->d3cold.lock);
 
 	if (total_vram_used_mb < xe->d3cold.vram_threshold)
-		xe->d3cold.allowed = true;
+		xe->d3cold.target_state = XE_D3COLD_OFF;
 	else
-		xe->d3cold.allowed = false;
+		xe->d3cold.target_state = XE_D3HOT;
 
 	mutex_unlock(&xe->d3cold.lock);
 }
drivers/gpu/drm/xe/xe_pm.h +7 -1
index 2b5df31db4c4..803c82f50d77 100644
@@ -12,6 +12,12 @@
 
 struct xe_device;
 
+enum xe_d3_state {
+	XE_D3HOT = 0,
+	XE_D3COLD_VRSR,
+	XE_D3COLD_OFF,
+};
+
 int xe_pm_suspend(struct xe_device *xe);
 int xe_pm_resume(struct xe_device *xe);
 
@@ -30,7 +36,7 @@ void xe_pm_runtime_get_noresume(struct xe_device *xe);
 bool xe_pm_runtime_resume_and_get(struct xe_device *xe);
 void xe_pm_assert_unbounded_bridge(struct xe_device *xe);
 int xe_pm_set_vram_threshold(struct xe_device *xe, u32 threshold);
-void xe_pm_d3cold_allowed_toggle(struct xe_device *xe);
+void xe_pm_d3cold_target_state_toggle(struct xe_device *xe);
 bool xe_rpm_reclaim_safe(const struct xe_device *xe);
 struct task_struct *xe_pm_read_callback_task(struct xe_device *xe);
 int xe_pm_module_init(void);
Signature · 1 line
2.43.0
#39 lore raw

PATCH 10/12 drm/xe/pm: D3Cold target state

In reply to Anshuman Gupta

Trade-off D3Cold target state based upon current vram usage. If vram usage is greater than vram_d3cold_threshold and GPU is VRSR capable target D3Cold state is D3Cold-VRSR otherwise target state is D3Cold-Off.

---
 drivers/gpu/drm/xe/xe_pm.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/gpu/drm/xe/xe_pm.c +14 -0
index d4149a2eace7..5db9313ae269 100644
@@ -148,6 +148,14 @@ static void xe_rpm_lockmap_release(const struct xe_device *xe)
 			 &xe_pm_runtime_d3cold_map);
 }
 
+static void xe_pm_suspend_prepare(struct xe_device *xe)
+{
+	if (pm_suspend_target_state == PM_SUSPEND_TO_IDLE)
+		xe_pm_d3cold_allowed_toggle(xe);
+	else
+		xe->d3cold.target_state = XE_D3COLD_OFF;
+}
+
 /**
  * xe_pm_suspend - Helper for System suspend, i.e. S0->S3 / S0->S2idle
  * @xe: xe device instance
@@ -163,6 +171,8 @@ int xe_pm_suspend(struct xe_device *xe)
 	drm_dbg(&xe->drm, "Suspending device\n");
 	trace_xe_pm_suspend(xe, __builtin_return_address(0));
 
+	xe_pm_suspend_prepare(xe);
+
 	err = xe_pxp_pm_suspend(xe->pxp);
 	if (err)
 		goto err;
@@ -927,10 +937,14 @@ void xe_pm_d3cold_target_state_toggle(struct xe_device *xe)
 
 	if (total_vram_used_mb < xe->d3cold.vram_threshold)
 		xe->d3cold.target_state = XE_D3COLD_OFF;
+	else if (xe->d3cold.vrsr_capable)
+		xe->d3cold.target_state = XE_D3COLD_VRSR;
 	else
 		xe->d3cold.target_state = XE_D3HOT;
 
 	mutex_unlock(&xe->d3cold.lock);
+
+	drm_dbg(&xe->drm, "Xe d3cold target state %d\n", xe->d3cold.allowed);
 }
 
 /**
Signature · 1 line
2.43.0
#40 lore raw

Re: [10/12] drm/xe/pm: D3Cold target state

Quoted 40 lines · Anshuman Gupta

Trade-off D3Cold target state based upon current vram usage. If vram usage is greater than vram_d3cold_threshold and GPU is VRSR capable target D3Cold state is D3Cold-VRSR otherwise target state is D3Cold-Off.

---
  drivers/gpu/drm/xe/xe_pm.c | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
drivers/gpu/drm/xe/xe_pm.c +10 -0
index d4149a2eace7..5db9313ae269 100644
@@ -148,6 +148,14 @@ static void xe_rpm_lockmap_release(const struct xe_device *xe)
  			 &xe_pm_runtime_d3cold_map);
  }
 
+static void xe_pm_suspend_prepare(struct xe_device *xe)
+{
+	if (pm_suspend_target_state == PM_SUSPEND_TO_IDLE)
+		xe_pm_d3cold_allowed_toggle(xe);
+	else
+		xe->d3cold.target_state = XE_D3COLD_OFF;
+}
+
  /**
   * xe_pm_suspend - Helper for System suspend, i.e. S0->S3 / S0->S2idle
   * @xe: xe device instance
@@ -163,6 +171,8 @@ int xe_pm_suspend(struct xe_device *xe)
  	drm_dbg(&xe->drm, "Suspending device\n");
  	trace_xe_pm_suspend(xe, __builtin_return_address(0));
 
+	xe_pm_suspend_prepare(xe);
+
  	err = xe_pxp_pm_suspend(xe->pxp);
  	if (err)
  		goto err;
@@ -927,10 +937,14 @@ void xe_pm_d3cold_target_state_toggle(struct xe_device *xe)
 

drivers/gpu/drm/xe/xe_pm.c void xe_pm_d3cold_target_state_toggle(struct xe_device *xe) · line 947

Quoted 10 lines
drivers/gpu/drm/xe/xe_pm.c +4 -0
  	if (total_vram_used_mb < xe->d3cold.vram_threshold)
  		xe->d3cold.target_state = XE_D3COLD_OFF;
+	else if (xe->d3cold.vrsr_capable)
+		xe->d3cold.target_state = XE_D3COLD_VRSR;
  	else
  		xe->d3cold.target_state = XE_D3HOT;
 
  	mutex_unlock(&xe->d3cold.lock);
+
+	drm_dbg(&xe->drm, "Xe d3cold target state %d\n", xe->d3cold.allowed);

the variable should be xe->d3cold.target_state

Quoted 3 lines
drivers/gpu/drm/xe/xe_pm.c +0 -0
  }
 
  /**
#41 lore raw

PATCH 11/12 drm/xe/vrsr: Enable VRSR

In reply to Anshuman Gupta

Enabling VRSR in runtime suspend and also in System wide suspend. Also fix couple of typo in xe_pm.c.

---
 drivers/gpu/drm/xe/xe_pci.c |  4 +--
 drivers/gpu/drm/xe/xe_pm.c  | 51 +++++++++++++++++++++++++++----------
 2 files changed, 39 insertions(+), 16 deletions(-)
drivers/gpu/drm/xe/xe_pci.c +2 -2
index fa2d43395129..3317d475be79 100644
@@ -925,7 +925,7 @@ static int xe_pci_suspend(struct device *dev)
 
 	/*
 	 * Enabling D3Cold is needed for S2Idle/S0ix.
-	 * It is save to allow here since xe_pm_suspend has evicted
+	 * It is safe to allow here since xe_pm_suspend has evicted
 	 * the local memory and the direct complete optimization is disabled.
 	 */
 	d3cold_toggle(pdev, D3COLD_ENABLE);
@@ -942,7 +942,7 @@ static int xe_pci_resume(struct device *dev)
 	struct pci_dev *pdev = to_pci_dev(dev);
 	int err;
 
-	/* Give back the D3Cold decision to the runtime P M*/
+	/* Give back the D3Cold decision to the runtime PM */
 	d3cold_toggle(pdev, D3COLD_DISABLE);
 
 	err = pci_set_power_state(pdev, PCI_D0);
drivers/gpu/drm/xe/xe_pm.c +37 -14

111 lines not on this page · raw message

Signature · 1 line
2.43.0
#42 lore raw

PATCH 12/12 drm/xe/vrsr: Introduce a debugfs node named vrsr_capable

In reply to Anshuman Gupta

From: Badal Nilawar <[email protected]>

Add a debugfs node named vrsr_capable to check if the device supports VRSR

---
 drivers/gpu/drm/xe/xe_debugfs.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/gpu/drm/xe/xe_debugfs.c +20 -0
index d0503959a8ed..9f8d635c750c 100644
@@ -191,6 +191,23 @@ static const struct file_operations wedged_mode_fops = {
 	.write = wedged_mode_set,
 };
 
+static ssize_t vrsr_capable_show(struct file *f, char __user *ubuf,
+				size_t size, loff_t *pos)
+{
+	struct xe_device *xe = file_inode(f)->i_private;
+	char buf[32];
+	int len = 0;
+
+	len = scnprintf(buf, sizeof(buf), "%s\n", xe->d3cold.vrsr_capable ? "true" : "false");
+
+	return simple_read_from_buffer(ubuf, size, pos, buf, len);
+}
+
+static const struct file_operations vrsr_capable_fops = {
+	.owner = THIS_MODULE,
+	.read = vrsr_capable_show,
+};
+
 void xe_debugfs_register(struct xe_device *xe)
 {
 	struct ttm_device *bdev = &xe->ttm;
@@ -211,6 +228,9 @@ void xe_debugfs_register(struct xe_device *xe)
 	debugfs_create_file("wedged_mode", 0600, root, xe,
 			    &wedged_mode_fops);
 
+	debugfs_create_file("vrsr_capable", 0400, root, xe,
+			    &vrsr_capable_fops);
+
 	for (mem_type = XE_PL_VRAM0; mem_type <= XE_PL_VRAM1; ++mem_type) {
 		man = ttm_manager_type(bdev, mem_type);
 
Signature · 1 line
2.43.0
#43 lore raw

✓ CI.Patch_applied: success for VRAM Self Refresh (rev2)

In reply to Anshuman Gupta
== Series Details ==

== Series Details ==

Series: VRAM Self Refresh (rev2)
URL : https://patchwork.freedesktop.org/series/145342/
State : success

== Summary ==

=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: 075a54ae8869 drm-tip: 2025y-04m-01d-14h-58m-16s UTC integration manifest === git am output follows ===
Applying: PCI/ACPI: Add D3cold Aux Power Limit_DSM method
Applying: PCI/ACPI: Add PERST# Assertion Delay _DSM method
Applying: PCI/ACPI: Add aux power grant notifier
Applying: drm/xe/vrsr: Introduce flag has_vrsr
Applying: drm/xe/vrsr: Detect VRSR Capability
Applying: drm/xe/vrsr: Initialize VRSR feature
Applying: drm/xe/vrsr: Enable VRSR on default VGA boot device
Applying: drm/xe: Add PCIe ACPI Aux Power notifier
Applying: drm/xe/vrsr: Refactor d3cold.allowed to a enum
Applying: drm/xe/pm: D3Cold target state
Applying: drm/xe/vrsr: Enable VRSR
Applying: drm/xe/vrsr: Introduce a debugfs node named vrsr_capable

#44 lore raw

✗ CI.checkpatch: warning for VRAM Self Refresh (rev2)

In reply to Anshuman Gupta
== Series Details ==

== Series Details ==

Series: VRAM Self Refresh (rev2)
URL : https://patchwork.freedesktop.org/series/145342/
State : warning

== Summary ==

+ KERNEL=/kernel
+ git clone https://gitlab.freedesktop.org/drm/maintainer-tools mt Cloning into 'mt'...
warning: redirecting to https://gitlab.freedesktop.org/drm/maintainer-tools.git/
+ git -C mt rev-list -n1 origin/master 99e5a866b5e13f134e606a3e29d9508d97826fb3
+ cd /kernel
+ git config --global --add safe.directory /kernel
+ git log -n1
commit ab1c592bbcdc021074954cf236dd2fa24641fb41

Author: Badal Nilawar <[email protected]>
Date:   Tue Apr 1 21:02:25 2025 +0530

drm/xe/vrsr: Introduce a debugfs node named vrsr_capable

Add a debugfs node named vrsr_capable to check if the device supports VRSR

+ /mt/dim checkpatch 075a54ae88695f050fb8baef7e98dee9dfd489df drm-intel 16a13737be22 PCI/ACPI: Add D3cold Aux Power Limit_DSM method 617cc8039d32 PCI/ACPI: Add PERST# Assertion Delay _DSM method -:64: WARNING:MISSING_SPACE: break quoted strings at a space character #64: FILE: drivers/pci/pci-acpi.c:1547:
+ "PERST# Assertion Delay request failed"
+ "Previous valid delay: %u microseconds\n", result);

total: 0 errors, 1 warnings, 0 checks, 84 lines checked f5c35285f625 PCI/ACPI: Add aux power grant notifier 4822e43abc6d drm/xe/vrsr: Introduce flag has_vrsr
423e85554df1 drm/xe/vrsr: Detect VRSR Capability
52417d71d2a1 drm/xe/vrsr: Initialize VRSR feature
-:74: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #74: FILE: drivers/gpu/drm/xe/xe_pm.c:280:
+ ret = xe_pcode_read(root_tile, PCODE_MBOX(PCODE_D3_VRAM_SELF_REFRESH,
+ PCODE_D3_VRSR_SC_AUX_PL_AND_PERST_DELAY, 0),

-:140: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #140: FILE: drivers/gpu/drm/xe/xe_pm.c:346:
+ ret = xe_pcode_write(root_tile, PCODE_MBOX(PCODE_D3_VRAM_SELF_REFRESH,
+ PCODE_D3_VRSR_SC_ENABLE, 0), uval);

-:143: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #143: FILE: drivers/gpu/drm/xe/xe_pm.c:349:
+ ret = xe_pcode_write(root_tile, PCODE_MBOX(PCODE_D3_VRAM_SELF_REFRESH,
+ PCODE_D3_VRSR_SC_DISABLE, 0), uval);

total: 0 errors, 0 warnings, 3 checks, 136 lines checked 203aff741da0 drm/xe/vrsr: Enable VRSR on default VGA boot device 656e063b1c66 drm/xe: Add PCIe ACPI Aux Power notifier d32bae784227 drm/xe/vrsr: Refactor d3cold.allowed to a enum ae4578e9578f drm/xe/pm: D3Cold target state
eeee16a5db81 drm/xe/vrsr: Enable VRSR
ab1c592bbcdc drm/xe/vrsr: Introduce a debugfs node named vrsr_capable -:20: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #20: FILE: drivers/gpu/drm/xe/xe_debugfs.c:195:
+static ssize_t vrsr_capable_show(struct file *f, char __user *ubuf,
+ size_t size, loff_t *pos)

total: 0 errors, 0 warnings, 1 checks, 32 lines checked

#45 lore raw

✗ CI.KUnit: failure for VRAM Self Refresh (rev2)

In reply to Anshuman Gupta
== Series Details ==

== Series Details ==

Series: VRAM Self Refresh (rev2)
URL : https://patchwork.freedesktop.org/series/145342/
State : failure

== Summary ==

+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig [15:42:24] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:

$ make ARCH=um O=.kunit olddefconfig
[15:42:28] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make all compile_commands.json ARCH=um O=.kunit --jobs=48
ERROR:root:In file included from ../drivers/gpu/drm/xe/xe_device_types.h:10,
                 from ../drivers/gpu/drm/xe/xe_gt_types.h:9,
                 from ../drivers/gpu/drm/xe/xe_assert.h:13,
                 from ../drivers/gpu/drm/xe/xe_bb.c:9:
../include/linux/pci-acpi.h:149:5: warning: no previous prototype for ‘pci_acpi_register_aux_power_notifier’ [-Wmissing-prototypes]
  149 | int pci_acpi_register_aux_power_notifier(struct notifier_block *nb)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:154:6: warning: no previous prototype for ‘pci_acpi_unregister_aux_power_notifier’ [-Wmissing-prototypes]
  154 | void pci_acpi_unregister_aux_power_notifier(struct notifier_block *nb) { }
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:156:5: warning: no previous prototype for ‘pci_acpi_request_d3cold_aux_power’ [-Wmissing-prototypes]
  156 | int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:161:5: warning: no previous prototype for ‘pci_acpi_add_perst_assertion_delay’ [-Wmissing-prototypes]
  161 | int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../drivers/gpu/drm/xe/xe_device_types.h:10,
                 from ../drivers/gpu/drm/xe/xe_bo_types.h:16,
                 from ../drivers/gpu/drm/xe/xe_bo.h:11,
                 from ../drivers/gpu/drm/xe/xe_bo.c:6:
../include/linux/pci-acpi.h:149:5: warning: no previous prototype for ‘pci_acpi_register_aux_power_notifier’ [-Wmissing-prototypes]
  149 | int pci_acpi_register_aux_power_notifier(struct notifier_block *nb)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:154:6: warning: no previous prototype for ‘pci_acpi_unregister_aux_power_notifier’ [-Wmissing-prototypes]
  154 | void pci_acpi_unregister_aux_power_notifier(struct notifier_block *nb) { }
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:156:5: warning: no previous prototype for ‘pci_acpi_request_d3cold_aux_power’ [-Wmissing-prototypes]
  156 | int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:161:5: warning: no previous prototype for ‘pci_acpi_add_perst_assertion_delay’ [-Wmissing-prototypes]
  161 | int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../drivers/gpu/drm/xe/xe_device_types.h:10,
                 from ../drivers/gpu/drm/xe/xe_device.h:11,
                 from ../drivers/gpu/drm/xe/tests/xe_pci_test.c:13:
../include/linux/pci-acpi.h:149:5: warning: no previous prototype for ‘pci_acpi_register_aux_power_notifier’ [-Wmissing-prototypes]
  149 | int pci_acpi_register_aux_power_notifier(struct notifier_block *nb)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:154:6: warning: no previous prototype for ‘pci_acpi_unregister_aux_power_notifier’ [-Wmissing-prototypes]
  154 | void pci_acpi_unregister_aux_power_notifier(struct notifier_block *nb) { }
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:156:5: warning: no previous prototype for ‘pci_acpi_request_d3cold_aux_power’ [-Wmissing-prototypes]
  156 | int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:161:5: warning: no previous prototype for ‘pci_acpi_add_perst_assertion_delay’ [-Wmissing-prototypes]
  161 | int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../drivers/gpu/drm/xe/xe_device_types.h:10,
                 from ../drivers/gpu/drm/xe/xe_device.h:11,
                 from ../drivers/gpu/drm/xe/tests/xe_wa_test.c:11:
../include/linux/pci-acpi.h:149:5: warning: no previous prototype for ‘pci_acpi_register_aux_power_notifier’ [-Wmissing-prototypes]
  149 | int pci_acpi_register_aux_power_notifier(struct notifier_block *nb)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:154:6: warning: no previous prototype for ‘pci_acpi_unregister_aux_power_notifier’ [-Wmissing-prototypes]
  154 | void pci_acpi_unregister_aux_power_notifier(struct notifier_block *nb) { }
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:156:5: warning: no previous prototype for ‘pci_acpi_request_d3cold_aux_power’ [-Wmissing-prototypes]
  156 | int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:161:5: warning: no previous prototype for ‘pci_acpi_add_perst_assertion_delay’ [-Wmissing-prototypes]
  161 | int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../drivers/gpu/drm/xe/xe_device_types.h:10,
                 from ../drivers/gpu/drm/xe/xe_device.h:11,
                 from ../drivers/gpu/drm/xe/tests/xe_rtp_test.c:16:
../include/linux/pci-acpi.h:149:5: warning: no previous prototype for ‘pci_acpi_register_aux_power_notifier’ [-Wmissing-prototypes]
  149 | int pci_acpi_register_aux_power_notifier(struct notifier_block *nb)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:154:6: warning: no previous prototype for ‘pci_acpi_unregister_aux_power_notifier’ [-Wmissing-prototypes]
  154 | void pci_acpi_unregister_aux_power_notifier(struct notifier_block *nb) { }
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:156:5: warning: no previous prototype for ‘pci_acpi_request_d3cold_aux_power’ [-Wmissing-prototypes]
  156 | int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:161:5: warning: no previous prototype for ‘pci_acpi_add_perst_assertion_delay’ [-Wmissing-prototypes]
  161 | int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../drivers/gpu/drm/xe/xe_device_types.h:10,
                 from ../drivers/gpu/drm/xe/xe_bo_types.h:16,
                 from ../drivers/gpu/drm/xe/xe_bo.h:11,
                 from ../drivers/gpu/drm/xe/xe_bo_evict.c:8:
../include/linux/pci-acpi.h:149:5: warning: no previous prototype for ‘pci_acpi_register_aux_power_notifier’ [-Wmissing-prototypes]
  149 | int pci_acpi_register_aux_power_notifier(struct notifier_block *nb)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:154:6: warning: no previous prototype for ‘pci_acpi_unregister_aux_power_notifier’ [-Wmissing-prototypes]
  154 | void pci_acpi_unregister_aux_power_notifier(struct notifier_block *nb) { }
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:156:5: warning: no previous prototype for ‘pci_acpi_request_d3cold_aux_power’ [-Wmissing-prototypes]
  156 | int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:161:5: warning: no previous prototype for ‘pci_acpi_add_perst_assertion_delay’ [-Wmissing-prototypes]
  161 | int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../drivers/gpu/drm/xe/xe_device_types.h:10,
                 from ../drivers/gpu/drm/xe/xe_device.h:11,
                 from ../drivers/gpu/drm/xe/xe_devcoredump.c:15:
../include/linux/pci-acpi.h:149:5: warning: no previous prototype for ‘pci_acpi_register_aux_power_notifier’ [-Wmissing-prototypes]
  149 | int pci_acpi_register_aux_power_notifier(struct notifier_block *nb)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:154:6: warning: no previous prototype for ‘pci_acpi_unregister_aux_power_notifier’ [-Wmissing-prototypes]
  154 | void pci_acpi_unregister_aux_power_notifier(struct notifier_block *nb) { }
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:156:5: warning: no previous prototype for ‘pci_acpi_request_d3cold_aux_power’ [-Wmissing-prototypes]
  156 | int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:161:5: warning: no previous prototype for ‘pci_acpi_add_perst_assertion_delay’ [-Wmissing-prototypes]
  161 | int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../drivers/gpu/drm/xe/xe_device_types.h:10,
                 from ../drivers/gpu/drm/xe/xe_device.h:11,
                 from ../drivers/gpu/drm/xe/xe_device.c:6:
../include/linux/pci-acpi.h:149:5: warning: no previous prototype for ‘pci_acpi_register_aux_power_notifier’ [-Wmissing-prototypes]
  149 | int pci_acpi_register_aux_power_notifier(struct notifier_block *nb)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:154:6: warning: no previous prototype for ‘pci_acpi_unregister_aux_power_notifier’ [-Wmissing-prototypes]
  154 | void pci_acpi_unregister_aux_power_notifier(struct notifier_block *nb) { }
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:156:5: warning: no previous prototype for ‘pci_acpi_request_d3cold_aux_power’ [-Wmissing-prototypes]
  156 | int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:161:5: warning: no previous prototype for ‘pci_acpi_add_perst_assertion_delay’ [-Wmissing-prototypes]
  161 | int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../drivers/gpu/drm/xe/xe_device.c:21:
../drivers/gpu/drm/xe/display/xe_display.h: In function ‘xe_display_connected’:
../drivers/gpu/drm/xe/display/xe_display.h:75:48: error: no return statement in function returning non-void [-Werror=return-type]
   75 | static inline bool xe_display_connected(struct xe_device *xe) {}
      |                                                ^~~~~~~~~
In file included from ../drivers/gpu/drm/xe/xe_device_types.h:10,
                 from ../drivers/gpu/drm/xe/xe_device.h:11,
                 from ../drivers/gpu/drm/xe/xe_device_sysfs.c:12:
../include/linux/pci-acpi.h:149:5: warning: no previous prototype for ‘pci_acpi_register_aux_power_notifier’ [-Wmissing-prototypes]
  149 | int pci_acpi_register_aux_power_notifier(struct notifier_block *nb)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:154:6: warning: no previous prototype for ‘pci_acpi_unregister_aux_power_notifier’ [-Wmissing-prototypes]
  154 | void pci_acpi_unregister_aux_power_notifier(struct notifier_block *nb) { }
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:156:5: warning: no previous prototype for ‘pci_acpi_request_d3cold_aux_power’ [-Wmissing-prototypes]
  156 | int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:161:5: warning: no previous prototype for ‘pci_acpi_add_perst_assertion_delay’ [-Wmissing-prototypes]
  161 | int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../drivers/gpu/drm/xe/xe_device_types.h:10,
                 from ../drivers/gpu/drm/xe/xe_bo_types.h:16,
                 from ../drivers/gpu/drm/xe/xe_bo.h:11,
                 from ../drivers/gpu/drm/xe/xe_dma_buf.c:17:
../include/linux/pci-acpi.h:149:5: warning: no previous prototype for ‘pci_acpi_register_aux_power_notifier’ [-Wmissing-prototypes]
  149 | int pci_acpi_register_aux_power_notifier(struct notifier_block *nb)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:154:6: warning: no previous prototype for ‘pci_acpi_unregister_aux_power_notifier’ [-Wmissing-prototypes]
  154 | void pci_acpi_unregister_aux_power_notifier(struct notifier_block *nb) { }
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:156:5: warning: no previous prototype for ‘pci_acpi_request_d3cold_aux_power’ [-Wmissing-prototypes]
  156 | int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:161:5: warning: no previous prototype for ‘pci_acpi_add_perst_assertion_delay’ [-Wmissing-prototypes]
  161 | int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[7]: *** [../scripts/Makefile.build:207: drivers/gpu/drm/xe/xe_device.o] Error 1
make[7]: *** Waiting for unfinished jobs....
In file included from ../drivers/gpu/drm/xe/xe_device_types.h:10,
                 from ../drivers/gpu/drm/xe/xe_gt_types.h:9,
                 from ../drivers/gpu/drm/xe/xe_assert.h:13,
                 from ../drivers/gpu/drm/xe/xe_drm_client.c:13:
../include/linux/pci-acpi.h:149:5: warning: no previous prototype for ‘pci_acpi_register_aux_power_notifier’ [-Wmissing-prototypes]
  149 | int pci_acpi_register_aux_power_notifier(struct notifier_block *nb)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:154:6: warning: no previous prototype for ‘pci_acpi_unregister_aux_power_notifier’ [-Wmissing-prototypes]
  154 | void pci_acpi_unregister_aux_power_notifier(struct notifier_block *nb) { }
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:156:5: warning: no previous prototype for ‘pci_acpi_request_d3cold_aux_power’ [-Wmissing-prototypes]
  156 | int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:161:5: warning: no previous prototype for ‘pci_acpi_add_perst_assertion_delay’ [-Wmissing-prototypes]
  161 | int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../drivers/gpu/drm/xe/xe_device_types.h:10,
                 from ../drivers/gpu/drm/xe/xe_bo_types.h:16,
                 from ../drivers/gpu/drm/xe/xe_bo.h:11,
                 from ../drivers/gpu/drm/xe/xe_eu_stall.c:15:
../include/linux/pci-acpi.h:149:5: warning: no previous prototype for ‘pci_acpi_register_aux_power_notifier’ [-Wmissing-prototypes]
  149 | int pci_acpi_register_aux_power_notifier(struct notifier_block *nb)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:154:6: warning: no previous prototype for ‘pci_acpi_unregister_aux_power_notifier’ [-Wmissing-prototypes]
  154 | void pci_acpi_unregister_aux_power_notifier(struct notifier_block *nb) { }
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:156:5: warning: no previous prototype for ‘pci_acpi_request_d3cold_aux_power’ [-Wmissing-prototypes]
  156 | int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/pci-acpi.h:161:5: warning: no previous prototype for ‘pci_acpi_add_perst_assertion_delay’ [-Wmissing-prototypes]
  161 | int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[6]: *** [../scripts/Makefile.build:465: drivers/gpu/drm/xe] Error 2
make[5]: *** [../scripts/Makefile.build:465: drivers/gpu/drm] Error 2
make[4]: *** [../scripts/Makefile.build:465: drivers/gpu] Error 2
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [../scripts/Makefile.build:465: drivers] Error 2
make[3]: *** Waiting for unfinished jobs....
../lib/iomap.c:156:5: warning: no previous prototype for ‘ioread64_lo_hi’ [-Wmissing-prototypes]
  156 | u64 ioread64_lo_hi(const void __iomem *addr)
      |     ^~~~~~~~~~~~~~
../lib/iomap.c:163:5: warning: no previous prototype for ‘ioread64_hi_lo’ [-Wmissing-prototypes]
  163 | u64 ioread64_hi_lo(const void __iomem *addr)
      |     ^~~~~~~~~~~~~~
../lib/iomap.c:170:5: warning: no previous prototype for ‘ioread64be_lo_hi’ [-Wmissing-prototypes]
  170 | u64 ioread64be_lo_hi(const void __iomem *addr)
      |     ^~~~~~~~~~~~~~~~
../lib/iomap.c:178:5: warning: no previous prototype for ‘ioread64be_hi_lo’ [-Wmissing-prototypes]
  178 | u64 ioread64be_hi_lo(const void __iomem *addr)
      |     ^~~~~~~~~~~~~~~~
../lib/iomap.c:264:6: warning: no previous prototype for ‘iowrite64_lo_hi’ [-Wmissing-prototypes]
  264 | void iowrite64_lo_hi(u64 val, void __iomem *addr)
      |      ^~~~~~~~~~~~~~~
../lib/iomap.c:272:6: warning: no previous prototype for ‘iowrite64_hi_lo’ [-Wmissing-prototypes]
  272 | void iowrite64_hi_lo(u64 val, void __iomem *addr)
      |      ^~~~~~~~~~~~~~~
../lib/iomap.c:280:6: warning: no previous prototype for ‘iowrite64be_lo_hi’ [-Wmissing-prototypes]
  280 | void iowrite64be_lo_hi(u64 val, void __iomem *addr)
      |      ^~~~~~~~~~~~~~~~~
../lib/iomap.c:288:6: warning: no previous prototype for ‘iowrite64be_hi_lo’ [-Wmissing-prototypes]
  288 | void iowrite64be_hi_lo(u64 val, void __iomem *addr)
      |      ^~~~~~~~~~~~~~~~~
make[2]: *** [/kernel/Makefile:1994: .] Error 2
make[1]: *** [/kernel/Makefile:251: __sub-make] Error 2
make: *** [Makefile:251: __sub-make] Error 2

+ cleanup
++ stat -c %u:%g /kernel
+ chown -R 1003:1003 /kernel