VRAM Self Refresh
Subsystems (6)
v4 cover VRAM Self Refresh
Changes in v4:
- Resolved build warnings
Changes in v3:
PCIe ACPI Patches:
- dropped the notifier block code and added patch to allow only one Aux power limit request per root port (Rafael J. Wysocki)
- 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(-)
Signature · 1 line
2.34.1
PATCH v4 1/11 PCI/ACPI: Add D3cold Aux Power Limit_DSM method
From: Anshuman Gupta <[email protected]>
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
V3(Kuppuswamy)
- Add NULL check for retry interval
--- drivers/pci/pci-acpi.c | 87 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-acpi.h | 8 ++++ 2 files changed, 95 insertions(+)
drivers/pci/pci-acpi.c +87 -0
@@ -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 || !retry_interval) +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;
include/linux/pci-acpi.h +8 -0
@@ -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 inline 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_ */
Signature · 1 line
2.34.1
Re: [PATCH v4 01/11] PCI/ACPI: Add D3cold Aux Power Limit_DSM method
Quoted 12 lines · Badal Nilawar
From: Anshuman Gupta <[email protected]>
Implement
_DSMmethod 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.
Quoted 5 lines
One possible mitigation would be only allowing only first PCIe Non-Bridge Endpoint Function 0 driver to
call_DSMmethod 0Ah.Signed-off-by Varun Gupta <[email protected]>Signed-off-by Badal Nilawar <[email protected]>
If it is Co-developed by above people, you need to add Co-developed-by tag followed by Signed-off-by tag.
Quoted 61 lines
Signed-off-by Anshuman Gupta <[email protected]>---
V2(Bjorn/Rafael):
- Callacpi_dsm_check()to find method 0Ah supported
- Return retry interval to caller
V3(Kuppuswamy)
- Add NULL check for retry interval--- drivers/pci/pci-acpi.c | 87 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-acpi.h | 8 ++++ 2 files changed, 95 insertions(+)drivers/pci/pci-acpi.c +41
-0@@ -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 || !retry_interval) +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 ;
drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1474
Quoted 10 lines
drivers/pci/pci-acpi.c +10
-0+ } + + 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)
Since you already do NULL check at the top, you don't need above check.
Quoted 9 lines
drivers/pci/pci-acpi.c +9
-0+ *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",
drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1493
Quoted 10 lines
drivers/pci/pci-acpi.c +10
-0+ 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) {
Same as above.
Quoted 50 lines
drivers/pci/pci-acpi.c +17
-0+ *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;include/linux/pci-acpi.h +8
-0@@ -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 inline 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_ */
Signature · 2 lines
Sathyanarayanan Kuppuswamy Linux Kernel Developer
Re: [PATCH v4 01/11] PCI/ACPI: Add D3cold Aux Power Limit_DSM method
Apologies for the delay in response.
Quoted 14 lines · Sathyanarayanan Kuppuswamy
Quoted 12 lines · Badal Nilawar
From: Anshuman Gupta <[email protected]>
Implement
_DSMmethod 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.
Quoted 8 lines
Quoted 5 lines
One possible mitigation would be only allowing only first PCIe Non-Bridge Endpoint Function 0 driver to
call_DSMmethod 0Ah.Signed-off-by Varun Gupta <[email protected]>Signed-off-by Badal Nilawar <[email protected]>If it is Co-developed by above people, you need to add Co-developed-by tag followed by Signed-off-by tag.
Sure I will add Co-developed by.
Quoted 75 lines
Quoted 75 lines
Signed-off-by Anshuman Gupta <[email protected]>---
V2(Bjorn/Rafael):
- Callacpi_dsm_check()to find method 0Ah supported
- Return retry interval to caller
V3(Kuppuswamy)
- Add NULL check for retry interval
---
drivers/pci/pci-acpi.c | 87 ++++++++++++++++++++++++++++++++++++++++include/linux/pci-acpi.h| 8 ++++2 files changed, 95 insertions(+)drivers/pci/pci-acpi.c +0
-0@@ -1421,6 +1421,93 @@ static void pci_acpi_optimize_delay(structpci_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_DSMFunction 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(structpci_dev*dev, u32requested_power,
+ u32*retry_interval)drivers/pci/pci-acpi.c +18
-0+{ + 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 || !retry_interval) + 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,
Quoted 8 lines
Quoted 6 lines
+
&in_obj,ACPI_TYPE_INTEGER); + if (!out_obj)
+ return-EINVAL;
+
+ result =out_obj->integer.value;
+ if (retry_interval)Since you already do NULL check at the top, you don't need above check.
Sure, I will fix it.
Quoted 22 lines
Quoted 13 lines
+
*retry_interval= 0;
+
+ switch (result) {
+ case0x0:
+pci_dbg(dev, "D3cold Aux Power %u mW request denied\n", + requested_power);
+ break;
+ case0x1:
+pci_info(dev, "D3cold Aux Power request granted: %u mW\n", + requested_power);
+ ret = 0;
+ break;Quoted 8 lines
+ 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) {
Quoted 1 line
Same as above.
Ok
Thanks,
Badal
Quoted 53 lines
Quoted 52 lines
+
*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;
+ }drivers/pci/pci-acpi.c +6
-0+ + 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;include/linux/pci-acpi.h +8
-0@@ -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 inline 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_ */
Rafael J. Wysocki
maintainerRe: [PATCH v4 01/11] PCI/ACPI: Add D3cold Aux Power Limit_DSM method
In reply to Badal NilawarQuoted 13 lines · Badal Nilawar
From: Anshuman Gupta <[email protected]>
Implement
_DSMmethod 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.
Quoted 4 lines
One possible mitigation would be only allowing only first PCIe Non-Bridge Endpoint Function 0 driver to
call_DSMmethod 0Ah.Signed-off-by Varun Gupta <[email protected]>
What's this S-o-b for?
Quoted 66 lines
Signed-off-by Badal Nilawar <[email protected]>Signed-off-by Anshuman Gupta <[email protected]>---
V2(Bjorn/Rafael):
- Callacpi_dsm_check()to find method 0Ah supported
- Return retry interval to caller
V3(Kuppuswamy)
- Add NULL check for retry interval--- drivers/pci/pci-acpi.c | 87 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-acpi.h | 8 ++++ 2 files changed, 95 insertions(+)drivers/pci/pci-acpi.c +45
-0@@ -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 || !retry_interval) +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,
drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1478
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; +if (retry_interval) + *retry_interval =0 ; + +switch (result) { +case 0x0 :
It would be better to use an enum for the possible return values.
Quoted 4 lines
drivers/pci/pci-acpi.c +4
-0+pci_dbg (dev,"D3cold Aux Power %u mW request denied\n" , + requested_power); +break ; +case 0x1 :
drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1492
Quoted 10 lines
drivers/pci/pci-acpi.c +10
-0+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 (!(result & ~0x1F))
I think, and it would be better to use a symbol for this mask (and below too).
drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1493
Quoted 1 line
drivers/pci/pci-acpi.c +1
-0+if (retry_interval) {
This has been checked already and is guaranteed to be nonzero at this point.
Quoted 51 lines
drivers/pci/pci-acpi.c +17
-0+ *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;include/linux/pci-acpi.h +8
-1@@ -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 inline 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_ */ --
Re: [PATCH v4 01/11] PCI/ACPI: Add D3cold Aux Power Limit_DSM method
Apologies for delay in response.
Quoted 13 lines · Rafael J. Wysocki
Quoted 12 lines · Badal Nilawar
From: Anshuman Gupta<[email protected]>
Implement
_DSMmethod 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.
Quoted 5 lines
Quoted 4 lines
One possible mitigation would be only allowing only first PCIe Non-Bridge Endpoint Function 0 driver to
call_DSMmethod 0Ah.Signed-off-by Varun Gupta<[email protected]>What's this S-o-b for?
Varun was handling this patch from Anshuman earlier. Anshuman can you please confirm whether the contribution from Varun was significant and needed to be co-developed or can this S-o-b be safely dropped in future versions.
Thanks,
Badal
Quoted 3 lines
Quoted 3 lines
Signed-off-by Badal Nilawar<[email protected]>Signed-off-by Anshuman Gupta<[email protected]>
Re: [PATCH v4 01/11] PCI/ACPI: Add D3cold Aux Power Limit_DSM method
In reply to Rafael J. WysockiQuoted 88 lines · Rafael J. Wysocki
Quoted 12 lines · Badal Nilawar
From: Anshuman Gupta <[email protected]>
Implement
_DSMmethod 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.
Quoted 4 lines
One possible mitigation would be only allowing only first PCIe Non-Bridge Endpoint Function 0 driver to
call_DSMmethod 0Ah.Signed-off-by Varun Gupta <[email protected]>What's this S-o-b for?
Quoted 69 lines
Signed-off-by Badal Nilawar <[email protected]>Signed-off-by Anshuman Gupta <[email protected]>---
V2(Bjorn/Rafael):
- Callacpi_dsm_check()to find method 0Ah supported
- Return retry interval to caller
V3(Kuppuswamy)
- Add NULL check for retry interval--- drivers/pci/pci-acpi.c | 87 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-acpi.h | 8 ++++ 2 files changed, 95 insertions(+)drivers/pci/pci-acpi.c +48
-0@@ -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 || !retry_interval) +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 ;
Quoted 8 lines
drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1478
Quoted 7 lines
drivers/pci/pci-acpi.c +7
-0+ + result = out_obj->integer.value; +if (retry_interval) + *retry_interval =0 ; + +switch (result) { +case 0x0 :It would be better to use an enum for the possible return values.
Sure I will use enum, something like
typedef enum {
AUX_PWR_REQ_DENIED = 0x0,
AUX_PWR_REQ_GRANTED = 0x1,
AUX_PWR_REQ_NO_MAIN_PWR_REMOVAL = 0x2
} AUX_PWR_REQ_STATUS;
Quoted 15 lines
Quoted 5 lines
drivers/pci/pci-acpi.c +4
-0+pci_dbg (dev,"D3cold Aux Power %u mW request denied\n" , + requested_power); +break ; +case 0x1 :drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1492
Quoted 10 lines
drivers/pci/pci-acpi.c +10
-0+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 ) {
Quoted 1 line
if (!(result & ~0x1F))
This will pick result = 0x10 as well, that's why checking the range 0x11 - 0x1F.
Quoted 1 line
I think, and it would be better to use a symbol for this mask (and below too).
I will add an enum for the retry interval range — something like AUX_PWR_REQ_RETRY_INT_MIN and AUX_PWR_REQ_RETRY_INT_MAX for 0x11 and 0x1F.
Quoted 3 lines
drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1493
Quoted 2 lines
drivers/pci/pci-acpi.c +1
-0+if (retry_interval) {This has been checked already and is guaranteed to be nonzero at this point.
Sure.
Thanks,
Badal
Quoted 52 lines
Quoted 52 lines
drivers/pci/pci-acpi.c +17
-0+ *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;include/linux/pci-acpi.h +8
-1@@ -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 inline 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_ */ --
Re: [PATCH v4 01/11] PCI/ACPI: Add D3cold Aux Power Limit_DSM method
In reply to Badal NilawarQuoted 5 lines · Badal Nilawar
From: Anshuman Gupta <[email protected]>
Implement
_DSMmethod 0Ah according to PCI firmware specifications, section 4.6.10 Rev 3.3., to request auxilary power needed for the device when in D3Cold.
Cite as "PCI Firmware r3.3, sec 4.6.10"
Quoted 6 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.
Wrap to fill 75 columns. Update citation as above.
Quoted 2 lines
One possible mitigation would be only allowing only first PCIe Non-Bridge Endpoint Function 0 driver to
call_DSMmethod 0Ah.
I don't quite understand how this mitigation would address the lack of aggregation or how the mitigation could be enforced. Maybe just drop this?
s/call_DSM/call _DSM/
Quoted 23 lines
Signed-off-by Varun Gupta <[email protected]>Signed-off-by Badal Nilawar <[email protected]>Signed-off-by Anshuman Gupta <[email protected]>---
V2(Bjorn/Rafael):
- Callacpi_dsm_check()to find method 0Ah supported
- Return retry interval to caller
V3(Kuppuswamy)
- Add NULL check for retry interval--- drivers/pci/pci-acpi.c | 87 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-acpi.h | 8 ++++ 2 files changed, 95 insertions(+)drivers/pci/pci-acpi.c +1
-0@@ -1421,6 +1421,93 @@ static void pci_acpi_optimize_delay(struct pci_dev *pdev,ACPI_FREE (obj); } +/**
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_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.
s/This functions sends a request/Request auxiliary power .../ (imperative mood) s/the host BIOS/platform firmware/ (non-x86 firmware may not be BIOS) s/D3Cold/D3cold/ (twice) to match other usage
s/root port/Root Port/ to match spec usage
s/It checks and evaluates the/Evaluate the/
s/and handles/and handle/
It's not quite clear from this description, but the code assumes this is called for a Root Port. I don't think that's quite the right approach because the spec only says this _DSM function is implemented in the scope of a Downstream Port. That *could* be a Root Port, but it doesn't have to be; it could be a Switch Downstream Port.
The caller shouldn't have to traverse up the tree, checking whether this _DSM function is implemented at each level. So I think the driver should call this with *its* device, and pci_acpi_request_d3cold_aux_power() should walk up the tree looking for this _DSM function.
drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1439
Quoted 4 lines
drivers/pci/pci-acpi.c +4
-0+* 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.
This last paragraph covers two separate issues:
1) Sec 4.6.10 requires driver for function 0 to aggregate power requirements for all functions in a multi-function device. We can't enforce that the driver, e.g., xe, does this, but it seems like this is a hint that we should only evaluate this _DSM for function 0 of a multi-function device. So it seems like we should return an error if called for a function other than 0.
2) The "Location" part of sec 4.6.10 has a separate restriction that system software, i.e., the PCI core, should aggregate requests from child devices, which we don't do so far.
If drivers call pci_acpi_request_d3cold_aux_power() for their devices (not the Root Port), there might be a way to do this aggregation by tracking the sum of all requests at the Downstream Port where we find this _DSM function implemented. But I don't know whether it's worth trying to implement this now because it seems complicated.
I don't know what "1st non-bridge Endpoint driver" means. How does a driver writer know whether the driver qualifies? Maybe just keep the part about this only being supported for function 0 and note that we don't support the aggregation across multiple devices?
Wrap this all to fit in 80 columns like the rest of the file.
drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1444
Quoted 4 lines
drivers/pci/pci-acpi.c +4
-0+* 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)
Name the parameter "requested_power_mw" or even just "requested_mw" so we know the units. Also in header file.
drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1456
Quoted 12 lines
drivers/pci/pci-acpi.c +12
-0+{ +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 || !retry_interval) +return -EINVAL ;
I think it's reasonable to allow retry_interval to be NULL if the caller doesn't want to bother with retries.
Quoted 29 lines
drivers/pci/pci-acpi.c +29
-0+ 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 ;
drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1496
Quoted 10 lines
drivers/pci/pci-acpi.c +10
-0+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);
Seems like pci_info() to me; the user can't do anything about this, nothing is really wrong, and the message shouldn't prompt a bug report.
Quoted 31 lines
drivers/pci/pci-acpi.c +14
-0+ 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;include/linux/pci-acpi.h +1
-0@@ -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) { }
include/linux/pci-acpi.h static inline void pci_acpi_remove_edr_notifier(struct pci_dev *pdev) { } · line 143
Quoted 10 lines
include/linux/pci-acpi.h +4
-0int 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 inline int pci_acpi_request_d3cold_aux_power (struct pci_dev *dev,u32 requested_power, +u32 *retry_interval)
Wrap this to fit in 80 columns like the rest of the file.
Quoted 9 lines
include/linux/pci-acpi.h +3
-0+{ +return -EOPNOTSUPP ; +}#endif /* CONFIG_ACPI */ #endif /* _PCI_ACPI_H_ */ Signature · 1 line
2.34.1
Re: [PATCH v4 01/11] PCI/ACPI: Add D3cold Aux Power Limit_DSM method
Quoted 7 lines · Bjorn Helgaas
Quoted 5 lines · Badal Nilawar
From: Anshuman Gupta <[email protected]>
Implement
_DSMmethod 0Ah according to PCI firmware specifications, section 4.6.10 Rev 3.3., to request auxilary power needed for the device when in D3Cold.Cite as "PCI Firmware r3.3, sec 4.6.10"
Ok.
Quoted 6 lines
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.
Wrap to fill 75 columns. Update citation as above.
Ok.
Quoted 6 lines
Quoted 3 lines
One possible mitigation would be only allowing only first PCIe Non-Bridge Endpoint Function 0 driver to
call_DSMmethod 0Ah.I don't quite understand how this mitigation would address the lack of aggregation or how the mitigation could be enforced. Maybe just drop this?
Ok. In patch 2 this is being mitigated by allowing one request per root port.
Quoted 2 lines
s/call_DSM/call _DSM/
Ok
Quoted 32 lines
Quoted 32 lines
Signed-off-by Varun Gupta <[email protected]>Signed-off-by Badal Nilawar <[email protected]>Signed-off-by Anshuman Gupta <[email protected]>---
V2(Bjorn/Rafael):
- Callacpi_dsm_check()to find method 0Ah supported
- Return retry interval to caller
V3(Kuppuswamy)
- Add NULL check for retry interval--- drivers/pci/pci-acpi.c | 87 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-acpi.h | 8 ++++ 2 files changed, 95 insertions(+)drivers/pci/pci-acpi.c +9
-0@@ -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.
Quoted 8 lines
drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1434
Quoted 2 lines
drivers/pci/pci-acpi.c +2
-0+* It checks and evaluates the _DSM (Device Specific Method) to request the auxiliary +* power and handles the response accordingly. s/This functions sends a request/Request auxiliary power .../ (imperative mood) s/the host BIOS/platform
firmware/(non-x86 firmware may not be BIOS) s/D3Cold/D3cold/ (twice) to match other usage
s/root port/Root Port/ to match spec usage
s/It checks and evaluates the/Evaluate the/
s/and handles/and handle/
Ok
Quoted 6 lines
It's not quite clear from this description, but the code assumes this is called for a Root Port. I don't think that's quite the right approach because the spec only says this
_DSMfunction is implemented in the scope of a Downstream Port. That *could* be a Root Port, but it doesn't have to be; it could be a Switch Downstream Port.
Agree, I will rephrase with "Root Port/Switch Downstream Port"
Quoted 6 lines
The caller shouldn't have to traverse up the tree, checking whether this
_DSMfunction is implemented at each level. So I think the driver should call this with *its* device, andpci_acpi_request_d3cold_aux_power()should walk up the tree looking for this_DSMfunction.
Agree, will handle this.
Quoted 5 lines
drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1439
Quoted 5 lines
drivers/pci/pci-acpi.c +4
-0+* 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.
Quoted 8 lines
This last paragraph covers two separate issues:
1) Sec 4.6.10 requires driver for function 0 to aggregate power requirements for all functions in a multi-function device. We can't enforce that the driver, e.g., xe, does this, but it seems like this is a hint that we should only evaluate this
_DSMfor function 0 of a multi-function device. So it seems like we should return an error if called for a function other than 0.
Fine, I will return error for function other than 0.
Quoted 11 lines
2) The "Location" part of sec 4.6.10 has a separate restriction that system software, i.e., the PCI core, should aggregate requests from child devices, which we don't do so far.
If drivers call
pci_acpi_request_d3cold_aux_power()for their devices (not the Root Port), there might be a way to do this aggregation by tracking the sum of all requests at the Downstream Port where we find this_DSMfunction implemented. But I don't know whether it's worth trying to implement this now because it seems complicated.
Aggregation is complicated and not required for current use case.
Quoted 5 lines
I don't know what "1st non-bridge Endpoint driver" means. How does a driver writer know whether the driver qualifies? Maybe just keep the part about this only being supported for function 0 and note that we don't support the aggregation across multiple devices?
Ok.
Quoted 2 lines
Wrap this all to fit in 80 columns like the rest of the file.
Now it is allowed to fit in 100 columns but I will fit it in 80 columns to maintain consistency with rest of the file.
Quoted 7 lines
drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1444
Quoted 5 lines
drivers/pci/pci-acpi.c +4
-0+* 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)Name the parameter "
requested_power_mw" or even just "requested_mw" so we know the units. Also in header file.
Ok
Quoted 15 lines
drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1456
Quoted 13 lines
drivers/pci/pci-acpi.c +12
-0+{ +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 || !retry_interval) +return -EINVAL ;I think it's reasonable to allow
retry_intervalto be NULL if the caller doesn't want to bother with retries.
Ok
Quoted 35 lines
Quoted 35 lines
drivers/pci/pci-acpi.c +34
-0+ 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 :
Quoted 8 lines
drivers/pci/pci-acpi.c static void pci_acpi_optimize_delay(struct pci_dev *pdev, · line 1496
Quoted 5 lines
drivers/pci/pci-acpi.c +5
-0+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);Seems like
pci_info()to me; the user can't do anything about this, nothing is really wrong, and the message shouldn't prompt a bug report.
Ok.
Quoted 37 lines
Quoted 37 lines
drivers/pci/pci-acpi.c +14
-0+ 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;include/linux/pci-acpi.h +3
-0@@ -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);
Quoted 6 lines
include/linux/pci-acpi.h static inline void pci_acpi_remove_edr_notifier(struct pci_dev *pdev) { } · line 143
Quoted 5 lines
include/linux/pci-acpi.h +2
-0#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 inline int pci_acpi_request_d3cold_aux_power (struct pci_dev *dev,u32 requested_power, +u32 *retry_interval)Wrap this to fit in 80 columns like the rest of the file.
Ok.
Thanks,
Badal
Quoted 10 lines
Quoted 10 lines
include/linux/pci-acpi.h +3
-0+{ +return -EOPNOTSUPP ; +}#endif /* CONFIG_ACPI */ #endif /* _PCI_ACPI_H_ */ Signature · 1 line
2.34.1
PATCH v4 2/11 PCI/ACPI: Per root port allow one Aux power limit request
In reply to Badal NilawarFor given root port allow one Aux power limit request.
--- drivers/acpi/scan.c | 1 + drivers/pci/pci-acpi.c | 25 ++++++++++++++++++++++++- include/acpi/acpi_bus.h | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-)
drivers/acpi/scan.c +1 -0
@@ -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);
drivers/pci/pci-acpi.c +24 -1
@@ -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 || !retry_interval)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; }
include/acpi/acpi_bus.h +2 -0
@@ -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 {
Signature · 1 line
2.34.1
Re: [PATCH v4 02/11] PCI/ACPI: Per root port allow one Aux power limit request
Quoted 100 lines · Badal Nilawar
For given root port allow one Aux power limit request.
Cc Rafael J. Wysocki <[email protected]>Cc Anshuman Gupta <[email protected]>Signed-off-by Badal Nilawar <[email protected]>--- drivers/acpi/scan.c | 1 + drivers/pci/pci-acpi.c | 25 ++++++++++++++++++++++++- include/acpi/acpi_bus.h | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-)drivers/acpi/scan.c +1
-0@@ -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);drivers/pci/pci-acpi.c +24
-1@@ -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 || !retry_interval)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; }include/acpi/acpi_bus.h +0
-0
include/acpi/acpi_bus.h struct acpi_device_power { · line 298
Quoted 5 lines
include/acpi/acpi_bus.h +2
-0@@ -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 */
Do you need a new lock ? Is it possible to reuse existing mutex like device_lock()?
Quoted 3 lines
include/acpi/acpi_bus.h +0
-0};struct acpi_dep_data {
Signature · 2 lines
Sathyanarayanan Kuppuswamy Linux Kernel Developer
Rafael J. Wysocki
maintainerRe: [PATCH v4 02/11] PCI/ACPI: Per root port allow one Aux power limit request
Quoted 103 lines · Sathyanarayanan Kuppuswamy
Quoted 100 lines · Badal Nilawar
For given root port allow one Aux power limit request.
Cc Rafael J. Wysocki <[email protected]>Cc Anshuman Gupta <[email protected]>Signed-off-by Badal Nilawar <[email protected]>--- drivers/acpi/scan.c | 1 + drivers/pci/pci-acpi.c | 25 ++++++++++++++++++++++++- include/acpi/acpi_bus.h | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-)drivers/acpi/scan.c +1
-0@@ -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);drivers/pci/pci-acpi.c +24
-1@@ -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 || !retry_interval)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; }include/acpi/acpi_bus.h +0
-0@@ -294,6 +294,8 @@ struct acpi_device_power {
Quoted 8 lines
include/acpi/acpi_bus.h struct acpi_device_power { · line 298
Quoted 5 lines
include/acpi/acpi_bus.h +2
-0struct 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 */ Do you need a new lock ?
Yes.
Quoted 1 line
Is it possible to reuse existing mutex like
device_lock()?
No.
Doing such things results in code where nobody knows what the given lock scope is.
Re: [PATCH v4 02/11] PCI/ACPI: Per root port allow one Aux power limit request
Quoted 111 lines · Rafael J. Wysocki
Quoted 101 lines · Sathyanarayanan Kuppuswamy
Quoted 99 lines · Badal Nilawar
For given root port allow one Aux power limit request.
Cc Rafael J. Wysocki <[email protected]>Cc Anshuman Gupta <[email protected]>Signed-off-by Badal Nilawar <[email protected]>--- drivers/acpi/scan.c | 1 + drivers/pci/pci-acpi.c | 25 ++++++++++++++++++++++++- include/acpi/acpi_bus.h | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-)drivers/acpi/scan.c +1
-0@@ -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);drivers/pci/pci-acpi.c +24
-1@@ -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 || !retry_interval)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; }include/acpi/acpi_bus.h +0
-0Quoted 8 lines
include/acpi/acpi_bus.h struct acpi_device_power { · line 298
Quoted 6 lines
include/acpi/acpi_bus.h +2
-0@@ -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 */ Do you need a new lock ?
Quoted 7 lines
Yes.
Quoted 1 line
Is it possible to reuse existing mutex like
device_lock()?No.
Doing such things results in code where nobody knows what the given lock scope is.
Got it. Thanks for the clarification.
Signature · 2 lines
Sathyanarayanan Kuppuswamy Linux Kernel Developer
Rafael J. Wysocki
maintainerRe: [PATCH v4 02/11] PCI/ACPI: Per root port allow one Aux power limit request
In reply to Badal NilawarQuoted 37 lines · Badal Nilawar
For given root port allow one Aux power limit request.
Cc Rafael J. Wysocki <[email protected]>Cc Anshuman Gupta <[email protected]>Signed-off-by Badal Nilawar <[email protected]>--- drivers/acpi/scan.c | 1 + drivers/pci/pci-acpi.c | 25 ++++++++++++++++++++++++- include/acpi/acpi_bus.h | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-)drivers/acpi/scan.c +1
-0@@ -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);drivers/pci/pci-acpi.c +1
-0@@ -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 || !retry_interval)return -EINVAL ;
drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power, · line 1472
Quoted 8 lines
drivers/pci/pci-acpi.c +5
-0@@ -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);
Use a mutex locking guard for this new lock, please.
drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power, · line 1479
Quoted 7 lines
drivers/pci/pci-acpi.c +7
-0+ +/* 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 ;
Maybe -EALREADY?
Quoted 60 lines
drivers/pci/pci-acpi.c +11
-1+ } + 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; }include/acpi/acpi_bus.h +2
-1@@ -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
Re: [PATCH v4 02/11] PCI/ACPI: Per root port allow one Aux power limit request
Quoted 40 lines · Rafael J. Wysocki
Quoted 39 lines · Badal Nilawar
For given root port allow one Aux power limit request.
Cc Rafael J. Wysocki <[email protected]>Cc Anshuman Gupta <[email protected]>Signed-off-by Badal Nilawar <[email protected]>--- drivers/acpi/scan.c | 1 + drivers/pci/pci-acpi.c | 25 ++++++++++++++++++++++++- include/acpi/acpi_bus.h | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-)drivers/acpi/scan.c +1
-0@@ -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);drivers/pci/pci-acpi.c +1
-0@@ -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 || !retry_interval)return -EINVAL ;@@ -1464,11 +1465,27 @@ int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power,return -ENODEV ; }
Quoted 6 lines
drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power, · line 1472
Quoted 5 lines
drivers/pci/pci-acpi.c +5
-0+ adev =ACPI_COMPANION (&dev->dev); +if (!adev) +return -EINVAL ; + +mutex_lock (&adev->power.aux_pwr_lock);Use a mutex locking guard for this new lock, please.
Sure.
Quoted 9 lines
drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power, · line 1479
Quoted 8 lines
drivers/pci/pci-acpi.c +7
-0+ +/* 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 ;Maybe
-EALREADY?
From definition it is for operation in progress. Not sure if it appropriate for "allow once" scenario.
#define EALREADY 114 /* Operation already in progress */
Thanks,
Badal
Quoted 61 lines
Quoted 61 lines
drivers/pci/pci-acpi.c +11
-1+ } + 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; }include/acpi/acpi_bus.h +2
-1@@ -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
Re: [PATCH v4 02/11] PCI/ACPI: Per root port allow one Aux power limit request
In reply to Badal NilawarQuoted 16 lines · Badal Nilawar
For given root port allow one Aux power limit request.
Cc Rafael J. Wysocki <[email protected]>Cc Anshuman Gupta <[email protected]>Signed-off-by Badal Nilawar <[email protected]>--- drivers/acpi/scan.c | 1 + drivers/pci/pci-acpi.c | 25 ++++++++++++++++++++++++- include/acpi/acpi_bus.h | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-)drivers/acpi/scan.c +0
-0
drivers/acpi/scan.c int acpi_device_add(struct acpi_device *device) · line 748
Quoted 4 lines
drivers/acpi/scan.c +1
-0@@ -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);
Hi,
mutex_destroy() also exists but I don't find any added by this patch? I think the pre-existing mutex might also have this same problem.
Quoted 89 lines
drivers/acpi/scan.c +0
-0mutex_lock (&acpi_device_lock);drivers/pci/pci-acpi.c +24
-1@@ -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 || !retry_interval)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; }include/acpi/acpi_bus.h +2
-0@@ -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 {
Signature · 1 line
i.
Re: [PATCH v4 02/11] PCI/ACPI: Per root port allow one Aux power limit request
Quoted 24 lines · Ilpo Järvinen
Quoted 16 lines · Badal Nilawar
For given root port allow one Aux power limit request.
Cc Rafael J. Wysocki <[email protected]>Cc Anshuman Gupta <[email protected]>Signed-off-by Badal Nilawar <[email protected]>--- drivers/acpi/scan.c | 1 + drivers/pci/pci-acpi.c | 25 ++++++++++++++++++++++++- include/acpi/acpi_bus.h | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-)drivers/acpi/scan.c +0
-0drivers/acpi/scan.c int acpi_device_add(struct acpi_device *device) · line 748
Quoted 4 lines
drivers/acpi/scan.c +1
-0@@ -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);Hi,
Quoted 2 lines
mutex_destroy()also exists but I don't find any added by this patch? I think the pre-existing mutex might also have this same problem.
I will add mutex_destroy in acpi_device_release().
Thanks,
Badal
Quoted 90 lines
Quoted 90 lines
drivers/acpi/scan.c +0
-0mutex_lock (&acpi_device_lock);drivers/pci/pci-acpi.c +24
-1@@ -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 || !retry_interval)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; }include/acpi/acpi_bus.h +2
-0@@ -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 {
Re: [PATCH v4 02/11] PCI/ACPI: Per root port allow one Aux power limit request
In reply to Badal NilawarQuoted 1 line · Badal Nilawar
For given root port allow one Aux power limit request.
Please include the reason why we do this. I don't think we need it.
PCI Firmware r3.3, sec 4.6.10 says this _DSM function can be invoked multiple times with different requests.
We might need a mutex just to avoid concurrent evaluations of this _DSM function by different drivers; I'm not sure whether there's a requirement to avoid that or whether the ACPI core already enforces something like that. But that would be a separate thing from aux_power_limit.
Quoted 109 lines
Cc Rafael J. Wysocki <[email protected]>Cc Anshuman Gupta <[email protected]>Signed-off-by Badal Nilawar <[email protected]>--- drivers/acpi/scan.c | 1 + drivers/pci/pci-acpi.c | 25 ++++++++++++++++++++++++- include/acpi/acpi_bus.h | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-)drivers/acpi/scan.c +1
-0@@ -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);drivers/pci/pci-acpi.c +24
-1@@ -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 || !retry_interval)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; }include/acpi/acpi_bus.h +2
-0@@ -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 {Signature · 1 line
2.34.1
Re: [PATCH v4 02/11] PCI/ACPI: Per root port allow one Aux power limit request
Quoted 3 lines · Bjorn Helgaas
Quoted 1 line · Badal Nilawar
For given root port allow one Aux power limit request.
Please include the reason why we do this. I don't think we need it.
This is added as aggregation is not supported. I will add the reason.
Quoted 9 lines
PCI Firmware r3.3, sec 4.6.10 says this
_DSMfunction can be invoked multiple times with different requests.We might need a mutex just to avoid concurrent evaluations of this
_DSMfunction by different drivers; I'm not sure whether there's a requirement to avoid that or whether the ACPI core already enforces something like that. But that would be a separate thing fromaux_power_limit.
As discussed in patch1 as driver's pci_dev will be passed to pci_acpi_request_d3cold_aux_power(), will save that |pci_dev| in |struct acpi_device_power| to support multiple |_DSM| invocations by the same driver.
Thanks,
Badal
Quoted 110 lines
Quoted 110 lines
Cc Rafael J. Wysocki<[email protected]>Cc Anshuman Gupta<[email protected]>Signed-off-by Badal Nilawar<[email protected]>--- drivers/acpi/scan.c | 1 + drivers/pci/pci-acpi.c | 25 ++++++++++++++++++++++++- include/acpi/acpi_bus.h | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-)drivers/acpi/scan.c +1
-0@@ -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);drivers/pci/pci-acpi.c +24
-1@@ -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 || !retry_interval)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; }include/acpi/acpi_bus.h +2
-0@@ -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 {Signature · 1 line
2.34.1
PATCH v4 3/11 PCI/ACPI: Add PERST# Assertion Delay _DSM method
In reply to Badal NilawarFrom: Anshuman Gupta <[email protected]>
Implement _DSM Method 0Bh as per PCI firmware specs section 4.6.11 Rev 3.3.
--- drivers/pci/pci-acpi.c | 57 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-acpi.h | 8 +++++- 2 files changed, 64 insertions(+), 1 deletion(-)
drivers/pci/pci-acpi.c +57 -0
@@ -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;
include/linux/pci-acpi.h +7 -1
@@ -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_devoid 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 inline int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 req {return -EOPNOTSUPP ; } + +static inline 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.34.1
Re: [PATCH v4 03/11] PCI/ACPI: Add PERST# Assertion Delay _DSM method
Quoted 55 lines · Badal Nilawar
From: Anshuman Gupta <[email protected]>
Implement
_DSMMethod 0Bh as per PCI firmware specs section 4.6.11 Rev 3.3.Signed-off-by Anshuman Gupta <[email protected]>Signed-off-by Badal Nilawar <[email protected]>--- drivers/pci/pci-acpi.c | 57 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-acpi.h | 8 +++++- 2 files changed, 64 insertions(+), 1 deletion(-)drivers/pci/pci-acpi.c +35
-0@@ -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,
drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power, · line 1578
Quoted 10 lines
drivers/pci/pci-acpi.c +10
-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) { +pci_info (dev,"PERST# Assertion Delay set to %u microseconds\n" , delay_us); + ret =0 ;
I think above is a debug message. If it is set properly, why would you want to know the details?
drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power, · line 1584
Quoted 6 lines
drivers/pci/pci-acpi.c +6
-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); + }
May be you don't need to elaborate the error details. Will following work?
pci_warn(dev, "PERST# Assertion Delay request failed, result:%u micro seconds\n", result);
Quoted 42 lines
drivers/pci/pci-acpi.c +6
-0+ +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;include/linux/pci-acpi.h +7
-1@@ -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_devoid 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 inline int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 req {return -EOPNOTSUPP ; } + +static inline int pci_acpi_add_perst_assertion_delay (struct pci_dev *dev,u32 delay_us) +{ +return -EOPNOTSUPP ; +}#endif /* CONFIG_ACPI */ #endif /* _PCI_ACPI_H_ */
Signature · 2 lines
Sathyanarayanan Kuppuswamy Linux Kernel Developer
Rafael J. Wysocki
maintainerRe: [PATCH v4 03/11] PCI/ACPI: Add PERST# Assertion Delay _DSM method
Quoted 79 lines · Sathyanarayanan Kuppuswamy
Quoted 55 lines · Badal Nilawar
From: Anshuman Gupta <[email protected]>
Implement
_DSMMethod 0Bh as per PCI firmware specs section 4.6.11 Rev 3.3.Signed-off-by Anshuman Gupta <[email protected]>Signed-off-by Badal Nilawar <[email protected]>--- drivers/pci/pci-acpi.c | 57 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-acpi.h | 8 +++++- 2 files changed, 64 insertions(+), 1 deletion(-)drivers/pci/pci-acpi.c +35
-0@@ -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,drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power, · line 1578
Quoted 10 lines
drivers/pci/pci-acpi.c +10
-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) { +pci_info (dev,"PERST# Assertion Delay set to %u microseconds\n" , delay_us); + ret =0 ;I think above is a debug message. If it is set properly, why would you want to know the details?
drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power, · line 1584
Quoted 6 lines
drivers/pci/pci-acpi.c +6
-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); + }
Quoted 3 lines
May be you don't need to elaborate the error details. Will following work?
pci_warn(dev, "PERST# Assertion Delay request failed, result:%u micro seconds\n", result);
Or even
pci_info(dev, "PERST# Assertion Delay request failed, using %u ms delay\n", result);
And it doesn't really need to be pci_warn().
Quoted 48 lines
Quoted 33 lines
drivers/pci/pci-acpi.c +6
-0+ +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;include/linux/pci-acpi.h +2
-1@@ -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_devoid 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 inline int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 req {include/linux/pci-acpi.h static inline int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 req · line 155
Quoted 10 lines
include/linux/pci-acpi.h +5
-0return -EOPNOTSUPP ; } + +static inline int pci_acpi_add_perst_assertion_delay (struct pci_dev *dev,u32 delay_us) +{ +return -EOPNOTSUPP ; +}#endif /* CONFIG_ACPI */ #endif /* _PCI_ACPI_H_ */ --
Sathyanarayanan Kuppuswamy
Linux Kernel Developer
Re: [PATCH v4 03/11] PCI/ACPI: Add PERST# Assertion Delay _DSM method
Quoted 80 lines · Rafael J. Wysocki
Quoted 78 lines · Sathyanarayanan Kuppuswamy
Quoted 55 lines · Badal Nilawar
From: Anshuman Gupta <[email protected]>
Implement
_DSMMethod 0Bh as per PCI firmware specs section 4.6.11 Rev 3.3.Signed-off-by Anshuman Gupta <[email protected]>Signed-off-by Badal Nilawar <[email protected]>--- drivers/pci/pci-acpi.c | 57 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-acpi.h | 8 +++++- 2 files changed, 64 insertions(+), 1 deletion(-)drivers/pci/pci-acpi.c +35
-0@@ -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,drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power, · line 1578
Quoted 10 lines
drivers/pci/pci-acpi.c +10
-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) { +pci_info (dev,"PERST# Assertion Delay set to %u microseconds\n" , delay_us); + ret =0 ;I think above is a debug message. If it is set properly, why would you want to know the details?
drivers/pci/pci-acpi.c int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power, · line 1584
Quoted 6 lines
drivers/pci/pci-acpi.c +6
-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); + }May be you don't need to elaborate the error details. Will following work?
Quoted 7 lines
Quoted 1 line
pci_warn(dev, "PERST# Assertion Delay request failed, result:%u micro seconds\n", result);Or even
pci_info(dev, "PERST# Assertion Delay request failed, using %u ms delay\n", result);And it doesn't really need to be
pci_warn().
Make sense. I will incorporate above suggestion in next rev.
Thanks,
Badal
Quoted 47 lines
Quoted 47 lines
Quoted 33 lines
drivers/pci/pci-acpi.c +6
-0+ +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;include/linux/pci-acpi.h +2
-1@@ -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_devoid 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 inline int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 req {include/linux/pci-acpi.h static inline int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 req · line 155
Quoted 10 lines
include/linux/pci-acpi.h +5
-0return -EOPNOTSUPP ; } + +static inline int pci_acpi_add_perst_assertion_delay (struct pci_dev *dev,u32 delay_us) +{ +return -EOPNOTSUPP ; +}#endif /* CONFIG_ACPI */ #endif /* _PCI_ACPI_H_ */ --
Sathyanarayanan Kuppuswamy
Linux Kernel Developer
Re: [PATCH v4 03/11] PCI/ACPI: Add PERST# Assertion Delay _DSM method
In reply to Badal NilawarQuoted 4 lines · Badal Nilawar
From: Anshuman Gupta <[email protected]>
Implement
_DSMMethod 0Bh as per PCI firmware specs section 4.6.11 Rev 3.3.
Update citation as for the other _DSM function.
Quoted 13 lines
Signed-off-by Anshuman Gupta <[email protected]>Signed-off-by Badal Nilawar <[email protected]>--- drivers/pci/pci-acpi.c | 57 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-acpi.h | 8 +++++- 2 files changed, 64 insertions(+), 1 deletion(-)drivers/pci/pci-acpi.c +0
-0@@ -1531,6 +1531,63 @@ 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 1541
Quoted 10 lines
drivers/pci/pci-acpi.c +8
-0EXPORT_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.
Reword in imperative mood.
Like pci_acpi_request_d3cold_aux_power(), I think the driver should call this with its device, not the Root Port.
Quoted 73 lines
drivers/pci/pci-acpi.c +48
-0+* 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;include/linux/pci-acpi.h +2
-1@@ -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_devoid 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) { }
include/linux/pci-acpi.h static inline int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 req · line 149
Quoted 5 lines
include/linux/pci-acpi.h +2
-0@@ -144,6 +145,11 @@ static inline int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 req {return -EOPNOTSUPP ; } + +static inline int pci_acpi_add_perst_assertion_delay (struct pci_dev *dev,u32 delay_us)
Wrap to fit in 80 columns like the rest of the file.
Quoted 9 lines
include/linux/pci-acpi.h +3
-0+{ +return -EOPNOTSUPP ; +}#endif /* CONFIG_ACPI */ #endif /* _PCI_ACPI_H_ */ Signature · 1 line
2.34.1
Re: [PATCH v4 03/11] PCI/ACPI: Add PERST# Assertion Delay _DSM method
Quoted 6 lines · Bjorn Helgaas
Quoted 4 lines · Badal Nilawar
From: Anshuman Gupta <[email protected]>
Implement
_DSMMethod 0Bh as per PCI firmware specs section 4.6.11 Rev 3.3.Update citation as for the other
_DSMfunction.
Sure.
Quoted 26 lines
Quoted 14 lines
Signed-off-by Anshuman Gupta <[email protected]>Signed-off-by Badal Nilawar <[email protected]>--- drivers/pci/pci-acpi.c | 57 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-acpi.h | 8 +++++- 2 files changed, 64 insertions(+), 1 deletion(-)drivers/pci/pci-acpi.c +0
-0@@ -1531,6 +1531,63 @@ 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 1541
Quoted 10 lines
drivers/pci/pci-acpi.c +8
-0EXPORT_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. Reword in imperative mood.
Quoted 2 lines
Like
pci_acpi_request_d3cold_aux_power(), I think the driver should call this with its device, not the Root Port.
Ok.
Quoted 72 lines
Quoted 72 lines
drivers/pci/pci-acpi.c +48
-0+* 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;include/linux/pci-acpi.h +2
-1@@ -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_devoid 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) { }
Quoted 8 lines
include/linux/pci-acpi.h static inline int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 req · line 149
Quoted 7 lines
include/linux/pci-acpi.h +2
-0static inline void acpi_pci_remove_bus (struct pci_bus *bus) { }@@ -144,6 +145,11 @@ static inline int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 req {return -EOPNOTSUPP ; } + +static inline int pci_acpi_add_perst_assertion_delay (struct pci_dev *dev,u32 delay_us)Wrap to fit in 80 columns like the rest of the file.
Ok.
Thanks,
Badal
Quoted 9 lines
Quoted 9 lines
include/linux/pci-acpi.h +3
-0+{ +return -EOPNOTSUPP ; +}#endif /* CONFIG_ACPI */ #endif /* _PCI_ACPI_H_ */ Signature · 1 line
2.34.1
PATCH v4 4/11 drm/xe/vrsr: Introduce flag has_vrsr
In reply to Badal NilawarIntroduce 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
@@ -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 */
drivers/gpu/drm/xe/xe_pci.c +3 -0
@@ -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;
Signature · 1 line
2.34.1
Re: [v4,04/11] drm/xe/vrsr: Introduce flag has_vrsr
Quoted 43 lines · Badal Nilawar
Introduce flag
has_vrsrto determine if platform supports VRSR featureCc Rodrigo Vivi <[email protected]>Signed-off-by Badal Nilawar <[email protected]>--- 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@@ -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 */ drivers/gpu/drm/xe/xe_pci.c +2
-0@@ -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, };
drivers/gpu/drm/xe/xe_pci.c static int xe_info_init_early(struct xe_device *xe, · line 597
Quoted 7 lines
drivers/gpu/drm/xe/xe_pci.c +1
-0@@ -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;
LGTM.
PATCH v4 5/11 drm/xe/vrsr: Detect VRSR Capability
In reply to Badal NilawarFrom: Anshuman Gupta <[email protected]>
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 | 26 ++++++++++++++++++++++++++ 3 files changed, 33 insertions(+)
drivers/gpu/drm/xe/regs/xe_regs.h +3 -0
@@ -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
@@ -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;
drivers/gpu/drm/xe/xe_pm.c +26 -0
@@ -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);
Signature · 1 line
2.34.1
PATCH v4 6/11 drm/xe/vrsr: Initialize VRSR feature
In reply to Badal NilawarAdd 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
--- 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(-)
drivers/gpu/drm/xe/xe_device_types.h +1 -0
@@ -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 +7 -0
@@ -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
drivers/gpu/drm/xe/xe_pm.c +104 -1
129 lines not on this page · raw message
drivers/gpu/drm/xe/xe_pm.h +1 -0
@@ -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.34.1
Re: [v4,06/11] drm/xe/vrsr: Initialize VRSR feature
Quoted 94 lines · Badal Nilawar
Add the API
xe_pm_vrsr_enableto 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 <[email protected]>Signed-off-by Anshuman Gupta <[email protected]>--- 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(-)drivers/gpu/drm/xe/xe_device_types.h +1
-0@@ -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 +7
-0@@ -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 0x0drivers/gpu/drm/xe/xe_pm.c +28
-0@@ -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);
drivers/gpu/drm/xe/xe_pm.c static bool xe_pm_vrsr_capable(struct xe_device *xe) · line 300
Quoted 10 lines
drivers/gpu/drm/xe/xe_pm.c +10
-0+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;
Instead of indefinite retry, can you retries with count, ~3 times, after which we can return failure.
Quoted 5 lines
drivers/gpu/drm/xe/xe_pm.c +5
-0+ } + +if (ret) +return ret; +
drivers/gpu/drm/xe/xe_pm.c static bool xe_pm_vrsr_capable(struct xe_device *xe) · line 315
Quoted 10 lines
drivers/gpu/drm/xe/xe_pm.c +10
-0+ 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 */
This can be rephrased to, "Check if Xe should support VRSR for the platform."
drivers/gpu/drm/xe/xe_pm.c static bool xe_pm_vrsr_capable(struct xe_device *xe) · line 318
Quoted 4 lines
drivers/gpu/drm/xe/xe_pm.c +3
-0+if (!xe->info.has_vrsr) +return ; +
Can you add a comment here also, viz "Check if GPU firmware supports VRSR"
Quoted 9 lines
drivers/gpu/drm/xe/xe_pm.c +9
-0+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) {
drivers/gpu/drm/xe/xe_pm.c static bool xe_pm_vrsr_capable(struct xe_device *xe) · line 337
Quoted 10 lines
drivers/gpu/drm/xe/xe_pm.c +10
-0+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
as this function does both enable & disable VRSR, this can be renamed to xe_pm_set_vrsr(xe, flag)
Quoted 50 lines
drivers/gpu/drm/xe/xe_pm.c +28
-0+* @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;drivers/gpu/drm/xe/xe_pm.c +1
-1@@ -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);drivers/gpu/drm/xe/xe_pm.h +1
-0@@ -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
Re: [v4,06/11] drm/xe/vrsr: Initialize VRSR feature
Quoted 98 lines · Karthik
Quoted 96 lines · Badal Nilawar
Add the API
xe_pm_vrsr_enableto 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 <[email protected]>Signed-off-by Anshuman Gupta <[email protected]>---
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(-)drivers/gpu/drm/xe/xe_device_types.h +1
-0@@ -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 +0
-0@@ -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
0x71drivers/gpu/drm/xe/xe_pcode_api.h +6
-0+#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_P00x0drivers/gpu/drm/xe/xe_pm.c +0
-0@@ -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>drivers/gpu/drm/xe/xe_pm.c +30
-0@@ -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);
Quoted 8 lines
Quoted 7 lines
+
+ 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;Instead of indefinite retry, can you retries with count, ~3 times, after which we can return failure.
Retry count is not needed because as per PCI firmware specifications, section 4.6.10 Rev 3.3. Firmware is not permitted to return a value in this range more than once for each _DSM instance (located within the ACPI namespace of a single downstream port DeviceObject), unless there is a subsequent invocation of this function before the previously returned retry interval has expired.
Quoted 9 lines
Quoted 9 lines
+ }
drivers/gpu/drm/xe/xe_pm.c +8
-0+ + if (ret) + return ret; + + ret = pci_acpi_add_perst_assertion_delay(root_pdev, perst_delay); + + return ret; +}
Quoted 8 lines
drivers/gpu/drm/xe/xe_pm.c static bool xe_pm_vrsr_capable(struct xe_device *xe) · line 315
Quoted 6 lines
drivers/gpu/drm/xe/xe_pm.c +6
-0+ +static void xe_pm_vrsr_init (struct xe_device *xe) +{ + int ret; + + /* Check if platform support D3Cold VRSR */This can be rephrased to, "Check if Xe should support VRSR for the platform."
Here with has_vrsr we are checking if DGFX platform support VRSR or not. If supported, VRSR will be enabled in Xe kmd. I think let's keep the comment as it is.
Quoted 6 lines
Quoted 5 lines
+ if (!xe->info.has_vrsr)
+ return;
+Can you add a comment here also, viz "Check if GPU firmware supports VRSR"
Sure, I will add.
Quoted 14 lines
Quoted 14 lines
+ 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;
+ }
+
Quoted 8 lines
drivers/gpu/drm/xe/xe_pm.c static bool xe_pm_vrsr_capable(struct xe_device *xe) · line 337
Quoted 6 lines
+
xe->d3cold.vrsr_capable= true;
+drm_info(&xe->drm, "VRSR capable: Yes\n");drivers/gpu/drm/xe/xe_pm.c +4
-0+} + +/** +* xe_pm_vrsr_enable - Enable VRAM self refresh as this function does both enable & disable VRSR, this can be renamed to
xe_pm_set_vrsr(xe, flag)
IMO, _vrsr_enable() is a more suitable name than _set_vrsr. Since the subsequent patches don't involve disabling VRSR, I can remove the flag and retain only the code for enabling it. Note that VRSR is internally disabled by pcode upon exiting D3Cold. Therefore, in subsequent patches, VRSR is re-enabled each time before entering D3Cold.
Thanks,
Badal
Quoted 50 lines
Quoted 50 lines
+ * @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.
+ */drivers/gpu/drm/xe/xe_pm.c +13
-0+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);drivers/gpu/drm/xe/xe_pm.c +4
-0+ + return ret; +} +static void
xe_pm_runtime_init(struct xe_device *xe){
struct device *dev =xe->drm.dev;drivers/gpu/drm/xe/xe_pm.c +1
-1@@ -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);drivers/gpu/drm/xe/xe_pm.h +0
-0@@ -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
Re: [v4,06/11] drm/xe/vrsr: Initialize VRSR feature
Quoted 110 lines · Badal
Quoted 99 lines · Karthik
Quoted 97 lines · Badal Nilawar
Add the API
xe_pm_vrsr_enableto 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 <[email protected]>Signed-off-by Anshuman Gupta <[email protected]>---
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(-)drivers/gpu/drm/xe/xe_device_types.h +1
-0@@ -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 +0
-0@@ -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
0x71drivers/gpu/drm/xe/xe_pcode_api.h +6
-0+#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_P00x0drivers/gpu/drm/xe/xe_pm.c +0
-0@@ -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>drivers/gpu/drm/xe/xe_pm.c +30
-0@@ -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);Quoted 8 lines
Quoted 7 lines
+
+ 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;Instead of indefinite retry, can you retries with count, ~3 times, after which we can return failure.
Quoted 3 lines
Retry count is not needed because as per PCI firmware specifications, section 4.6.10 Rev 3.3. Firmware is not permitted to return a value in this range more than once for each
_DSMinstance (located within the ACPI namespace of a single downstream port DeviceObject), unless there is a subsequent invocation of this function before the previously returned retry interval has expired.
okay, so -EGAIN shall be returned only once from the firmware, right ?
Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
+ }
drivers/gpu/drm/xe/xe_pm.c +8
-0+ + if (ret) + return ret; + + ret = pci_acpi_add_perst_assertion_delay(root_pdev, perst_delay); + + return ret; +}Quoted 8 lines
drivers/gpu/drm/xe/xe_pm.c static bool xe_pm_vrsr_capable(struct xe_device *xe) · line 315
Quoted 6 lines
drivers/gpu/drm/xe/xe_pm.c +6
-0+ +static void xe_pm_vrsr_init (struct xe_device *xe) +{ + int ret; + + /* Check if platform support D3Cold VRSR */This can be rephrased to, "Check if Xe should support VRSR for the platform."
Quoted 2 lines
Here with
has_vrsrwe are checking if DGFX platform support VRSR or not. If supported, VRSR will be enabled in Xe kmd. I think let's keep the comment as it is.
"platform support" here is confusing, as there is another check below in xe_pm_vrsr_capable for actual platform support.
I think we may not need need has_vrsr at all !
xe_pm_vrsr_capable should suffice.
Quoted 31 lines
Quoted 7 lines
Quoted 6 lines
+ if (!xe->info.has_vrsr)
+ return;
+Can you add a comment here also, viz "Check if GPU firmware supports VRSR"
Sure, I will add.
Quoted 14 lines
Quoted 14 lines
+ 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;
+ }
+Quoted 8 lines
drivers/gpu/drm/xe/xe_pm.c static bool xe_pm_vrsr_capable(struct xe_device *xe) · line 337
Quoted 6 lines
+
xe->d3cold.vrsr_capable= true;
+drm_info(&xe->drm, "VRSR capable: Yes\n");drivers/gpu/drm/xe/xe_pm.c +4
-0+} + +/** +* xe_pm_vrsr_enable - Enable VRAM self refresh as this function does both enable & disable VRSR, this can be renamed to
xe_pm_set_vrsr(xe, flag)
Quoted 5 lines
IMO,
_vrsr_enable()is a more suitable name than_set_vrsr. Since the subsequent patches don't involve disabling VRSR, I can remove the flag and retain only the code for enabling it. Note that VRSR is internally disabled by pcode upon exiting D3Cold. Therefore, in subsequent patches, VRSR is re-enabled each time before entering D3Cold.Thanks,
Badal
No need to change the implementation, let the enable flag be there for future usage, just update description to
This function enables/disables the VRSR feature on the GPU.
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
+ * @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.
+ */drivers/gpu/drm/xe/xe_pm.c +13
-0+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);drivers/gpu/drm/xe/xe_pm.c +4
-0+ + return ret; +} +static void
xe_pm_runtime_init(struct xe_device *xe){
struct device *dev =xe->drm.dev;drivers/gpu/drm/xe/xe_pm.c +1
-1@@ -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);drivers/gpu/drm/xe/xe_pm.h +0
-0@@ -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
PATCH v4 7/11 drm/xe/vrsr: Enable VRSR on default VGA boot device
In reply to Badal NilawarThe 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
@@ -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
@@ -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) {return false; }#endif /* CONFIG_DRM_XE_DISPLAY */ #endif /* _XE_DISPLAY_H_ */
drivers/gpu/drm/xe/xe_pm.c +5 -0
@@ -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
Signature · 1 line
2.34.1
Jani Nikula
maintainerRe: [PATCH v4 07/11] drm/xe/vrsr: Enable VRSR on default VGA boot device
Quoted 32 lines · Badal Nilawar
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 <[email protected]>Signed-off-by Anshuman Gupta <[email protected]>--- 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 +12
-0@@ -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;
drivers/gpu/drm/xe/display/xe_display.c static void display_destroy(struct drm_device *dev, void *dummy) · line 112
Quoted 10 lines
drivers/gpu/drm/xe/display/xe_display.c +10
-0+break ; + } + } + +drm_connector_list_iter_end (&iter); +mutex_unlock (&xe->drm.mode_config.mutex); + +return ret; +} +
Xe display/ should contain the *minimal* glue to attach i915 display to it. It should *not* contain generic display stuff like this. At all.
The goal is for i915 display to become a dedicated kernel module. The above should not be part of xe.ko.
BR,
Jani.
Quoted 52 lines
drivers/gpu/drm/xe/display/xe_display.c +0
-0/** * xe_display_create - create display struct * @xe: XE device instance drivers/gpu/drm/xe/display/xe_display.h +2
-0@@ -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) {return false; }#endif /* CONFIG_DRM_XE_DISPLAY */ #endif /* _XE_DISPLAY_H_ */ drivers/gpu/drm/xe/xe_pm.c +5
-0@@ -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
Signature · 1 line
Jani Nikula, Intel
Re: [PATCH v4 07/11] drm/xe/vrsr: Enable VRSR on default VGA boot device
Quoted 46 lines · Jani Nikula
Quoted 32 lines · Badal Nilawar
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 <[email protected]>Signed-off-by Anshuman Gupta <[email protected]>--- 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 +12
-0@@ -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;drivers/gpu/drm/xe/display/xe_display.c static void display_destroy(struct drm_device *dev, void *dummy) · line 112
Quoted 10 lines
drivers/gpu/drm/xe/display/xe_display.c +10
-0+break ; + } + } + +drm_connector_list_iter_end (&iter); +mutex_unlock (&xe->drm.mode_config.mutex); + +return ret; +} +Xe display/ should contain the *minimal* glue to attach i915 display to it. It should *not* contain generic display stuff like this. At all.
Quoted 2 lines
The goal is for i915 display to become a dedicated kernel module. The above should not be part of xe.ko.
I will move this to i915/display/intel_display.c.
Thanks,
Badal
Quoted 56 lines
BR,
Jani.Quoted 52 lines
drivers/gpu/drm/xe/display/xe_display.c +0
-0/** * xe_display_create - create display struct * @xe: XE device instance drivers/gpu/drm/xe/display/xe_display.h +2
-0@@ -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) {return false; }#endif /* CONFIG_DRM_XE_DISPLAY */ #endif /* _XE_DISPLAY_H_ */ drivers/gpu/drm/xe/xe_pm.c +5
-0@@ -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
PATCH v4 8/11 drm/xe/vrsr: Refactor d3cold.allowed to a enum
In reply to Badal NilawarFrom: Anshuman Gupta <[email protected]>
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
@@ -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
@@ -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;
drivers/gpu/drm/xe/xe_pci.c +3 -3
@@ -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 ; }
drivers/gpu/drm/xe/xe_pm.c +8 -8
@@ -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); }
drivers/gpu/drm/xe/xe_pm.h +7 -1
@@ -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.34.1
Re: [v4,08/11] drm/xe/vrsr: Refactor d3cold.allowed to a enum
Quoted 185 lines · Badal Nilawar
From: Anshuman Gupta<[email protected]>
Add
xe_d3_stateenum to add support for VRAM Self Refresh d3cold state.Signed-off-by Anshuman Gupta<[email protected]>--- 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@@ -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@@ -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;drivers/gpu/drm/xe/xe_pci.c +3
-3@@ -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 ; }drivers/gpu/drm/xe/xe_pm.c +8
-8@@ -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); }drivers/gpu/drm/xe/xe_pm.h +6
-0@@ -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);
drivers/gpu/drm/xe/xe_pm.h void xe_pm_runtime_get_noresume(struct xe_device *xe); · line 42
Quoted 8 lines
drivers/gpu/drm/xe/xe_pm.h +1
-1@@ -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 );
LGTM.
PATCH v4 9/11 drm/xe/pm: D3Cold target state
In reply to Badal NilawarFrom: Anshuman Gupta <[email protected]>
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
@@ -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); }/**
Signature · 1 line
2.34.1
Re: [v4,09/11] drm/xe/pm: D3Cold target state
Quoted 5 lines · Badal Nilawar
From: Anshuman Gupta <[email protected]>
Trade-off D3Cold target state based upon current vram usage. If vram usage is greater than
vram_d3cold_thresholdand GPU is VRSR capable target D3Cold state is D3Cold-VRSR
rephrase above line to,
is VRSR capable, then target D3Cold state is D3Cold-VRSR
Quoted 40 lines
otherwise target state is D3Cold-Off.
Signed-off-by Anshuman Gupta <[email protected]>--- drivers/gpu/drm/xe/xe_pm.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)drivers/gpu/drm/xe/xe_pm.c +11
-0@@ -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)
drivers/gpu/drm/xe/xe_pm.c void xe_pm_d3cold_target_state_toggle(struct xe_device *xe) · line 971
Quoted 10 lines
drivers/gpu/drm/xe/xe_pm.c +3
-0+ 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); }/**
LGTM.
With minor commit message change above, this is
PATCH v4 10/11 drm/xe/vrsr: Enable VRSR
In reply to Badal NilawarFrom: Anshuman Gupta <[email protected]>
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 | 46 +++++++++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 14 deletions(-)
drivers/gpu/drm/xe/xe_pci.c +2 -2
@@ -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 );
drivers/gpu/drm/xe/xe_pm.c +34 -12
95 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [v4,10/11] drm/xe/vrsr: Enable VRSR
Quoted 3 lines · Badal Nilawar
From: Anshuman Gupta <[email protected]>
Enabling VRSR in runtime suspend and also in System wide suspend.
This can be rephrased to -
Integrate VRSR into both system-wide and runtime suspend-resume flows.
Quoted 130 lines
Also fix couple of typo in
xe_pm.c.Signed-off-by Anshuman Gupta <[email protected]>Signed-off-by Badal Nilawar <[email protected]>--- drivers/gpu/drm/xe/xe_pci.c | 4 ++-- drivers/gpu/drm/xe/xe_pm.c | 46 +++++++++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 14 deletions(-)drivers/gpu/drm/xe/xe_pci.c +2
-2@@ -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 );drivers/gpu/drm/xe/xe_pm.c +33
-11@@ -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.
drivers/gpu/drm/xe/xe_pm.c int xe_pm_runtime_resume(struct xe_device *xe) · line 714
Quoted 8 lines
drivers/gpu/drm/xe/xe_pm.c +1
-1@@ -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;
Please rephrase commit message. Other than that, code code flow looks fine.
Re: [v4,10/11] drm/xe/vrsr: Enable VRSR
Quoted 9 lines · Karthik
Quoted 3 lines · Badal Nilawar
From: Anshuman Gupta <[email protected]>
Enabling VRSR in runtime suspend and also in System wide suspend.
This can be rephrased to -
Integrate VRSR into both system-wide and runtime suspend-resume flows.
I will drop gerund. So it will be "Enable VRSR in runtime suspend and in System wide suspend".
Thanks,
Badal
Quoted 121 lines
Quoted 110 lines
Also fix couple of typo in
xe_pm.c.Signed-off-by Anshuman Gupta <[email protected]>Signed-off-by Badal Nilawar <[email protected]>---
drivers/gpu/drm/xe/xe_pci.c| 4 ++-- drivers/gpu/drm/xe/xe_pm.c | 46 +++++++++++++++++++++++++++----------2 files changed, 36 insertions(+), 14 deletions(-)drivers/gpu/drm/xe/xe_pci.c +1
-1@@ -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);drivers/gpu/drm/xe/xe_pm.c +0
-0@@ -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)
- gotoerr_pxp;
+ if (xe->d3cold.target_state==XE_D3COLD_OFF) { + /* FIXME: Super racey... */
+ err =xe_bo_evict_all(xe);
+ if (err)
+ gotoerr_pxp;
+ }
for_each_gt(gt, xe, id){
err =xe_gt_suspend(gt);drivers/gpu/drm/xe/xe_pm.c +5
-0@@ -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 @@ intxe_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 @@ intxe_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)
gotoout_resume;drivers/gpu/drm/xe/xe_pm.c +8
-0@@ -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. drivers/gpu/drm/xe/xe_pm.c int xe_pm_runtime_resume(struct xe_device *xe) · line 713
Quoted 6 lines
drivers/gpu/drm/xe/xe_pm.c +1
-0@@ -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;Please rephrase commit message. Other than that, code code flow looks fine.
Acked-by Karthik Poosa <[email protected]>
Re: [v4,10/11] drm/xe/vrsr: Enable VRSR
Quoted 6 lines · Badal
Quoted 4 lines · Karthik
Quoted 2 lines · Badal Nilawar
From: Anshuman Gupta <[email protected]>
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Enabling VRSR in runtime suspend and also in System wide suspend.
This can be rephrased to -
Integrate VRSR into both system-wide and runtime suspend-resume flows.
I will drop gerund. So it will be "Enable VRSR in runtime suspend and in System wide suspend".
Okay
Quoted 126 lines
Thanks,
BadalQuoted 122 lines
Quoted 111 lines
Also fix couple of typo in
xe_pm.c.Signed-off-by Anshuman Gupta <[email protected]>Signed-off-by Badal Nilawar <[email protected]>---
drivers/gpu/drm/xe/xe_pci.c| 4 ++--
drivers/gpu/drm/xe/xe_pm.c | 46
+++++++++++++++++++++++++++----------2 files changed, 36 insertions(+), 14 deletions(-)drivers/gpu/drm/xe/xe_pci.c +1
-1@@ -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);drivers/gpu/drm/xe/xe_pm.c +0
-0@@ -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)
- gotoerr_pxp;
+ if (xe->d3cold.target_state==XE_D3COLD_OFF) { + /* FIXME: Super racey... */
+ err =xe_bo_evict_all(xe);
+ if (err)
+ gotoerr_pxp;
+ }
for_each_gt(gt, xe, id){
err =xe_gt_suspend(gt);drivers/gpu/drm/xe/xe_pm.c +5
-0@@ -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 @@ intxe_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 @@ intxe_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)
gotoout_resume;drivers/gpu/drm/xe/xe_pm.c +8
-0@@ -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. drivers/gpu/drm/xe/xe_pm.c int xe_pm_runtime_resume(struct xe_device *xe) · line 713
Quoted 6 lines
drivers/gpu/drm/xe/xe_pm.c +1
-0@@ -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;Please rephrase commit message. Other than that, code code flow looks fine.
Acked-by Karthik Poosa <[email protected]>
PATCH v4 11/11 drm/xe/vrsr: Introduce a debugfs node named vrsr_capable
In reply to Badal NilawarAdd 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
@@ -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);
Signature · 1 line
2.34.1
Re: [v4,11/11] drm/xe/vrsr: Introduce a debugfs node named vrsr_capable
Quoted 37 lines · Badal Nilawar
Add a debugfs node named
vrsr_capableto check if the device supports VRSR.Signed-off-by Badal Nilawar<[email protected]>--- drivers/gpu/drm/xe/xe_debugfs.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/gpu/drm/xe/xe_debugfs.c +17
-0@@ -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;
drivers/gpu/drm/xe/xe_debugfs.c void xe_debugfs_register(struct xe_device *xe) · line 270
Quoted 5 lines
drivers/gpu/drm/xe/xe_debugfs.c +2
-0@@ -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);
Instead of debugfs_create_file, you can use debugfs_create_bool here, which will simplify the code.
Quoted 4 lines
drivers/gpu/drm/xe/xe_debugfs.c +1
-0+for (mem_type =XE_PL_VRAM0 ; mem_type <=XE_PL_VRAM1 ; ++mem_type) { man =ttm_manager_type (bdev, mem_type);
Patchwork
CI✗ CI.Patch_applied: failure for VRAM Self Refresh (rev4)
In reply to Badal Nilawar== Series Details ==
== Series Details ==
Series: VRAM Self Refresh (rev4)
URL : https://patchwork.freedesktop.org/series/145342/
State : failure
== Summary ==
=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: bf0749a9930e drm-tip: 2025y-05m-29d-05h-28m-18s UTC integration manifest === git am output follows ===
error: patch failed: drivers/gpu/drm/xe/display/xe_display.c:88
error: drivers/gpu/drm/xe/display/xe_display.c: patch does not apply
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Applying: PCI/ACPI: Add D3cold Aux Power Limit_DSM method
Applying: PCI/ACPI: Per root port allow one Aux power limit request
Applying: PCI/ACPI: Add PERST# Assertion Delay _DSM method
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
Patch failed at 0007 drm/xe/vrsr: Enable VRSR on default VGA boot device When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".