Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Vinay Belgaumkar <vinay.belgaumkar@intel.com>,
	Badal Nilawar <badal.nilawar@intel.com>,
	Rodrigo Viv <rodrigo.vivi@intel.com>
Subject: [PATCH 2/2] drm/xe: Poll GT for C6 before D3
Date: Tue,  8 Sep 2026 18:37:12 -0700	[thread overview]
Message-ID: <20260909013712.1962521-2-vinay.belgaumkar@intel.com> (raw)
In-Reply-To: <20260909013712.1962521-1-vinay.belgaumkar@intel.com>

Check if GTs are in C6 before transitioning to D3. PM subsystem can
retry if this is not the case. This ensures some component is not
accessing the GT when D3 state is forced.

Cc: Badal Nilawar <badal.nilawar@intel.com>
Cc: Rodrigo Viv <rodrigo.vivi@intel.com>
Signed-off-by: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
---
 drivers/gpu/drm/xe/xe_pci.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
index 187a39894513..62af84c041cf 100644
--- a/drivers/gpu/drm/xe/xe_pci.c
+++ b/drivers/gpu/drm/xe/xe_pci.c
@@ -7,6 +7,7 @@
 
 #include <kunit/static_stub.h>
 #include <linux/device/driver.h>
+#include <linux/iopoll.h>
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/pm_runtime.h>
@@ -1378,10 +1379,25 @@ static int xe_pci_resume(struct device *dev)
 	return 0;
 }
 
+static int wait_for_gt_c6_state(struct xe_gt *gt,
+				int timeout_ms)
+{
+	struct xe_guc_pc *pc = &gt->uc.guc.pc;
+	enum xe_gt_idle_state state;
+
+	return poll_timeout_us(state = gt->gtidle.idle_status(pc),
+			       state == GT_IDLE_C6,
+			       20,
+			       timeout_ms * USEC_PER_MSEC,
+			       false);
+}
+
 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);
+	struct xe_gt *gt;
+	u8 id;
 	int err;
 
 	/*
@@ -1397,6 +1413,14 @@ static int xe_pci_runtime_suspend(struct device *dev)
 	if (err)
 		return err;
 
+	/* Poll and retry if we don't enter C6 on any GT */
+	for_each_gt(gt, xe, id) {
+		if (wait_for_gt_c6_state(gt, 200)) {
+			xe_gt_info(gt, "GT is not in C6\n");
+			return -EAGAIN;
+		}
+	}
+
 	pci_save_state(pdev);
 
 	if (xe->d3cold.allowed) {
-- 
2.38.1


  reply	other threads:[~2026-09-09  1:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09  1:37 [PATCH 1/2] drm/xe: Inspect all forcewake bits for runtime idleness Vinay Belgaumkar
2026-09-09  1:37 ` Vinay Belgaumkar [this message]
2026-09-09  1:53   ` [PATCH 2/2] drm/xe: Poll GT for C6 before D3 sashiko-bot
2026-09-10  0:48     ` Belgaumkar, Vinay
2026-09-09  1:50 ` ✓ CI.KUnit: success for series starting with [1/2] drm/xe: Inspect all forcewake bits for runtime idleness Patchwork
2026-09-09  1:56 ` [PATCH 1/2] " sashiko-bot
2026-09-10  0:47   ` Belgaumkar, Vinay
2026-09-09  2:26 ` ✓ Xe.CI.BAT: success for series starting with [1/2] " Patchwork
2026-09-09 10:17 ` ✗ 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=20260909013712.1962521-2-vinay.belgaumkar@intel.com \
    --to=vinay.belgaumkar@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=rodrigo.vivi@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