提交 8bb92516 编写于 作者: C Chris Wilson 提交者: Daniel Vetter

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: NChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: NMika Kuoppala <mika.kuoppala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210201100448.9802-1-chris@chris-wilson.co.ukSigned-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
上级 c10e4a79
...@@ -12,8 +12,9 @@ ...@@ -12,8 +12,9 @@
#include "selftests/igt_spinner.h" #include "selftests/igt_spinner.h"
struct live_mocs { struct live_mocs {
struct drm_i915_mocs_table mocs; struct drm_i915_mocs_table table;
struct drm_i915_mocs_table l3cc; struct drm_i915_mocs_table *mocs;
struct drm_i915_mocs_table *l3cc;
struct i915_vma *scratch; struct i915_vma *scratch;
void *vaddr; void *vaddr;
}; };
...@@ -58,21 +59,20 @@ static int request_add_spin(struct i915_request *rq, struct igt_spinner *spin) ...@@ -58,21 +59,20 @@ static int request_add_spin(struct i915_request *rq, struct igt_spinner *spin)
static int live_mocs_init(struct live_mocs *arg, struct intel_gt *gt) static int live_mocs_init(struct live_mocs *arg, struct intel_gt *gt)
{ {
struct drm_i915_mocs_table table;
unsigned int flags; unsigned int flags;
int err; int err;
memset(arg, 0, sizeof(*arg)); memset(arg, 0, sizeof(*arg));
flags = get_mocs_settings(gt->i915, &table); flags = get_mocs_settings(gt->i915, &arg->table);
if (!flags) if (!flags)
return -EINVAL; return -EINVAL;
if (flags & HAS_RENDER_L3CC) if (flags & HAS_RENDER_L3CC)
arg->l3cc = table; arg->l3cc = &arg->table;
if (flags & (HAS_GLOBAL_MOCS | HAS_ENGINE_MOCS)) if (flags & (HAS_GLOBAL_MOCS | HAS_ENGINE_MOCS))
arg->mocs = table; arg->mocs = &arg->table;
arg->scratch = __vm_create_scratch_for_read(&gt->ggtt->vm, PAGE_SIZE); arg->scratch = __vm_create_scratch_for_read(&gt->ggtt->vm, PAGE_SIZE);
if (IS_ERR(arg->scratch)) if (IS_ERR(arg->scratch))
...@@ -130,6 +130,9 @@ static int read_mocs_table(struct i915_request *rq, ...@@ -130,6 +130,9 @@ static int read_mocs_table(struct i915_request *rq,
{ {
u32 addr; u32 addr;
if (!table)
return 0;
if (HAS_GLOBAL_MOCS_REGISTERS(rq->engine->i915)) if (HAS_GLOBAL_MOCS_REGISTERS(rq->engine->i915))
addr = global_mocs_offset(); addr = global_mocs_offset();
else else
...@@ -144,6 +147,9 @@ static int read_l3cc_table(struct i915_request *rq, ...@@ -144,6 +147,9 @@ static int read_l3cc_table(struct i915_request *rq,
{ {
u32 addr = i915_mmio_reg_offset(GEN9_LNCFCMOCS(0)); u32 addr = i915_mmio_reg_offset(GEN9_LNCFCMOCS(0));
if (!table)
return 0;
return read_regs(rq, addr, (table->n_entries + 1) / 2, offset); return read_regs(rq, addr, (table->n_entries + 1) / 2, offset);
} }
...@@ -154,6 +160,9 @@ static int check_mocs_table(struct intel_engine_cs *engine, ...@@ -154,6 +160,9 @@ static int check_mocs_table(struct intel_engine_cs *engine,
unsigned int i; unsigned int i;
u32 expect; u32 expect;
if (!table)
return 0;
for_each_mocs(expect, table, i) { for_each_mocs(expect, table, i) {
if (**vaddr != expect) { if (**vaddr != expect) {
pr_err("%s: Invalid MOCS[%d] entry, found %08x, expected %08x\n", 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, ...@@ -185,6 +194,9 @@ static int check_l3cc_table(struct intel_engine_cs *engine,
unsigned int i; unsigned int i;
u32 expect; u32 expect;
if (!table)
return 0;
for_each_l3cc(expect, table, i) { for_each_l3cc(expect, table, i) {
if (!mcr_range(engine->i915, reg) && **vaddr != expect) { if (!mcr_range(engine->i915, reg) && **vaddr != expect) {
pr_err("%s: Invalid L3CC[%d] entry, found %08x, expected %08x\n", 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, ...@@ -222,9 +234,9 @@ static int check_mocs_engine(struct live_mocs *arg,
/* Read the mocs tables back using SRM */ /* Read the mocs tables back using SRM */
offset = i915_ggtt_offset(vma); offset = i915_ggtt_offset(vma);
if (!err) if (!err)
err = read_mocs_table(rq, &arg->mocs, &offset); err = read_mocs_table(rq, arg->mocs, &offset);
if (!err && ce->engine->class == RENDER_CLASS) if (!err && ce->engine->class == RENDER_CLASS)
err = read_l3cc_table(rq, &arg->l3cc, &offset); err = read_l3cc_table(rq, arg->l3cc, &offset);
offset -= i915_ggtt_offset(vma); offset -= i915_ggtt_offset(vma);
GEM_BUG_ON(offset > PAGE_SIZE); GEM_BUG_ON(offset > PAGE_SIZE);
...@@ -235,9 +247,9 @@ static int check_mocs_engine(struct live_mocs *arg, ...@@ -235,9 +247,9 @@ static int check_mocs_engine(struct live_mocs *arg,
/* Compare the results against the expected tables */ /* Compare the results against the expected tables */
vaddr = arg->vaddr; vaddr = arg->vaddr;
if (!err) if (!err)
err = check_mocs_table(ce->engine, &arg->mocs, &vaddr); err = check_mocs_table(ce->engine, arg->mocs, &vaddr);
if (!err && ce->engine->class == RENDER_CLASS) if (!err && ce->engine->class == RENDER_CLASS)
err = check_l3cc_table(ce->engine, &arg->l3cc, &vaddr); err = check_l3cc_table(ce->engine, arg->l3cc, &vaddr);
if (err) if (err)
return err; return err;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册