With the node selectable per allocation through ttm_operation_ctx and amdgpu converted, no caller picks a node per pool anymore. Remove the nid argument and derive the pool's default node from the device, as ttm_device_init() already did, so there is a single way to choose a node.
Signed-off-by: Himal Prasad Ghimiray <[email protected]> --- drivers/gpu/drm/ttm/tests/ttm_pool_test.c | 10 +++++----- drivers/gpu/drm/ttm/ttm_device.c | 9 ++------- drivers/gpu/drm/ttm/ttm_pool.c | 9 +++++---- include/drm/ttm/ttm_pool.h | 4 ++-- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/ttm/tests/ttm_pool_test.c b/drivers/gpu/drm/ttm/tests/ttm_pool_test.c index be75c8abf388..5497672173a2 100644 --- a/drivers/gpu/drm/ttm/tests/ttm_pool_test.c +++ b/drivers/gpu/drm/ttm/tests/ttm_pool_test.c @@ -87,7 +87,7 @@ static struct ttm_pool *ttm_pool_pre_populated(struct kunit *test, pool = kunit_kzalloc(test, sizeof(*pool), GFP_KERNEL); KUNIT_ASSERT_NOT_NULL(test, pool); - ttm_pool_init(pool, devs->dev, NUMA_NO_NODE, TTM_ALLOCATION_POOL_USE_DMA_ALLOC); + ttm_pool_init(pool, devs->dev, TTM_ALLOCATION_POOL_USE_DMA_ALLOC); err = ttm_pool_alloc(pool, tt, &simple_ctx); KUNIT_ASSERT_EQ(test, err, 0); @@ -151,7 +151,7 @@ static void ttm_pool_alloc_basic(struct kunit *test) pool = kunit_kzalloc(test, sizeof(*pool), GFP_KERNEL); KUNIT_ASSERT_NOT_NULL(test, pool); - ttm_pool_init(pool, devs->dev, NUMA_NO_NODE, params->alloc_flags); + ttm_pool_init(pool, devs->dev, params->alloc_flags); KUNIT_ASSERT_PTR_EQ(test, pool->dev, devs->dev); KUNIT_ASSERT_EQ(test, pool->nid, NUMA_NO_NODE); @@ -218,7 +218,7 @@ static void ttm_pool_alloc_basic_dma_addr(struct kunit *test) pool = kunit_kzalloc(test, sizeof(*pool), GFP_KERNEL); KUNIT_ASSERT_NOT_NULL(test, pool); - ttm_pool_init(pool, devs->dev, NUMA_NO_NODE, TTM_ALLOCATION_POOL_USE_DMA_ALLOC); + ttm_pool_init(pool, devs->dev, TTM_ALLOCATION_POOL_USE_DMA_ALLOC); err = ttm_pool_alloc(pool, tt, &simple_ctx); KUNIT_ASSERT_EQ(test, err, 0); @@ -348,7 +348,7 @@ static void ttm_pool_free_dma_alloc(struct kunit *test) pool = kunit_kzalloc(test, sizeof(*pool), GFP_KERNEL); KUNIT_ASSERT_NOT_NULL(test, pool); - ttm_pool_init(pool, devs->dev, NUMA_NO_NODE, TTM_ALLOCATION_POOL_USE_DMA_ALLOC); + ttm_pool_init(pool, devs->dev, TTM_ALLOCATION_POOL_USE_DMA_ALLOC); ttm_pool_alloc(pool, tt, &simple_ctx); pt = &pool->caching[caching].orders[order]; @@ -378,7 +378,7 @@ static void ttm_pool_free_no_dma_alloc(struct kunit *test) pool = kunit_kzalloc(test, sizeof(*pool), GFP_KERNEL); KUNIT_ASSERT_NOT_NULL(test, pool); - ttm_pool_init(pool, devs->dev, NUMA_NO_NODE, 0); + ttm_pool_init(pool, devs->dev, 0); ttm_pool_alloc(pool, tt, &simple_ctx); ttm_pool_free(pool, tt); diff --git a/drivers/gpu/drm/ttm/ttm_device.c b/drivers/gpu/drm/ttm/ttm_device.c index d3bfb9a696a7..4ba07254f5fd 100644 --- a/drivers/gpu/drm/ttm/ttm_device.c +++ b/drivers/gpu/drm/ttm/ttm_device.c @@ -208,7 +208,7 @@ int ttm_device_init(struct ttm_device *bdev, const struct ttm_device_funcs *func unsigned int alloc_flags) { struct ttm_global *glob = &ttm_glob; - int ret, nid; + int ret; if (WARN_ON(vma_manager == NULL)) return -EINVAL; @@ -229,12 +229,7 @@ int ttm_device_init(struct ttm_device *bdev, const struct ttm_device_funcs *func ttm_sys_man_init(bdev); - if (dev) - nid = dev_to_node(dev); - else - nid = NUMA_NO_NODE; - - ttm_pool_init(&bdev->pool, dev, nid, alloc_flags); + ttm_pool_init(&bdev->pool, dev, alloc_flags); bdev->vma_manager = vma_manager; spin_lock_init(&bdev->lru_lock); diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c index 4ab37af0f1ba..4262e4b6fb64 100644 --- a/drivers/gpu/drm/ttm/ttm_pool.c +++ b/drivers/gpu/drm/ttm/ttm_pool.c @@ -1414,20 +1414,21 @@ long ttm_pool_backup(struct ttm_pool *pool, struct ttm_tt *tt, * * @pool: the pool to initialize * @dev: device for DMA allocations and mappings - * @nid: NUMA node to use for allocations * @alloc_flags: TTM_ALLOCATION_POOL_* flags * - * Initialize the pool and its pool types. + * Initialize the pool and its pool types. The pool allocates on @dev's NUMA + * node unless the caller selects one per allocation through + * &ttm_operation_ctx.numa_info. */ void ttm_pool_init(struct ttm_pool *pool, struct device *dev, - int nid, unsigned int alloc_flags) + unsigned int alloc_flags) { unsigned int i, j; WARN_ON(!dev && ttm_pool_uses_dma_alloc(pool)); pool->dev = dev; - pool->nid = nid; + pool->nid = dev ? dev_to_node(dev) : NUMA_NO_NODE; pool->alloc_flags = alloc_flags; for (i = 0; i < TTM_NUM_CACHING_TYPES; ++i) { diff --git a/include/drm/ttm/ttm_pool.h b/include/drm/ttm/ttm_pool.h index 26ee592e1994..863e8f7af948 100644 --- a/include/drm/ttm/ttm_pool.h +++ b/include/drm/ttm/ttm_pool.h @@ -62,7 +62,7 @@ struct ttm_pool_type { * struct ttm_pool - Pool for all caching and orders * * @dev: the device we allocate pages for - * @nid: which numa node to use + * @nid: default NUMA node, derived from @dev * @alloc_flags: TTM_ALLOCATION_POOL_* flags * @caching: pools for each caching/order */ @@ -82,7 +82,7 @@ int ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt, void ttm_pool_free(struct ttm_pool *pool, struct ttm_tt *tt); void ttm_pool_init(struct ttm_pool *pool, struct device *dev, - int nid, unsigned int alloc_flags); + unsigned int alloc_flags); void ttm_pool_fini(struct ttm_pool *pool); int ttm_pool_debugfs(struct ttm_pool *pool, struct seq_file *m); -- 2.43.0
