@@ -373,6 +373,8 @@ assert_rotated(struct drm_i915_gem_object *obj,
373
373
unsigned int x , y ;
374
374
375
375
for (x = 0 ; x < r -> plane [n ].width ; x ++ ) {
376
+ unsigned int left ;
377
+
376
378
for (y = 0 ; y < r -> plane [n ].height ; y ++ ) {
377
379
unsigned long src_idx ;
378
380
dma_addr_t src ;
@@ -401,6 +403,31 @@ assert_rotated(struct drm_i915_gem_object *obj,
401
403
402
404
sg = sg_next (sg );
403
405
}
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 );
404
431
}
405
432
406
433
return sg ;
@@ -462,15 +489,55 @@ assert_remapped(struct drm_i915_gem_object *obj,
462
489
if (!left )
463
490
sg = sg_next (sg );
464
491
}
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 ;
465
527
}
466
528
467
529
return sg ;
468
530
}
469
531
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 )
472
535
{
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 ;
474
541
}
475
542
476
543
static int igt_vma_rotate_remap (void * arg )
@@ -494,6 +561,11 @@ static int igt_vma_rotate_remap(void *arg)
494
561
495
562
{ .width = 4 , .height = 6 , .src_stride = 6 },
496
563
{ .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
+
497
569
{ }
498
570
}, * a , * b ;
499
571
enum i915_ggtt_view_type types [] = {
@@ -555,7 +627,7 @@ static int igt_vma_rotate_remap(void *arg)
555
627
goto out_object ;
556
628
}
557
629
558
- expected_pages = rotated_size ( & plane_info [0 ], & plane_info [1 ]);
630
+ expected_pages = remapped_size ( view . type , & plane_info [0 ], & plane_info [1 ]);
559
631
560
632
if (view .type == I915_GGTT_VIEW_ROTATED &&
561
633
vma -> size != expected_pages * PAGE_SIZE ) {
@@ -600,16 +672,18 @@ static int igt_vma_rotate_remap(void *arg)
600
672
else
601
673
sg = assert_remapped (obj , & view .remapped , n , sg );
602
674
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" ,
604
676
view .type == I915_GGTT_VIEW_ROTATED ?
605
677
"rotated" : "remapped" , n ,
606
678
plane_info [0 ].width ,
607
679
plane_info [0 ].height ,
608
680
plane_info [0 ].src_stride ,
681
+ plane_info [0 ].dst_stride ,
609
682
plane_info [0 ].offset ,
610
683
plane_info [1 ].width ,
611
684
plane_info [1 ].height ,
612
685
plane_info [1 ].src_stride ,
686
+ plane_info [1 ].dst_stride ,
613
687
plane_info [1 ].offset );
614
688
err = - EINVAL ;
615
689
goto out_object ;
@@ -877,6 +951,11 @@ static int igt_vma_remapped_gtt(void *arg)
877
951
878
952
{ .width = 4 , .height = 6 , .src_stride = 6 },
879
953
{ .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
+
880
959
{ }
881
960
}, * p ;
882
961
enum i915_ggtt_view_type types [] = {
@@ -936,9 +1015,9 @@ static int igt_vma_remapped_gtt(void *arg)
936
1015
u32 val = y << 16 | x ;
937
1016
938
1017
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 ;
940
1019
else
941
- offset = (y * plane_info [0 ].width + x ) * PAGE_SIZE ;
1020
+ offset = (y * plane_info [0 ].dst_stride + x ) * PAGE_SIZE ;
942
1021
943
1022
iowrite32 (val , & map [offset / sizeof (* map )]);
944
1023
}
0 commit comments