mm, treewide: introduce NR_PAGE_ORDERS
authorjsg <jsg@openbsd.org>
Mon, 6 May 2024 01:59:03 +0000 (01:59 +0000)
committerjsg <jsg@openbsd.org>
Mon, 6 May 2024 01:59:03 +0000 (01:59 +0000)
From Kirill A. Shutemov
ded1ffea52132e58eaaa7d4ea39477f911796a40 in linux-6.6.y/6.6.30
fd37721803c6e73619108f76ad2e12a9aa5fafaf in mainline linux

sys/dev/pci/drm/include/drm/ttm/ttm_pool.h
sys/dev/pci/drm/ttm/tests/ttm_device_test.c
sys/dev/pci/drm/ttm/ttm_pool.c

index 0ffb28e..983fff1 100644 (file)
@@ -81,7 +81,7 @@ struct ttm_pool {
        bool use_dma32;
 
        struct {
-               struct ttm_pool_type orders[MAX_ORDER + 1];
+               struct ttm_pool_type orders[NR_PAGE_ORDERS];
        } caching[TTM_NUM_CACHING_TYPES];
 };
 
index b1b423b..19eaff2 100644 (file)
@@ -175,7 +175,7 @@ static void ttm_device_init_pools(struct kunit *test)
 
        if (params->pools_init_expected) {
                for (int i = 0; i < TTM_NUM_CACHING_TYPES; ++i) {
-                       for (int j = 0; j <= MAX_ORDER; ++j) {
+                       for (int j = 0; j < NR_PAGE_ORDERS; ++j) {
                                pt = pool->caching[i].orders[j];
                                KUNIT_EXPECT_PTR_EQ(test, pt.pool, pool);
                                KUNIT_EXPECT_EQ(test, pt.caching, i);
index 8b6f538..8c13211 100644 (file)
@@ -70,11 +70,11 @@ module_param(page_pool_size, ulong, 0644);
 
 static atomic_long_t allocated_pages;
 
-static struct ttm_pool_type global_write_combined[MAX_ORDER + 1];
-static struct ttm_pool_type global_uncached[MAX_ORDER + 1];
+static struct ttm_pool_type global_write_combined[NR_PAGE_ORDERS];
+static struct ttm_pool_type global_uncached[NR_PAGE_ORDERS];
 
-static struct ttm_pool_type global_dma32_write_combined[MAX_ORDER + 1];
-static struct ttm_pool_type global_dma32_uncached[MAX_ORDER + 1];
+static struct ttm_pool_type global_dma32_write_combined[NR_PAGE_ORDERS];
+static struct ttm_pool_type global_dma32_uncached[NR_PAGE_ORDERS];
 
 static spinlock_t shrinker_lock;
 static struct list_head shrinker_list;
@@ -712,7 +712,7 @@ void ttm_pool_init(struct ttm_pool *pool, struct device *dev,
 
        if (use_dma_alloc || nid != NUMA_NO_NODE) {
                for (i = 0; i < TTM_NUM_CACHING_TYPES; ++i)
-                       for (j = 0; j <= MAX_ORDER; ++j)
+                       for (j = 0; j < NR_PAGE_ORDERS; ++j)
                                ttm_pool_type_init(&pool->caching[i].orders[j],
                                                   pool, i, j);
        }
@@ -733,7 +733,7 @@ void ttm_pool_fini(struct ttm_pool *pool)
 
        if (pool->use_dma_alloc || pool->nid != NUMA_NO_NODE) {
                for (i = 0; i < TTM_NUM_CACHING_TYPES; ++i)
-                       for (j = 0; j <= MAX_ORDER; ++j)
+                       for (j = 0; j < NR_PAGE_ORDERS; ++j)
                                ttm_pool_type_fini(&pool->caching[i].orders[j]);
        }
 
@@ -795,7 +795,7 @@ static void ttm_pool_debugfs_header(struct seq_file *m)
        unsigned int i;
 
        seq_puts(m, "\t ");
-       for (i = 0; i <= MAX_ORDER; ++i)
+       for (i = 0; i < NR_PAGE_ORDERS; ++i)
                seq_printf(m, " ---%2u---", i);
        seq_puts(m, "\n");
 }
@@ -806,7 +806,7 @@ static void ttm_pool_debugfs_orders(struct ttm_pool_type *pt,
 {
        unsigned int i;
 
-       for (i = 0; i <= MAX_ORDER; ++i)
+       for (i = 0; i < NR_PAGE_ORDERS; ++i)
                seq_printf(m, " %8u", ttm_pool_type_count(&pt[i]));
        seq_puts(m, "\n");
 }
@@ -915,7 +915,7 @@ int ttm_pool_mgr_init(unsigned long num_pages)
        mtx_init(&shrinker_lock, IPL_NONE);
        INIT_LIST_HEAD(&shrinker_list);
 
-       for (i = 0; i <= MAX_ORDER; ++i) {
+       for (i = 0; i < NR_PAGE_ORDERS; ++i) {
                ttm_pool_type_init(&global_write_combined[i], NULL,
                                   ttm_write_combined, i);
                ttm_pool_type_init(&global_uncached[i], NULL, ttm_uncached, i);
@@ -948,7 +948,7 @@ void ttm_pool_mgr_fini(void)
 {
        unsigned int i;
 
-       for (i = 0; i <= MAX_ORDER; ++i) {
+       for (i = 0; i < NR_PAGE_ORDERS; ++i) {
                ttm_pool_type_fini(&global_write_combined[i]);
                ttm_pool_type_fini(&global_uncached[i]);