Skip to content

Commit cedf238

Browse files
committed
drm/xe/rtp: Drop sentinels from arg to xe_rtp_process_to_sr()
There's a mismatch on API: while xe_rtp_process_to_sr() processes entries until an entry without name, the active tracking with xe_rtp_process_ctx_enable_active_tracking() needs to use the number of elements. The number of elements is taken everywhere using ARRAY_SIZE(), but that will have one entry too many. This leads to the following warning, as reported by lkp: drivers/gpu/drm/xe/xe_tuning.c: In function 'xe_tuning_dump': >> include/drm/drm_print.h:228:31: warning: '%s' directive argument is null [-Wformat-overflow=] 228 | drm_printf((printer), "%.*s" fmt, (indent), "\t\t\t\t\tX", ##__VA_ARGS__) | ^~~~~~ drivers/gpu/drm/xe/xe_tuning.c:226:17: note: in expansion of macro 'drm_printf_indent' 226 | drm_printf_indent(p, 1, "%s\n", engine_tunings[idx].name); | ^~~~~~~~~~~~~~~~~ That's because it will still process the last entry when tracking the active tunings. The same issue exists in the WAs. Change xe_rtp_process_to_sr() to also take the number of elements so the empty entry can be removed and the warning should go away. Fixing on the active-tracking side would more fragile as the it would need a `- 1` everywhere and continue to use a different approach for number of elements. Aside from the warning, it's a non-issue as there would always be enough bits allocated and the last entry would never be active since xe_rtp_process_to_sr() stops on the sentinel. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202503021906.P2MwAvyK-lkp@intel.com/ Cc: Tvrtko Ursulin <tvrtko.ursulin@igalia.com> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250306-fix-print-warning-v1-1-979c3dc03c0d@intel.com Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> (cherry picked from commit 8aa8c2d) Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
1 parent fd6c10e commit cedf238

File tree

7 files changed

+18
-26
lines changed

7 files changed

+18
-26
lines changed

drivers/gpu/drm/xe/tests/xe_rtp_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ static void xe_rtp_process_to_sr_tests(struct kunit *test)
320320
count_rtp_entries++;
321321

322322
xe_rtp_process_ctx_enable_active_tracking(&ctx, &active, count_rtp_entries);
323-
xe_rtp_process_to_sr(&ctx, param->entries, reg_sr);
323+
xe_rtp_process_to_sr(&ctx, param->entries, count_rtp_entries, reg_sr);
324324

325325
xa_for_each(&reg_sr->xa, idx, sre) {
326326
if (idx == param->expected_reg.addr)

drivers/gpu/drm/xe/xe_hw_engine.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,9 @@ xe_hw_engine_setup_default_lrc_state(struct xe_hw_engine *hwe)
400400
PREEMPT_GPGPU_THREAD_GROUP_LEVEL)),
401401
XE_RTP_ENTRY_FLAG(FOREACH_ENGINE)
402402
},
403-
{}
404403
};
405404

406-
xe_rtp_process_to_sr(&ctx, lrc_setup, &hwe->reg_lrc);
405+
xe_rtp_process_to_sr(&ctx, lrc_setup, ARRAY_SIZE(lrc_setup), &hwe->reg_lrc);
407406
}
408407

409408
static void
@@ -459,10 +458,9 @@ hw_engine_setup_default_state(struct xe_hw_engine *hwe)
459458
XE_RTP_ACTIONS(SET(CSFE_CHICKEN1(0), CS_PRIORITY_MEM_READ,
460459
XE_RTP_ACTION_FLAG(ENGINE_BASE)))
461460
},
462-
{}
463461
};
464462

465-
xe_rtp_process_to_sr(&ctx, engine_entries, &hwe->reg_sr);
463+
xe_rtp_process_to_sr(&ctx, engine_entries, ARRAY_SIZE(engine_entries), &hwe->reg_sr);
466464
}
467465

468466
static const struct engine_info *find_engine_info(enum xe_engine_class class, int instance)

drivers/gpu/drm/xe/xe_reg_whitelist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ static const struct xe_rtp_entry_sr register_whitelist[] = {
8888
RING_FORCE_TO_NONPRIV_ACCESS_RD |
8989
RING_FORCE_TO_NONPRIV_RANGE_4))
9090
},
91-
{}
9291
};
9392

9493
static void whitelist_apply_to_hwe(struct xe_hw_engine *hwe)
@@ -137,7 +136,8 @@ void xe_reg_whitelist_process_engine(struct xe_hw_engine *hwe)
137136
{
138137
struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(hwe);
139138

140-
xe_rtp_process_to_sr(&ctx, register_whitelist, &hwe->reg_whitelist);
139+
xe_rtp_process_to_sr(&ctx, register_whitelist, ARRAY_SIZE(register_whitelist),
140+
&hwe->reg_whitelist);
141141
whitelist_apply_to_hwe(hwe);
142142
}
143143

drivers/gpu/drm/xe/xe_rtp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ static void rtp_mark_active(struct xe_device *xe,
237237
* the save-restore argument.
238238
* @ctx: The context for processing the table, with one of device, gt or hwe
239239
* @entries: Table with RTP definitions
240+
* @n_entries: Number of entries to process, usually ARRAY_SIZE(entries)
240241
* @sr: Save-restore struct where matching rules execute the action. This can be
241242
* viewed as the "coalesced view" of multiple the tables. The bits for each
242243
* register set are expected not to collide with previously added entries
@@ -247,6 +248,7 @@ static void rtp_mark_active(struct xe_device *xe,
247248
*/
248249
void xe_rtp_process_to_sr(struct xe_rtp_process_ctx *ctx,
249250
const struct xe_rtp_entry_sr *entries,
251+
size_t n_entries,
250252
struct xe_reg_sr *sr)
251253
{
252254
const struct xe_rtp_entry_sr *entry;
@@ -259,7 +261,9 @@ void xe_rtp_process_to_sr(struct xe_rtp_process_ctx *ctx,
259261
if (IS_SRIOV_VF(xe))
260262
return;
261263

262-
for (entry = entries; entry && entry->name; entry++) {
264+
xe_assert(xe, entries);
265+
266+
for (entry = entries; entry - entries < n_entries; entry++) {
263267
bool match = false;
264268

265269
if (entry->flags & XE_RTP_ENTRY_FLAG_FOREACH_ENGINE) {

drivers/gpu/drm/xe/xe_rtp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ void xe_rtp_process_ctx_enable_active_tracking(struct xe_rtp_process_ctx *ctx,
430430

431431
void xe_rtp_process_to_sr(struct xe_rtp_process_ctx *ctx,
432432
const struct xe_rtp_entry_sr *entries,
433-
struct xe_reg_sr *sr);
433+
size_t n_entries, struct xe_reg_sr *sr);
434434

435435
void xe_rtp_process(struct xe_rtp_process_ctx *ctx,
436436
const struct xe_rtp_entry *entries);

drivers/gpu/drm/xe/xe_tuning.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ static const struct xe_rtp_entry_sr gt_tunings[] = {
8585
XE_RTP_RULES(MEDIA_VERSION(2000)),
8686
XE_RTP_ACTIONS(SET(XE2LPM_SCRATCH3_LBCF, RWFLUSHALLEN))
8787
},
88-
89-
{}
9088
};
9189

9290
static const struct xe_rtp_entry_sr engine_tunings[] = {
@@ -100,7 +98,6 @@ static const struct xe_rtp_entry_sr engine_tunings[] = {
10098
ENGINE_CLASS(RENDER)),
10199
XE_RTP_ACTIONS(SET(SAMPLER_MODE, INDIRECT_STATE_BASE_ADDR_OVERRIDE))
102100
},
103-
{}
104101
};
105102

106103
static const struct xe_rtp_entry_sr lrc_tunings[] = {
@@ -138,8 +135,6 @@ static const struct xe_rtp_entry_sr lrc_tunings[] = {
138135
XE_RTP_ACTIONS(FIELD_SET(FF_MODE, VS_HIT_MAX_VALUE_MASK,
139136
REG_FIELD_PREP(VS_HIT_MAX_VALUE_MASK, 0x3f)))
140137
},
141-
142-
{}
143138
};
144139

145140
/**
@@ -180,7 +175,7 @@ void xe_tuning_process_gt(struct xe_gt *gt)
180175
xe_rtp_process_ctx_enable_active_tracking(&ctx,
181176
gt->tuning_active.gt,
182177
ARRAY_SIZE(gt_tunings));
183-
xe_rtp_process_to_sr(&ctx, gt_tunings, &gt->reg_sr);
178+
xe_rtp_process_to_sr(&ctx, gt_tunings, ARRAY_SIZE(gt_tunings), &gt->reg_sr);
184179
}
185180
EXPORT_SYMBOL_IF_KUNIT(xe_tuning_process_gt);
186181

@@ -191,7 +186,8 @@ void xe_tuning_process_engine(struct xe_hw_engine *hwe)
191186
xe_rtp_process_ctx_enable_active_tracking(&ctx,
192187
hwe->gt->tuning_active.engine,
193188
ARRAY_SIZE(engine_tunings));
194-
xe_rtp_process_to_sr(&ctx, engine_tunings, &hwe->reg_sr);
189+
xe_rtp_process_to_sr(&ctx, engine_tunings, ARRAY_SIZE(engine_tunings),
190+
&hwe->reg_sr);
195191
}
196192
EXPORT_SYMBOL_IF_KUNIT(xe_tuning_process_engine);
197193

@@ -210,7 +206,7 @@ void xe_tuning_process_lrc(struct xe_hw_engine *hwe)
210206
xe_rtp_process_ctx_enable_active_tracking(&ctx,
211207
hwe->gt->tuning_active.lrc,
212208
ARRAY_SIZE(lrc_tunings));
213-
xe_rtp_process_to_sr(&ctx, lrc_tunings, &hwe->reg_lrc);
209+
xe_rtp_process_to_sr(&ctx, lrc_tunings, ARRAY_SIZE(lrc_tunings), &hwe->reg_lrc);
214210
}
215211

216212
void xe_tuning_dump(struct xe_gt *gt, struct drm_printer *p)

drivers/gpu/drm/xe/xe_wa.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,6 @@ static const struct xe_rtp_entry_sr gt_was[] = {
279279
XE_RTP_ACTIONS(SET(VDBOX_CGCTL3F10(0), RAMDFTUNIT_CLKGATE_DIS)),
280280
XE_RTP_ENTRY_FLAG(FOREACH_ENGINE),
281281
},
282-
283-
{}
284282
};
285283

286284
static const struct xe_rtp_entry_sr engine_was[] = {
@@ -624,8 +622,6 @@ static const struct xe_rtp_entry_sr engine_was[] = {
624622
FUNC(xe_rtp_match_first_render_or_compute)),
625623
XE_RTP_ACTIONS(SET(TDL_TSL_CHICKEN, RES_CHK_SPR_DIS))
626624
},
627-
628-
{}
629625
};
630626

631627
static const struct xe_rtp_entry_sr lrc_was[] = {
@@ -825,8 +821,6 @@ static const struct xe_rtp_entry_sr lrc_was[] = {
825821
DIS_PARTIAL_AUTOSTRIP |
826822
DIS_AUTOSTRIP))
827823
},
828-
829-
{}
830824
};
831825

832826
static __maybe_unused const struct xe_rtp_entry oob_was[] = {
@@ -868,7 +862,7 @@ void xe_wa_process_gt(struct xe_gt *gt)
868862

869863
xe_rtp_process_ctx_enable_active_tracking(&ctx, gt->wa_active.gt,
870864
ARRAY_SIZE(gt_was));
871-
xe_rtp_process_to_sr(&ctx, gt_was, &gt->reg_sr);
865+
xe_rtp_process_to_sr(&ctx, gt_was, ARRAY_SIZE(gt_was), &gt->reg_sr);
872866
}
873867
EXPORT_SYMBOL_IF_KUNIT(xe_wa_process_gt);
874868

@@ -886,7 +880,7 @@ void xe_wa_process_engine(struct xe_hw_engine *hwe)
886880

887881
xe_rtp_process_ctx_enable_active_tracking(&ctx, hwe->gt->wa_active.engine,
888882
ARRAY_SIZE(engine_was));
889-
xe_rtp_process_to_sr(&ctx, engine_was, &hwe->reg_sr);
883+
xe_rtp_process_to_sr(&ctx, engine_was, ARRAY_SIZE(engine_was), &hwe->reg_sr);
890884
}
891885

892886
/**
@@ -903,7 +897,7 @@ void xe_wa_process_lrc(struct xe_hw_engine *hwe)
903897

904898
xe_rtp_process_ctx_enable_active_tracking(&ctx, hwe->gt->wa_active.lrc,
905899
ARRAY_SIZE(lrc_was));
906-
xe_rtp_process_to_sr(&ctx, lrc_was, &hwe->reg_lrc);
900+
xe_rtp_process_to_sr(&ctx, lrc_was, ARRAY_SIZE(lrc_was), &hwe->reg_lrc);
907901
}
908902

909903
/**

0 commit comments

Comments
 (0)