Skip to content

Commit dbcbfc7

Browse files
committed
drm/xe: Migrate OOB WAs to OR rules
Now that rtp has OR rules, it's not needed to extend it to process OOB WAs. Previously if an entry had no name, it was considered as "a set of rules OR'ed with the last named entry". Instead of generating new entries, add OR rules. The syntax for xe_wa_oob.rules remains the same, with xe_gen_wa_oob generating the slightly different table. Object sizes delta are negligible, but having just one logic makes it easier to maintain: add/remove: 0/0 grow/shrink: 1/2 up/down: 160/-269 (-109) Function old new delta __compound_literal 6104 6264 +160 xe_wa_dump 1839 1810 -29 oob_was 816 576 -240 Total: Before=17257, After=17148, chg -0.63% Reviewed-by: Gustavo Sousa <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Lucas De Marchi <[email protected]>
1 parent 1c408c5 commit dbcbfc7

File tree

3 files changed

+37
-49
lines changed

3 files changed

+37
-49
lines changed

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

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -401,16 +401,15 @@ static const struct rtp_test_case rtp_cases[] = {
401401
},
402402
{
403403
.name = "inactive-1st_or_active-inactive",
404-
.expected_active = BIT(1) | BIT(2) | BIT(3),
404+
.expected_active = BIT(1),
405405
.entries = (const struct xe_rtp_entry[]) {
406406
{ XE_RTP_NAME("r1"),
407407
XE_RTP_RULES(FUNC(match_no)),
408408
},
409409
{ XE_RTP_NAME("r2_or_conditions"),
410-
XE_RTP_RULES(FUNC(match_yes)),
411-
},
412-
{ XE_RTP_RULES(FUNC(match_no)) },
413-
{ XE_RTP_RULES(FUNC(match_no)) },
410+
XE_RTP_RULES(FUNC(match_yes), OR,
411+
FUNC(match_no), OR,
412+
FUNC(match_no)) },
414413
{ XE_RTP_NAME("r3"),
415414
XE_RTP_RULES(FUNC(match_no)),
416415
},
@@ -419,16 +418,15 @@ static const struct rtp_test_case rtp_cases[] = {
419418
},
420419
{
421420
.name = "inactive-2nd_or_active-inactive",
422-
.expected_active = BIT(1) | BIT(2) | BIT(3),
421+
.expected_active = BIT(1),
423422
.entries = (const struct xe_rtp_entry[]) {
424423
{ XE_RTP_NAME("r1"),
425424
XE_RTP_RULES(FUNC(match_no)),
426425
},
427426
{ XE_RTP_NAME("r2_or_conditions"),
428-
XE_RTP_RULES(FUNC(match_no)),
429-
},
430-
{ XE_RTP_RULES(FUNC(match_yes)) },
431-
{ XE_RTP_RULES(FUNC(match_no)) },
427+
XE_RTP_RULES(FUNC(match_no), OR,
428+
FUNC(match_yes), OR,
429+
FUNC(match_no)) },
432430
{ XE_RTP_NAME("r3"),
433431
XE_RTP_RULES(FUNC(match_no)),
434432
},
@@ -437,16 +435,15 @@ static const struct rtp_test_case rtp_cases[] = {
437435
},
438436
{
439437
.name = "inactive-last_or_active-inactive",
440-
.expected_active = BIT(1) | BIT(2) | BIT(3),
438+
.expected_active = BIT(1),
441439
.entries = (const struct xe_rtp_entry[]) {
442440
{ XE_RTP_NAME("r1"),
443441
XE_RTP_RULES(FUNC(match_no)),
444442
},
445443
{ XE_RTP_NAME("r2_or_conditions"),
446-
XE_RTP_RULES(FUNC(match_no)),
447-
},
448-
{ XE_RTP_RULES(FUNC(match_no)) },
449-
{ XE_RTP_RULES(FUNC(match_yes)) },
444+
XE_RTP_RULES(FUNC(match_no), OR,
445+
FUNC(match_no), OR,
446+
FUNC(match_yes)) },
450447
{ XE_RTP_NAME("r3"),
451448
XE_RTP_RULES(FUNC(match_no)),
452449
},
@@ -461,10 +458,9 @@ static const struct rtp_test_case rtp_cases[] = {
461458
XE_RTP_RULES(FUNC(match_no)),
462459
},
463460
{ XE_RTP_NAME("r2_or_conditions"),
464-
XE_RTP_RULES(FUNC(match_no)),
465-
},
466-
{ XE_RTP_RULES(FUNC(match_no)) },
467-
{ XE_RTP_RULES(FUNC(match_no)) },
461+
XE_RTP_RULES(FUNC(match_no), OR,
462+
FUNC(match_no), OR,
463+
FUNC(match_no)) },
468464
{ XE_RTP_NAME("r3"),
469465
XE_RTP_RULES(FUNC(match_no)),
470466
},

drivers/gpu/drm/xe/xe_gen_wa_oob.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,27 @@ static int parse(FILE *input, FILE *csource, FILE *cheader)
9797

9898
if (name) {
9999
fprintf(cheader, "\tXE_WA_OOB_%s = %u,\n", name, idx);
100-
fprintf(csource, "{ XE_RTP_NAME(\"%s\"), XE_RTP_RULES(%s) },\n",
100+
101+
/* Close previous entry before starting a new one */
102+
if (idx)
103+
fprintf(csource, ") },\n");
104+
105+
fprintf(csource, "{ XE_RTP_NAME(\"%s\"),\n XE_RTP_RULES(%s",
101106
name, rules);
107+
idx++;
102108
} else {
103-
fprintf(csource, "{ XE_RTP_NAME(NULL), XE_RTP_RULES(%s) },\n",
104-
rules);
109+
fprintf(csource, ", OR,\n\t%s", rules);
105110
}
106111

107-
idx++;
108112
lineno++;
109113
if (!is_continuation)
110114
prev_name = name;
111115
}
112116

117+
/* Close last entry */
118+
if (idx)
119+
fprintf(csource, ") },\n");
120+
113121
fprintf(cheader, "\t_XE_WA_OOB_COUNT = %u\n", idx);
114122

115123
return 0;

drivers/gpu/drm/xe/xe_rtp.c

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,15 @@ EXPORT_SYMBOL_IF_KUNIT(xe_rtp_process_ctx_enable_active_tracking);
221221

222222
static void rtp_mark_active(struct xe_device *xe,
223223
struct xe_rtp_process_ctx *ctx,
224-
unsigned int first, unsigned int n_entries)
224+
unsigned int idx)
225225
{
226226
if (!ctx->active_entries)
227227
return;
228228

229-
if (drm_WARN_ON(&xe->drm, first + n_entries > ctx->n_entries))
229+
if (drm_WARN_ON(&xe->drm, idx >= ctx->n_entries))
230230
return;
231231

232-
bitmap_set(ctx->active_entries, first, n_entries);
232+
bitmap_set(ctx->active_entries, idx, 1);
233233
}
234234

235235
/**
@@ -274,7 +274,7 @@ void xe_rtp_process_to_sr(struct xe_rtp_process_ctx *ctx,
274274
}
275275

276276
if (match)
277-
rtp_mark_active(xe, ctx, entry - entries, 1);
277+
rtp_mark_active(xe, ctx, entry - entries);
278278
}
279279
}
280280
EXPORT_SYMBOL_IF_KUNIT(xe_rtp_process_to_sr);
@@ -285,42 +285,26 @@ EXPORT_SYMBOL_IF_KUNIT(xe_rtp_process_to_sr);
285285
* @entries: Table with RTP definitions
286286
*
287287
* Walk the table pointed by @entries (with an empty sentinel), executing the
288-
* rules. A few differences from xe_rtp_process_to_sr():
289-
*
290-
* 1. There is no action associated with each entry since this uses
291-
* struct xe_rtp_entry. Its main use is for marking active workarounds via
292-
* xe_rtp_process_ctx_enable_active_tracking().
293-
* 2. There is support for OR operations by having entries with no name.
288+
* rules. One difference from xe_rtp_process_to_sr(): there is no action
289+
* associated with each entry since this uses struct xe_rtp_entry. Its main use
290+
* is for marking active workarounds via
291+
* xe_rtp_process_ctx_enable_active_tracking().
294292
*/
295293
void xe_rtp_process(struct xe_rtp_process_ctx *ctx,
296294
const struct xe_rtp_entry *entries)
297295
{
298-
const struct xe_rtp_entry *entry, *first_entry;
296+
const struct xe_rtp_entry *entry;
299297
struct xe_hw_engine *hwe;
300298
struct xe_gt *gt;
301299
struct xe_device *xe;
302300

303301
rtp_get_context(ctx, &hwe, &gt, &xe);
304302

305-
first_entry = entries;
306-
if (drm_WARN_ON(&xe->drm, !first_entry->name))
307-
return;
308-
309303
for (entry = entries; entry && entry->rules; entry++) {
310-
if (entry->name)
311-
first_entry = entry;
312-
313304
if (!rule_matches(xe, gt, hwe, entry->rules, entry->n_rules))
314305
continue;
315306

316-
/* Fast-forward entry, eliminating the OR'ed entries */
317-
for (entry++; entry && entry->rules; entry++)
318-
if (entry->name)
319-
break;
320-
entry--;
321-
322-
rtp_mark_active(xe, ctx, first_entry - entries,
323-
entry - first_entry + 1);
307+
rtp_mark_active(xe, ctx, entry - entries);
324308
}
325309
}
326310
EXPORT_SYMBOL_IF_KUNIT(xe_rtp_process);

0 commit comments

Comments
 (0)