Commit b05787ae authored by Imre Deak's avatar Imre Deak

drm/i915/selftest: Unify use of intel_remapped_plane_info in igt_vma_rotate_remap()

Always use the modified copy of the intel_remapped_plane_info variables.
An upcoming patch updates the dst_stride field in these copies after
which we can't use the original versions.

v2: Init view in igt_vma_rotate_remap() when declaring it. (Ville)
Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210325214808.2071517-22-imre.deak@intel.com
parent 1b6b032a
...@@ -515,22 +515,24 @@ static int igt_vma_rotate_remap(void *arg) ...@@ -515,22 +515,24 @@ static int igt_vma_rotate_remap(void *arg)
for (t = types; *t; t++) { for (t = types; *t; t++) {
for (a = planes; a->width; a++) { for (a = planes; a->width; a++) {
for (b = planes + ARRAY_SIZE(planes); b-- != planes; ) { for (b = planes + ARRAY_SIZE(planes); b-- != planes; ) {
struct i915_ggtt_view view = {}; struct i915_ggtt_view view = {
.type = *t,
.remapped.plane[0] = *a,
.remapped.plane[1] = *b,
};
struct intel_remapped_plane_info *plane_info = view.remapped.plane;
unsigned int n, max_offset; unsigned int n, max_offset;
max_offset = max(a->stride * a->height, max_offset = max(plane_info[0].stride * plane_info[0].height,
b->stride * b->height); plane_info[1].stride * plane_info[1].height);
GEM_BUG_ON(max_offset > max_pages); GEM_BUG_ON(max_offset > max_pages);
max_offset = max_pages - max_offset; max_offset = max_pages - max_offset;
view.type = *t; for_each_prime_number_from(plane_info[0].offset, 0, max_offset) {
view.rotated.plane[0] = *a; for_each_prime_number_from(plane_info[1].offset, 0, max_offset) {
view.rotated.plane[1] = *b;
for_each_prime_number_from(view.rotated.plane[0].offset, 0, max_offset) {
for_each_prime_number_from(view.rotated.plane[1].offset, 0, max_offset) {
struct scatterlist *sg; struct scatterlist *sg;
struct i915_vma *vma; struct i915_vma *vma;
unsigned int expected_pages;
vma = checked_vma_instance(obj, vm, &view); vma = checked_vma_instance(obj, vm, &view);
if (IS_ERR(vma)) { if (IS_ERR(vma)) {
...@@ -544,25 +546,27 @@ static int igt_vma_rotate_remap(void *arg) ...@@ -544,25 +546,27 @@ static int igt_vma_rotate_remap(void *arg)
goto out_object; goto out_object;
} }
expected_pages = rotated_size(&plane_info[0], &plane_info[1]);
if (view.type == I915_GGTT_VIEW_ROTATED && if (view.type == I915_GGTT_VIEW_ROTATED &&
vma->size != rotated_size(a, b) * PAGE_SIZE) { vma->size != expected_pages * PAGE_SIZE) {
pr_err("VMA is wrong size, expected %lu, found %llu\n", pr_err("VMA is wrong size, expected %lu, found %llu\n",
PAGE_SIZE * rotated_size(a, b), vma->size); PAGE_SIZE * expected_pages, vma->size);
err = -EINVAL; err = -EINVAL;
goto out_object; goto out_object;
} }
if (view.type == I915_GGTT_VIEW_REMAPPED && if (view.type == I915_GGTT_VIEW_REMAPPED &&
vma->size > rotated_size(a, b) * PAGE_SIZE) { vma->size > expected_pages * PAGE_SIZE) {
pr_err("VMA is wrong size, expected %lu, found %llu\n", pr_err("VMA is wrong size, expected %lu, found %llu\n",
PAGE_SIZE * rotated_size(a, b), vma->size); PAGE_SIZE * expected_pages, vma->size);
err = -EINVAL; err = -EINVAL;
goto out_object; goto out_object;
} }
if (vma->pages->nents > rotated_size(a, b)) { if (vma->pages->nents > expected_pages) {
pr_err("sg table is wrong sizeo, expected %u, found %u nents\n", pr_err("sg table is wrong sizeo, expected %u, found %u nents\n",
rotated_size(a, b), vma->pages->nents); expected_pages, vma->pages->nents);
err = -EINVAL; err = -EINVAL;
goto out_object; goto out_object;
} }
...@@ -590,14 +594,14 @@ static int igt_vma_rotate_remap(void *arg) ...@@ -590,14 +594,14 @@ static int igt_vma_rotate_remap(void *arg)
pr_err("Inconsistent %s VMA pages for plane %d: [(%d, %d, %d, %d), (%d, %d, %d, %d)]\n", pr_err("Inconsistent %s VMA pages for plane %d: [(%d, %d, %d, %d), (%d, %d, %d, %d)]\n",
view.type == I915_GGTT_VIEW_ROTATED ? view.type == I915_GGTT_VIEW_ROTATED ?
"rotated" : "remapped", n, "rotated" : "remapped", n,
view.rotated.plane[0].width, plane_info[0].width,
view.rotated.plane[0].height, plane_info[0].height,
view.rotated.plane[0].stride, plane_info[0].stride,
view.rotated.plane[0].offset, plane_info[0].offset,
view.rotated.plane[1].width, plane_info[1].width,
view.rotated.plane[1].height, plane_info[1].height,
view.rotated.plane[1].stride, plane_info[1].stride,
view.rotated.plane[1].offset); plane_info[1].offset);
err = -EINVAL; err = -EINVAL;
goto out_object; goto out_object;
} }
...@@ -887,6 +891,7 @@ static int igt_vma_remapped_gtt(void *arg) ...@@ -887,6 +891,7 @@ static int igt_vma_remapped_gtt(void *arg)
.type = *t, .type = *t,
.rotated.plane[0] = *p, .rotated.plane[0] = *p,
}; };
struct intel_remapped_plane_info *plane_info = view.rotated.plane;
struct i915_vma *vma; struct i915_vma *vma;
u32 __iomem *map; u32 __iomem *map;
unsigned int x, y; unsigned int x, y;
...@@ -912,15 +917,15 @@ static int igt_vma_remapped_gtt(void *arg) ...@@ -912,15 +917,15 @@ static int igt_vma_remapped_gtt(void *arg)
goto out; goto out;
} }
for (y = 0 ; y < p->height; y++) { for (y = 0 ; y < plane_info[0].height; y++) {
for (x = 0 ; x < p->width; x++) { for (x = 0 ; x < plane_info[0].width; x++) {
unsigned int offset; unsigned int offset;
u32 val = y << 16 | x; u32 val = y << 16 | x;
if (*t == I915_GGTT_VIEW_ROTATED) if (*t == I915_GGTT_VIEW_ROTATED)
offset = (x * p->height + y) * PAGE_SIZE; offset = (x * plane_info[0].height + y) * PAGE_SIZE;
else else
offset = (y * p->width + x) * PAGE_SIZE; offset = (y * plane_info[0].width + x) * PAGE_SIZE;
iowrite32(val, &map[offset / sizeof(*map)]); iowrite32(val, &map[offset / sizeof(*map)]);
} }
...@@ -943,8 +948,8 @@ static int igt_vma_remapped_gtt(void *arg) ...@@ -943,8 +948,8 @@ static int igt_vma_remapped_gtt(void *arg)
goto out; goto out;
} }
for (y = 0 ; y < p->height; y++) { for (y = 0 ; y < plane_info[0].height; y++) {
for (x = 0 ; x < p->width; x++) { for (x = 0 ; x < plane_info[0].width; x++) {
unsigned int offset, src_idx; unsigned int offset, src_idx;
u32 exp = y << 16 | x; u32 exp = y << 16 | x;
u32 val; u32 val;
......
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