Skip to content

Commit 067a974

Browse files
Tvrtko Ursulinlucasdemarchi
Tvrtko Ursulin
authored andcommitted
drm/xe: Add performance tunings to debugfs
Add a list of active tunings to debugfs, analogous to the existing list of workarounds. Rationale being that it seems to make sense to either have both or none. Signed-off-by: Tvrtko Ursulin <[email protected]> Cc: Lucas De Marchi <[email protected]> Cc: Matt Roper <[email protected]> Reviewed-by: Lucas De Marchi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Lucas De Marchi <[email protected]>
1 parent 4f12237 commit 067a974

File tree

5 files changed

+87
-0
lines changed

5 files changed

+87
-0
lines changed

drivers/gpu/drm/xe/xe_gt.c

+4
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,10 @@ int xe_gt_init_early(struct xe_gt *gt)
362362
if (err)
363363
return err;
364364

365+
err = xe_tuning_init(gt);
366+
if (err)
367+
return err;
368+
365369
xe_wa_process_oob(gt);
366370

367371
xe_force_wake_init_gt(gt, gt_to_fw(gt));

drivers/gpu/drm/xe/xe_gt_debugfs.c

+11
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "xe_reg_sr.h"
3131
#include "xe_reg_whitelist.h"
3232
#include "xe_sriov.h"
33+
#include "xe_tuning.h"
3334
#include "xe_uc_debugfs.h"
3435
#include "xe_wa.h"
3536

@@ -217,6 +218,15 @@ static int workarounds(struct xe_gt *gt, struct drm_printer *p)
217218
return 0;
218219
}
219220

221+
static int tunings(struct xe_gt *gt, struct drm_printer *p)
222+
{
223+
xe_pm_runtime_get(gt_to_xe(gt));
224+
xe_tuning_dump(gt, p);
225+
xe_pm_runtime_put(gt_to_xe(gt));
226+
227+
return 0;
228+
}
229+
220230
static int pat(struct xe_gt *gt, struct drm_printer *p)
221231
{
222232
xe_pm_runtime_get(gt_to_xe(gt));
@@ -300,6 +310,7 @@ static const struct drm_info_list debugfs_list[] = {
300310
{"powergate_info", .show = xe_gt_debugfs_simple_show, .data = powergate_info},
301311
{"register-save-restore", .show = xe_gt_debugfs_simple_show, .data = register_save_restore},
302312
{"workarounds", .show = xe_gt_debugfs_simple_show, .data = workarounds},
313+
{"tunings", .show = xe_gt_debugfs_simple_show, .data = tunings},
303314
{"pat", .show = xe_gt_debugfs_simple_show, .data = pat},
304315
{"mocs", .show = xe_gt_debugfs_simple_show, .data = mocs},
305316
{"default_lrc_rcs", .show = xe_gt_debugfs_simple_show, .data = rcs_default_lrc},

drivers/gpu/drm/xe/xe_gt_types.h

+10
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,16 @@ struct xe_gt {
413413
bool oob_initialized;
414414
} wa_active;
415415

416+
/** @tuning_active: keep track of active tunings */
417+
struct {
418+
/** @tuning_active.gt: bitmap with active GT tunings */
419+
unsigned long *gt;
420+
/** @tuning_active.engine: bitmap with active engine tunings */
421+
unsigned long *engine;
422+
/** @tuning_active.lrc: bitmap with active LRC tunings */
423+
unsigned long *lrc;
424+
} tuning_active;
425+
416426
/** @user_engines: engines present in GT and available to userspace */
417427
struct {
418428
/**

drivers/gpu/drm/xe/xe_tuning.c

+59
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#include <kunit/visibility.h>
99

10+
#include <drm/drm_managed.h>
11+
1012
#include "regs/xe_gt_regs.h"
1113
#include "xe_gt_types.h"
1214
#include "xe_platform_types.h"
@@ -140,10 +142,44 @@ static const struct xe_rtp_entry_sr lrc_tunings[] = {
140142
{}
141143
};
142144

145+
/**
146+
* xe_tuning_init - initialize gt with tunings bookkeeping
147+
* @gt: GT instance to initialize
148+
*
149+
* Returns 0 for success, negative error code otherwise.
150+
*/
151+
int xe_tuning_init(struct xe_gt *gt)
152+
{
153+
struct xe_device *xe = gt_to_xe(gt);
154+
size_t n_lrc, n_engine, n_gt, total;
155+
unsigned long *p;
156+
157+
n_gt = BITS_TO_LONGS(ARRAY_SIZE(gt_tunings));
158+
n_engine = BITS_TO_LONGS(ARRAY_SIZE(engine_tunings));
159+
n_lrc = BITS_TO_LONGS(ARRAY_SIZE(lrc_tunings));
160+
total = n_gt + n_engine + n_lrc;
161+
162+
p = drmm_kzalloc(&xe->drm, sizeof(*p) * total, GFP_KERNEL);
163+
if (!p)
164+
return -ENOMEM;
165+
166+
gt->tuning_active.gt = p;
167+
p += n_gt;
168+
gt->tuning_active.engine = p;
169+
p += n_engine;
170+
gt->tuning_active.lrc = p;
171+
172+
return 0;
173+
}
174+
ALLOW_ERROR_INJECTION(xe_tuning_init, ERRNO); /* See xe_pci_probe() */
175+
143176
void xe_tuning_process_gt(struct xe_gt *gt)
144177
{
145178
struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(gt);
146179

180+
xe_rtp_process_ctx_enable_active_tracking(&ctx,
181+
gt->tuning_active.gt,
182+
ARRAY_SIZE(gt_tunings));
147183
xe_rtp_process_to_sr(&ctx, gt_tunings, &gt->reg_sr);
148184
}
149185
EXPORT_SYMBOL_IF_KUNIT(xe_tuning_process_gt);
@@ -152,6 +188,9 @@ void xe_tuning_process_engine(struct xe_hw_engine *hwe)
152188
{
153189
struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(hwe);
154190

191+
xe_rtp_process_ctx_enable_active_tracking(&ctx,
192+
hwe->gt->tuning_active.engine,
193+
ARRAY_SIZE(engine_tunings));
155194
xe_rtp_process_to_sr(&ctx, engine_tunings, &hwe->reg_sr);
156195
}
157196
EXPORT_SYMBOL_IF_KUNIT(xe_tuning_process_engine);
@@ -168,5 +207,25 @@ void xe_tuning_process_lrc(struct xe_hw_engine *hwe)
168207
{
169208
struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(hwe);
170209

210+
xe_rtp_process_ctx_enable_active_tracking(&ctx,
211+
hwe->gt->tuning_active.lrc,
212+
ARRAY_SIZE(lrc_tunings));
171213
xe_rtp_process_to_sr(&ctx, lrc_tunings, &hwe->reg_lrc);
172214
}
215+
216+
void xe_tuning_dump(struct xe_gt *gt, struct drm_printer *p)
217+
{
218+
size_t idx;
219+
220+
drm_printf(p, "GT Tunings\n");
221+
for_each_set_bit(idx, gt->tuning_active.gt, ARRAY_SIZE(gt_tunings))
222+
drm_printf_indent(p, 1, "%s\n", gt_tunings[idx].name);
223+
224+
drm_printf(p, "\nEngine Tunings\n");
225+
for_each_set_bit(idx, gt->tuning_active.engine, ARRAY_SIZE(engine_tunings))
226+
drm_printf_indent(p, 1, "%s\n", engine_tunings[idx].name);
227+
228+
drm_printf(p, "\nLRC Tunings\n");
229+
for_each_set_bit(idx, gt->tuning_active.lrc, ARRAY_SIZE(lrc_tunings))
230+
drm_printf_indent(p, 1, "%s\n", lrc_tunings[idx].name);
231+
}

drivers/gpu/drm/xe/xe_tuning.h

+3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
#ifndef _XE_TUNING_
77
#define _XE_TUNING_
88

9+
struct drm_printer;
910
struct xe_gt;
1011
struct xe_hw_engine;
1112

13+
int xe_tuning_init(struct xe_gt *gt);
1214
void xe_tuning_process_gt(struct xe_gt *gt);
1315
void xe_tuning_process_engine(struct xe_hw_engine *hwe);
1416
void xe_tuning_process_lrc(struct xe_hw_engine *hwe);
17+
void xe_tuning_dump(struct xe_gt *gt, struct drm_printer *p);
1518

1619
#endif

0 commit comments

Comments
 (0)