summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/ttm/tests/ttm_device_test.c
diff options
context:
space:
mode:
authorTvrtko Ursulin <tvrtko.ursulin@igalia.com>2025-10-20 12:54:07 +0100
committerTvrtko Ursulin <tursulin@ursulin.net>2025-10-31 09:01:08 +0000
commit0af5b6a8f8dd41fd801bb0f2af3295d69ba8b7fe (patch)
tree916000b46e1064b84a3c6d062e230126a93d353b /drivers/gpu/drm/ttm/tests/ttm_device_test.c
parentd53adc244fbf965d7efeefb278ff8f2664bbe20e (diff)
drm/ttm: Replace multiple booleans with flags in pool init
Multiple consecutive boolean function arguments are usually not very readable. Replace the ones in ttm_pool_init() with flags with the additional benefit of soon being able to pass in more data with just this one code base churning cost. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com> Cc: Alex Deucher <alexander.deucher@amd.com> Cc: Christian König <christian.koenig@amd.com> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Tvrtko Ursulin <tursulin@ursulin.net> Link: https://lore.kernel.org/r/20251020115411.36818-3-tvrtko.ursulin@igalia.com
Diffstat (limited to 'drivers/gpu/drm/ttm/tests/ttm_device_test.c')
-rw-r--r--drivers/gpu/drm/ttm/tests/ttm_device_test.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/drivers/gpu/drm/ttm/tests/ttm_device_test.c b/drivers/gpu/drm/ttm/tests/ttm_device_test.c
index 1621903818e5..98648d5f20e7 100644
--- a/drivers/gpu/drm/ttm/tests/ttm_device_test.c
+++ b/drivers/gpu/drm/ttm/tests/ttm_device_test.c
@@ -7,11 +7,11 @@
#include <drm/ttm/ttm_placement.h>
#include "ttm_kunit_helpers.h"
+#include "../ttm_pool_internal.h"
struct ttm_device_test_case {
const char *description;
- bool use_dma_alloc;
- bool use_dma32;
+ unsigned int alloc_flags;
bool pools_init_expected;
};
@@ -119,26 +119,22 @@ static void ttm_device_init_no_vma_man(struct kunit *test)
static const struct ttm_device_test_case ttm_device_cases[] = {
{
.description = "No DMA allocations, no DMA32 required",
- .use_dma_alloc = false,
- .use_dma32 = false,
.pools_init_expected = false,
},
{
.description = "DMA allocations, DMA32 required",
- .use_dma_alloc = true,
- .use_dma32 = true,
+ .alloc_flags = TTM_ALLOCATION_POOL_USE_DMA_ALLOC |
+ TTM_ALLOCATION_POOL_USE_DMA32,
.pools_init_expected = true,
},
{
.description = "No DMA allocations, DMA32 required",
- .use_dma_alloc = false,
- .use_dma32 = true,
+ .alloc_flags = TTM_ALLOCATION_POOL_USE_DMA32,
.pools_init_expected = false,
},
{
.description = "DMA allocations, no DMA32 required",
- .use_dma_alloc = true,
- .use_dma32 = false,
+ .alloc_flags = TTM_ALLOCATION_POOL_USE_DMA_ALLOC,
.pools_init_expected = true,
},
};
@@ -163,15 +159,14 @@ static void ttm_device_init_pools(struct kunit *test)
KUNIT_ASSERT_NOT_NULL(test, ttm_dev);
err = ttm_device_kunit_init(priv, ttm_dev,
- params->use_dma_alloc,
- params->use_dma32);
+ params->alloc_flags & TTM_ALLOCATION_POOL_USE_DMA_ALLOC,
+ params->alloc_flags & TTM_ALLOCATION_POOL_USE_DMA32);
KUNIT_ASSERT_EQ(test, err, 0);
pool = &ttm_dev->pool;
KUNIT_ASSERT_NOT_NULL(test, pool);
KUNIT_EXPECT_PTR_EQ(test, pool->dev, priv->dev);
- KUNIT_EXPECT_EQ(test, pool->use_dma_alloc, params->use_dma_alloc);
- KUNIT_EXPECT_EQ(test, pool->use_dma32, params->use_dma32);
+ KUNIT_EXPECT_EQ(test, pool->alloc_flags, params->alloc_flags);
if (params->pools_init_expected) {
for (int i = 0; i < TTM_NUM_CACHING_TYPES; ++i) {
@@ -181,7 +176,7 @@ static void ttm_device_init_pools(struct kunit *test)
KUNIT_EXPECT_EQ(test, pt.caching, i);
KUNIT_EXPECT_EQ(test, pt.order, j);
- if (params->use_dma_alloc)
+ if (ttm_pool_uses_dma_alloc(pool))
KUNIT_ASSERT_FALSE(test,
list_empty(&pt.pages));
}