linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/11] VRAM Self Refresh
@ 2025-05-23 19:01 Badal Nilawar
  2025-05-23 19:01 ` [PATCH v3 01/11] PCI/ACPI: Add D3cold Aux Power Limit_DSM method Badal Nilawar
                   ` (10 more replies)
  0 siblings, 11 replies; 17+ messages in thread
From: Badal Nilawar @ 2025-05-23 19:01 UTC (permalink / raw)
  To: intel-xe, linux-acpi, linux-pci
  Cc: anshuman.gupta, rafael, lenb, bhelgaas, ilpo.jarvinen,
	lucas.demarchi, rodrigo.vivi, varun.gupta, ville.syrjala,
	uma.shankar

This revision has fixed the below review comment on rev2 series.

PCIe ACPI Patches:
- dropped the notifier block code and added patch to allow only one Aux
  power limit request per root port (Rafael)
- Addressed Review comments (Rafael J. Wysocki, Bjorn Helgaas)

Xe Pacthes:
- Addressed Review comments (Bjorn Helgaas)



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

Badal Nilawar (5):
  PCI/ACPI: Per root port allow one Aux power limit request
  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/acpi/scan.c                     |   1 +
 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    |  12 +-
 drivers/gpu/drm/xe/xe_pci.c             |  13 +-
 drivers/gpu/drm/xe/xe_pcode_api.h       |   7 +
 drivers/gpu/drm/xe/xe_pm.c              | 206 +++++++++++++++++++++---
 drivers/gpu/drm/xe/xe_pm.h              |   9 +-
 drivers/pci/pci-acpi.c                  | 167 +++++++++++++++++++
 include/acpi/acpi_bus.h                 |   2 +
 include/linux/pci-acpi.h                |  16 +-
 13 files changed, 456 insertions(+), 30 deletions(-)

-- 
2.34.1


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

* [PATCH v3 01/11] PCI/ACPI: Add D3cold Aux Power Limit_DSM method
  2025-05-23 19:01 [PATCH v3 00/11] VRAM Self Refresh Badal Nilawar
@ 2025-05-23 19:01 ` Badal Nilawar
  2025-05-24  6:00   ` Sathyanarayanan Kuppuswamy
  2025-05-23 19:01 ` [PATCH v3 02/11] PCI/ACPI: Per root port allow one Aux power limit request Badal Nilawar
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 17+ messages in thread
From: Badal Nilawar @ 2025-05-23 19:01 UTC (permalink / raw)
  To: intel-xe, linux-acpi, linux-pci
  Cc: anshuman.gupta, rafael, lenb, bhelgaas, ilpo.jarvinen,
	lucas.demarchi, rodrigo.vivi, varun.gupta, ville.syrjala,
	uma.shankar

From: Anshuman Gupta <anshuman.gupta@intel.com>

Implement _DSM method 0Ah according to PCI firmware specifications,
section 4.6.10 Rev 3.3., to request auxilary power needed for the
device when in D3Cold.

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 0Ah.

V2(Bjorn/Rafael):
  - Call acpi_dsm_check() to find method 0Ah supported
  - Return retry interval to caller

Signed-off-by: Varun Gupta <varun.gupta@intel.com>
Signed-off-by: Badal Nilawar <badal.nilawar@intel.com>
Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
---
 drivers/pci/pci-acpi.c   | 87 ++++++++++++++++++++++++++++++++++++++++
 include/linux/pci-acpi.h |  8 ++++
 2 files changed, 95 insertions(+)

diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index af370628e583..76b19525535f 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -1421,6 +1421,93 @@ static void pci_acpi_optimize_delay(struct pci_dev *pdev,
 	ACPI_FREE(obj);
 }
 
+/**
+ * pci_acpi_request_d3cold_aux_power - Request aux power while device is in D3Cold
+ * @dev: PCI device instance
+ * @requested_power: Requested auxiliary power in milliwatts
+ * @retry_interval: Retry interval returned by platform to retry auxiliary
+ *                  power request
+ *
+ * This function sends a request to the host BIOS via root port ACPI _DSM Function 0Ah
+ * for the auxiliary power needed by the PCI device when it is in D3Cold.
+ * It checks and 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,
+				      u32 *retry_interval)
+{
+	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)
+		return -EINVAL;
+
+	handle = ACPI_HANDLE(&dev->dev);
+	if (!handle)
+		return -EINVAL;
+
+	if (!acpi_check_dsm(handle, &pci_acpi_dsm_guid, 4, 1 << DSM_PCI_D3COLD_AUX_POWER_LIMIT)) {
+		pci_dbg(dev, "ACPI _DSM 0%Xh not supported\n", DSM_PCI_D3COLD_AUX_POWER_LIMIT);
+		return -ENODEV;
+	}
+
+	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;
+	if (retry_interval)
+		*retry_interval = 0;
+
+	switch (result) {
+	case 0x0:
+		pci_dbg(dev, "D3cold Aux Power %u mW request denied\n",
+			requested_power);
+		break;
+	case 0x1:
+		pci_info(dev, "D3cold Aux Power request granted: %u mW\n",
+			 requested_power);
+		ret = 0;
+		break;
+	case 0x2:
+		pci_info(dev, "D3cold Aux Power: Main power won't be removed\n");
+		ret = -EBUSY;
+		break;
+	default:
+		if (result >= 0x11 && result <= 0x1F) {
+			if (retry_interval) {
+				*retry_interval = result & 0xF;
+				pci_warn(dev, "D3cold Aux Power request needs retry interval: %u seconds\n",
+					 *retry_interval);
+				ret = -EAGAIN;
+			}
+		} else {
+			pci_err(dev, "D3cold Aux Power: Reserved or unsupported response: 0x%x\n",
+				result);
+		}
+		break;
+	}
+
+	ACPI_FREE(out_obj);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(pci_acpi_request_d3cold_aux_power);
+
 static void pci_acpi_set_external_facing(struct pci_dev *dev)
 {
 	u8 val;
diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
index 078225b514d4..1705d03bfe26 100644
--- a/include/linux/pci-acpi.h
+++ b/include/linux/pci-acpi.h
@@ -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,17 @@ 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,
+				      u32 *retry_interval);
 
 #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) { }
+static int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power,
+					     u32 *retry_interval)
+{
+	return -EOPNOTSUPP;
+}
 #endif	/* CONFIG_ACPI */
 
 #endif	/* _PCI_ACPI_H_ */
-- 
2.34.1


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

* [PATCH v3 02/11] PCI/ACPI: Per root port allow one Aux power limit request
  2025-05-23 19:01 [PATCH v3 00/11] VRAM Self Refresh Badal Nilawar
  2025-05-23 19:01 ` [PATCH v3 01/11] PCI/ACPI: Add D3cold Aux Power Limit_DSM method Badal Nilawar
@ 2025-05-23 19:01 ` Badal Nilawar
  2025-05-23 19:01 ` [PATCH v3 03/11] PCI/ACPI: Add PERST# Assertion Delay _DSM method Badal Nilawar
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Badal Nilawar @ 2025-05-23 19:01 UTC (permalink / raw)
  To: intel-xe, linux-acpi, linux-pci
  Cc: anshuman.gupta, rafael, lenb, bhelgaas, ilpo.jarvinen,
	lucas.demarchi, rodrigo.vivi, varun.gupta, ville.syrjala,
	uma.shankar

For given root port allow one Aux power limit request.

Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Anshuman Gupta <anshuman.gupta@intel.com>
Signed-off-by: Badal Nilawar <badal.nilawar@intel.com>
---
 drivers/acpi/scan.c     |  1 +
 drivers/pci/pci-acpi.c  | 25 ++++++++++++++++++++++++-
 include/acpi/acpi_bus.h |  2 ++
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index fb1fe9f3b1a3..9ae7be9db01a 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -745,6 +745,7 @@ int acpi_device_add(struct acpi_device *device)
 	INIT_LIST_HEAD(&device->physical_node_list);
 	INIT_LIST_HEAD(&device->del_list);
 	mutex_init(&device->physical_node_lock);
+	mutex_init(&device->power.aux_pwr_lock);
 
 	mutex_lock(&acpi_device_lock);
 
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 76b19525535f..53ba67678c3d 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -1451,6 +1451,7 @@ int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power,
 	union acpi_object *out_obj;
 	acpi_handle handle;
 	int result, ret = -EINVAL;
+	struct acpi_device *adev;
 
 	if (!dev)
 		return -EINVAL;
@@ -1464,11 +1465,27 @@ int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power,
 		return -ENODEV;
 	}
 
+	adev = ACPI_COMPANION(&dev->dev);
+	if (!adev)
+		return -EINVAL;
+
+	mutex_lock(&adev->power.aux_pwr_lock);
+
+	/* Check if aux power already granted */
+	if (adev->power.aux_power_limit) {
+		pci_info(dev, "D3cold Aux Power request already granted: %u mW\n",
+			 adev->power.aux_power_limit);
+		mutex_unlock(&adev->power.aux_pwr_lock);
+		return -EPERM;
+	}
+
 	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)
+	if (!out_obj) {
+		mutex_unlock(&adev->power.aux_pwr_lock);
 		return -EINVAL;
+	}
 
 	result = out_obj->integer.value;
 	if (retry_interval)
@@ -1478,14 +1495,17 @@ int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power,
 	case 0x0:
 		pci_dbg(dev, "D3cold Aux Power %u mW request denied\n",
 			requested_power);
+		adev->power.aux_power_limit = 0;
 		break;
 	case 0x1:
 		pci_info(dev, "D3cold Aux Power request granted: %u mW\n",
 			 requested_power);
+		adev->power.aux_power_limit = requested_power;
 		ret = 0;
 		break;
 	case 0x2:
 		pci_info(dev, "D3cold Aux Power: Main power won't be removed\n");
+		adev->power.aux_power_limit = 0;
 		ret = -EBUSY;
 		break;
 	default:
@@ -1500,9 +1520,12 @@ int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power,
 			pci_err(dev, "D3cold Aux Power: Reserved or unsupported response: 0x%x\n",
 				result);
 		}
+		adev->power.aux_power_limit = 0;
 		break;
 	}
 
+	mutex_unlock(&adev->power.aux_pwr_lock);
+
 	ACPI_FREE(out_obj);
 	return ret;
 }
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index aad1a95e6863..c4ce3d84be00 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -294,6 +294,8 @@ struct acpi_device_power {
 	struct acpi_device_power_flags flags;
 	struct acpi_device_power_state states[ACPI_D_STATE_COUNT];	/* Power states (D0-D3Cold) */
 	u8 state_for_enumeration; /* Deepest power state for enumeration */
+	u32 aux_power_limit;		/* aux power limit granted by bios */
+	struct mutex aux_pwr_lock;	/* prevent concurrent aux power limit requests */
 };
 
 struct acpi_dep_data {
-- 
2.34.1


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

* [PATCH v3 03/11] PCI/ACPI: Add PERST# Assertion Delay _DSM method
  2025-05-23 19:01 [PATCH v3 00/11] VRAM Self Refresh Badal Nilawar
  2025-05-23 19:01 ` [PATCH v3 01/11] PCI/ACPI: Add D3cold Aux Power Limit_DSM method Badal Nilawar
  2025-05-23 19:01 ` [PATCH v3 02/11] PCI/ACPI: Per root port allow one Aux power limit request Badal Nilawar
@ 2025-05-23 19:01 ` Badal Nilawar
  2025-05-23 19:01 ` [PATCH v3 04/11] drm/xe/vrsr: Introduce flag has_vrsr Badal Nilawar
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Badal Nilawar @ 2025-05-23 19:01 UTC (permalink / raw)
  To: intel-xe, linux-acpi, linux-pci
  Cc: anshuman.gupta, rafael, lenb, bhelgaas, ilpo.jarvinen,
	lucas.demarchi, rodrigo.vivi, varun.gupta, ville.syrjala,
	uma.shankar

From: Anshuman Gupta <anshuman.gupta@intel.com>

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

Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
Signed-off-by: Badal Nilawar <badal.nilawar@intel.com>
---
 drivers/pci/pci-acpi.c   | 57 ++++++++++++++++++++++++++++++++++++++++
 include/linux/pci-acpi.h |  8 +++++-
 2 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 53ba67678c3d..678c48f72010 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -1531,6 +1531,63 @@ int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power,
 }
 EXPORT_SYMBOL_GPL(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)
+		return -EINVAL;
+
+	handle = ACPI_HANDLE(&dev->dev);
+	if (!handle)
+		return -EINVAL;
+
+	if (!acpi_check_dsm(handle, &pci_acpi_dsm_guid, 4, 1 << DSM_PCI_PERST_ASSERTION_DELAY)) {
+		pci_dbg(dev, "ACPI _DSM 0%Xh not supported\n", DSM_PCI_PERST_ASSERTION_DELAY);
+		return -ENODEV;
+	}
+
+	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) {
+		pci_info(dev, "PERST# Assertion Delay set to %u microseconds\n", delay_us);
+		ret = 0;
+	} else if (result == 0) {
+		pci_warn(dev, "PERST# Assertion Delay request failed, no previous valid request\n");
+	} else {
+		pci_warn(dev, "PERST# Assertion Delay request failed, Previous valid delay: %u microseconds\n",
+			 result);
+	}
+
+	ACPI_FREE(out_obj);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(pci_acpi_add_perst_assertion_delay);
+
 static void pci_acpi_set_external_facing(struct pci_dev *dev)
 {
 	u8 val;
diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
index 1705d03bfe26..889e469206e2 100644
--- a/include/linux/pci-acpi.h
+++ b/include/linux/pci-acpi.h
@@ -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);
@@ -135,7 +136,7 @@ int pci_acpi_set_companion_lookup_hook(struct acpi_device *(*func)(struct pci_de
 void pci_acpi_clear_companion_lookup_hook(void);
 int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power,
 				      u32 *retry_interval);
-
+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) { }
@@ -144,6 +145,11 @@ static int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_
 {
 	return -EOPNOTSUPP;
 }
+
+static int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
+{
+	return -EOPNOTSUPP;
+}
 #endif	/* CONFIG_ACPI */
 
 #endif	/* _PCI_ACPI_H_ */
-- 
2.34.1


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

* [PATCH v3 04/11] drm/xe/vrsr: Introduce flag has_vrsr
  2025-05-23 19:01 [PATCH v3 00/11] VRAM Self Refresh Badal Nilawar
                   ` (2 preceding siblings ...)
  2025-05-23 19:01 ` [PATCH v3 03/11] PCI/ACPI: Add PERST# Assertion Delay _DSM method Badal Nilawar
@ 2025-05-23 19:01 ` Badal Nilawar
  2025-05-23 19:01 ` [PATCH v3 05/11] drm/xe/vrsr: Detect VRSR Capability Badal Nilawar
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Badal Nilawar @ 2025-05-23 19:01 UTC (permalink / raw)
  To: intel-xe, linux-acpi, linux-pci
  Cc: anshuman.gupta, rafael, lenb, bhelgaas, ilpo.jarvinen,
	lucas.demarchi, rodrigo.vivi, varun.gupta, ville.syrjala,
	uma.shankar

Introduce flag has_vrsr to determine if platform supports VRSR feature

Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Badal Nilawar <badal.nilawar@intel.com>
---
 drivers/gpu/drm/xe/xe_device_types.h | 2 ++
 drivers/gpu/drm/xe/xe_pci.c          | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
index f81be293b260..e2749ed2a61f 100644
--- a/drivers/gpu/drm/xe/xe_device_types.h
+++ b/drivers/gpu/drm/xe/xe_device_types.h
@@ -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.has_64bit_timestamp: Device supports 64-bit timestamps */
 		u8 has_64bit_timestamp:1;
 		/** @info.is_dgfx: is discrete device */
diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
index 024175cfe61e..46a99d6ef1a5 100644
--- a/drivers/gpu/drm/xe/xe_pci.c
+++ b/drivers/gpu/drm/xe/xe_pci.c
@@ -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 needs_scratch:1;
 	u8 skip_guc_pc:1;
 	u8 skip_mtcfg:1;
@@ -342,6 +343,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,
 	.needs_scratch = true,
 };
@@ -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;
-- 
2.34.1


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

* [PATCH v3 05/11] drm/xe/vrsr: Detect VRSR Capability
  2025-05-23 19:01 [PATCH v3 00/11] VRAM Self Refresh Badal Nilawar
                   ` (3 preceding siblings ...)
  2025-05-23 19:01 ` [PATCH v3 04/11] drm/xe/vrsr: Introduce flag has_vrsr Badal Nilawar
@ 2025-05-23 19:01 ` Badal Nilawar
  2025-05-23 19:01 ` [PATCH v3 06/11] drm/xe/vrsr: Initialize VRSR feature Badal Nilawar
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Badal Nilawar @ 2025-05-23 19:01 UTC (permalink / raw)
  To: intel-xe, linux-acpi, linux-pci
  Cc: anshuman.gupta, rafael, lenb, bhelgaas, ilpo.jarvinen,
	lucas.demarchi, rodrigo.vivi, varun.gupta, ville.syrjala,
	uma.shankar

From: Anshuman Gupta <anshuman.gupta@intel.com>

Detect VRAM Self Refresh(vrsr) Capability.

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
---
 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           | 26 ++++++++++++++++++++++++++
 3 files changed, 33 insertions(+)

diff --git a/drivers/gpu/drm/xe/regs/xe_regs.h b/drivers/gpu/drm/xe/regs/xe_regs.h
index 3abb17d2ca33..4db486fb310a 100644
--- a/drivers/gpu/drm/xe/regs/xe_regs.h
+++ b/drivers/gpu/drm/xe/regs/xe_regs.h
@@ -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)
 
diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
index e2749ed2a61f..3a15b3a252fd 100644
--- a/drivers/gpu/drm/xe/xe_device_types.h
+++ b/drivers/gpu/drm/xe/xe_device_types.h
@@ -512,6 +512,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:
 		 *
@@ -522,6 +525,7 @@ struct xe_device {
 		 * Default threshold value is 300mb.
 		 */
 		u32 vram_threshold;
+
 		/** @d3cold.lock: protect vram_threshold */
 		struct mutex lock;
 	} d3cold;
diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
index 693866def183..c9395e62d21d 100644
--- a/drivers/gpu/drm/xe/xe_pm.c
+++ b/drivers/gpu/drm/xe/xe_pm.c
@@ -13,13 +13,16 @@
 #include <drm/ttm/ttm_placement.h>
 
 #include "display/xe_display.h"
+#include "regs/xe_regs.h"
 #include "xe_bo.h"
 #include "xe_bo_evict.h"
 #include "xe_device.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 "xe_trace.h"
@@ -235,6 +238,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;
@@ -349,6 +374,7 @@ int xe_pm_init(struct xe_device *xe)
 		err = xe_pm_set_vram_threshold(xe, vram_threshold);
 		if (err)
 			goto err_unregister;
+		xe->d3cold.vrsr_capable = xe_pm_vrsr_capable(xe);
 	}
 
 	xe_pm_runtime_init(xe);
-- 
2.34.1


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

* [PATCH v3 06/11] drm/xe/vrsr: Initialize VRSR feature
  2025-05-23 19:01 [PATCH v3 00/11] VRAM Self Refresh Badal Nilawar
                   ` (4 preceding siblings ...)
  2025-05-23 19:01 ` [PATCH v3 05/11] drm/xe/vrsr: Detect VRSR Capability Badal Nilawar
@ 2025-05-23 19:01 ` Badal Nilawar
  2025-05-23 21:33   ` kernel test robot
  2025-05-23 19:01 ` [PATCH v3 07/11] drm/xe/vrsr: Enable VRSR on default VGA boot device Badal Nilawar
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 17+ messages in thread
From: Badal Nilawar @ 2025-05-23 19:01 UTC (permalink / raw)
  To: intel-xe, linux-acpi, linux-pci
  Cc: anshuman.gupta, rafael, lenb, bhelgaas, ilpo.jarvinen,
	lucas.demarchi, rodrigo.vivi, varun.gupta, ville.syrjala,
	uma.shankar

Add the API xe_pm_vrsr_enable to initialize the VRSR feature,
requesting AUX power limit and PERST# assertion delay.

V2: Add retry mechanism while requesting AUX power limit

Signed-off-by: Badal Nilawar <badal.nilawar@intel.com>
Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
---
 drivers/gpu/drm/xe/xe_device_types.h |   1 +
 drivers/gpu/drm/xe/xe_pcode_api.h    |   7 ++
 drivers/gpu/drm/xe/xe_pm.c           | 105 ++++++++++++++++++++++++++-
 drivers/gpu/drm/xe/xe_pm.h           |   1 +
 4 files changed, 113 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
index 3a15b3a252fd..5f9a1a358468 100644
--- a/drivers/gpu/drm/xe/xe_device_types.h
+++ b/drivers/gpu/drm/xe/xe_device_types.h
@@ -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>
diff --git a/drivers/gpu/drm/xe/xe_pcode_api.h b/drivers/gpu/drm/xe/xe_pcode_api.h
index 127d4d26c4cf..f54ef03799d4 100644
--- a/drivers/gpu/drm/xe/xe_pcode_api.h
+++ b/drivers/gpu/drm/xe/xe_pcode_api.h
@@ -43,6 +43,13 @@
 #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	    POWER_D3_VRSR_PERST_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
diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
index c9395e62d21d..278f2eeeaab6 100644
--- a/drivers/gpu/drm/xe/xe_pm.c
+++ b/drivers/gpu/drm/xe/xe_pm.c
@@ -5,6 +5,7 @@
 
 #include "xe_pm.h"
 
+#include <linux/delay.h>
 #include <linux/fault-inject.h>
 #include <linux/pm_runtime.h>
 #include <linux/suspend.h>
@@ -23,6 +24,7 @@
 #include "xe_guc.h"
 #include "xe_irq.h"
 #include "xe_mmio.h"
+#include "xe_pcode_api.h"
 #include "xe_pcode.h"
 #include "xe_pxp.h"
 #include "xe_trace.h"
@@ -260,6 +262,107 @@ static bool xe_pm_vrsr_capable(struct xe_device *xe)
 	return val & VRAM_SR_SUPPORTED;
 }
 
+static int pci_acpi_aux_power_setup(struct xe_device *xe)
+{
+	struct xe_tile *root_tile = xe_device_get_root_tile(xe);
+	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
+	struct pci_dev *root_pdev;
+	int ret;
+	u32 uval;
+	u32 aux_pwr_limit;
+	u32 retry_interval;
+	u32 perst_delay;
+
+	root_pdev = pcie_find_root_port(pdev);
+	if (!root_pdev)
+		return -EINVAL;
+
+	ret = xe_pcode_read(root_tile, PCODE_MBOX(PCODE_D3_VRAM_SELF_REFRESH,
+			    PCODE_D3_VRSR_SC_AUX_PL_AND_PERST_DELAY, 0),
+			    &uval, NULL);
+
+	if (ret)
+		return ret;
+
+	aux_pwr_limit = REG_FIELD_GET(POWER_D3_VRSR_AUX_PL_MASK, uval);
+	perst_delay = REG_FIELD_GET(POWER_D3_VRSR_PERST_MASK, uval);
+
+	drm_dbg(&xe->drm, "Aux Power limit = %d mW\n", aux_pwr_limit);
+	drm_dbg(&xe->drm, "PERST# Assertion delay = %d microseconds\n", perst_delay);
+
+retry:
+	ret = pci_acpi_request_d3cold_aux_power(root_pdev, aux_pwr_limit, &retry_interval);
+
+	if (ret == -EAGAIN) {
+		drm_warn(&xe->drm, "D3cold Aux Power request needs retry interval: %d seconds\n",
+			 retry_interval);
+		msleep(retry_interval * 1000);
+		goto retry;
+	}
+
+	if (ret)
+		return ret;
+
+	ret = pci_acpi_add_perst_assertion_delay(root_pdev, perst_delay);
+
+	return ret;
+}
+
+static void xe_pm_vrsr_init(struct xe_device *xe)
+{
+	int ret;
+
+	/* Check if platform support D3Cold VRSR */
+	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
+	 * D3Cold flow
+	 */
+	ret = pci_acpi_aux_power_setup(xe);
+	if (ret) {
+		drm_info(&xe->drm, "VRSR capable: No\n");
+		return;
+	}
+
+	xe->d3cold.vrsr_capable = true;
+	drm_info(&xe->drm, "VRSR capable: Yes\n");
+}
+
+/**
+ * xe_pm_vrsr_enable - Enable VRAM self refresh
+ * @xe: The xe device.
+ * @enable: true: Enable, false: Disable
+ *
+ * This function enables the VRSR feature in D3Cold path.
+ *
+ * Return: It returns 0 on success and errno on failure.
+ */
+int xe_pm_vrsr_enable(struct xe_device *xe, bool enable)
+{
+	struct xe_tile *root_tile = xe_device_get_root_tile(xe);
+	int ret;
+	u32 uval = 0;
+
+	if (!xe->d3cold.vrsr_capable)
+		return -ENXIO;
+
+	drm_dbg(&xe->drm, "%s VRSR\n", enable ? "Enabling" : "Disabling");
+
+	if (enable)
+		ret = xe_pcode_write(root_tile, PCODE_MBOX(PCODE_D3_VRAM_SELF_REFRESH,
+				     PCODE_D3_VRSR_SC_ENABLE, 0), uval);
+	else
+		ret = xe_pcode_write(root_tile, PCODE_MBOX(PCODE_D3_VRAM_SELF_REFRESH,
+				     PCODE_D3_VRSR_SC_DISABLE, 0), uval);
+
+	return ret;
+}
+
 static void xe_pm_runtime_init(struct xe_device *xe)
 {
 	struct device *dev = xe->drm.dev;
@@ -374,7 +477,7 @@ int xe_pm_init(struct xe_device *xe)
 		err = xe_pm_set_vram_threshold(xe, vram_threshold);
 		if (err)
 			goto err_unregister;
-		xe->d3cold.vrsr_capable = xe_pm_vrsr_capable(xe);
+		xe_pm_vrsr_init(xe);
 	}
 
 	xe_pm_runtime_init(xe);
diff --git a/drivers/gpu/drm/xe/xe_pm.h b/drivers/gpu/drm/xe/xe_pm.h
index 59678b310e55..ba550281b130 100644
--- a/drivers/gpu/drm/xe/xe_pm.h
+++ b/drivers/gpu/drm/xe/xe_pm.h
@@ -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
-- 
2.34.1


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

* [PATCH v3 07/11] drm/xe/vrsr: Enable VRSR on default VGA boot device
  2025-05-23 19:01 [PATCH v3 00/11] VRAM Self Refresh Badal Nilawar
                   ` (5 preceding siblings ...)
  2025-05-23 19:01 ` [PATCH v3 06/11] drm/xe/vrsr: Initialize VRSR feature Badal Nilawar
@ 2025-05-23 19:01 ` Badal Nilawar
  2025-05-23 22:04   ` kernel test robot
  2025-05-23 19:01 ` [PATCH v3 08/11] drm/xe/vrsr: Refactor d3cold.allowed to a enum Badal Nilawar
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 17+ messages in thread
From: Badal Nilawar @ 2025-05-23 19:01 UTC (permalink / raw)
  To: intel-xe, linux-acpi, linux-pci
  Cc: anshuman.gupta, rafael, lenb, bhelgaas, ilpo.jarvinen,
	lucas.demarchi, rodrigo.vivi, varun.gupta, ville.syrjala,
	uma.shankar

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.

Signed-off-by: Badal Nilawar <badal.nilawar@intel.com>
Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
---
 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(+)

diff --git a/drivers/gpu/drm/xe/display/xe_display.c b/drivers/gpu/drm/xe/display/xe_display.c
index 20c3bcd953b7..b3da88b12b35 100644
--- a/drivers/gpu/drm/xe/display/xe_display.c
+++ b/drivers/gpu/drm/xe/display/xe_display.c
@@ -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
diff --git a/drivers/gpu/drm/xe/display/xe_display.h b/drivers/gpu/drm/xe/display/xe_display.h
index 46e14f8dee28..a432790d6d34 100644
--- a/drivers/gpu/drm/xe/display/xe_display.h
+++ b/drivers/gpu/drm/xe/display/xe_display.h
@@ -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_ */
diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
index 278f2eeeaab6..c84b9b3f7371 100644
--- a/drivers/gpu/drm/xe/xe_pm.c
+++ b/drivers/gpu/drm/xe/xe_pm.c
@@ -9,6 +9,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>
@@ -310,6 +311,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 */
@@ -319,6 +321,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
 	 * D3Cold flow
-- 
2.34.1


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

* [PATCH v3 08/11] drm/xe/vrsr: Refactor d3cold.allowed to a enum
  2025-05-23 19:01 [PATCH v3 00/11] VRAM Self Refresh Badal Nilawar
                   ` (6 preceding siblings ...)
  2025-05-23 19:01 ` [PATCH v3 07/11] drm/xe/vrsr: Enable VRSR on default VGA boot device Badal Nilawar
@ 2025-05-23 19:01 ` Badal Nilawar
  2025-05-23 19:01 ` [PATCH v3 09/11] drm/xe/pm: D3Cold target state Badal Nilawar
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Badal Nilawar @ 2025-05-23 19:01 UTC (permalink / raw)
  To: intel-xe, linux-acpi, linux-pci
  Cc: anshuman.gupta, rafael, lenb, bhelgaas, ilpo.jarvinen,
	lucas.demarchi, rodrigo.vivi, varun.gupta, ville.syrjala,
	uma.shankar

From: Anshuman Gupta <anshuman.gupta@intel.com>

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

Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
---
 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(-)

diff --git a/drivers/gpu/drm/xe/display/xe_display.c b/drivers/gpu/drm/xe/display/xe_display.c
index b3da88b12b35..7ccd9b447ace 100644
--- a/drivers/gpu/drm/xe/display/xe_display.c
+++ b/drivers/gpu/drm/xe/display/xe_display.c
@@ -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;
 	}
diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
index 5f9a1a358468..48ca0d8c4c45 100644
--- a/drivers/gpu/drm/xe/xe_device_types.h
+++ b/drivers/gpu/drm/xe/xe_device_types.h
@@ -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"
@@ -510,8 +511,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;
diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
index 46a99d6ef1a5..5ae1df345416 100644
--- a/drivers/gpu/drm/xe/xe_pci.c
+++ b/drivers/gpu/drm/xe/xe_pci.c
@@ -977,7 +977,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);
@@ -1002,7 +1002,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;
@@ -1018,7 +1018,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;
 }
diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
index c84b9b3f7371..b86e95493cb5 100644
--- a/drivers/gpu/drm/xe/xe_pm.c
+++ b/drivers/gpu/drm/xe/xe_pm.c
@@ -606,7 +606,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;
@@ -653,7 +653,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;
@@ -676,7 +676,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_late(xe);
 		if (err)
 			goto out;
@@ -918,13 +918,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;
@@ -932,7 +932,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;
 	}
 
@@ -947,9 +947,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);
 }
diff --git a/drivers/gpu/drm/xe/xe_pm.h b/drivers/gpu/drm/xe/xe_pm.h
index ba550281b130..c6c2bd6187a5 100644
--- a/drivers/gpu/drm/xe/xe_pm.h
+++ b/drivers/gpu/drm/xe/xe_pm.h
@@ -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);
-- 
2.34.1


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

* [PATCH v3 09/11] drm/xe/pm: D3Cold target state
  2025-05-23 19:01 [PATCH v3 00/11] VRAM Self Refresh Badal Nilawar
                   ` (7 preceding siblings ...)
  2025-05-23 19:01 ` [PATCH v3 08/11] drm/xe/vrsr: Refactor d3cold.allowed to a enum Badal Nilawar
@ 2025-05-23 19:01 ` Badal Nilawar
  2025-05-23 19:01 ` [PATCH v3 10/11] drm/xe/vrsr: Enable VRSR Badal Nilawar
  2025-05-23 19:01 ` [PATCH v3 11/11] drm/xe/vrsr: Introduce a debugfs node named vrsr_capable Badal Nilawar
  10 siblings, 0 replies; 17+ messages in thread
From: Badal Nilawar @ 2025-05-23 19:01 UTC (permalink / raw)
  To: intel-xe, linux-acpi, linux-pci
  Cc: anshuman.gupta, rafael, lenb, bhelgaas, ilpo.jarvinen,
	lucas.demarchi, rodrigo.vivi, varun.gupta, ville.syrjala,
	uma.shankar

From: Anshuman Gupta <anshuman.gupta@intel.com>

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.

Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
---
 drivers/gpu/drm/xe/xe_pm.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
index b86e95493cb5..1e061bfc3e52 100644
--- a/drivers/gpu/drm/xe/xe_pm.c
+++ b/drivers/gpu/drm/xe/xe_pm.c
@@ -113,6 +113,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_target_state_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
@@ -128,6 +136,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;
@@ -948,10 +958,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.target_state);
 }
 
 /**
-- 
2.34.1


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

* [PATCH v3 10/11] drm/xe/vrsr: Enable VRSR
  2025-05-23 19:01 [PATCH v3 00/11] VRAM Self Refresh Badal Nilawar
                   ` (8 preceding siblings ...)
  2025-05-23 19:01 ` [PATCH v3 09/11] drm/xe/pm: D3Cold target state Badal Nilawar
@ 2025-05-23 19:01 ` Badal Nilawar
  2025-05-23 19:01 ` [PATCH v3 11/11] drm/xe/vrsr: Introduce a debugfs node named vrsr_capable Badal Nilawar
  10 siblings, 0 replies; 17+ messages in thread
From: Badal Nilawar @ 2025-05-23 19:01 UTC (permalink / raw)
  To: intel-xe, linux-acpi, linux-pci
  Cc: anshuman.gupta, rafael, lenb, bhelgaas, ilpo.jarvinen,
	lucas.demarchi, rodrigo.vivi, varun.gupta, ville.syrjala,
	uma.shankar

From: Anshuman Gupta <anshuman.gupta@intel.com>

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

Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
Signed-off-by: Badal Nilawar <badal.nilawar@intel.com>
---
 drivers/gpu/drm/xe/xe_pci.c |  4 ++--
 drivers/gpu/drm/xe/xe_pm.c  | 46 +++++++++++++++++++++++++++----------
 2 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
index 5ae1df345416..fdf878594fb0 100644
--- a/drivers/gpu/drm/xe/xe_pci.c
+++ b/drivers/gpu/drm/xe/xe_pci.c
@@ -926,7 +926,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);
@@ -943,7 +943,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);
diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
index 1e061bfc3e52..19596d467298 100644
--- a/drivers/gpu/drm/xe/xe_pm.c
+++ b/drivers/gpu/drm/xe/xe_pm.c
@@ -147,10 +147,12 @@ int xe_pm_suspend(struct xe_device *xe)
 
 	xe_display_pm_suspend(xe);
 
-	/* FIXME: Super racey... */
-	err = xe_bo_evict_all(xe);
-	if (err)
-		goto err_pxp;
+	if (xe->d3cold.target_state == XE_D3COLD_OFF) {
+		/* FIXME: Super racey... */
+		err = xe_bo_evict_all(xe);
+		if (err)
+			goto err_pxp;
+	}
 
 	for_each_gt(gt, xe, id) {
 		err = xe_gt_suspend(gt);
@@ -162,6 +164,12 @@ int xe_pm_suspend(struct xe_device *xe)
 
 	xe_display_pm_suspend_late(xe);
 
+	if (xe->d3cold.target_state == XE_D3COLD_VRSR) {
+		err = xe_pm_vrsr_enable(xe, true);
+			if (err)
+				goto err_display;
+	}
+
 	drm_dbg(&xe->drm, "Device suspended\n");
 	return 0;
 
@@ -203,9 +211,11 @@ int xe_pm_resume(struct xe_device *xe)
 	 * This only restores pinned memory which is the memory required for the
 	 * GT(s) to resume.
 	 */
-	err = xe_bo_restore_early(xe);
-	if (err)
-		goto err;
+	if (xe->d3cold.target_state == XE_D3COLD_OFF) {
+		err = xe_bo_restore_early(xe);
+		if (err)
+			goto err;
+	}
 
 	xe_irq_resume(xe);
 
@@ -214,9 +224,11 @@ int xe_pm_resume(struct xe_device *xe)
 
 	xe_display_pm_resume(xe);
 
-	err = xe_bo_restore_late(xe);
-	if (err)
-		goto err;
+	if (xe->d3cold.target_state == XE_D3COLD_OFF) {
+		err = xe_bo_restore_late(xe);
+		if (err)
+			goto err;
+	}
 
 	xe_pxp_pm_resume(xe->pxp);
 
@@ -616,7 +628,7 @@ int xe_pm_runtime_suspend(struct xe_device *xe)
 
 	xe_display_pm_runtime_suspend(xe);
 
-	if (xe->d3cold.target_state) {
+	if (xe->d3cold.target_state == XE_D3COLD_OFF) {
 		err = xe_bo_evict_all(xe);
 		if (err)
 			goto out_resume;
@@ -632,6 +644,14 @@ int xe_pm_runtime_suspend(struct xe_device *xe)
 
 	xe_display_pm_runtime_suspend_late(xe);
 
+	if (xe->d3cold.target_state == XE_D3COLD_VRSR) {
+		err = xe_pm_vrsr_enable(xe, true);
+			if (err) {
+				drm_err(&xe->drm, "Failed to enable VRSR: %d\n", err);
+				goto out_resume;
+			}
+	}
+
 	xe_rpm_lockmap_release(xe);
 	xe_pm_write_callback_task(xe, NULL);
 	return 0;
@@ -669,7 +689,9 @@ int xe_pm_runtime_resume(struct xe_device *xe)
 			goto out;
 
 		xe_display_pm_resume_early(xe);
+	}
 
+	if (xe->d3cold.target_state == XE_D3COLD_OFF) {
 		/*
 		 * This only restores pinned memory which is the memory
 		 * required for the GT(s) to resume.
@@ -686,7 +708,7 @@ int xe_pm_runtime_resume(struct xe_device *xe)
 
 	xe_display_pm_runtime_resume(xe);
 
-	if (xe->d3cold.target_state) {
+	if (xe->d3cold.target_state == XE_D3COLD_OFF) {
 		err = xe_bo_restore_late(xe);
 		if (err)
 			goto out;
-- 
2.34.1


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

* [PATCH v3 11/11] drm/xe/vrsr: Introduce a debugfs node named vrsr_capable
  2025-05-23 19:01 [PATCH v3 00/11] VRAM Self Refresh Badal Nilawar
                   ` (9 preceding siblings ...)
  2025-05-23 19:01 ` [PATCH v3 10/11] drm/xe/vrsr: Enable VRSR Badal Nilawar
@ 2025-05-23 19:01 ` Badal Nilawar
  10 siblings, 0 replies; 17+ messages in thread
From: Badal Nilawar @ 2025-05-23 19:01 UTC (permalink / raw)
  To: intel-xe, linux-acpi, linux-pci
  Cc: anshuman.gupta, rafael, lenb, bhelgaas, ilpo.jarvinen,
	lucas.demarchi, rodrigo.vivi, varun.gupta, ville.syrjala,
	uma.shankar

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

Signed-off-by: Badal Nilawar <badal.nilawar@intel.com>
---
 drivers/gpu/drm/xe/xe_debugfs.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_debugfs.c b/drivers/gpu/drm/xe/xe_debugfs.c
index d83cd6ed3fa8..d969a8f6d430 100644
--- a/drivers/gpu/drm/xe/xe_debugfs.c
+++ b/drivers/gpu/drm/xe/xe_debugfs.c
@@ -226,6 +226,23 @@ static const struct file_operations atomic_svm_timeslice_ms_fops = {
 	.write = atomic_svm_timeslice_ms_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;
@@ -249,6 +266,9 @@ void xe_debugfs_register(struct xe_device *xe)
 	debugfs_create_file("atomic_svm_timeslice_ms", 0600, root, xe,
 			    &atomic_svm_timeslice_ms_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);
 
-- 
2.34.1


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

* Re: [PATCH v3 06/11] drm/xe/vrsr: Initialize VRSR feature
  2025-05-23 19:01 ` [PATCH v3 06/11] drm/xe/vrsr: Initialize VRSR feature Badal Nilawar
@ 2025-05-23 21:33   ` kernel test robot
  0 siblings, 0 replies; 17+ messages in thread
From: kernel test robot @ 2025-05-23 21:33 UTC (permalink / raw)
  To: Badal Nilawar, intel-xe, linux-acpi, linux-pci
  Cc: oe-kbuild-all, anshuman.gupta, rafael, lenb, bhelgaas,
	ilpo.jarvinen, lucas.demarchi, rodrigo.vivi, varun.gupta,
	ville.syrjala, uma.shankar

Hi Badal,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-xe/drm-xe-next]
[also build test WARNING on next-20250523]
[cannot apply to rafael-pm/linux-next rafael-pm/bleeding-edge pci/next pci/for-linus linus/master v6.15-rc7]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Badal-Nilawar/PCI-ACPI-Add-D3cold-Aux-Power-Limit_DSM-method/20250524-030125
base:   https://gitlab.freedesktop.org/drm/xe/kernel.git drm-xe-next
patch link:    https://lore.kernel.org/r/20250523190155.2623462-7-badal.nilawar%40intel.com
patch subject: [PATCH v3 06/11] drm/xe/vrsr: Initialize VRSR feature
config: arm-randconfig-002-20250524 (https://download.01.org/0day-ci/archive/20250524/202505240511.h1zy992X-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250524/202505240511.h1zy992X-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202505240511.h1zy992X-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from drivers/gpu/drm/xe/xe_device_types.h:10:0,
                    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_query.c:17:
>> include/linux/pci-acpi.h:149:12: warning: 'pci_acpi_add_perst_assertion_delay' defined but not used [-Wunused-function]
    static int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/pci-acpi.h:143:12: warning: 'pci_acpi_request_d3cold_aux_power' defined but not used [-Wunused-function]
    static int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power,
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/pci_acpi_add_perst_assertion_delay +149 include/linux/pci-acpi.h

ac1c8e35a3262d Kuppuswamy Sathyanarayanan 2020-03-23  134  
59dc33252ee777 Rafael J. Wysocki          2021-08-24  135  int pci_acpi_set_companion_lookup_hook(struct acpi_device *(*func)(struct pci_dev *));
59dc33252ee777 Rafael J. Wysocki          2021-08-24  136  void pci_acpi_clear_companion_lookup_hook(void);
004b1d6651d930 Anshuman Gupta             2025-05-24  137  int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power,
004b1d6651d930 Anshuman Gupta             2025-05-24  138  				      u32 *retry_interval);
57059451b12af0 Anshuman Gupta             2025-05-24  139  int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us);
5090d4a6a1f150 Jiang Liu                  2013-04-12  140  #else	/* CONFIG_ACPI */
5090d4a6a1f150 Jiang Liu                  2013-04-12  141  static inline void acpi_pci_add_bus(struct pci_bus *bus) { }
5090d4a6a1f150 Jiang Liu                  2013-04-12  142  static inline void acpi_pci_remove_bus(struct pci_bus *bus) { }
004b1d6651d930 Anshuman Gupta             2025-05-24 @143  static int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power,
004b1d6651d930 Anshuman Gupta             2025-05-24  144  					     u32 *retry_interval)
004b1d6651d930 Anshuman Gupta             2025-05-24  145  {
004b1d6651d930 Anshuman Gupta             2025-05-24  146  	return -EOPNOTSUPP;
004b1d6651d930 Anshuman Gupta             2025-05-24  147  }
57059451b12af0 Anshuman Gupta             2025-05-24  148  
57059451b12af0 Anshuman Gupta             2025-05-24 @149  static int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
57059451b12af0 Anshuman Gupta             2025-05-24  150  {
57059451b12af0 Anshuman Gupta             2025-05-24  151  	return -EOPNOTSUPP;
57059451b12af0 Anshuman Gupta             2025-05-24  152  }
5090d4a6a1f150 Jiang Liu                  2013-04-12  153  #endif	/* CONFIG_ACPI */
^1da177e4c3f41 Linus Torvalds             2005-04-16  154  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH v3 07/11] drm/xe/vrsr: Enable VRSR on default VGA boot device
  2025-05-23 19:01 ` [PATCH v3 07/11] drm/xe/vrsr: Enable VRSR on default VGA boot device Badal Nilawar
@ 2025-05-23 22:04   ` kernel test robot
  0 siblings, 0 replies; 17+ messages in thread
From: kernel test robot @ 2025-05-23 22:04 UTC (permalink / raw)
  To: Badal Nilawar, intel-xe, linux-acpi, linux-pci
  Cc: llvm, oe-kbuild-all, anshuman.gupta, rafael, lenb, bhelgaas,
	ilpo.jarvinen, lucas.demarchi, rodrigo.vivi, varun.gupta,
	ville.syrjala, uma.shankar

Hi Badal,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-xe/drm-xe-next]
[also build test WARNING on next-20250523]
[cannot apply to rafael-pm/linux-next rafael-pm/bleeding-edge pci/next pci/for-linus linus/master v6.15-rc7]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Badal-Nilawar/PCI-ACPI-Add-D3cold-Aux-Power-Limit_DSM-method/20250524-030125
base:   https://gitlab.freedesktop.org/drm/xe/kernel.git drm-xe-next
patch link:    https://lore.kernel.org/r/20250523190155.2623462-8-badal.nilawar%40intel.com
patch subject: [PATCH v3 07/11] drm/xe/vrsr: Enable VRSR on default VGA boot device
config: s390-randconfig-001-20250524 (https://download.01.org/0day-ci/archive/20250524/202505240521.BnNwr31U-lkp@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250524/202505240521.BnNwr31U-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202505240521.BnNwr31U-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from drivers/gpu/drm/xe/xe_irq.c:12:
>> drivers/gpu/drm/xe/display/xe_display.h:75:64: warning: non-void function does not return a value [-Wreturn-type]
      75 | static inline bool xe_display_connected(struct xe_device *xe) {}
         |                                                                ^
   In file included from drivers/gpu/drm/xe/xe_irq.c:12:
   In file included from drivers/gpu/drm/xe/display/xe_display.h:9:
   In file included from drivers/gpu/drm/xe/xe_device.h:11:
   In file included from drivers/gpu/drm/xe/xe_device_types.h:10:
   include/linux/pci-acpi.h:143:12: warning: unused function 'pci_acpi_request_d3cold_aux_power' [-Wunused-function]
     143 | static int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power,
         |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/pci-acpi.h:149:12: warning: unused function 'pci_acpi_add_perst_assertion_delay' [-Wunused-function]
     149 | static int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us)
         |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   3 warnings generated.
--
   In file included from drivers/gpu/drm/xe/xe_pm.c:17:
>> drivers/gpu/drm/xe/display/xe_display.h:75:64: warning: non-void function does not return a value [-Wreturn-type]
      75 | static inline bool xe_display_connected(struct xe_device *xe) {}
         |                                                                ^
   1 warning generated.


vim +75 drivers/gpu/drm/xe/display/xe_display.h

    74	
  > 75	static inline bool xe_display_connected(struct xe_device *xe) {}

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH v3 01/11] PCI/ACPI: Add D3cold Aux Power Limit_DSM method
  2025-05-23 19:01 ` [PATCH v3 01/11] PCI/ACPI: Add D3cold Aux Power Limit_DSM method Badal Nilawar
@ 2025-05-24  6:00   ` Sathyanarayanan Kuppuswamy
  2025-05-29  6:18     ` Nilawar, Badal
  0 siblings, 1 reply; 17+ messages in thread
From: Sathyanarayanan Kuppuswamy @ 2025-05-24  6:00 UTC (permalink / raw)
  To: Badal Nilawar, intel-xe, linux-acpi, linux-pci
  Cc: anshuman.gupta, rafael, lenb, bhelgaas, ilpo.jarvinen,
	lucas.demarchi, rodrigo.vivi, varun.gupta, ville.syrjala,
	uma.shankar


On 5/23/25 12:01 PM, Badal Nilawar wrote:
> From: Anshuman Gupta<anshuman.gupta@intel.com>
>
> Implement _DSM method 0Ah according to PCI firmware specifications,
> section 4.6.10 Rev 3.3., to request auxilary power needed for the
> device when in D3Cold.
>
> 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.

Add some info about why you are not adding this support?

> One possible mitigation would be only allowing only first PCIe
> Non-Bridge Endpoint Function 0 driver to call_DSM method 0Ah.
>
> V2(Bjorn/Rafael):
>    - Call acpi_dsm_check() to find method 0Ah supported
>    - Return retry interval to caller
>
> Signed-off-by: Varun Gupta<varun.gupta@intel.com>
> Signed-off-by: Badal Nilawar<badal.nilawar@intel.com>
> Signed-off-by: Anshuman Gupta<anshuman.gupta@intel.com>
> ---
>   drivers/pci/pci-acpi.c   | 87 ++++++++++++++++++++++++++++++++++++++++
>   include/linux/pci-acpi.h |  8 ++++
>   2 files changed, 95 insertions(+)
>
> diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
> index af370628e583..76b19525535f 100644
> --- a/drivers/pci/pci-acpi.c
> +++ b/drivers/pci/pci-acpi.c
> @@ -1421,6 +1421,93 @@ static void pci_acpi_optimize_delay(struct pci_dev *pdev,
>   	ACPI_FREE(obj);
>   }
>   
> +/**
> + * pci_acpi_request_d3cold_aux_power - Request aux power while device is in D3Cold
> + * @dev: PCI device instance
> + * @requested_power: Requested auxiliary power in milliwatts
> + * @retry_interval: Retry interval returned by platform to retry auxiliary
> + *                  power request
> + *
> + * This function sends a request to the host BIOS via root port ACPI _DSM Function 0Ah
> + * for the auxiliary power needed by the PCI device when it is in D3Cold.
> + * It checks and 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,
> +				      u32 *retry_interval)
> +{
> +	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)
> +		return -EINVAL;

Is retry_interval param optional? If not may be a check here for non NULL condition is needed.

> +
> +	handle = ACPI_HANDLE(&dev->dev);
> +	if (!handle)
> +		return -EINVAL;
> +
> +	if (!acpi_check_dsm(handle, &pci_acpi_dsm_guid, 4, 1 << DSM_PCI_D3COLD_AUX_POWER_LIMIT)) {
> +		pci_dbg(dev, "ACPI _DSM 0%Xh not supported\n", DSM_PCI_D3COLD_AUX_POWER_LIMIT);
> +		return -ENODEV;
> +	}
> +
> +	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;
> +	if (retry_interval)
> +		*retry_interval = 0;
> +
> +	switch (result) {
> +	case 0x0:
> +		pci_dbg(dev, "D3cold Aux Power %u mW request denied\n",
> +			requested_power);

is this not a error?

> +		break;
> +	case 0x1:
> +		pci_info(dev, "D3cold Aux Power request granted: %u mW\n",
> +			 requested_power);
> +		ret = 0;
> +		break;
> +	case 0x2:
> +		pci_info(dev, "D3cold Aux Power: Main power won't be removed\n");
> +		ret = -EBUSY;
> +		break;
> +	default:
> +		if (result >= 0x11 && result <= 0x1F) {
> +			if (retry_interval) {
> +				*retry_interval = result & 0xF;
> +				pci_warn(dev, "D3cold Aux Power request needs retry interval: %u seconds\n",
> +					 *retry_interval);
> +				ret = -EAGAIN;
> +			}
> +		} else {
> +			pci_err(dev, "D3cold Aux Power: Reserved or unsupported response: 0x%x\n",
> +				result);
> +		}
> +		break;
> +	}
> +
> +	ACPI_FREE(out_obj);
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(pci_acpi_request_d3cold_aux_power);
> +
>   static void pci_acpi_set_external_facing(struct pci_dev *dev)
>   {
>   	u8 val;
> diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
> index 078225b514d4..1705d03bfe26 100644
> --- a/include/linux/pci-acpi.h
> +++ b/include/linux/pci-acpi.h
> @@ -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,17 @@ 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,
> +				      u32 *retry_interval);
>   
>   #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) { }
> +static int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power,
> +					     u32 *retry_interval)
> +{
> +	return -EOPNOTSUPP;
> +}
>   #endif	/* CONFIG_ACPI */
>   
>   #endif	/* _PCI_ACPI_H_ */

-- 
Sathyanarayanan Kuppuswamy
Linux Kernel Developer


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

* Re: [PATCH v3 01/11] PCI/ACPI: Add D3cold Aux Power Limit_DSM method
  2025-05-24  6:00   ` Sathyanarayanan Kuppuswamy
@ 2025-05-29  6:18     ` Nilawar, Badal
  2025-05-29  7:11       ` Nilawar, Badal
  0 siblings, 1 reply; 17+ messages in thread
From: Nilawar, Badal @ 2025-05-29  6:18 UTC (permalink / raw)
  To: Sathyanarayanan Kuppuswamy, intel-xe, linux-acpi, linux-pci
  Cc: anshuman.gupta, rafael, lenb, bhelgaas, ilpo.jarvinen,
	lucas.demarchi, rodrigo.vivi, varun.gupta, ville.syrjala,
	uma.shankar


On 24-05-2025 11:30, Sathyanarayanan Kuppuswamy wrote:
>
> On 5/23/25 12:01 PM, Badal Nilawar wrote:
>> From: Anshuman Gupta<anshuman.gupta@intel.com>
>>
>> Implement _DSM method 0Ah according to PCI firmware specifications,
>> section 4.6.10 Rev 3.3., to request auxilary power needed for the
>> device when in D3Cold.
>>
>> 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.
>
> Add some info about why you are not adding this support?
Scope is limited to enable the use case of VRAM-SR on BMG GPU. I will 
mention this in cover letter.
>
>> One possible mitigation would be only allowing only first PCIe
>> Non-Bridge Endpoint Function 0 driver to call_DSM method 0Ah.
>>
>> V2(Bjorn/Rafael):
>>    - Call acpi_dsm_check() to find method 0Ah supported
>>    - Return retry interval to caller
>>
>> Signed-off-by: Varun Gupta<varun.gupta@intel.com>
>> Signed-off-by: Badal Nilawar<badal.nilawar@intel.com>
>> Signed-off-by: Anshuman Gupta<anshuman.gupta@intel.com>
>> ---
>>   drivers/pci/pci-acpi.c   | 87 ++++++++++++++++++++++++++++++++++++++++
>>   include/linux/pci-acpi.h |  8 ++++
>>   2 files changed, 95 insertions(+)
>>
>> diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
>> index af370628e583..76b19525535f 100644
>> --- a/drivers/pci/pci-acpi.c
>> +++ b/drivers/pci/pci-acpi.c
>> @@ -1421,6 +1421,93 @@ static void pci_acpi_optimize_delay(struct 
>> pci_dev *pdev,
>>       ACPI_FREE(obj);
>>   }
>>   +/**
>> + * pci_acpi_request_d3cold_aux_power - Request aux power while 
>> device is in D3Cold
>> + * @dev: PCI device instance
>> + * @requested_power: Requested auxiliary power in milliwatts
>> + * @retry_interval: Retry interval returned by platform to retry 
>> auxiliary
>> + *                  power request
>> + *
>> + * This function sends a request to the host BIOS via root port ACPI 
>> _DSM Function 0Ah
>> + * for the auxiliary power needed by the PCI device when it is in 
>> D3Cold.
>> + * It checks and 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,
>> +                      u32 *retry_interval)
>> +{
>> +    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)
>> +        return -EINVAL;
>
> Is retry_interval param optional? If not may be a check here for non 
> NULL condition is needed.
Yes its optional, its up to caller weather to retry or not.
>
>> +
>> +    handle = ACPI_HANDLE(&dev->dev);
>> +    if (!handle)
>> +        return -EINVAL;
>> +
>> +    if (!acpi_check_dsm(handle, &pci_acpi_dsm_guid, 4, 1 << 
>> DSM_PCI_D3COLD_AUX_POWER_LIMIT)) {
>> +        pci_dbg(dev, "ACPI _DSM 0%Xh not supported\n", 
>> DSM_PCI_D3COLD_AUX_POWER_LIMIT);
>> +        return -ENODEV;
>> +    }
>> +
>> +    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;
>> +    if (retry_interval)
>> +        *retry_interval = 0;
>> +
>> +    switch (result) {
>> +    case 0x0:
>> +        pci_dbg(dev, "D3cold Aux Power %u mW request denied\n",
>> +            requested_power);
>
> is this not a error?

No its not error. BIOS Firmware can deny the aux power request.

Regards,
Badal

>
>> +        break;
>> +    case 0x1:
>> +        pci_info(dev, "D3cold Aux Power request granted: %u mW\n",
>> +             requested_power);
>> +        ret = 0;
>> +        break;
>> +    case 0x2:
>> +        pci_info(dev, "D3cold Aux Power: Main power won't be 
>> removed\n");
>> +        ret = -EBUSY;
>> +        break;
>> +    default:
>> +        if (result >= 0x11 && result <= 0x1F) {
>> +            if (retry_interval) {
>> +                *retry_interval = result & 0xF;
>> +                pci_warn(dev, "D3cold Aux Power request needs retry 
>> interval: %u seconds\n",
>> +                     *retry_interval);
>> +                ret = -EAGAIN;
>> +            }
>> +        } else {
>> +            pci_err(dev, "D3cold Aux Power: Reserved or unsupported 
>> response: 0x%x\n",
>> +                result);
>> +        }
>> +        break;
>> +    }
>> +
>> +    ACPI_FREE(out_obj);
>> +    return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(pci_acpi_request_d3cold_aux_power);
>> +
>>   static void pci_acpi_set_external_facing(struct pci_dev *dev)
>>   {
>>       u8 val;
>> diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
>> index 078225b514d4..1705d03bfe26 100644
>> --- a/include/linux/pci-acpi.h
>> +++ b/include/linux/pci-acpi.h
>> @@ -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,17 @@ 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,
>> +                      u32 *retry_interval);
>>     #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) { }
>> +static int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, 
>> u32 requested_power,
>> +                         u32 *retry_interval)
>> +{
>> +    return -EOPNOTSUPP;
>> +}
>>   #endif    /* CONFIG_ACPI */
>>     #endif    /* _PCI_ACPI_H_ */
>

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

* Re: [PATCH v3 01/11] PCI/ACPI: Add D3cold Aux Power Limit_DSM method
  2025-05-29  6:18     ` Nilawar, Badal
@ 2025-05-29  7:11       ` Nilawar, Badal
  0 siblings, 0 replies; 17+ messages in thread
From: Nilawar, Badal @ 2025-05-29  7:11 UTC (permalink / raw)
  To: Sathyanarayanan Kuppuswamy, intel-xe, linux-acpi, linux-pci
  Cc: anshuman.gupta, rafael, lenb, bhelgaas, ilpo.jarvinen,
	lucas.demarchi, rodrigo.vivi, varun.gupta, ville.syrjala,
	uma.shankar


On 29-05-2025 11:48, Nilawar, Badal wrote:
>
> On 24-05-2025 11:30, Sathyanarayanan Kuppuswamy wrote:
>>
>> On 5/23/25 12:01 PM, Badal Nilawar wrote:
>>> From: Anshuman Gupta<anshuman.gupta@intel.com>
>>>
>>> Implement _DSM method 0Ah according to PCI firmware specifications,
>>> section 4.6.10 Rev 3.3., to request auxilary power needed for the
>>> device when in D3Cold.
>>>
>>> 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.
>>
>> Add some info about why you are not adding this support?
> Scope is limited to enable the use case of VRAM-SR on BMG GPU. I will 
> mention this in cover letter.
>>
>>> One possible mitigation would be only allowing only first PCIe
>>> Non-Bridge Endpoint Function 0 driver to call_DSM method 0Ah.
>>>
>>> V2(Bjorn/Rafael):
>>>    - Call acpi_dsm_check() to find method 0Ah supported
>>>    - Return retry interval to caller
>>>
>>> Signed-off-by: Varun Gupta<varun.gupta@intel.com>
>>> Signed-off-by: Badal Nilawar<badal.nilawar@intel.com>
>>> Signed-off-by: Anshuman Gupta<anshuman.gupta@intel.com>
>>> ---
>>>   drivers/pci/pci-acpi.c   | 87 
>>> ++++++++++++++++++++++++++++++++++++++++
>>>   include/linux/pci-acpi.h |  8 ++++
>>>   2 files changed, 95 insertions(+)
>>>
>>> diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
>>> index af370628e583..76b19525535f 100644
>>> --- a/drivers/pci/pci-acpi.c
>>> +++ b/drivers/pci/pci-acpi.c
>>> @@ -1421,6 +1421,93 @@ static void pci_acpi_optimize_delay(struct 
>>> pci_dev *pdev,
>>>       ACPI_FREE(obj);
>>>   }
>>>   +/**
>>> + * pci_acpi_request_d3cold_aux_power - Request aux power while 
>>> device is in D3Cold
>>> + * @dev: PCI device instance
>>> + * @requested_power: Requested auxiliary power in milliwatts
>>> + * @retry_interval: Retry interval returned by platform to retry 
>>> auxiliary
>>> + *                  power request
>>> + *
>>> + * This function sends a request to the host BIOS via root port 
>>> ACPI _DSM Function 0Ah
>>> + * for the auxiliary power needed by the PCI device when it is in 
>>> D3Cold.
>>> + * It checks and 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,
>>> +                      u32 *retry_interval)
>>> +{
>>> +    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)
>>> +        return -EINVAL;
>>
>> Is retry_interval param optional? If not may be a check here for non 
>> NULL condition is needed.
> Yes its optional, its up to caller weather to retry or not.

I will make this param mandatory and add NULL check here. Then its up to 
caller to decide whether to retry.

Thanks,
Badal

>>
>>> +
>>> +    handle = ACPI_HANDLE(&dev->dev);
>>> +    if (!handle)
>>> +        return -EINVAL;
>>> +
>>> +    if (!acpi_check_dsm(handle, &pci_acpi_dsm_guid, 4, 1 << 
>>> DSM_PCI_D3COLD_AUX_POWER_LIMIT)) {
>>> +        pci_dbg(dev, "ACPI _DSM 0%Xh not supported\n", 
>>> DSM_PCI_D3COLD_AUX_POWER_LIMIT);
>>> +        return -ENODEV;
>>> +    }
>>> +
>>> +    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;
>>> +    if (retry_interval)
>>> +        *retry_interval = 0;
>>> +
>>> +    switch (result) {
>>> +    case 0x0:
>>> +        pci_dbg(dev, "D3cold Aux Power %u mW request denied\n",
>>> +            requested_power);
>>
>> is this not a error?
>
> No its not error. BIOS Firmware can deny the aux power request.
>
> Regards,
> Badal
>
>>
>>> +        break;
>>> +    case 0x1:
>>> +        pci_info(dev, "D3cold Aux Power request granted: %u mW\n",
>>> +             requested_power);
>>> +        ret = 0;
>>> +        break;
>>> +    case 0x2:
>>> +        pci_info(dev, "D3cold Aux Power: Main power won't be 
>>> removed\n");
>>> +        ret = -EBUSY;
>>> +        break;
>>> +    default:
>>> +        if (result >= 0x11 && result <= 0x1F) {
>>> +            if (retry_interval) {
>>> +                *retry_interval = result & 0xF;
>>> +                pci_warn(dev, "D3cold Aux Power request needs retry 
>>> interval: %u seconds\n",
>>> +                     *retry_interval);
>>> +                ret = -EAGAIN;
>>> +            }
>>> +        } else {
>>> +            pci_err(dev, "D3cold Aux Power: Reserved or unsupported 
>>> response: 0x%x\n",
>>> +                result);
>>> +        }
>>> +        break;
>>> +    }
>>> +
>>> +    ACPI_FREE(out_obj);
>>> +    return ret;
>>> +}
>>> +EXPORT_SYMBOL_GPL(pci_acpi_request_d3cold_aux_power);
>>> +
>>>   static void pci_acpi_set_external_facing(struct pci_dev *dev)
>>>   {
>>>       u8 val;
>>> diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
>>> index 078225b514d4..1705d03bfe26 100644
>>> --- a/include/linux/pci-acpi.h
>>> +++ b/include/linux/pci-acpi.h
>>> @@ -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,17 @@ 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,
>>> +                      u32 *retry_interval);
>>>     #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) { }
>>> +static int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, 
>>> u32 requested_power,
>>> +                         u32 *retry_interval)
>>> +{
>>> +    return -EOPNOTSUPP;
>>> +}
>>>   #endif    /* CONFIG_ACPI */
>>>     #endif    /* _PCI_ACPI_H_ */
>>

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

end of thread, other threads:[~2025-05-29  7:11 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-23 19:01 [PATCH v3 00/11] VRAM Self Refresh Badal Nilawar
2025-05-23 19:01 ` [PATCH v3 01/11] PCI/ACPI: Add D3cold Aux Power Limit_DSM method Badal Nilawar
2025-05-24  6:00   ` Sathyanarayanan Kuppuswamy
2025-05-29  6:18     ` Nilawar, Badal
2025-05-29  7:11       ` Nilawar, Badal
2025-05-23 19:01 ` [PATCH v3 02/11] PCI/ACPI: Per root port allow one Aux power limit request Badal Nilawar
2025-05-23 19:01 ` [PATCH v3 03/11] PCI/ACPI: Add PERST# Assertion Delay _DSM method Badal Nilawar
2025-05-23 19:01 ` [PATCH v3 04/11] drm/xe/vrsr: Introduce flag has_vrsr Badal Nilawar
2025-05-23 19:01 ` [PATCH v3 05/11] drm/xe/vrsr: Detect VRSR Capability Badal Nilawar
2025-05-23 19:01 ` [PATCH v3 06/11] drm/xe/vrsr: Initialize VRSR feature Badal Nilawar
2025-05-23 21:33   ` kernel test robot
2025-05-23 19:01 ` [PATCH v3 07/11] drm/xe/vrsr: Enable VRSR on default VGA boot device Badal Nilawar
2025-05-23 22:04   ` kernel test robot
2025-05-23 19:01 ` [PATCH v3 08/11] drm/xe/vrsr: Refactor d3cold.allowed to a enum Badal Nilawar
2025-05-23 19:01 ` [PATCH v3 09/11] drm/xe/pm: D3Cold target state Badal Nilawar
2025-05-23 19:01 ` [PATCH v3 10/11] drm/xe/vrsr: Enable VRSR Badal Nilawar
2025-05-23 19:01 ` [PATCH v3 11/11] drm/xe/vrsr: Introduce a debugfs node named vrsr_capable Badal Nilawar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).