]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/xe/lrc: Refactor out engine id to hwe conversion
authorUmesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Thu, 7 May 2026 16:20:24 +0000 (09:20 -0700)
committerUmesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Fri, 8 May 2026 20:48:46 +0000 (13:48 -0700)
We need to define more helpers that read engine ID specific register, so
move that logic outside of get_ctx_timestamp().

Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Reviewed-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Link: https://patch.msgid.link/20260507162016.3888309-20-umesh.nerlige.ramappa@intel.com
drivers/gpu/drm/xe/xe_lrc.c

index 0dc50627e1b7393cce7ae7c0cc55f1d638dec61c..0fe9738cb360ece6448b1a4d3d3f26e3eeb892a2 100644 (file)
@@ -2617,17 +2617,27 @@ void xe_lrc_snapshot_free(struct xe_lrc_snapshot *snapshot)
        kfree(snapshot);
 }
 
-static int get_ctx_timestamp(struct xe_lrc *lrc, u32 engine_id, u64 *reg_ctx_ts)
+static struct xe_hw_engine *engine_id_to_hwe(struct xe_gt *gt, u32 engine_id)
 {
        u16 class = REG_FIELD_GET(ENGINE_CLASS_ID, engine_id);
        u16 instance = REG_FIELD_GET(ENGINE_INSTANCE_ID, engine_id);
+       struct xe_hw_engine *hwe = xe_gt_hw_engine(gt, class, instance, false);
+
+       if (xe_gt_WARN_ONCE(gt, !hwe || xe_hw_engine_is_reserved(hwe),
+                           "Unexpected engine class:instance %d:%d for utilization\n",
+                           class, instance))
+               return NULL;
+
+       return hwe;
+}
+
+static int get_ctx_timestamp(struct xe_lrc *lrc, u32 engine_id, u64 *reg_ctx_ts)
+{
        struct xe_hw_engine *hwe;
        u64 val;
 
-       hwe = xe_gt_hw_engine(lrc->gt, class, instance, false);
-       if (xe_gt_WARN_ONCE(lrc->gt, !hwe || xe_hw_engine_is_reserved(hwe),
-                           "Unexpected engine class:instance %d:%d for context utilization\n",
-                           class, instance))
+       hwe = engine_id_to_hwe(lrc->gt, engine_id);
+       if (!hwe)
                return -1;
 
        if (lrc_to_xe(lrc)->info.has_64bit_timestamp)