Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Auld <matthew.auld@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Matthew Brost" <matthew.brost@intel.com>
Subject: [PATCH 1/2] drm/xe/shrinker: use async RPM get
Date: Fri, 25 Sep 2026 12:55:22 +0100	[thread overview]
Message-ID: <20260925115521.1018940-3-matthew.auld@intel.com> (raw)

Use pm_runtime_get() with RPM_ASYNC to queue a resume request. This
eliminates the custom worker, letting the runtime PM core do this for
us. This also allows holding an RPM ref for the queued request, which
will be useful later. Note that the put() does NOT cancel the request,
the queued resume request still takes priority.

Shouldn't be any functional change.

Assisted-by: LLM
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
---
 drivers/gpu/drm/xe/xe_pm.c       | 12 ++++++++++++
 drivers/gpu/drm/xe/xe_pm.h       |  1 +
 drivers/gpu/drm/xe/xe_shrinker.c | 19 +++----------------
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
index daa7ba2df317..223821dfdc02 100644
--- a/drivers/gpu/drm/xe/xe_pm.c
+++ b/drivers/gpu/drm/xe/xe_pm.c
@@ -824,6 +824,18 @@ void xe_pm_runtime_get(struct xe_device *xe)
 	pm_runtime_resume(xe->drm.dev);
 }
 
+/**
+ * xe_pm_runtime_get_async - Get a runtime_pm reference and queue up a resume
+ * @xe: xe device instance
+ *
+ * Grabs a runtime PM reference and requests an asynchronous resume without
+ * blocking. Safe to call from contexts such as reclaim.
+ */
+void xe_pm_runtime_get_async(struct xe_device *xe)
+{
+	pm_runtime_get(xe->drm.dev);
+}
+
 /**
  * xe_pm_runtime_put - Put the runtime_pm reference back and mark as idle
  * @xe: xe device instance
diff --git a/drivers/gpu/drm/xe/xe_pm.h b/drivers/gpu/drm/xe/xe_pm.h
index 16d4e6c629f1..1aca527580fc 100644
--- a/drivers/gpu/drm/xe/xe_pm.h
+++ b/drivers/gpu/drm/xe/xe_pm.h
@@ -24,6 +24,7 @@ bool xe_pm_runtime_suspended(struct xe_device *xe);
 int xe_pm_runtime_suspend(struct xe_device *xe);
 int xe_pm_runtime_resume(struct xe_device *xe);
 void xe_pm_runtime_get(struct xe_device *xe);
+void xe_pm_runtime_get_async(struct xe_device *xe);
 int xe_pm_runtime_get_ioctl(struct xe_device *xe);
 void xe_pm_runtime_put(struct xe_device *xe);
 bool xe_pm_runtime_get_if_active(struct xe_device *xe);
diff --git a/drivers/gpu/drm/xe/xe_shrinker.c b/drivers/gpu/drm/xe/xe_shrinker.c
index deb4378c1ec1..518f77acf1dd 100644
--- a/drivers/gpu/drm/xe/xe_shrinker.c
+++ b/drivers/gpu/drm/xe/xe_shrinker.c
@@ -21,7 +21,6 @@
  * @shrinkable_pages: Number of pages that are currently shrinkable.
  * @purgeable_pages: Number of pages that are currently purgeable.
  * @shrink: Pointer to the mm shrinker.
- * @pm_worker: Worker to wake up the device if required.
  */
 struct xe_shrinker {
 	struct xe_device *xe;
@@ -29,7 +28,6 @@ struct xe_shrinker {
 	long shrinkable_pages;
 	long purgeable_pages;
 	struct shrinker *shrink;
-	struct work_struct pm_worker;
 };
 
 static struct xe_shrinker *to_xe_shrinker(struct shrinker *shrink)
@@ -66,7 +64,8 @@ static bool __xe_shrinker_runtime_pm_get(struct xe_shrinker *shrinker)
 		return true;
 	}
 
-	queue_work(xe->unordered_wq, &shrinker->pm_worker);
+	xe_pm_runtime_get_async(xe);
+	xe_pm_runtime_put(xe);
 
 	return false;
 }
@@ -193,7 +192,7 @@ xe_shrinker_count(struct shrinker *shrink, struct shrink_control *sc)
 
 /*
  * Check if we need runtime pm, and if so try to grab a reference if
- * already active. If grabbing a reference fails, queue a worker that
+ * already active. If sync RPM get fails, queue an async RPM get that
  * does it for us outside of reclaim, but don't wait for it to complete.
  * If bo shrinking needs an rpm reference and we don't have it (yet),
  * that bo will be skipped anyway.
@@ -267,16 +266,6 @@ static unsigned long xe_shrinker_scan(struct shrinker *shrink, struct shrink_con
 	return nr_scanned ? freed : SHRINK_STOP;
 }
 
-/* Wake up the device for shrinking. */
-static void xe_shrinker_pm(struct work_struct *work)
-{
-	struct xe_shrinker *shrinker =
-		container_of(work, typeof(*shrinker), pm_worker);
-
-	xe_pm_runtime_get(shrinker->xe);
-	xe_pm_runtime_put(shrinker->xe);
-}
-
 static void xe_shrinker_fini(struct drm_device *drm, void *arg)
 {
 	struct xe_shrinker *shrinker = arg;
@@ -284,7 +273,6 @@ static void xe_shrinker_fini(struct drm_device *drm, void *arg)
 	xe_assert(shrinker->xe, !shrinker->shrinkable_pages);
 	xe_assert(shrinker->xe, !shrinker->purgeable_pages);
 	shrinker_free(shrinker->shrink);
-	flush_work(&shrinker->pm_worker);
 	kfree(shrinker);
 }
 
@@ -307,7 +295,6 @@ int xe_shrinker_create(struct xe_device *xe)
 		return -ENOMEM;
 	}
 
-	INIT_WORK(&shrinker->pm_worker, xe_shrinker_pm);
 	shrinker->xe = xe;
 	rwlock_init(&shrinker->lock);
 	shrinker->shrink->count_objects = xe_shrinker_count;
-- 
2.55.0


             reply	other threads:[~2026-09-25 11:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25 11:55 Matthew Auld [this message]
2026-09-25 11:55 ` [PATCH 2/2] drm/xe/shrinker: hold a stable RPM ref across scan Matthew Auld
2026-09-26 16:56   ` Karl Mehltretter
2026-09-28 11:37     ` Matthew Auld
2026-09-25 12:02 ` [PATCH 1/2] drm/xe/shrinker: use async RPM get sashiko-bot
2026-09-25 12:03 ` ✓ CI.KUnit: success for series starting with [1/2] " Patchwork
2026-09-25 13:43 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-25 21:07 ` ✗ 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=20260925115521.1018940-3-matthew.auld@intel.com \
    --to=matthew.auld@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.brost@intel.com \
    --cc=thomas.hellstrom@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