Skip to content

Commit e9088ac

Browse files
committed
Merge tag 'drm-intel-fixes-2024-12-18' of https://gitlab.freedesktop.org/drm/i915/kernel into drm-fixes
- Reset engine utilization buffer before registration (Umesh Nerlige Ramappa) - Ensure busyness counter increases motonically (Umesh Nerlige Ramappa) - Accumulate active runtime on gt reset (Umesh Nerlige Ramappa) Signed-off-by: Dave Airlie <[email protected]> From: Tvrtko Ursulin <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/Z2LppUZudGKXwWjW@linux
2 parents 78d4f34 + 1622ed2 commit e9088ac

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

drivers/gpu/drm/i915/gt/intel_engine_types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,11 @@ struct intel_engine_guc_stats {
343343
* @start_gt_clk: GT clock time of last idle to active transition.
344344
*/
345345
u64 start_gt_clk;
346+
347+
/**
348+
* @total: The last value of total returned
349+
*/
350+
u64 total;
346351
};
347352

348353
union intel_engine_tlb_inv_reg {

drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,21 @@ static void __get_engine_usage_record(struct intel_engine_cs *engine,
12431243
} while (++i < 6);
12441244
}
12451245

1246+
static void __set_engine_usage_record(struct intel_engine_cs *engine,
1247+
u32 last_in, u32 id, u32 total)
1248+
{
1249+
struct iosys_map rec_map = intel_guc_engine_usage_record_map(engine);
1250+
1251+
#define record_write(map_, field_, val_) \
1252+
iosys_map_wr_field(map_, 0, struct guc_engine_usage_record, field_, val_)
1253+
1254+
record_write(&rec_map, last_switch_in_stamp, last_in);
1255+
record_write(&rec_map, current_context_index, id);
1256+
record_write(&rec_map, total_runtime, total);
1257+
1258+
#undef record_write
1259+
}
1260+
12461261
static void guc_update_engine_gt_clks(struct intel_engine_cs *engine)
12471262
{
12481263
struct intel_engine_guc_stats *stats = &engine->stats.guc;
@@ -1363,9 +1378,12 @@ static ktime_t guc_engine_busyness(struct intel_engine_cs *engine, ktime_t *now)
13631378
total += intel_gt_clock_interval_to_ns(gt, clk);
13641379
}
13651380

1381+
if (total > stats->total)
1382+
stats->total = total;
1383+
13661384
spin_unlock_irqrestore(&guc->timestamp.lock, flags);
13671385

1368-
return ns_to_ktime(total);
1386+
return ns_to_ktime(stats->total);
13691387
}
13701388

13711389
static void guc_enable_busyness_worker(struct intel_guc *guc)
@@ -1431,8 +1449,21 @@ static void __reset_guc_busyness_stats(struct intel_guc *guc)
14311449

14321450
guc_update_pm_timestamp(guc, &unused);
14331451
for_each_engine(engine, gt, id) {
1452+
struct intel_engine_guc_stats *stats = &engine->stats.guc;
1453+
14341454
guc_update_engine_gt_clks(engine);
1435-
engine->stats.guc.prev_total = 0;
1455+
1456+
/*
1457+
* If resetting a running context, accumulate the active
1458+
* time as well since there will be no context switch.
1459+
*/
1460+
if (stats->running) {
1461+
u64 clk = guc->timestamp.gt_stamp - stats->start_gt_clk;
1462+
1463+
stats->total_gt_clks += clk;
1464+
}
1465+
stats->prev_total = 0;
1466+
stats->running = 0;
14361467
}
14371468

14381469
spin_unlock_irqrestore(&guc->timestamp.lock, flags);
@@ -1543,13 +1574,19 @@ static void guc_timestamp_ping(struct work_struct *wrk)
15431574

15441575
static int guc_action_enable_usage_stats(struct intel_guc *guc)
15451576
{
1577+
struct intel_gt *gt = guc_to_gt(guc);
1578+
struct intel_engine_cs *engine;
1579+
enum intel_engine_id id;
15461580
u32 offset = intel_guc_engine_usage_offset(guc);
15471581
u32 action[] = {
15481582
INTEL_GUC_ACTION_SET_ENG_UTIL_BUFF,
15491583
offset,
15501584
0,
15511585
};
15521586

1587+
for_each_engine(engine, gt, id)
1588+
__set_engine_usage_record(engine, 0, 0xffffffff, 0);
1589+
15531590
return intel_guc_send(guc, action, ARRAY_SIZE(action));
15541591
}
15551592

0 commit comments

Comments
 (0)