Skip to content

Commit 4482d3c

Browse files
rajbharalexdeucher
authored andcommitted
drm/ttm: add NUMA node id to the pool
This allows backing ttm_tt structure with pages from different NUMA pools. Tested-by: Graham Sider <[email protected]> Reviewed-by: Felix Kuehling <[email protected]> Signed-off-by: Christian König <[email protected]> Signed-off-by: Rajneesh Bhardwaj <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent c1d3f62 commit 4482d3c

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

drivers/gpu/drm/ttm/ttm_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ int ttm_device_init(struct ttm_device *bdev, struct ttm_device_funcs *funcs,
213213
bdev->funcs = funcs;
214214

215215
ttm_sys_man_init(bdev);
216-
ttm_pool_init(&bdev->pool, dev, use_dma_alloc, use_dma32);
216+
ttm_pool_init(&bdev->pool, dev, NUMA_NO_NODE, use_dma_alloc, use_dma32);
217217

218218
bdev->vma_manager = vma_manager;
219219
spin_lock_init(&bdev->lru_lock);

drivers/gpu/drm/ttm/ttm_pool.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags,
9898
__GFP_KSWAPD_RECLAIM;
9999

100100
if (!pool->use_dma_alloc) {
101-
p = alloc_pages(gfp_flags, order);
101+
p = alloc_pages_node(pool->nid, gfp_flags, order);
102102
if (p)
103103
p->private = order;
104104
return p;
@@ -292,7 +292,7 @@ static struct ttm_pool_type *ttm_pool_select_type(struct ttm_pool *pool,
292292
enum ttm_caching caching,
293293
unsigned int order)
294294
{
295-
if (pool->use_dma_alloc)
295+
if (pool->use_dma_alloc || pool->nid != NUMA_NO_NODE)
296296
return &pool->caching[caching].orders[order];
297297

298298
#ifdef CONFIG_X86
@@ -550,29 +550,32 @@ EXPORT_SYMBOL(ttm_pool_free);
550550
*
551551
* @pool: the pool to initialize
552552
* @dev: device for DMA allocations and mappings
553+
* @nid: NUMA node to use for allocations
553554
* @use_dma_alloc: true if coherent DMA alloc should be used
554555
* @use_dma32: true if GFP_DMA32 should be used
555556
*
556557
* Initialize the pool and its pool types.
557558
*/
558559
void ttm_pool_init(struct ttm_pool *pool, struct device *dev,
559-
bool use_dma_alloc, bool use_dma32)
560+
int nid, bool use_dma_alloc, bool use_dma32)
560561
{
561562
unsigned int i, j;
562563

563564
WARN_ON(!dev && use_dma_alloc);
564565

565566
pool->dev = dev;
567+
pool->nid = nid;
566568
pool->use_dma_alloc = use_dma_alloc;
567569
pool->use_dma32 = use_dma32;
568570

569-
if (use_dma_alloc) {
571+
if (use_dma_alloc || nid != NUMA_NO_NODE) {
570572
for (i = 0; i < TTM_NUM_CACHING_TYPES; ++i)
571573
for (j = 0; j < TTM_DIM_ORDER; ++j)
572574
ttm_pool_type_init(&pool->caching[i].orders[j],
573575
pool, i, j);
574576
}
575577
}
578+
EXPORT_SYMBOL(ttm_pool_init);
576579

577580
/**
578581
* ttm_pool_fini - Cleanup a pool
@@ -586,7 +589,7 @@ void ttm_pool_fini(struct ttm_pool *pool)
586589
{
587590
unsigned int i, j;
588591

589-
if (pool->use_dma_alloc) {
592+
if (pool->use_dma_alloc || pool->nid != NUMA_NO_NODE) {
590593
for (i = 0; i < TTM_NUM_CACHING_TYPES; ++i)
591594
for (j = 0; j < TTM_DIM_ORDER; ++j)
592595
ttm_pool_type_fini(&pool->caching[i].orders[j]);

include/drm/ttm/ttm_pool.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@ struct ttm_pool_type {
6161
* struct ttm_pool - Pool for all caching and orders
6262
*
6363
* @dev: the device we allocate pages for
64+
* @nid: which numa node to use
6465
* @use_dma_alloc: if coherent DMA allocations should be used
6566
* @use_dma32: if GFP_DMA32 should be used
6667
* @caching: pools for each caching/order
6768
*/
6869
struct ttm_pool {
6970
struct device *dev;
71+
int nid;
7072

7173
bool use_dma_alloc;
7274
bool use_dma32;
@@ -81,7 +83,7 @@ int ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt,
8183
void ttm_pool_free(struct ttm_pool *pool, struct ttm_tt *tt);
8284

8385
void ttm_pool_init(struct ttm_pool *pool, struct device *dev,
84-
bool use_dma_alloc, bool use_dma32);
86+
int nid, bool use_dma_alloc, bool use_dma32);
8587
void ttm_pool_fini(struct ttm_pool *pool);
8688

8789
int ttm_pool_debugfs(struct ttm_pool *pool, struct seq_file *m);

0 commit comments

Comments
 (0)