Store a host NUMA node in the BO and its tt, and pass it to
ttm_pool_alloc_node() on populate. It defaults to NUMA_NO_NODE, so no
functional change.

Signed-off-by: Himal Prasad Ghimiray <[email protected]>
---
 drivers/gpu/drm/xe/xe_bo.c       | 7 ++++++-
 drivers/gpu/drm/xe/xe_bo_types.h | 7 +++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index 42a6aa1a2e4a..b0760d5d6bad 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -394,6 +394,8 @@ struct xe_ttm_tt {
        struct sg_table *sg;
        /** @purgeable: Whether the content of the pages of @ttm is purgeable. 
*/
        bool purgeable;
+       /** @numa_node: Preferred host NUMA node for backing pages. */
+       s16 numa_node;
 };
 
 static int xe_tt_map_sg(struct xe_device *xe, struct ttm_tt *tt)
@@ -595,6 +597,7 @@ static struct ttm_tt *xe_ttm_tt_create(struct 
ttm_buffer_object *ttm_bo,
                return NULL;
 
        tt = &xe_tt->ttm;
+       xe_tt->numa_node = bo->numa_node;
 
        extra_pages = 0;
        if (xe_bo_needs_ccs_pages(bo))
@@ -676,7 +679,8 @@ static int xe_ttm_tt_populate(struct ttm_device *ttm_dev, 
struct ttm_tt *tt,
                err = ttm_tt_restore(ttm_dev, tt, ctx);
        } else {
                ttm_tt_clear_backed_up(tt);
-               err = ttm_pool_alloc(&ttm_dev->pool, tt, ctx);
+               err = ttm_pool_alloc_node(&ttm_dev->pool, tt, ctx,
+                                         xe_tt->numa_node);
        }
        if (err)
                return err;
@@ -2542,6 +2546,7 @@ struct xe_bo *xe_bo_init_locked(struct xe_device *xe, 
struct xe_bo *bo,
        bo->tile = tile;
        bo->flags = flags;
        bo->cpu_caching = cpu_caching;
+       bo->numa_node = NUMA_NO_NODE;
        bo->ttm.base.funcs = &xe_gem_object_funcs;
        bo->ttm.priority = XE_BO_PRIORITY_NORMAL;
        INIT_LIST_HEAD(&bo->pinned_link);
diff --git a/drivers/gpu/drm/xe/xe_bo_types.h b/drivers/gpu/drm/xe/xe_bo_types.h
index 0265fb314c77..91e1c541b616 100644
--- a/drivers/gpu/drm/xe/xe_bo_types.h
+++ b/drivers/gpu/drm/xe/xe_bo_types.h
@@ -112,6 +112,13 @@ struct xe_bo {
         */
        u16 cpu_caching;
 
+       /**
+        * @numa_node: Preferred host NUMA node for system-memory backing
+        * pages, or NUMA_NO_NODE to use the device-local node. Only honored
+        * for user objects with a system-memory placement.
+        */
+       s16 numa_node;
+
        /** @devmem_allocation: SVM device memory allocation */
        struct drm_pagemap_devmem devmem_allocation;
 
-- 
2.43.0

Reply via email to