public inbox for intel-xe@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Badal Nilawar <badal.nilawar@intel.com>
To: intel-xe@lists.freedesktop.org, linux-acpi@vger.kernel.org,
	linux-pci@vger.kernel.org
Cc: anshuman.gupta@intel.com, rafael@kernel.org, lenb@kernel.org,
	bhelgaas@google.com, ilpo.jarvinen@linux.intel.com,
	rodrigo.vivi@intel.com, varun.gupta@intel.com,
	ville.syrjala@linux.intel.com, uma.shankar@intel.com,
	karthik.poosa@intel.com, matthew.auld@intel.com,
	sk.anirban@intel.com, raag.jadav@intel.com
Subject: [PATCH v6 09/12] drm/xe/pm: Refactor PM Sleep Ops
Date: Tue, 13 Jan 2026 22:12:10 +0530	[thread overview]
Message-ID: <20260113164200.1151788-23-badal.nilawar@intel.com> (raw)
In-Reply-To: <20260113164200.1151788-14-badal.nilawar@intel.com>

Refactor PM Sleep OPS to indicate xe_pm_suspend/resume is called
during hibernation (S4) or suspend (S3/S2idle).

Signed-off-by: Badal Nilawar <badal.nilawar@intel.com>
---
 drivers/gpu/drm/xe/xe_pci.c | 64 +++++++++++++++++++++++++++++++++++--
 drivers/gpu/drm/xe/xe_pm.c  | 10 +++---
 drivers/gpu/drm/xe/xe_pm.h  |  4 +--
 3 files changed, 69 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
index e1de6b337f1f..f1ec6aa26faa 100644
--- a/drivers/gpu/drm/xe/xe_pci.c
+++ b/drivers/gpu/drm/xe/xe_pci.c
@@ -1135,7 +1135,7 @@ static int xe_pci_suspend(struct device *dev)
 	if (xe_survivability_mode_is_boot_enabled(xe))
 		return -EBUSY;
 
-	err = xe_pm_suspend(xe);
+	err = xe_pm_suspend(xe, false);
 	if (err)
 		return err;
 
@@ -1173,13 +1173,66 @@ static int xe_pci_resume(struct device *dev)
 
 	pci_set_master(pdev);
 
-	err = xe_pm_resume(pdev_to_xe_device(pdev));
+	err = xe_pm_resume(pdev_to_xe_device(pdev), false);
 	if (err)
 		return err;
 
 	return 0;
 }
 
+static int xe_pci_freeze(struct device *dev)
+{
+	struct pci_dev *pdev = to_pci_dev(dev);
+	struct xe_device *xe = pdev_to_xe_device(pdev);
+	int err;
+
+	if (xe_survivability_mode_is_boot_enabled(xe))
+		return -EBUSY;
+
+	err = xe_pm_suspend(xe, true);
+	if (err)
+		return err;
+
+	/*
+	 * Enabling D3Cold is needed for S2Idle/S0ix.
+	 * It is save to allow here since xe_pm_suspend has evicted
+	 * the local memory and the direct complete optimization is disabled.
+	 */
+	d3cold_toggle(pdev, D3COLD_ENABLE);
+
+	pci_save_state(pdev);
+	pci_disable_device(pdev);
+	pci_set_power_state(pdev, PCI_D3cold);
+
+	return 0;
+}
+
+static int xe_pci_thaw(struct device *dev)
+{
+	struct pci_dev *pdev = to_pci_dev(dev);
+	int err;
+
+	/* Give back the D3Cold decision to the runtime P M*/
+	d3cold_toggle(pdev, D3COLD_DISABLE);
+
+	err = pci_set_power_state(pdev, PCI_D0);
+	if (err)
+		return err;
+
+	pci_restore_state(pdev);
+
+	err = pci_enable_device(pdev);
+	if (err)
+		return err;
+
+	pci_set_master(pdev);
+
+	err = xe_pm_resume(pdev_to_xe_device(pdev), true);
+	if (err)
+		return err;
+
+	return 0;
+}
 static int xe_pci_runtime_suspend(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
@@ -1248,7 +1301,12 @@ static int xe_pci_runtime_idle(struct device *dev)
 }
 
 static const struct dev_pm_ops xe_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(xe_pci_suspend, xe_pci_resume)
+	.suspend = xe_pci_suspend,
+	.resume = xe_pci_resume,
+	.freeze = xe_pci_freeze,
+	.thaw = xe_pci_thaw,
+	.poweroff = xe_pci_freeze,
+	.restore = xe_pci_thaw,
 	SET_RUNTIME_PM_OPS(xe_pci_runtime_suspend, xe_pci_runtime_resume, xe_pci_runtime_idle)
 };
 #endif
diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
index 1a1edbfcf240..2cbcb9de7586 100644
--- a/drivers/gpu/drm/xe/xe_pm.c
+++ b/drivers/gpu/drm/xe/xe_pm.c
@@ -178,16 +178,17 @@ static void xe_pm_suspend_prepare(struct xe_device *xe)
 /**
  * xe_pm_suspend - Helper for System suspend, i.e. S0->S3 / S0->S2idle
  * @xe: xe device instance
+ * @hibernation: whether the suspend is for hibernation
  *
  * Return: 0 on success
  */
-int xe_pm_suspend(struct xe_device *xe)
+int xe_pm_suspend(struct xe_device *xe, bool hibernation)
 {
 	struct xe_gt *gt;
 	u8 id;
 	int err;
 
-	drm_dbg(&xe->drm, "Suspending device\n");
+	drm_dbg(&xe->drm, "Suspending device for %s\n", hibernation ? "hibernation" : "S3/S2idle");
 	xe_pm_block_begin_signalling();
 	trace_xe_pm_suspend(xe, __builtin_return_address(0));
 
@@ -238,10 +239,11 @@ int xe_pm_suspend(struct xe_device *xe)
 /**
  * xe_pm_resume - Helper for System resume S3->S0 / S2idle->S0
  * @xe: xe device instance
+ * @hibernation: whether the resume is from hibernation
  *
  * Return: 0 on success
  */
-int xe_pm_resume(struct xe_device *xe)
+int xe_pm_resume(struct xe_device *xe, bool hibernation)
 {
 	struct xe_tile *tile;
 	struct xe_gt *gt;
@@ -249,7 +251,7 @@ int xe_pm_resume(struct xe_device *xe)
 	int err;
 
 	xe_pm_block_begin_signalling();
-	drm_dbg(&xe->drm, "Resuming device\n");
+	drm_dbg(&xe->drm, "Resuming device from %s\n", hibernation ? "hibernation" : "S3/S2idle");
 	trace_xe_pm_resume(xe, __builtin_return_address(0));
 
 	for_each_gt(gt, xe, id)
diff --git a/drivers/gpu/drm/xe/xe_pm.h b/drivers/gpu/drm/xe/xe_pm.h
index cd7b4a9b2c05..973475f2f7dd 100644
--- a/drivers/gpu/drm/xe/xe_pm.h
+++ b/drivers/gpu/drm/xe/xe_pm.h
@@ -19,8 +19,8 @@ enum xe_d3_state {
 	XE_D3COLD_OFF,
 };
 
-int xe_pm_suspend(struct xe_device *xe);
-int xe_pm_resume(struct xe_device *xe);
+int xe_pm_suspend(struct xe_device *xe, bool hibernation);
+int xe_pm_resume(struct xe_device *xe, bool hibernation);
 
 int xe_pm_init_early(struct xe_device *xe);
 int xe_pm_init(struct xe_device *xe);
-- 
2.52.0


  parent reply	other threads:[~2026-01-13 16:32 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-13 16:42 [PATCH v6 00/12] VRAM Self Refresh Badal Nilawar
2026-01-13 16:40 ` ✓ CI.KUnit: success for VRAM Self Refresh (rev6) Patchwork
2026-01-13 16:42 ` [PATCH v6 01/12] PCI/ACPI: Add D3cold Aux Power Limit_DSM method Badal Nilawar
2026-01-14 20:24   ` Bjorn Helgaas
2026-01-20 14:03     ` Nilawar, Badal
2026-01-22 20:53       ` Bjorn Helgaas
2026-01-13 16:42 ` [PATCH v6 02/12] PCI/ACPI: Add PERST# Assertion Delay _DSM method Badal Nilawar
2026-01-13 17:04   ` Manivannan Sadhasivam
2026-01-14 13:47     ` Nilawar, Badal
2026-01-14 19:55   ` Bjorn Helgaas
2026-01-14 20:19     ` Bjorn Helgaas
2026-01-20 15:59     ` Nilawar, Badal
2026-01-22 23:27       ` Bjorn Helgaas
2026-01-13 16:42 ` [PATCH v6 03/12] drm/xe/vrsr: Introduce flag has_vrsr Badal Nilawar
2026-01-13 16:42 ` [PATCH v6 04/12] drm/xe/vrsr: Detect VRSR Capability Badal Nilawar
2026-01-13 16:42 ` [PATCH v6 05/12] drm/xe/vrsr: Initialize VRSR feature Badal Nilawar
2026-01-13 16:42 ` [PATCH v6 06/12] drm/xe/vrsr: Enable VRSR on default VGA boot device Badal Nilawar
2026-01-15 14:25   ` Jani Nikula
2026-01-15 15:25     ` Rodrigo Vivi
2026-01-20 13:28       ` Nilawar, Badal
2026-01-20 13:43         ` Jani Nikula
2026-01-20 14:42           ` Shankar, Uma
2026-01-20 15:37             ` Nilawar, Badal
2026-01-20 15:07         ` Vivi, Rodrigo
2026-01-13 16:42 ` [PATCH v6 07/12] drm/xe/vrsr: Refactor d3cold.allowed to a enum Badal Nilawar
2026-01-13 16:42 ` [PATCH v6 08/12] drm/xe/pm: D3cold target state Badal Nilawar
2026-01-13 16:42 ` Badal Nilawar [this message]
2026-01-14 18:00   ` [PATCH v6 09/12] drm/xe/pm: Refactor PM Sleep Ops Bjorn Helgaas
2026-01-20 14:05     ` Nilawar, Badal
2026-01-13 16:42 ` [PATCH v6 10/12] drm/xe/vrsr: Enable VRSR Badal Nilawar
2026-01-14 18:02   ` Bjorn Helgaas
2026-01-13 16:42 ` [PATCH v6 11/12] drm/xe/pm/s2idle: Don't evict user BOs D3cold-VRSR state Badal Nilawar
2026-01-13 16:42 ` [PATCH v6 12/12] drm/xe/vrsr: Introduce a debugfs node named vrsr_capable Badal Nilawar
2026-01-13 16:55 ` ✗ CI.checksparse: warning for VRAM Self Refresh (rev6) Patchwork
2026-01-14  2:41 ` ✗ Xe.CI.Full: failure " Patchwork
2026-01-14  5:57 ` ✓ CI.KUnit: success for VRAM Self Refresh (rev7) Patchwork
2026-01-14  6:13 ` ✗ CI.checksparse: warning " Patchwork
2026-01-14  6:31 ` ✓ Xe.CI.BAT: success " Patchwork
2026-01-14 13:55 ` ✗ Xe.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=20260113164200.1151788-23-badal.nilawar@intel.com \
    --to=badal.nilawar@intel.com \
    --cc=anshuman.gupta@intel.com \
    --cc=bhelgaas@google.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=karthik.poosa@intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=matthew.auld@intel.com \
    --cc=raag.jadav@intel.com \
    --cc=rafael@kernel.org \
    --cc=rodrigo.vivi@intel.com \
    --cc=sk.anirban@intel.com \
    --cc=uma.shankar@intel.com \
    --cc=varun.gupta@intel.com \
    --cc=ville.syrjala@linux.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