Skip to content

Commit b05787a

Browse files
committed
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: Imre Deak <[email protected]> Reviewed-by: Ville Syrjälä <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 1b6b032 commit b05787a

File tree

1 file changed

+34
-29
lines changed

1 file changed

+34
-29
lines changed

drivers/gpu/drm/i915/selftests/i915_vma.c

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -515,22 +515,24 @@ static int igt_vma_rotate_remap(void *arg)
515515
for (t = types; *t; t++) {
516516
for (a = planes; a->width; a++) {
517517
for (b = planes + ARRAY_SIZE(planes); b-- != planes; ) {
518-
struct i915_ggtt_view view = {};
518+
struct i915_ggtt_view view = {
519+
.type = *t,
520+
.remapped.plane[0] = *a,
521+
.remapped.plane[1] = *b,
522+
};
523+
struct intel_remapped_plane_info *plane_info = view.remapped.plane;
519524
unsigned int n, max_offset;
520525

521-
max_offset = max(a->stride * a->height,
522-
b->stride * b->height);
526+
max_offset = max(plane_info[0].stride * plane_info[0].height,
527+
plane_info[1].stride * plane_info[1].height);
523528
GEM_BUG_ON(max_offset > max_pages);
524529
max_offset = max_pages - max_offset;
525530

526-
view.type = *t;
527-
view.rotated.plane[0] = *a;
528-
view.rotated.plane[1] = *b;
529-
530-
for_each_prime_number_from(view.rotated.plane[0].offset, 0, max_offset) {
531-
for_each_prime_number_from(view.rotated.plane[1].offset, 0, max_offset) {
531+
for_each_prime_number_from(plane_info[0].offset, 0, max_offset) {
532+
for_each_prime_number_from(plane_info[1].offset, 0, max_offset) {
532533
struct scatterlist *sg;
533534
struct i915_vma *vma;
535+
unsigned int expected_pages;
534536

535537
vma = checked_vma_instance(obj, vm, &view);
536538
if (IS_ERR(vma)) {
@@ -544,25 +546,27 @@ static int igt_vma_rotate_remap(void *arg)
544546
goto out_object;
545547
}
546548

549+
expected_pages = rotated_size(&plane_info[0], &plane_info[1]);
550+
547551
if (view.type == I915_GGTT_VIEW_ROTATED &&
548-
vma->size != rotated_size(a, b) * PAGE_SIZE) {
552+
vma->size != expected_pages * PAGE_SIZE) {
549553
pr_err("VMA is wrong size, expected %lu, found %llu\n",
550-
PAGE_SIZE * rotated_size(a, b), vma->size);
554+
PAGE_SIZE * expected_pages, vma->size);
551555
err = -EINVAL;
552556
goto out_object;
553557
}
554558

555559
if (view.type == I915_GGTT_VIEW_REMAPPED &&
556-
vma->size > rotated_size(a, b) * PAGE_SIZE) {
560+
vma->size > expected_pages * PAGE_SIZE) {
557561
pr_err("VMA is wrong size, expected %lu, found %llu\n",
558-
PAGE_SIZE * rotated_size(a, b), vma->size);
562+
PAGE_SIZE * expected_pages, vma->size);
559563
err = -EINVAL;
560564
goto out_object;
561565
}
562566

563-
if (vma->pages->nents > rotated_size(a, b)) {
567+
if (vma->pages->nents > expected_pages) {
564568
pr_err("sg table is wrong sizeo, expected %u, found %u nents\n",
565-
rotated_size(a, b), vma->pages->nents);
569+
expected_pages, vma->pages->nents);
566570
err = -EINVAL;
567571
goto out_object;
568572
}
@@ -590,14 +594,14 @@ static int igt_vma_rotate_remap(void *arg)
590594
pr_err("Inconsistent %s VMA pages for plane %d: [(%d, %d, %d, %d), (%d, %d, %d, %d)]\n",
591595
view.type == I915_GGTT_VIEW_ROTATED ?
592596
"rotated" : "remapped", n,
593-
view.rotated.plane[0].width,
594-
view.rotated.plane[0].height,
595-
view.rotated.plane[0].stride,
596-
view.rotated.plane[0].offset,
597-
view.rotated.plane[1].width,
598-
view.rotated.plane[1].height,
599-
view.rotated.plane[1].stride,
600-
view.rotated.plane[1].offset);
597+
plane_info[0].width,
598+
plane_info[0].height,
599+
plane_info[0].stride,
600+
plane_info[0].offset,
601+
plane_info[1].width,
602+
plane_info[1].height,
603+
plane_info[1].stride,
604+
plane_info[1].offset);
601605
err = -EINVAL;
602606
goto out_object;
603607
}
@@ -887,6 +891,7 @@ static int igt_vma_remapped_gtt(void *arg)
887891
.type = *t,
888892
.rotated.plane[0] = *p,
889893
};
894+
struct intel_remapped_plane_info *plane_info = view.rotated.plane;
890895
struct i915_vma *vma;
891896
u32 __iomem *map;
892897
unsigned int x, y;
@@ -912,15 +917,15 @@ static int igt_vma_remapped_gtt(void *arg)
912917
goto out;
913918
}
914919

915-
for (y = 0 ; y < p->height; y++) {
916-
for (x = 0 ; x < p->width; x++) {
920+
for (y = 0 ; y < plane_info[0].height; y++) {
921+
for (x = 0 ; x < plane_info[0].width; x++) {
917922
unsigned int offset;
918923
u32 val = y << 16 | x;
919924

920925
if (*t == I915_GGTT_VIEW_ROTATED)
921-
offset = (x * p->height + y) * PAGE_SIZE;
926+
offset = (x * plane_info[0].height + y) * PAGE_SIZE;
922927
else
923-
offset = (y * p->width + x) * PAGE_SIZE;
928+
offset = (y * plane_info[0].width + x) * PAGE_SIZE;
924929

925930
iowrite32(val, &map[offset / sizeof(*map)]);
926931
}
@@ -943,8 +948,8 @@ static int igt_vma_remapped_gtt(void *arg)
943948
goto out;
944949
}
945950

946-
for (y = 0 ; y < p->height; y++) {
947-
for (x = 0 ; x < p->width; x++) {
951+
for (y = 0 ; y < plane_info[0].height; y++) {
952+
for (x = 0 ; x < plane_info[0].width; x++) {
948953
unsigned int offset, src_idx;
949954
u32 exp = y << 16 | x;
950955
u32 val;

0 commit comments

Comments
 (0)