Skip to content

Commit 8bb9251

Browse files
ickledanvet
authored andcommitted
drm/i915/selftests: Use a single copy of the mocs table
Instead of copying the whole table to each category (mocs, l3cc), use a single table with a pointer to it if the category is enabled. Signed-off-by: Chris Wilson <[email protected]> Reviewed-by: Mika Kuoppala <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Daniel Vetter <[email protected]>
1 parent c10e4a7 commit 8bb9251

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

drivers/gpu/drm/i915/gt/selftest_mocs.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
#include "selftests/igt_spinner.h"
1313

1414
struct live_mocs {
15-
struct drm_i915_mocs_table mocs;
16-
struct drm_i915_mocs_table l3cc;
15+
struct drm_i915_mocs_table table;
16+
struct drm_i915_mocs_table *mocs;
17+
struct drm_i915_mocs_table *l3cc;
1718
struct i915_vma *scratch;
1819
void *vaddr;
1920
};
@@ -58,21 +59,20 @@ static int request_add_spin(struct i915_request *rq, struct igt_spinner *spin)
5859

5960
static int live_mocs_init(struct live_mocs *arg, struct intel_gt *gt)
6061
{
61-
struct drm_i915_mocs_table table;
6262
unsigned int flags;
6363
int err;
6464

6565
memset(arg, 0, sizeof(*arg));
6666

67-
flags = get_mocs_settings(gt->i915, &table);
67+
flags = get_mocs_settings(gt->i915, &arg->table);
6868
if (!flags)
6969
return -EINVAL;
7070

7171
if (flags & HAS_RENDER_L3CC)
72-
arg->l3cc = table;
72+
arg->l3cc = &arg->table;
7373

7474
if (flags & (HAS_GLOBAL_MOCS | HAS_ENGINE_MOCS))
75-
arg->mocs = table;
75+
arg->mocs = &arg->table;
7676

7777
arg->scratch = __vm_create_scratch_for_read(&gt->ggtt->vm, PAGE_SIZE);
7878
if (IS_ERR(arg->scratch))
@@ -130,6 +130,9 @@ static int read_mocs_table(struct i915_request *rq,
130130
{
131131
u32 addr;
132132

133+
if (!table)
134+
return 0;
135+
133136
if (HAS_GLOBAL_MOCS_REGISTERS(rq->engine->i915))
134137
addr = global_mocs_offset();
135138
else
@@ -144,6 +147,9 @@ static int read_l3cc_table(struct i915_request *rq,
144147
{
145148
u32 addr = i915_mmio_reg_offset(GEN9_LNCFCMOCS(0));
146149

150+
if (!table)
151+
return 0;
152+
147153
return read_regs(rq, addr, (table->n_entries + 1) / 2, offset);
148154
}
149155

@@ -154,6 +160,9 @@ static int check_mocs_table(struct intel_engine_cs *engine,
154160
unsigned int i;
155161
u32 expect;
156162

163+
if (!table)
164+
return 0;
165+
157166
for_each_mocs(expect, table, i) {
158167
if (**vaddr != expect) {
159168
pr_err("%s: Invalid MOCS[%d] entry, found %08x, expected %08x\n",
@@ -185,6 +194,9 @@ static int check_l3cc_table(struct intel_engine_cs *engine,
185194
unsigned int i;
186195
u32 expect;
187196

197+
if (!table)
198+
return 0;
199+
188200
for_each_l3cc(expect, table, i) {
189201
if (!mcr_range(engine->i915, reg) && **vaddr != expect) {
190202
pr_err("%s: Invalid L3CC[%d] entry, found %08x, expected %08x\n",
@@ -222,9 +234,9 @@ static int check_mocs_engine(struct live_mocs *arg,
222234
/* Read the mocs tables back using SRM */
223235
offset = i915_ggtt_offset(vma);
224236
if (!err)
225-
err = read_mocs_table(rq, &arg->mocs, &offset);
237+
err = read_mocs_table(rq, arg->mocs, &offset);
226238
if (!err && ce->engine->class == RENDER_CLASS)
227-
err = read_l3cc_table(rq, &arg->l3cc, &offset);
239+
err = read_l3cc_table(rq, arg->l3cc, &offset);
228240
offset -= i915_ggtt_offset(vma);
229241
GEM_BUG_ON(offset > PAGE_SIZE);
230242

@@ -235,9 +247,9 @@ static int check_mocs_engine(struct live_mocs *arg,
235247
/* Compare the results against the expected tables */
236248
vaddr = arg->vaddr;
237249
if (!err)
238-
err = check_mocs_table(ce->engine, &arg->mocs, &vaddr);
250+
err = check_mocs_table(ce->engine, arg->mocs, &vaddr);
239251
if (!err && ce->engine->class == RENDER_CLASS)
240-
err = check_l3cc_table(ce->engine, &arg->l3cc, &vaddr);
252+
err = check_l3cc_table(ce->engine, arg->l3cc, &vaddr);
241253
if (err)
242254
return err;
243255

0 commit comments

Comments
 (0)