[CI 38/43] drm/xe/svm: Register xe memory region to drm layer
Oak Zeng
oak.zeng at intel.com
Wed Jun 12 02:26:00 UTC 2024
Register xe memory region to drm layer for SVM purpose.
This will essentially create struct page backing for
xe device memory, which will be used by SVM functions.
Cc: Thomas Hellström <thomas.hellstrom at linux.intel.com>
Cc: Matthew Brost <matthew.brost at intel.com>
Cc: Brian Welty <brian.welty at intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray at intel.com>
Signed-off-by: Oak Zeng <oak.zeng at intel.com>
---
drivers/gpu/drm/xe/xe_tile.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/drivers/gpu/drm/xe/xe_tile.c b/drivers/gpu/drm/xe/xe_tile.c
index 109f3118e821..5daf02f5d0be 100644
--- a/drivers/gpu/drm/xe/xe_tile.c
+++ b/drivers/gpu/drm/xe/xe_tile.c
@@ -4,6 +4,7 @@
*/
#include <drm/drm_managed.h>
+#include <drm/drm_svm.h>
#include "xe_device.h"
#include "xe_ggtt.h"
@@ -14,6 +15,7 @@
#include "xe_tile_sysfs.h"
#include "xe_ttm_vram_mgr.h"
#include "xe_wa.h"
+#include "xe_svm.h"
/**
* DOC: Multi-tile Design
@@ -142,6 +144,15 @@ static int tile_ttm_mgr_init(struct xe_tile *tile)
return 0;
}
+static void __init_drm_mem_region_ops(struct drm_mem_region_ops *ops)
+{
+ ops->drm_mem_region_alloc_pages = &xe_svm_alloc_pages;
+ ops->drm_mem_region_free_page = &xe_svm_free_page;
+ ops->drm_mem_region_migrate = &xe_svm_migrate;
+ ops->drm_mem_region_pagemap_owner = &xe_svm_mem_region_to_pagemap_owner;
+ ops->drm_mem_region_get_device = &xe_mem_region_to_device;
+}
+
/**
* xe_tile_init_noalloc - Init tile up to the point where allocations can happen.
* @tile: The tile to initialize.
@@ -159,6 +170,8 @@ static int tile_ttm_mgr_init(struct xe_tile *tile)
int xe_tile_init_noalloc(struct xe_tile *tile)
{
int err;
+ struct xe_device *xe = tile_to_xe(tile);
+ struct drm_device *drm = &xe->drm;
err = tile_ttm_mgr_init(tile);
if (err)
@@ -172,6 +185,11 @@ int xe_tile_init_noalloc(struct xe_tile *tile)
err = xe_tile_sysfs_init(tile);
+ if (xe->info.has_usm) {
+ __init_drm_mem_region_ops(&tile->mem.vram.drm_mr.mr_ops);
+ drm_svm_register_mem_region(drm, &tile->mem.vram.drm_mr);
+ }
+
return 0;
}
--
2.26.3
More information about the Intel-xe
mailing list