[CI 16/44] drm/svm: Introduce DRM_SVM kernel config
Oak Zeng
oak.zeng at intel.com
Fri Jun 14 21:57:49 UTC 2024
Introduce a DRM_SVM kernel config entry for
DRM svm feature. DRM svm provides helpers for
driver to implement share virtual address space
between CPU and GPU program.
Cc: Daniel Vetter <daniel.vetter at intel.com>
Cc: Dave Airlie <airlied at redhat.com>
Cc: Thomas Hellström <thomas.hellstrom at linux.intel.com>
Cc: Christian König <christian.koenig at amd.com>
Cc: Felix Kuehling <felix.kuehling at amd.com>
Cc: Brian Welty <brian.welty at intel.com>
Cc: Krishna Bommu <krishnaiah.bommu at intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray at intel.com>
Cc: <dri-devel at lists.freedesktop.org>
Signed-off-by: Oak Zeng <oak.zeng at intel.com>
---
drivers/gpu/drm/Kconfig | 23 ++++++++++++++++++
drivers/gpu/drm/Makefile | 2 +-
include/drm/drm_svm.h | 50 ++++++++++++++++++++++++++++++++++++----
3 files changed, 70 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 981f43d4ca8c..2d9079f65ab0 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -312,6 +312,29 @@ config DRM_SCHED
tristate
depends on DRM
+config DRM_SVM
+ bool "Enable Shared Virtual Memory support in DRM"
+ depends on DRM
+ depends on ARCH_ENABLE_MEMORY_HOTPLUG
+ depends on ARCH_ENABLE_MEMORY_HOTREMOVE
+ depends on MEMORY_HOTPLUG
+ depends on MEMORY_HOTREMOVE
+ depends on ARCH_HAS_PTE_DEVMAP
+ depends on SPARSEMEM_VMEMMAP
+ depends on ZONE_DEVICE
+ depends on DEVICE_PRIVATE
+ depends on MMU
+ select HMM_MIRROR
+ select MMU_NOTIFIER
+ default y
+ help
+ Choose this option if you want Shared Virtual Memory (SVM)
+ and userptr support in DRM. With SVM, virtual address space
+ is shared between CPU and GPU program. This means any virtual
+ address such as malloc or mmap returned, variables on stack,
+ or global ointers, can be used for GPU program transparently.
+ If you are not sure, say yes.
+
source "drivers/gpu/drm/i2c/Kconfig"
source "drivers/gpu/drm/arm/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 1e4237d80cff..b129a25d404c 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -68,7 +68,6 @@ drm-y := \
drm_prime.o \
drm_print.o \
drm_property.o \
- drm_svm.o \
drm_syncobj.o \
drm_sysfs.o \
drm_trace_points.o \
@@ -91,6 +90,7 @@ drm-$(CONFIG_DRM_PRIVACY_SCREEN) += \
drm-$(CONFIG_DRM_ACCEL) += ../../accel/drm_accel.o
drm-$(CONFIG_DRM_PANIC) += drm_panic.o
obj-$(CONFIG_DRM) += drm.o
+obj-$(CONFIG_DRM_SVM) += drm_svm.o
obj-$(CONFIG_DRM_PANEL_ORIENTATION_QUIRKS) += drm_panel_orientation_quirks.o
diff --git a/include/drm/drm_svm.h b/include/drm/drm_svm.h
index 4a97ab030569..17888091d7f4 100644
--- a/include/drm/drm_svm.h
+++ b/include/drm/drm_svm.h
@@ -166,10 +166,6 @@ static inline u64 drm_mem_region_page_to_dpa(struct drm_mem_region *mr, struct p
return dpa;
}
-int drm_svm_register_mem_region(const struct drm_device *drm,
- struct drm_mem_region *mr,
- enum memory_type type);
-
/**
* struct drm_hmmptr- hmmptr pointer
*
@@ -220,6 +216,11 @@ struct drm_hmmptr {
struct drm_gpuva * (*get_gpuva)(struct drm_hmmptr *hmmptr);
};
+#if defined(CONFIG_DRM_SVM)
+int drm_svm_register_mem_region(const struct drm_device *drm,
+ struct drm_mem_region *mr,
+ enum memory_type type);
+
int drm_svm_hmmptr_init(struct drm_hmmptr *hmmptr,
const struct mmu_interval_notifier_ops *ops);
void drm_svm_hmmptr_release(struct drm_hmmptr *hmmptr);
@@ -233,4 +234,45 @@ int drm_svm_migrate_hmmptr_to_vram(struct drm_gpuvm *vm,
struct drm_mem_region *mr,
struct drm_hmmptr *hmmptr,
unsigned long start, unsigned long end);
+#else
+static inline int drm_svm_register_mem_region(const struct drm_device *drm,
+ struct drm_mem_region *mr,
+ enum memory_type type)
+{
+ DRM_WARN_ONCE("DRM_SVM kernel config is not enabled, "
+ "Add CONFIG_DRM_SVM in config file to fix this\n");
+ return -ENODEV;
+}
+
+static inline int drm_svm_hmmptr_init(struct drm_hmmptr *hmmptr,
+ const struct mmu_interval_notifier_ops *ops)
+{
+ DRM_WARN_ONCE("DRM_SVM kernel config is not enabled, "
+ "Add CONFIG_DRM_SVM in config file to fix this\n");
+ return -ENODEV;
+}
+static inline void drm_svm_hmmptr_release(struct drm_hmmptr *hmmptr) {}
+static inline void drm_svm_hmmptr_map_dma_pages(struct drm_hmmptr *hmmptr,
+ u64 page_idx, u64 npages) {}
+static inline void drm_svm_hmmptr_unmap_dma_pages(struct drm_hmmptr *hmmptr,
+ u64 page_idx, u64 npages) {}
+static inline int drm_svm_hmmptr_populate(struct drm_hmmptr *hmmptr, void *owner, u64 start,
+ u64 end, bool write, bool is_mmap_locked)
+{
+ DRM_WARN_ONCE("DRM_SVM kernel config is not enabled, "
+ "Add CONFIG_DRM_SVM in config file to fix this\n");
+ return -ENODEV;
+}
+
+static inline int drm_svm_migrate_hmmptr_to_vram(struct drm_gpuvm *vm,
+ struct drm_mem_region *mr,
+ struct drm_hmmptr *hmmptr,
+ unsigned long start, unsigned long end)
+{
+ DRM_WARN_ONCE("DRM_SVM kernel config is not enabled, "
+ "Add CONFIG_DRM_SVM in config file to fix this\n");
+ return -ENODEV;
+}
+#endif
+
#endif
--
2.26.3
More information about the Intel-xe
mailing list