@@ -515,22 +515,24 @@ static int igt_vma_rotate_remap(void *arg)
515
515
for (t = types ; * t ; t ++ ) {
516
516
for (a = planes ; a -> width ; a ++ ) {
517
517
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 ;
519
524
unsigned int n , max_offset ;
520
525
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 );
523
528
GEM_BUG_ON (max_offset > max_pages );
524
529
max_offset = max_pages - max_offset ;
525
530
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 ) {
532
533
struct scatterlist * sg ;
533
534
struct i915_vma * vma ;
535
+ unsigned int expected_pages ;
534
536
535
537
vma = checked_vma_instance (obj , vm , & view );
536
538
if (IS_ERR (vma )) {
@@ -544,25 +546,27 @@ static int igt_vma_rotate_remap(void *arg)
544
546
goto out_object ;
545
547
}
546
548
549
+ expected_pages = rotated_size (& plane_info [0 ], & plane_info [1 ]);
550
+
547
551
if (view .type == I915_GGTT_VIEW_ROTATED &&
548
- vma -> size != rotated_size ( a , b ) * PAGE_SIZE ) {
552
+ vma -> size != expected_pages * PAGE_SIZE ) {
549
553
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 );
551
555
err = - EINVAL ;
552
556
goto out_object ;
553
557
}
554
558
555
559
if (view .type == I915_GGTT_VIEW_REMAPPED &&
556
- vma -> size > rotated_size ( a , b ) * PAGE_SIZE ) {
560
+ vma -> size > expected_pages * PAGE_SIZE ) {
557
561
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 );
559
563
err = - EINVAL ;
560
564
goto out_object ;
561
565
}
562
566
563
- if (vma -> pages -> nents > rotated_size ( a , b ) ) {
567
+ if (vma -> pages -> nents > expected_pages ) {
564
568
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 );
566
570
err = - EINVAL ;
567
571
goto out_object ;
568
572
}
@@ -590,14 +594,14 @@ static int igt_vma_rotate_remap(void *arg)
590
594
pr_err ("Inconsistent %s VMA pages for plane %d: [(%d, %d, %d, %d), (%d, %d, %d, %d)]\n" ,
591
595
view .type == I915_GGTT_VIEW_ROTATED ?
592
596
"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 );
601
605
err = - EINVAL ;
602
606
goto out_object ;
603
607
}
@@ -887,6 +891,7 @@ static int igt_vma_remapped_gtt(void *arg)
887
891
.type = * t ,
888
892
.rotated .plane [0 ] = * p ,
889
893
};
894
+ struct intel_remapped_plane_info * plane_info = view .rotated .plane ;
890
895
struct i915_vma * vma ;
891
896
u32 __iomem * map ;
892
897
unsigned int x , y ;
@@ -912,15 +917,15 @@ static int igt_vma_remapped_gtt(void *arg)
912
917
goto out ;
913
918
}
914
919
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 ++ ) {
917
922
unsigned int offset ;
918
923
u32 val = y << 16 | x ;
919
924
920
925
if (* t == I915_GGTT_VIEW_ROTATED )
921
- offset = (x * p -> height + y ) * PAGE_SIZE ;
926
+ offset = (x * plane_info [ 0 ]. height + y ) * PAGE_SIZE ;
922
927
else
923
- offset = (y * p -> width + x ) * PAGE_SIZE ;
928
+ offset = (y * plane_info [ 0 ]. width + x ) * PAGE_SIZE ;
924
929
925
930
iowrite32 (val , & map [offset / sizeof (* map )]);
926
931
}
@@ -943,8 +948,8 @@ static int igt_vma_remapped_gtt(void *arg)
943
948
goto out ;
944
949
}
945
950
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 ++ ) {
948
953
unsigned int offset , src_idx ;
949
954
u32 exp = y << 16 | x ;
950
955
u32 val ;
0 commit comments