]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/pm: Hold the validation lock around evicting user-space bos for suspend
authorThomas Hellström <thomas.hellstrom@linux.intel.com>
Thu, 18 Sep 2025 14:28:47 +0000 (16:28 +0200)
committerThomas Hellström <thomas.hellstrom@linux.intel.com>
Tue, 23 Sep 2025 12:42:57 +0000 (14:42 +0200)
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>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://lore.kernel.org/r/20250918142848.21807-2-thomas.hellstrom@linux.intel.com
drivers/gpu/drm/xe/xe_pm.c

index d6625c71115b1f99fbe75bda000ecd674a7fae42..1ec03ef19d9e8a8bb60ca7e6f68a8729623c4cb0 100644 (file)
@@ -329,9 +329,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);
 
@@ -344,6 +350,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);