Skip to content

Commit 6da8acf

Browse files
committed
drm/xe/kunit: Test rtp with no actions
The OOB WAs use xe_rtp_process(), without passing an sr to save result of the actions since there are none. They are also executed in a gt-only context, making it harder to share the implementation. Thus, introduce a new set of tests to check these RTP entries. The only check that can be done is if the entry was marked as active. Before commit fd6797e ("drm/xe/rtp: Fix off-by-one when processing rules") several of these tests were failing: the processing of OR'ed entries would make the subsequent entry to be inadvertently enabled. 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 9eab82c commit 6da8acf

File tree

2 files changed

+162
-0
lines changed

2 files changed

+162
-0
lines changed

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

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ struct rtp_to_sr_test_case {
4242
const struct xe_rtp_entry_sr *entries;
4343
};
4444

45+
struct rtp_test_case {
46+
const char *name;
47+
unsigned long expected_active;
48+
const struct xe_rtp_entry *entries;
49+
};
50+
4551
static bool match_yes(const struct xe_gt *gt, const struct xe_hw_engine *hwe)
4652
{
4753
return true;
@@ -337,13 +343,167 @@ static void xe_rtp_process_to_sr_tests(struct kunit *test)
337343
KUNIT_EXPECT_EQ(test, reg_sr->errors, param->expected_sr_errors);
338344
}
339345

346+
/*
347+
* Entries below follow the logic used with xe_wa_oob.rules:
348+
* 1) Entries with empty name are OR'ed: all entries marked active since the
349+
* last entry with a name
350+
* 2) There are no action associated with rules
351+
*/
352+
static const struct rtp_test_case rtp_cases[] = {
353+
{
354+
.name = "active1",
355+
.expected_active = BIT(0),
356+
.entries = (const struct xe_rtp_entry[]) {
357+
{ XE_RTP_NAME("r1"),
358+
XE_RTP_RULES(FUNC(match_yes)),
359+
},
360+
{}
361+
},
362+
},
363+
{
364+
.name = "active2",
365+
.expected_active = BIT(0) | BIT(1),
366+
.entries = (const struct xe_rtp_entry[]) {
367+
{ XE_RTP_NAME("r1"),
368+
XE_RTP_RULES(FUNC(match_yes)),
369+
},
370+
{ XE_RTP_NAME("r2"),
371+
XE_RTP_RULES(FUNC(match_yes)),
372+
},
373+
{}
374+
},
375+
},
376+
{
377+
.name = "active-inactive",
378+
.expected_active = BIT(0),
379+
.entries = (const struct xe_rtp_entry[]) {
380+
{ XE_RTP_NAME("r1"),
381+
XE_RTP_RULES(FUNC(match_yes)),
382+
},
383+
{ XE_RTP_NAME("r2"),
384+
XE_RTP_RULES(FUNC(match_no)),
385+
},
386+
{}
387+
},
388+
},
389+
{
390+
.name = "inactive-active",
391+
.expected_active = BIT(1),
392+
.entries = (const struct xe_rtp_entry[]) {
393+
{ XE_RTP_NAME("r1"),
394+
XE_RTP_RULES(FUNC(match_no)),
395+
},
396+
{ XE_RTP_NAME("r2"),
397+
XE_RTP_RULES(FUNC(match_yes)),
398+
},
399+
{}
400+
},
401+
},
402+
{
403+
.name = "inactive-1st_or_active-inactive",
404+
.expected_active = BIT(1) | BIT(2) | BIT(3),
405+
.entries = (const struct xe_rtp_entry[]) {
406+
{ XE_RTP_NAME("r1"),
407+
XE_RTP_RULES(FUNC(match_no)),
408+
},
409+
{ 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)) },
414+
{ XE_RTP_NAME("r3"),
415+
XE_RTP_RULES(FUNC(match_no)),
416+
},
417+
{}
418+
},
419+
},
420+
{
421+
.name = "inactive-2nd_or_active-inactive",
422+
.expected_active = BIT(1) | BIT(2) | BIT(3),
423+
.entries = (const struct xe_rtp_entry[]) {
424+
{ XE_RTP_NAME("r1"),
425+
XE_RTP_RULES(FUNC(match_no)),
426+
},
427+
{ 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)) },
432+
{ XE_RTP_NAME("r3"),
433+
XE_RTP_RULES(FUNC(match_no)),
434+
},
435+
{}
436+
},
437+
},
438+
{
439+
.name = "inactive-last_or_active-inactive",
440+
.expected_active = BIT(1) | BIT(2) | BIT(3),
441+
.entries = (const struct xe_rtp_entry[]) {
442+
{ XE_RTP_NAME("r1"),
443+
XE_RTP_RULES(FUNC(match_no)),
444+
},
445+
{ 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)) },
450+
{ XE_RTP_NAME("r3"),
451+
XE_RTP_RULES(FUNC(match_no)),
452+
},
453+
{}
454+
},
455+
},
456+
{
457+
.name = "inactive-no_or_active-inactive",
458+
.expected_active = 0,
459+
.entries = (const struct xe_rtp_entry[]) {
460+
{ XE_RTP_NAME("r1"),
461+
XE_RTP_RULES(FUNC(match_no)),
462+
},
463+
{ 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)) },
468+
{ XE_RTP_NAME("r3"),
469+
XE_RTP_RULES(FUNC(match_no)),
470+
},
471+
{}
472+
},
473+
},
474+
};
475+
476+
static void xe_rtp_process_tests(struct kunit *test)
477+
{
478+
const struct rtp_test_case *param = test->param_value;
479+
struct xe_device *xe = test->priv;
480+
struct xe_gt *gt = xe_device_get_root_tile(xe)->primary_gt;
481+
struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(gt);
482+
unsigned long count_rtp_entries = 0, active = 0;
483+
484+
while (param->entries[count_rtp_entries].rules)
485+
count_rtp_entries++;
486+
487+
xe_rtp_process_ctx_enable_active_tracking(&ctx, &active, count_rtp_entries);
488+
xe_rtp_process(&ctx, param->entries);
489+
490+
KUNIT_EXPECT_EQ(test, active, param->expected_active);
491+
}
492+
340493
static void rtp_to_sr_desc(const struct rtp_to_sr_test_case *t, char *desc)
341494
{
342495
strscpy(desc, t->name, KUNIT_PARAM_DESC_SIZE);
343496
}
344497

345498
KUNIT_ARRAY_PARAM(rtp_to_sr, rtp_to_sr_cases, rtp_to_sr_desc);
346499

500+
static void rtp_desc(const struct rtp_test_case *t, char *desc)
501+
{
502+
strscpy(desc, t->name, KUNIT_PARAM_DESC_SIZE);
503+
}
504+
505+
KUNIT_ARRAY_PARAM(rtp, rtp_cases, rtp_desc);
506+
347507
static int xe_rtp_test_init(struct kunit *test)
348508
{
349509
struct xe_device *xe;
@@ -376,6 +536,7 @@ static void xe_rtp_test_exit(struct kunit *test)
376536

377537
static struct kunit_case xe_rtp_tests[] = {
378538
KUNIT_CASE_PARAM(xe_rtp_process_to_sr_tests, rtp_to_sr_gen_params),
539+
KUNIT_CASE_PARAM(xe_rtp_process_tests, rtp_gen_params),
379540
{}
380541
};
381542

drivers/gpu/drm/xe/xe_rtp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ void xe_rtp_process(struct xe_rtp_process_ctx *ctx,
327327
entry - entries);
328328
}
329329
}
330+
EXPORT_SYMBOL_IF_KUNIT(xe_rtp_process);
330331

331332
bool xe_rtp_match_even_instance(const struct xe_gt *gt,
332333
const struct xe_hw_engine *hwe)

0 commit comments

Comments
 (0)