drm/xe/tests: Use scope-based runtime PM
authorMatt Roper <matthew.d.roper@intel.com>
Tue, 18 Nov 2025 16:44:04 +0000 (08:44 -0800)
committerMatt Roper <matthew.d.roper@intel.com>
Wed, 19 Nov 2025 19:58:58 +0000 (11:58 -0800)
Use scope-based handling of runtime PM in the kunit tests for
consistency with other parts of the driver.

Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com>
Link: https://patch.msgid.link/20251118164338.3572146-54-matthew.d.roper@intel.com
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
drivers/gpu/drm/xe/tests/xe_bo.c
drivers/gpu/drm/xe/tests/xe_dma_buf.c
drivers/gpu/drm/xe/tests/xe_migrate.c
drivers/gpu/drm/xe/tests/xe_mocs.c

index 2294cf8..2278e58 100644 (file)
@@ -185,8 +185,7 @@ static int ccs_test_run_device(struct xe_device *xe)
                return 0;
        }
 
-       xe_pm_runtime_get(xe);
-
+       guard(xe_pm_runtime)(xe);
        for_each_tile(tile, xe, id) {
                /* For igfx run only for primary tile */
                if (!IS_DGFX(xe) && id > 0)
@@ -194,8 +193,6 @@ static int ccs_test_run_device(struct xe_device *xe)
                ccs_test_run_tile(xe, tile, test);
        }
 
-       xe_pm_runtime_put(xe);
-
        return 0;
 }
 
@@ -356,13 +353,10 @@ static int evict_test_run_device(struct xe_device *xe)
                return 0;
        }
 
-       xe_pm_runtime_get(xe);
-
+       guard(xe_pm_runtime)(xe);
        for_each_tile(tile, xe, id)
                evict_test_run_tile(xe, tile, test);
 
-       xe_pm_runtime_put(xe);
-
        return 0;
 }
 
index 5df98de..954b6b9 100644 (file)
@@ -266,7 +266,7 @@ static int dma_buf_run_device(struct xe_device *xe)
        const struct dma_buf_test_params *params;
        struct kunit *test = kunit_get_current_test();
 
-       xe_pm_runtime_get(xe);
+       guard(xe_pm_runtime)(xe);
        for (params = test_params; params->mem_mask; ++params) {
                struct dma_buf_test_params p = *params;
 
@@ -274,7 +274,6 @@ static int dma_buf_run_device(struct xe_device *xe)
                test->priv = &p;
                xe_test_dmabuf_import_same_driver(xe);
        }
-       xe_pm_runtime_put(xe);
 
        /* A non-zero return would halt iteration over driver devices */
        return 0;
index 5904d65..34e2f0f 100644 (file)
@@ -344,8 +344,7 @@ static int migrate_test_run_device(struct xe_device *xe)
        struct xe_tile *tile;
        int id;
 
-       xe_pm_runtime_get(xe);
-
+       guard(xe_pm_runtime)(xe);
        for_each_tile(tile, xe, id) {
                struct xe_migrate *m = tile->migrate;
                struct drm_exec *exec = XE_VALIDATION_OPT_OUT;
@@ -356,8 +355,6 @@ static int migrate_test_run_device(struct xe_device *xe)
                xe_vm_unlock(m->q->vm);
        }
 
-       xe_pm_runtime_put(xe);
-
        return 0;
 }
 
@@ -759,13 +756,10 @@ static int validate_ccs_test_run_device(struct xe_device *xe)
                return 0;
        }
 
-       xe_pm_runtime_get(xe);
-
+       guard(xe_pm_runtime)(xe);
        for_each_tile(tile, xe, id)
                validate_ccs_test_run_tile(xe, tile, test);
 
-       xe_pm_runtime_put(xe);
-
        return 0;
 }
 
index 2837433..daf3c68 100644 (file)
@@ -115,8 +115,7 @@ static int mocs_kernel_test_run_device(struct xe_device *xe)
        unsigned int flags;
        int id;
 
-       xe_pm_runtime_get(xe);
-
+       guard(xe_pm_runtime)(xe);
        for_each_gt(gt, xe, id) {
                flags = live_mocs_init(&mocs, gt);
                if (flags & HAS_GLOBAL_MOCS)
@@ -125,8 +124,6 @@ static int mocs_kernel_test_run_device(struct xe_device *xe)
                        read_l3cc_table(gt, &mocs.table);
        }
 
-       xe_pm_runtime_put(xe);
-
        return 0;
 }
 
@@ -150,8 +147,7 @@ static int mocs_reset_test_run_device(struct xe_device *xe)
        int id;
        struct kunit *test = kunit_get_current_test();
 
-       xe_pm_runtime_get(xe);
-
+       guard(xe_pm_runtime)(xe);
        for_each_gt(gt, xe, id) {
                flags = live_mocs_init(&mocs, gt);
                kunit_info(test, "mocs_reset_test before reset\n");
@@ -169,8 +165,6 @@ static int mocs_reset_test_run_device(struct xe_device *xe)
                        read_l3cc_table(gt, &mocs.table);
        }
 
-       xe_pm_runtime_put(xe);
-
        return 0;
 }