Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: intel-xe@lists.freedesktop.org
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Matthew Auld" <matthew.auld@intel.com>
Subject: [PATCH 1/2] drm/xe/pm: Hold the validation lock around evicting user-space bos for suspend
Date: Thu, 18 Sep 2025 16:28:47 +0200	[thread overview]
Message-ID: <20250918142848.21807-2-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20250918142848.21807-1-thomas.hellstrom@linux.intel.com>

During pm notifier eviction we may still race with validations.
Ensure those are blocked out during eviction to ensure we have
access to as much system memory as possible.

During the suspend operation itself, we run single-threaded so that
shouldn't be a problem.

Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
 drivers/gpu/drm/xe/xe_pm.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
index 211935590e21..b1c536b39034 100644
--- a/drivers/gpu/drm/xe/xe_pm.c
+++ b/drivers/gpu/drm/xe/xe_pm.c
@@ -320,9 +320,15 @@ static int xe_pm_notifier_callback(struct notifier_block *nb,
 	switch (action) {
 	case PM_HIBERNATION_PREPARE:
 	case PM_SUSPEND_PREPARE:
+	{
+		struct xe_validation_ctx ctx;
+
 		reinit_completion(&xe->pm_block);
 		xe_pm_runtime_get(xe);
+		(void)xe_validation_ctx_init(&ctx, &xe->val, NULL,
+					     (struct xe_val_flags) {.exclusive = true});
 		err = xe_bo_evict_all_user(xe);
+		xe_validation_ctx_fini(&ctx);
 		if (err)
 			drm_dbg(&xe->drm, "Notifier evict user failed (%d)\n", err);
 
@@ -335,6 +341,7 @@ static int xe_pm_notifier_callback(struct notifier_block *nb,
 		 * allocations.
 		 */
 		break;
+	}
 	case PM_POST_HIBERNATION:
 	case PM_POST_SUSPEND:
 		complete_all(&xe->pm_block);
-- 
2.51.0


  reply	other threads:[~2025-09-18 14:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-18 14:28 [PATCH 0/2] Suspend improvements Thomas Hellström
2025-09-18 14:28 ` Thomas Hellström [this message]
2025-09-19 10:13   ` [PATCH 1/2] drm/xe/pm: Hold the validation lock around evicting user-space bos for suspend Matthew Auld
2025-09-18 14:28 ` [PATCH 2/2] drm/xe/pm: Add lockdep annotation for the pm_block completion Thomas Hellström
2025-09-19 11:00   ` Matthew Auld
2025-09-19 11:04     ` Thomas Hellström
2025-09-18 16:03 ` ✓ CI.KUnit: success for Suspend improvements Patchwork
2025-09-18 16:42 ` ✓ Xe.CI.BAT: " Patchwork
2025-09-19  1:17 ` ✗ Xe.CI.Full: failure " Patchwork
2025-09-23 12:37   ` Thomas Hellström

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=20250918142848.21807-2-thomas.hellstrom@linux.intel.com \
    --to=thomas.hellstrom@linux.intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --cc=matthew.brost@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