Commit aee20aae authored by John Harrison's avatar John Harrison Committed by Tvrtko Ursulin

drm/i915: Implement read-only support in whitelist selftest

Newer hardware supports extra feature in the whitelist registers. This
patch updates the selftest to test that entries marked as read only
are actually read only.

v2: Removed all use of 'rsvd' for read-only registers to avoid
ambiguous code or error messages.
Signed-off-by: default avatarJohn Harrison <John.C.Harrison@Intel.com>
CC: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190712070745.35239-3-John.C.Harrison@Intel.com
parent 1e2b7f49
...@@ -485,12 +485,12 @@ static int check_dirty_whitelist(struct i915_gem_context *ctx, ...@@ -485,12 +485,12 @@ static int check_dirty_whitelist(struct i915_gem_context *ctx,
u32 srm, lrm, rsvd; u32 srm, lrm, rsvd;
u32 expect; u32 expect;
int idx; int idx;
bool ro_reg;
if (wo_register(engine, reg)) if (wo_register(engine, reg))
continue; continue;
if (ro_register(reg)) ro_reg = ro_register(reg);
continue;
srm = MI_STORE_REGISTER_MEM; srm = MI_STORE_REGISTER_MEM;
lrm = MI_LOAD_REGISTER_MEM; lrm = MI_LOAD_REGISTER_MEM;
...@@ -591,24 +591,35 @@ static int check_dirty_whitelist(struct i915_gem_context *ctx, ...@@ -591,24 +591,35 @@ static int check_dirty_whitelist(struct i915_gem_context *ctx,
} }
GEM_BUG_ON(values[ARRAY_SIZE(values) - 1] != 0xffffffff); GEM_BUG_ON(values[ARRAY_SIZE(values) - 1] != 0xffffffff);
rsvd = results[ARRAY_SIZE(values)]; /* detect write masking */ if (!ro_reg) {
if (!rsvd) { /* detect write masking */
pr_err("%s: Unable to write to whitelisted register %x\n", rsvd = results[ARRAY_SIZE(values)];
engine->name, reg); if (!rsvd) {
err = -EINVAL; pr_err("%s: Unable to write to whitelisted register %x\n",
goto out_unpin; engine->name, reg);
err = -EINVAL;
goto out_unpin;
}
} }
expect = results[0]; expect = results[0];
idx = 1; idx = 1;
for (v = 0; v < ARRAY_SIZE(values); v++) { for (v = 0; v < ARRAY_SIZE(values); v++) {
expect = reg_write(expect, values[v], rsvd); if (ro_reg)
expect = results[0];
else
expect = reg_write(expect, values[v], rsvd);
if (results[idx] != expect) if (results[idx] != expect)
err++; err++;
idx++; idx++;
} }
for (v = 0; v < ARRAY_SIZE(values); v++) { for (v = 0; v < ARRAY_SIZE(values); v++) {
expect = reg_write(expect, ~values[v], rsvd); if (ro_reg)
expect = results[0];
else
expect = reg_write(expect, ~values[v], rsvd);
if (results[idx] != expect) if (results[idx] != expect)
err++; err++;
idx++; idx++;
...@@ -617,15 +628,22 @@ static int check_dirty_whitelist(struct i915_gem_context *ctx, ...@@ -617,15 +628,22 @@ static int check_dirty_whitelist(struct i915_gem_context *ctx,
pr_err("%s: %d mismatch between values written to whitelisted register [%x], and values read back!\n", pr_err("%s: %d mismatch between values written to whitelisted register [%x], and values read back!\n",
engine->name, err, reg); engine->name, err, reg);
pr_info("%s: Whitelisted register: %x, original value %08x, rsvd %08x\n", if (ro_reg)
engine->name, reg, results[0], rsvd); pr_info("%s: Whitelisted read-only register: %x, original value %08x\n",
engine->name, reg, results[0]);
else
pr_info("%s: Whitelisted register: %x, original value %08x, rsvd %08x\n",
engine->name, reg, results[0], rsvd);
expect = results[0]; expect = results[0];
idx = 1; idx = 1;
for (v = 0; v < ARRAY_SIZE(values); v++) { for (v = 0; v < ARRAY_SIZE(values); v++) {
u32 w = values[v]; u32 w = values[v];
expect = reg_write(expect, w, rsvd); if (ro_reg)
expect = results[0];
else
expect = reg_write(expect, w, rsvd);
pr_info("Wrote %08x, read %08x, expect %08x\n", pr_info("Wrote %08x, read %08x, expect %08x\n",
w, results[idx], expect); w, results[idx], expect);
idx++; idx++;
...@@ -633,7 +651,10 @@ static int check_dirty_whitelist(struct i915_gem_context *ctx, ...@@ -633,7 +651,10 @@ static int check_dirty_whitelist(struct i915_gem_context *ctx,
for (v = 0; v < ARRAY_SIZE(values); v++) { for (v = 0; v < ARRAY_SIZE(values); v++) {
u32 w = ~values[v]; u32 w = ~values[v];
expect = reg_write(expect, w, rsvd); if (ro_reg)
expect = results[0];
else
expect = reg_write(expect, w, rsvd);
pr_info("Wrote %08x, read %08x, expect %08x\n", pr_info("Wrote %08x, read %08x, expect %08x\n",
w, results[idx], expect); w, results[idx], expect);
idx++; idx++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment