Skip to content

Commit d93a4fe

Browse files
committed
drm/xe/kunit: Test active rtp entries
Enabling active tracking in the rtp context and check for all the tests the expected entries become active. Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240727015907.899192-4-lucas.demarchi@intel.com Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
1 parent 20c3a02 commit d93a4fe

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ struct rtp_test_case {
3838
u32 expected_clr_bits;
3939
unsigned long expected_count_sr_entries;
4040
unsigned int expected_sr_errors;
41+
unsigned long expected_active;
4142
const struct xe_rtp_entry_sr *entries;
4243
};
4344

@@ -57,6 +58,7 @@ static const struct rtp_test_case cases[] = {
5758
.expected_reg = REGULAR_REG1,
5859
.expected_set_bits = REG_BIT(0) | REG_BIT(1),
5960
.expected_clr_bits = REG_BIT(0) | REG_BIT(1),
61+
.expected_active = BIT(0) | BIT(1),
6062
.expected_count_sr_entries = 1,
6163
/* Different bits on the same register: create a single entry */
6264
.entries = (const struct xe_rtp_entry_sr[]) {
@@ -76,6 +78,7 @@ static const struct rtp_test_case cases[] = {
7678
.expected_reg = REGULAR_REG1,
7779
.expected_set_bits = REG_BIT(0),
7880
.expected_clr_bits = REG_BIT(0),
81+
.expected_active = BIT(0),
7982
.expected_count_sr_entries = 1,
8083
/* Don't coalesce second entry since rules don't match */
8184
.entries = (const struct xe_rtp_entry_sr[]) {
@@ -95,6 +98,7 @@ static const struct rtp_test_case cases[] = {
9598
.expected_reg = REGULAR_REG1,
9699
.expected_set_bits = REG_BIT(0) | REG_BIT(1) | REG_BIT(2),
97100
.expected_clr_bits = REG_BIT(0) | REG_BIT(1) | REG_BIT(2),
101+
.expected_active = BIT(0) | BIT(1) | BIT(2),
98102
.expected_count_sr_entries = 1,
99103
.entries = (const struct xe_rtp_entry_sr[]) {
100104
{ XE_RTP_NAME("first"),
@@ -148,6 +152,7 @@ static const struct rtp_test_case cases[] = {
148152
.expected_reg = REGULAR_REG1,
149153
.expected_set_bits = REG_BIT(0),
150154
.expected_clr_bits = REG_BIT(0),
155+
.expected_active = BIT(0),
151156
.expected_count_sr_entries = 1,
152157
/* Don't coalesce second entry due to one of the rules */
153158
.entries = (const struct xe_rtp_entry_sr[]) {
@@ -167,6 +172,7 @@ static const struct rtp_test_case cases[] = {
167172
.expected_reg = REGULAR_REG1,
168173
.expected_set_bits = REG_BIT(0),
169174
.expected_clr_bits = REG_BIT(0),
175+
.expected_active = BIT(0) | BIT(1),
170176
.expected_count_sr_entries = 2,
171177
/* Same bits on different registers are not coalesced */
172178
.entries = (const struct xe_rtp_entry_sr[]) {
@@ -186,6 +192,7 @@ static const struct rtp_test_case cases[] = {
186192
.expected_reg = REGULAR_REG1,
187193
.expected_set_bits = REG_BIT(0),
188194
.expected_clr_bits = REG_BIT(1) | REG_BIT(0),
195+
.expected_active = BIT(0) | BIT(1),
189196
.expected_count_sr_entries = 1,
190197
/* Check clr vs set actions on different bits */
191198
.entries = (const struct xe_rtp_entry_sr[]) {
@@ -207,6 +214,7 @@ static const struct rtp_test_case cases[] = {
207214
.expected_reg = REGULAR_REG1,
208215
.expected_set_bits = TEMP_FIELD,
209216
.expected_clr_bits = TEMP_MASK,
217+
.expected_active = BIT(0),
210218
.expected_count_sr_entries = 1,
211219
/* Check FIELD_SET works */
212220
.entries = (const struct xe_rtp_entry_sr[]) {
@@ -225,6 +233,7 @@ static const struct rtp_test_case cases[] = {
225233
.expected_reg = REGULAR_REG1,
226234
.expected_set_bits = REG_BIT(0),
227235
.expected_clr_bits = REG_BIT(0),
236+
.expected_active = BIT(0) | BIT(1),
228237
.expected_count_sr_entries = 1,
229238
.expected_sr_errors = 1,
230239
.entries = (const struct xe_rtp_entry_sr[]) {
@@ -245,6 +254,7 @@ static const struct rtp_test_case cases[] = {
245254
.expected_reg = REGULAR_REG1,
246255
.expected_set_bits = REG_BIT(0),
247256
.expected_clr_bits = REG_BIT(0),
257+
.expected_active = BIT(0) | BIT(1),
248258
.expected_count_sr_entries = 1,
249259
.expected_sr_errors = 1,
250260
.entries = (const struct xe_rtp_entry_sr[]) {
@@ -265,6 +275,7 @@ static const struct rtp_test_case cases[] = {
265275
.expected_reg = REGULAR_REG1,
266276
.expected_set_bits = REG_BIT(0),
267277
.expected_clr_bits = REG_BIT(0),
278+
.expected_active = BIT(0) | BIT(1) | BIT(2),
268279
.expected_count_sr_entries = 1,
269280
.expected_sr_errors = 2,
270281
.entries = (const struct xe_rtp_entry_sr[]) {
@@ -295,9 +306,14 @@ static void xe_rtp_process_tests(struct kunit *test)
295306
struct xe_reg_sr *reg_sr = &gt->reg_sr;
296307
const struct xe_reg_sr_entry *sre, *sr_entry = NULL;
297308
struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(gt);
298-
unsigned long idx, count_sr_entries = 0;
309+
unsigned long idx, count_sr_entries = 0, count_rtp_entries = 0, active = 0;
299310

300311
xe_reg_sr_init(reg_sr, "xe_rtp_tests", xe);
312+
313+
while (param->entries[count_rtp_entries].rules)
314+
count_rtp_entries++;
315+
316+
xe_rtp_process_ctx_enable_active_tracking(&ctx, &active, count_rtp_entries);
301317
xe_rtp_process_to_sr(&ctx, param->entries, reg_sr);
302318

303319
xa_for_each(&reg_sr->xa, idx, sre) {
@@ -307,6 +323,8 @@ static void xe_rtp_process_tests(struct kunit *test)
307323
count_sr_entries++;
308324
}
309325

326+
KUNIT_EXPECT_EQ(test, active, param->expected_active);
327+
310328
KUNIT_EXPECT_EQ(test, count_sr_entries, param->expected_count_sr_entries);
311329
if (count_sr_entries) {
312330
KUNIT_EXPECT_EQ(test, sr_entry->clr_bits, param->expected_clr_bits);

drivers/gpu/drm/xe/xe_rtp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ void xe_rtp_process_ctx_enable_active_tracking(struct xe_rtp_process_ctx *ctx,
217217
ctx->active_entries = active_entries;
218218
ctx->n_entries = n_entries;
219219
}
220+
EXPORT_SYMBOL_IF_KUNIT(xe_rtp_process_ctx_enable_active_tracking);
220221

221222
static void rtp_mark_active(struct xe_device *xe,
222223
struct xe_rtp_process_ctx *ctx,

0 commit comments

Comments
 (0)