]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
i915/guc: Reset engine utilization buffer before registration
authorUmesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Wed, 27 Nov 2024 17:40:04 +0000 (09:40 -0800)
committerUmesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Fri, 13 Dec 2024 23:13:49 +0000 (15:13 -0800)
On GT reset, we store total busyness counts for all engines and
re-register the utilization buffer with GuC. At that time we should
reset the buffer, so that we don't get spurious busyness counts on
subsequent queries.

To repro this issue, run igt@perf_pmu@busy-hang followed by
igt@perf_pmu@most-busy-idle-check-all for a couple iterations.

Fixes: 77cdd054dd2c ("drm/i915/pmu: Connect engine busyness stats from GuC to pmu")
Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Reviewed-by: John Harrison <John.C.Harrison@Intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241127174006.190128-2-umesh.nerlige.ramappa@intel.com
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c

index 6a3d550f6ed1589f483920102f74bb1adc0ef97d..795058bb714118a833c20184abd5a7bce519d31f 100644 (file)
@@ -1243,6 +1243,21 @@ static void __get_engine_usage_record(struct intel_engine_cs *engine,
        } while (++i < 6);
 }
 
+static void __set_engine_usage_record(struct intel_engine_cs *engine,
+                                     u32 last_in, u32 id, u32 total)
+{
+       struct iosys_map rec_map = intel_guc_engine_usage_record_map(engine);
+
+#define record_write(map_, field_, val_) \
+       iosys_map_wr_field(map_, 0, struct guc_engine_usage_record, field_, val_)
+
+       record_write(&rec_map, last_switch_in_stamp, last_in);
+       record_write(&rec_map, current_context_index, id);
+       record_write(&rec_map, total_runtime, total);
+
+#undef record_write
+}
+
 static void guc_update_engine_gt_clks(struct intel_engine_cs *engine)
 {
        struct intel_engine_guc_stats *stats = &engine->stats.guc;
@@ -1543,6 +1558,9 @@ err_trylock:
 
 static int guc_action_enable_usage_stats(struct intel_guc *guc)
 {
+       struct intel_gt *gt = guc_to_gt(guc);
+       struct intel_engine_cs *engine;
+       enum intel_engine_id id;
        u32 offset = intel_guc_engine_usage_offset(guc);
        u32 action[] = {
                INTEL_GUC_ACTION_SET_ENG_UTIL_BUFF,
@@ -1550,6 +1568,9 @@ static int guc_action_enable_usage_stats(struct intel_guc *guc)
                0,
        };
 
+       for_each_engine(engine, gt, id)
+               __set_engine_usage_record(engine, 0, 0xffffffff, 0);
+
        return intel_guc_send(guc, action, ARRAY_SIZE(action));
 }