All of 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,
	pranay.samala@intel.com
Subject: [PATCH 3/4] drm/xe/pm: allow the device to signal PME from D3hot
Date: Thu, 27 Aug 2026 01:53:36 +0300	[thread overview]
Message-ID: <20260826225338.804902-4-vinod.govindapillai@intel.com> (raw)
In-Reply-To: <20260826225338.804902-1-vinod.govindapillai@intel.com>

Make the device a usable wakeup source so it can raise PME while runtime
suspended to D3hot The PCI core marks endpoints wakeup-capable but leaves
them disabled, so pci_enable_wake() returns -EINVAL until the driver opts
in using devm_device_init_wakeup(). D3cold is excluded, as the device
loses power there and cannot signal at all.

Assisted-by: GitHub_Copilot:claude-opus-5
Signed-off-by: Vinod Govindapillai <vinod.govindapillai@intel.com>
---
 drivers/gpu/drm/xe/xe_pci.c | 22 ++++++++++++++++++++--
 drivers/gpu/drm/xe/xe_pm.c  | 25 +++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_pm.h  |  1 +
 3 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
index c22b40045f7b..42c933390d0d 100644
--- a/drivers/gpu/drm/xe/xe_pci.c
+++ b/drivers/gpu/drm/xe/xe_pci.c
@@ -1217,6 +1217,10 @@ static int __xe_pci_probe(struct pci_dev *pdev, const struct xe_device_desc *des
 
 	pci_set_master(pdev);
 
+	err = devm_device_init_wakeup(&pdev->dev);
+	if (err)
+		return err;
+
 	err = xe_probe_info_early(xe, desc, &probed_info);
 	if (err)
 		return err;
@@ -1381,6 +1385,7 @@ static int xe_pci_runtime_suspend(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct xe_device *xe = pdev_to_xe_device(pdev);
+	bool pme_armed = false;
 	int err;
 
 	/*
@@ -1392,9 +1397,20 @@ static int xe_pci_runtime_suspend(struct device *dev)
 	xe_assert(xe, !IS_SRIOV_VF(xe));
 	xe_assert(xe, !pci_num_vf(pdev));
 
-	err = xe_pm_runtime_suspend(xe, false);
-	if (err)
+	if (xe_pm_pme_capable(xe)) {
+		pme_armed = !pci_enable_wake(pdev, PCI_D3hot, true);
+		if (!pme_armed)
+			drm_warn(&xe->drm,
+				 "Failed to arm PME for D3hot: %d\n", err);
+	}
+
+	err = xe_pm_runtime_suspend(xe, pme_armed);
+	if (err) {
+		if (pme_armed)
+			pci_enable_wake(pdev, PCI_D3hot, false);
+
 		return err;
+	}
 
 	pci_save_state(pdev);
 
@@ -1421,6 +1437,8 @@ static int xe_pci_runtime_resume(struct device *dev)
 	if (err)
 		return err;
 
+	pci_enable_wake(pdev, PCI_D3hot, false);
+
 	pci_restore_state(pdev);
 
 	if (xe->d3cold.allowed) {
diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
index c3a53c5f8b33..e488bfa086ea 100644
--- a/drivers/gpu/drm/xe/xe_pm.c
+++ b/drivers/gpu/drm/xe/xe_pm.c
@@ -555,6 +555,31 @@ struct task_struct *xe_pm_read_callback_task(struct xe_device *xe)
 	return READ_ONCE(xe->pm_callback_task);
 }
 
+/**
+ * xe_pm_pme_capable - Can the device raise PME from runtime D3hot?
+ * @xe: xe device instance
+ *
+ * Only meaningful on the D3hot runtime suspend path: on D3cold the device
+ * loses power and cannot signal a hotplug. Honours the user-visible
+ * power/wakeup policy via device_may_wakeup(), so a user who disables
+ * wakeup falls back to the normal reset-and-poll behaviour rather than
+ * losing both mechanisms.
+ *
+ * Return: true if PME can be armed for D3hot.
+ */
+bool xe_pm_pme_capable(struct xe_device *xe)
+{
+	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
+
+	if (xe->d3cold.allowed)
+		return false;
+
+	if (!pci_pme_capable(pdev, PCI_D3hot))
+		return false;
+
+	return device_may_wakeup(&pdev->dev);
+}
+
 /**
  * xe_pm_runtime_suspended - Check if runtime_pm state is suspended
  * @xe: xe device instance
diff --git a/drivers/gpu/drm/xe/xe_pm.h b/drivers/gpu/drm/xe/xe_pm.h
index 27455a8d2061..876afd5bebc6 100644
--- a/drivers/gpu/drm/xe/xe_pm.h
+++ b/drivers/gpu/drm/xe/xe_pm.h
@@ -23,6 +23,7 @@ void xe_pm_fini(struct xe_device *xe);
 bool xe_pm_runtime_suspended(struct xe_device *xe);
 int xe_pm_runtime_suspend(struct xe_device *xe, bool pme_capable);
 int xe_pm_runtime_resume(struct xe_device *xe);
+bool xe_pm_pme_capable(struct xe_device *xe);
 void xe_pm_runtime_get(struct xe_device *xe);
 int xe_pm_runtime_get_ioctl(struct xe_device *xe);
 void xe_pm_runtime_put(struct xe_device *xe);
-- 
2.43.0


  parent reply	other threads:[~2026-08-26 22:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26 22:53 [PATCH 0/4] PM_PME support on display hotplug Vinod Govindapillai
2026-08-26 22:53 ` [PATCH 1/4] drm/i915/hpd: plumb keep_hpd through irq reset Vinod Govindapillai
2026-08-26 23:08   ` sashiko-bot
2026-08-26 22:53 ` [PATCH 2/4] drm/xe/pm: plumb PME capability to runtime suspend handler Vinod Govindapillai
2026-08-26 23:04   ` sashiko-bot
2026-08-26 22:53 ` Vinod Govindapillai [this message]
2026-08-26 23:01   ` [PATCH 3/4] drm/xe/pm: allow the device to signal PME from D3hot sashiko-bot
2026-09-02  6:10     ` Govindapillai, Vinod
2026-08-26 22:53 ` [PATCH 4/4] drm/i915/display: Avoid HPD polling if the device is PME capable Vinod Govindapillai
2026-08-26 23:02 ` ✓ CI.KUnit: success for pm_pme support on display hotplug (rev2) Patchwork
2026-08-26 23:38 ` ✓ Xe.CI.BAT: " Patchwork
2026-08-27  0:08 ` ✓ i915.CI.BAT: " Patchwork
2026-08-27  2:02 ` ✓ Xe.CI.FULL: " Patchwork
2026-08-27  7:29 ` ✗ i915.CI.Full: failure " 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=20260826225338.804902-4-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=pranay.samala@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.