47
47
48
48
#include "ttm_module.h"
49
49
50
- #define TTM_MAX_ORDER (PMD_SHIFT - PAGE_SHIFT)
51
- #define __TTM_DIM_ORDER (TTM_MAX_ORDER + 1)
52
- /* Some architectures have a weird PMD_SHIFT */
53
- #define TTM_DIM_ORDER (__TTM_DIM_ORDER <= MAX_ORDER ? __TTM_DIM_ORDER : MAX_ORDER)
54
-
55
50
/**
56
51
* struct ttm_pool_dma - Helper object for coherent DMA mappings
57
52
*
@@ -70,11 +65,11 @@ module_param(page_pool_size, ulong, 0644);
70
65
71
66
static atomic_long_t allocated_pages ;
72
67
73
- static struct ttm_pool_type global_write_combined [TTM_DIM_ORDER ];
74
- static struct ttm_pool_type global_uncached [TTM_DIM_ORDER ];
68
+ static struct ttm_pool_type global_write_combined [MAX_ORDER ];
69
+ static struct ttm_pool_type global_uncached [MAX_ORDER ];
75
70
76
- static struct ttm_pool_type global_dma32_write_combined [TTM_DIM_ORDER ];
77
- static struct ttm_pool_type global_dma32_uncached [TTM_DIM_ORDER ];
71
+ static struct ttm_pool_type global_dma32_write_combined [MAX_ORDER ];
72
+ static struct ttm_pool_type global_dma32_uncached [MAX_ORDER ];
78
73
79
74
static spinlock_t shrinker_lock ;
80
75
static struct list_head shrinker_list ;
@@ -449,7 +444,7 @@ int ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt,
449
444
else
450
445
gfp_flags |= GFP_HIGHUSER ;
451
446
452
- for (order = min_t (unsigned int , TTM_MAX_ORDER , __fls (num_pages ));
447
+ for (order = min_t (unsigned int , MAX_ORDER - 1 , __fls (num_pages ));
453
448
num_pages ;
454
449
order = min_t (unsigned int , order , __fls (num_pages ))) {
455
450
struct ttm_pool_type * pt ;
@@ -568,7 +563,7 @@ void ttm_pool_init(struct ttm_pool *pool, struct device *dev,
568
563
569
564
if (use_dma_alloc ) {
570
565
for (i = 0 ; i < TTM_NUM_CACHING_TYPES ; ++ i )
571
- for (j = 0 ; j < TTM_DIM_ORDER ; ++ j )
566
+ for (j = 0 ; j < MAX_ORDER ; ++ j )
572
567
ttm_pool_type_init (& pool -> caching [i ].orders [j ],
573
568
pool , i , j );
574
569
}
@@ -588,7 +583,7 @@ void ttm_pool_fini(struct ttm_pool *pool)
588
583
589
584
if (pool -> use_dma_alloc ) {
590
585
for (i = 0 ; i < TTM_NUM_CACHING_TYPES ; ++ i )
591
- for (j = 0 ; j < TTM_DIM_ORDER ; ++ j )
586
+ for (j = 0 ; j < MAX_ORDER ; ++ j )
592
587
ttm_pool_type_fini (& pool -> caching [i ].orders [j ]);
593
588
}
594
589
@@ -642,7 +637,7 @@ static void ttm_pool_debugfs_header(struct seq_file *m)
642
637
unsigned int i ;
643
638
644
639
seq_puts (m , "\t " );
645
- for (i = 0 ; i < TTM_DIM_ORDER ; ++ i )
640
+ for (i = 0 ; i < MAX_ORDER ; ++ i )
646
641
seq_printf (m , " ---%2u---" , i );
647
642
seq_puts (m , "\n" );
648
643
}
@@ -653,7 +648,7 @@ static void ttm_pool_debugfs_orders(struct ttm_pool_type *pt,
653
648
{
654
649
unsigned int i ;
655
650
656
- for (i = 0 ; i < TTM_DIM_ORDER ; ++ i )
651
+ for (i = 0 ; i < MAX_ORDER ; ++ i )
657
652
seq_printf (m , " %8u" , ttm_pool_type_count (& pt [i ]));
658
653
seq_puts (m , "\n" );
659
654
}
@@ -756,16 +751,13 @@ int ttm_pool_mgr_init(unsigned long num_pages)
756
751
{
757
752
unsigned int i ;
758
753
759
- BUILD_BUG_ON (TTM_DIM_ORDER > MAX_ORDER );
760
- BUILD_BUG_ON (TTM_DIM_ORDER < 1 );
761
-
762
754
if (!page_pool_size )
763
755
page_pool_size = num_pages ;
764
756
765
757
spin_lock_init (& shrinker_lock );
766
758
INIT_LIST_HEAD (& shrinker_list );
767
759
768
- for (i = 0 ; i < TTM_DIM_ORDER ; ++ i ) {
760
+ for (i = 0 ; i < MAX_ORDER ; ++ i ) {
769
761
ttm_pool_type_init (& global_write_combined [i ], NULL ,
770
762
ttm_write_combined , i );
771
763
ttm_pool_type_init (& global_uncached [i ], NULL , ttm_uncached , i );
@@ -798,7 +790,7 @@ void ttm_pool_mgr_fini(void)
798
790
{
799
791
unsigned int i ;
800
792
801
- for (i = 0 ; i < TTM_DIM_ORDER ; ++ i ) {
793
+ for (i = 0 ; i < MAX_ORDER ; ++ i ) {
802
794
ttm_pool_type_fini (& global_write_combined [i ]);
803
795
ttm_pool_type_fini (& global_uncached [i ]);
804
796
0 commit comments