Introduce the helper to check if the device can signal a wakeup event
while runtime suspended. This can avoid scheduling the HPD polling.

Assisted-by: GitHub_Copilot:claude-opus-5
Signed-off-by: Vinod Govindapillai <[email protected]>
---
 drivers/gpu/drm/xe/xe_pm.c | 21 +++++++++++++++++++++
 drivers/gpu/drm/xe/xe_pm.h |  1 +
 2 files changed, 22 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
index a5289a9df8d2..635bfb1c7f78 100644
--- a/drivers/gpu/drm/xe/xe_pm.c
+++ b/drivers/gpu/drm/xe/xe_pm.c
@@ -937,6 +937,27 @@ bool xe_pm_runtime_resume_and_get(struct xe_device *xe)
        return pm_runtime_resume_and_get(xe->drm.dev) >= 0;
 }
 
+/**
+ * xe_pm_pme_supported - Can the device signal PME from its suspend target 
state?
+ * @xe: xe device instance
+ *
+ * Determine whether the device can generate a Power Management Event while
+ * runtime suspended.
+ *
+ * Return: true if PME is supported from the target state, false otherwise.
+ */
+bool xe_pm_pme_supported(struct xe_device *xe)
+{
+       struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
+
+       /*
+        * pci_dev_run_wake() checks dev->pme_support, verifies
+        * pci_pme_capable() against the state pci_target_state() picks, and
+        * walks upstream to confirm the wake can actually be routed.
+        */
+       return pci_dev_run_wake(pdev);
+}
+
 /**
  * xe_pm_assert_unbounded_bridge - Disable PM on unbounded pcie parent bridge
  * @xe: xe device instance
diff --git a/drivers/gpu/drm/xe/xe_pm.h b/drivers/gpu/drm/xe/xe_pm.h
index 6d5ab09cb769..16b8699e59ec 100644
--- a/drivers/gpu/drm/xe/xe_pm.h
+++ b/drivers/gpu/drm/xe/xe_pm.h
@@ -30,6 +30,7 @@ bool xe_pm_runtime_get_if_active(struct xe_device *xe);
 bool xe_pm_runtime_get_if_in_use(struct xe_device *xe);
 void xe_pm_runtime_get_noresume(struct xe_device *xe);
 bool xe_pm_runtime_resume_and_get(struct xe_device *xe);
+bool xe_pm_pme_supported(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);
-- 
2.43.0

Reply via email to