[CI 37/42] drm/xe/svm: Register xe memory region to drm layer
Oak Zeng
oak.zeng at intel.com
Thu Jun 13 04:24:24 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 | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/gpu/drm/xe/xe_tile.c b/drivers/gpu/drm/xe/xe_tile.c
index 109f3118e821..6c50df281b11 100644
--- a/drivers/gpu/drm/xe/xe_tile.c
+++ b/drivers/gpu/drm/xe/xe_tile.c
@@ -3,7 +3,9 @@
* Copyright © 2023 Intel Corporation
*/
+#include <linux/memremap.h>
#include <drm/drm_managed.h>
+#include <drm/drm_svm.h>
#include "xe_device.h"
#include "xe_ggtt.h"
@@ -14,6 +16,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 +145,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 +171,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 +186,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, MEMORY_DEVICE_PRIVATE);
+ }
+
return 0;
}
--
2.26.3
More information about the Intel-xe
mailing list