Commit 6c55404d authored by Thomas Hellström's avatar Thomas Hellström
Browse files

drm/xe: Introduce CONFIG_DRM_XE_GPUSVM



Don't rely on CONFIG_DRM_GPUSVM because other drivers may enable it
causing us to compile in SVM support unintentionally.

Also take the opportunity to leave more code out of compilation if
!CONFIG_DRM_XE_GPUSVM and !CONFIG_DRM_XE_DEVMEM_MIRROR

v3:
- Fixes for compilation errors on 32-bit. This changes the Kconfig
  logic a bit.

Signed-off-by: default avatarThomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: default avatarMatthew Brost <matthew.brost@intel.com>
Link: https://lore.kernel.org/r/20250326080551.40201-2-thomas.hellstrom@linux.intel.com
parent cca9734e
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ config DRM_XE
	select DRM_TTM_HELPER
	select DRM_EXEC
	select DRM_GPUVM
	select DRM_GPUSVM if !UML && DEVICE_PRIVATE
	select DRM_SCHED
	select MMU_NOTIFIER
	select WANT_DEV_COREDUMP
@@ -74,9 +73,22 @@ config DRM_XE_DP_TUNNEL

	  If in doubt say "Y".

config DRM_XE_GPUSVM
	bool "Enable CPU to GPU address mirroring"
	depends on DRM_XE
	depends on !UML
	depends on DEVICE_PRIVATE
	default y
	select DRM_GPUSVM
	help
	  Enable this option if you want support for CPU to GPU address
	  mirroring.

	  If in doubut say "Y".

config DRM_XE_DEVMEM_MIRROR
	bool "Enable device memory mirror"
	depends on DRM_XE
	depends on DRM_XE_GPUSVM
	select GET_FREE_REGION
	default y
	help
+1 −1
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ xe-y += xe_bb.o \
	xe_wopcm.o

xe-$(CONFIG_HMM_MIRROR) += xe_hmm.o
xe-$(CONFIG_DRM_GPUSVM) += xe_svm.o
xe-$(CONFIG_DRM_XE_GPUSVM) += xe_svm.o

# graphics hardware monitoring (HWMON) support
xe-$(CONFIG_HWMON) += xe_hwmon.o
+4 −2
Original line number Diff line number Diff line
@@ -107,6 +107,9 @@ struct xe_vram_region {
	resource_size_t actual_physical_size;
	/** @mapping: pointer to VRAM mappable space */
	void __iomem *mapping;
	/** @ttm: VRAM TTM manager */
	struct xe_ttm_vram_mgr ttm;
#if IS_ENABLED(CONFIG_DRM_XE_DEVMEM_MIRROR)
	/** @pagemap: Used to remap device memory as ZONE_DEVICE */
	struct dev_pagemap pagemap;
	/**
@@ -120,8 +123,7 @@ struct xe_vram_region {
	 * This is generated when remap device memory as ZONE_DEVICE
	 */
	resource_size_t hpa_base;
	/** @ttm: VRAM TTM manager */
	struct xe_ttm_vram_mgr ttm;
#endif
};

/**
+3 −0
Original line number Diff line number Diff line
@@ -1544,6 +1544,7 @@ void xe_migrate_wait(struct xe_migrate *m)
		dma_fence_wait(m->fence, false);
}

#if IS_ENABLED(CONFIG_DRM_XE_DEVMEM_MIRROR)
static u32 pte_update_cmd_size(u64 size)
{
	u32 num_dword;
@@ -1719,6 +1720,8 @@ struct dma_fence *xe_migrate_from_vram(struct xe_migrate *m,
			       XE_MIGRATE_COPY_TO_SRAM);
}

#endif

#if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST)
#include "tests/xe_migrate.c"
#endif
+6 −0
Original line number Diff line number Diff line
@@ -1420,6 +1420,7 @@ static int xe_pt_userptr_pre_commit(struct xe_migrate_pt_update *pt_update)
	return err;
}

#if IS_ENABLED(CONFIG_DRM_XE_GPUSVM)
static int xe_pt_svm_pre_commit(struct xe_migrate_pt_update *pt_update)
{
	struct xe_vm *vm = pt_update->vops->vm;
@@ -1453,6 +1454,7 @@ static int xe_pt_svm_pre_commit(struct xe_migrate_pt_update *pt_update)

	return 0;
}
#endif

struct invalidation_fence {
	struct xe_gt_tlb_invalidation_fence base;
@@ -2257,11 +2259,15 @@ static const struct xe_migrate_pt_update_ops userptr_migrate_ops = {
	.pre_commit = xe_pt_userptr_pre_commit,
};

#if IS_ENABLED(CONFIG_DRM_XE_GPUSVM)
static const struct xe_migrate_pt_update_ops svm_migrate_ops = {
	.populate = xe_vm_populate_pgtable,
	.clear = xe_migrate_clear_pgtable_callback,
	.pre_commit = xe_pt_svm_pre_commit,
};
#else
static const struct xe_migrate_pt_update_ops svm_migrate_ops;
#endif

/**
 * xe_pt_update_ops_run() - Run PT update operations
Loading