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)