Skip to content

Commit 25926cd

Browse files
committed
drm/i915/selftest: Add remap/rotate vma subtests when dst_stride!=width/height
Add selftests to test the POT stride padding functionality added in the previous patch. 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 a4606d4 commit 25926cd

File tree

1 file changed

+86
-7
lines changed

1 file changed

+86
-7
lines changed

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

Lines changed: 86 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ assert_rotated(struct drm_i915_gem_object *obj,
373373
unsigned int x, y;
374374

375375
for (x = 0; x < r->plane[n].width; x++) {
376+
unsigned int left;
377+
376378
for (y = 0; y < r->plane[n].height; y++) {
377379
unsigned long src_idx;
378380
dma_addr_t src;
@@ -401,6 +403,31 @@ assert_rotated(struct drm_i915_gem_object *obj,
401403

402404
sg = sg_next(sg);
403405
}
406+
407+
left = (r->plane[n].dst_stride - y) * PAGE_SIZE;
408+
409+
if (!left)
410+
continue;
411+
412+
if (!sg) {
413+
pr_err("Invalid sg table: too short at plane %d, (%d, %d)!\n",
414+
n, x, y);
415+
return ERR_PTR(-EINVAL);
416+
}
417+
418+
if (sg_dma_len(sg) != left) {
419+
pr_err("Invalid sg.length, found %d, expected %u for rotated page (%d, %d)\n",
420+
sg_dma_len(sg), left, x, y);
421+
return ERR_PTR(-EINVAL);
422+
}
423+
424+
if (sg_dma_address(sg) != 0) {
425+
pr_err("Invalid address, found %pad, expected 0 for remapped page (%d, %d)\n",
426+
&sg_dma_address(sg), x, y);
427+
return ERR_PTR(-EINVAL);
428+
}
429+
430+
sg = sg_next(sg);
404431
}
405432

406433
return sg;
@@ -462,15 +489,55 @@ assert_remapped(struct drm_i915_gem_object *obj,
462489
if (!left)
463490
sg = sg_next(sg);
464491
}
492+
493+
if (left) {
494+
pr_err("Unexpected sg tail with %d size for remapped page (%d, %d)\n",
495+
left,
496+
x, y);
497+
return ERR_PTR(-EINVAL);
498+
}
499+
500+
left = (r->plane[n].dst_stride - r->plane[n].width) * PAGE_SIZE;
501+
502+
if (!left)
503+
continue;
504+
505+
if (!sg) {
506+
pr_err("Invalid sg table: too short at plane %d, (%d, %d)!\n",
507+
n, x, y);
508+
return ERR_PTR(-EINVAL);
509+
}
510+
511+
if (sg_dma_len(sg) != left) {
512+
pr_err("Invalid sg.length, found %u, expected %u for remapped page (%d, %d)\n",
513+
sg_dma_len(sg), left,
514+
x, y);
515+
return ERR_PTR(-EINVAL);
516+
}
517+
518+
if (sg_dma_address(sg) != 0) {
519+
pr_err("Invalid address, found %pad, expected 0 for remapped page (%d, %d)\n",
520+
&sg_dma_address(sg),
521+
x, y);
522+
return ERR_PTR(-EINVAL);
523+
}
524+
525+
sg = sg_next(sg);
526+
left = 0;
465527
}
466528

467529
return sg;
468530
}
469531

470-
static unsigned int rotated_size(const struct intel_remapped_plane_info *a,
471-
const struct intel_remapped_plane_info *b)
532+
static unsigned int remapped_size(enum i915_ggtt_view_type view_type,
533+
const struct intel_remapped_plane_info *a,
534+
const struct intel_remapped_plane_info *b)
472535
{
473-
return a->width * a->height + b->width * b->height;
536+
537+
if (view_type == I915_GGTT_VIEW_ROTATED)
538+
return a->dst_stride * a->width + b->dst_stride * b->width;
539+
else
540+
return a->dst_stride * a->height + b->dst_stride * b->height;
474541
}
475542

476543
static int igt_vma_rotate_remap(void *arg)
@@ -494,6 +561,11 @@ static int igt_vma_rotate_remap(void *arg)
494561

495562
{ .width = 4, .height = 6, .src_stride = 6 },
496563
{ .width = 6, .height = 4, .src_stride = 6 },
564+
565+
{ .width = 2, .height = 2, .src_stride = 2, .dst_stride = 2 },
566+
{ .width = 3, .height = 3, .src_stride = 3, .dst_stride = 4 },
567+
{ .width = 5, .height = 6, .src_stride = 7, .dst_stride = 8 },
568+
497569
{ }
498570
}, *a, *b;
499571
enum i915_ggtt_view_type types[] = {
@@ -555,7 +627,7 @@ static int igt_vma_rotate_remap(void *arg)
555627
goto out_object;
556628
}
557629

558-
expected_pages = rotated_size(&plane_info[0], &plane_info[1]);
630+
expected_pages = remapped_size(view.type, &plane_info[0], &plane_info[1]);
559631

560632
if (view.type == I915_GGTT_VIEW_ROTATED &&
561633
vma->size != expected_pages * PAGE_SIZE) {
@@ -600,16 +672,18 @@ static int igt_vma_rotate_remap(void *arg)
600672
else
601673
sg = assert_remapped(obj, &view.remapped, n, sg);
602674
if (IS_ERR(sg)) {
603-
pr_err("Inconsistent %s VMA pages for plane %d: [(%d, %d, %d, %d), (%d, %d, %d, %d)]\n",
675+
pr_err("Inconsistent %s VMA pages for plane %d: [(%d, %d, %d, %d, %d), (%d, %d, %d, %d, %d)]\n",
604676
view.type == I915_GGTT_VIEW_ROTATED ?
605677
"rotated" : "remapped", n,
606678
plane_info[0].width,
607679
plane_info[0].height,
608680
plane_info[0].src_stride,
681+
plane_info[0].dst_stride,
609682
plane_info[0].offset,
610683
plane_info[1].width,
611684
plane_info[1].height,
612685
plane_info[1].src_stride,
686+
plane_info[1].dst_stride,
613687
plane_info[1].offset);
614688
err = -EINVAL;
615689
goto out_object;
@@ -877,6 +951,11 @@ static int igt_vma_remapped_gtt(void *arg)
877951

878952
{ .width = 4, .height = 6, .src_stride = 6 },
879953
{ .width = 6, .height = 4, .src_stride = 6 },
954+
955+
{ .width = 2, .height = 2, .src_stride = 2, .dst_stride = 2 },
956+
{ .width = 3, .height = 3, .src_stride = 3, .dst_stride = 4 },
957+
{ .width = 5, .height = 6, .src_stride = 7, .dst_stride = 8 },
958+
880959
{ }
881960
}, *p;
882961
enum i915_ggtt_view_type types[] = {
@@ -936,9 +1015,9 @@ static int igt_vma_remapped_gtt(void *arg)
9361015
u32 val = y << 16 | x;
9371016

9381017
if (*t == I915_GGTT_VIEW_ROTATED)
939-
offset = (x * plane_info[0].height + y) * PAGE_SIZE;
1018+
offset = (x * plane_info[0].dst_stride + y) * PAGE_SIZE;
9401019
else
941-
offset = (y * plane_info[0].width + x) * PAGE_SIZE;
1020+
offset = (y * plane_info[0].dst_stride + x) * PAGE_SIZE;
9421021

9431022
iowrite32(val, &map[offset / sizeof(*map)]);
9441023
}

0 commit comments

Comments
 (0)