Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Vinod Govindapillai <vinod.govindapillai@intel.com>
To: intel-xe@lists.freedesktop.org, intel-gfx@lists.freedesktop.org
Cc: vinod.govindapillai@intel.com, imre.deak@intel.com,
	jouni.hogander@intel.com
Subject: [PATCH v5 02/10] drm/xe/pm: introduce PM PME support
Date: Fri, 11 Sep 2026 11:04:40 +0300	[thread overview]
Message-ID: <20260911080448.778316-3-vinod.govindapillai@intel.com> (raw)
In-Reply-To: <20260911080448.778316-1-vinod.govindapillai@intel.com>

Introduce PME support for PME capable devices. Whether device is
PME capable is assessed during PCI probe routine. And the whether
PME is enabled for a specific context is assessed during the PM
runtime suspend call if the device is PME capable.

If the PME is enabled, HPDs can generate PME which in turn call
the runtime resume call and do the wakeup routines. Till now
the driver was relying on HPD polling to wakeup in case of any
HPDs. HPD polling can be avoided in platforms with PME support
and instead rely on this PCI PME for HPD induced wakeup.

Bspec: 52979, 52980, 68857, 68867, 68970
Assisted-by: GitHub_Copilot:claude-opus-5
Signed-off-by: Vinod Govindapillai <vinod.govindapillai@intel.com>
---
 drivers/gpu/drm/xe/xe_device_types.h | 13 +++++++++++++
 drivers/gpu/drm/xe/xe_pci.c          | 13 ++++++++++++-
 drivers/gpu/drm/xe/xe_pm.c           | 13 +++++++++++++
 3 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
index f88bacf63c83..37190473f6db 100644
--- a/drivers/gpu/drm/xe/xe_device_types.h
+++ b/drivers/gpu/drm/xe/xe_device_types.h
@@ -454,6 +454,19 @@ struct xe_device {
 		struct mutex lock;
 	} d3cold;
 
+	/** @pme: Encapsulate pme related stuff */
+	struct {
+		/** @pme.capable: Indicates if device is PME capable */
+		bool capable;
+
+		/** @pme.enabled:
+		 *
+		 * Indicates if PME is enabled - depends on user controllable
+		 * sysfs interface as well
+		 */
+		bool enabled;
+	} pme;
+
 	/** @pm_notifier: Our PM notifier to perform actions in response to various PM events. */
 	struct notifier_block pm_notifier;
 	/** @pm_block: Completion to block validating tasks on suspend / hibernate prepare */
diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
index f8e16aefd2f8..5cb9c140461b 100644
--- a/drivers/gpu/drm/xe/xe_pci.c
+++ b/drivers/gpu/drm/xe/xe_pci.c
@@ -1387,6 +1387,9 @@ static int xe_pci_runtime_suspend(struct device *dev)
 	struct xe_device *xe = pdev_to_xe_device(pdev);
 	int err;
 
+	xe->pme.enabled = xe->pme.capable && !xe->d3cold.allowed &&
+			  pci_enable_wake(pdev, PCI_D3hot, true) == 0;
+
 	/*
 	 * We hold an additional reference to the runtime PM to keep PF in D0
 	 * during VFs lifetime, as our VFs do not implement the PM capability.
@@ -1397,8 +1400,14 @@ static int xe_pci_runtime_suspend(struct device *dev)
 	xe_assert(xe, !pci_num_vf(pdev));
 
 	err = xe_pm_runtime_suspend(xe);
-	if (err)
+	if (err) {
+		if (xe->pme.enabled) {
+			pci_enable_wake(pdev, PCI_D3hot, false);
+			xe->pme.enabled = false;
+		}
+
 		return err;
+	}
 
 	pci_save_state(pdev);
 
@@ -1427,6 +1436,8 @@ static int xe_pci_runtime_resume(struct device *dev)
 
 	pci_restore_state(pdev);
 
+	xe->pme.enabled = false;
+
 	if (xe->d3cold.allowed) {
 		err = pci_enable_device(pdev);
 		if (err)
diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
index f517bf453b54..c79f55b66a41 100644
--- a/drivers/gpu/drm/xe/xe_pm.c
+++ b/drivers/gpu/drm/xe/xe_pm.c
@@ -78,6 +78,8 @@
  * management (RPS).
  */
 
+#define HAS_PM_PME_SUPPORT(xe) (GRAPHICS_VERx100(xe) >= 3500)
+
 #ifdef CONFIG_LOCKDEP
 static struct lockdep_map xe_pm_runtime_d3cold_map = {
 	.name = "xe_rpm_d3cold_map"
@@ -384,6 +386,14 @@ int xe_pm_init_early(struct xe_device *xe)
 }
 ALLOW_ERROR_INJECTION(xe_pm_init_early, ERRNO); /* See xe_pci_probe() */
 
+static bool xe_pm_pci_pme_capable(struct xe_device *xe)
+{
+	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
+
+	return HAS_PM_PME_SUPPORT(xe) ?
+		pci_pme_capable(pdev, PCI_D3hot) : false;
+}
+
 /**
  * xe_pm_probe() - Initialize Xe Power Management
  * @xe: the &xe_device instance
@@ -397,6 +407,9 @@ int xe_pm_probe(struct xe_device *xe)
 	xe->d3cold.capable = xe_pm_pci_d3cold_capable(xe);
 	xe_dbg(xe, "d3cold: capable=%s\n", str_yes_no(xe->d3cold.capable));
 
+	xe->pme.capable = xe_pm_pci_pme_capable(xe);
+	xe_dbg(xe, "pme: capable=%s\n", str_yes_no(xe->pme.capable));
+
 	return 0;
 }
 
-- 
2.43.0


  parent reply	other threads:[~2026-09-11  8:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11  8:04 [PATCH v5 00/10] pm_pme support on display hotplug Vinod Govindapillai
2026-09-11  8:04 ` [PATCH v5 01/10] drm/xe/pm: initialize the device's system wakeup capabilities Vinod Govindapillai
2026-09-11  8:04 ` Vinod Govindapillai [this message]
2026-09-11  8:04 ` [PATCH v5 03/10] drm/xe/pm: avoid reclaim when arming PME wakeup Vinod Govindapillai
2026-09-11  8:22   ` sashiko-bot
2026-09-11  8:04 ` [PATCH v5 04/10] drm/i915: add pme_enabled() to the parent interface Vinod Govindapillai
2026-09-11  8:04 ` [PATCH v5 05/10] drm/i915/xe: plug the pme_enabed implementation for xe Vinod Govindapillai
2026-09-11  8:04 ` [PATCH v5 06/10] drm/i915/hotplug: add helpers to track HPDs can generate PME Vinod Govindapillai
2026-09-11 13:00   ` Jani Nikula
2026-09-11 15:36     ` Govindapillai, Vinod
2026-09-11  8:04 ` [PATCH v5 07/10] drm/i915: plug the pm runtime handlers with PME HPD handling Vinod Govindapillai
2026-09-11  8:04 ` [PATCH v5 08/10] drm/xe/pm: clear PME HPD flag on runtime suspend error handler Vinod Govindapillai
2026-09-11  8:20   ` sashiko-bot
2026-09-11  8:04 ` [PATCH v5 09/10] drm/i915/irq: conditional HPD IRQ resets based on PME capability Vinod Govindapillai
2026-09-11  8:27   ` sashiko-bot
2026-09-11  8:04 ` [PATCH v5 10/10] drm/i915/hotplug: avoid HPD polling if the device is PME capable Vinod Govindapillai
2026-09-11  8:34   ` sashiko-bot
2026-09-11  8:17 ` ✓ CI.KUnit: success for pm_pme support on display hotplug (rev5) Patchwork
2026-09-11  9:06 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-11 15:39 ` ✓ Xe.CI.FULL: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260911080448.778316-3-vinod.govindapillai@intel.com \
    --to=vinod.govindapillai@intel.com \
    --cc=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jouni.hogander@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox