On Wed, Jun 03, 2026 at 02:56:20PM +0800, Honglei Huang wrote: > From: Honglei Huang <[email protected]> > > The core mechanism of drm_gpusvm is HMM, which is fundamentally an > MM side subsystem. A drm_device, enters the picture on the device side at > DMA mapping / GPU bind. > > So drop struct drm_device from struct drm_gpusvm. Let drm_gpusvm keep > its core neutral and leave device side decisions to the driver. > Make drm_gpusvm a pure MM level object. > > - Drop the drm from struct drm_gpusvm > - Drop the drm parameter from drm_gpusvm_init() > - Update the xe call sites in xe_svm_init() and other callers. >
I'd mention somewhere that drm_device is now stored in the pages. Otherwise LGTM. Matt > Suggested-by: Matthew Brost <[email protected]> > Signed-off-by: Honglei Huang <[email protected]> > --- > drivers/gpu/drm/drm_gpusvm.c | 7 +++---- > drivers/gpu/drm/xe/xe_svm.c | 4 ++-- > drivers/gpu/drm/xe/xe_svm.h | 2 +- > include/drm/drm_gpusvm.h | 4 +--- > 4 files changed, 7 insertions(+), 10 deletions(-) > > diff --git a/drivers/gpu/drm/drm_gpusvm.c b/drivers/gpu/drm/drm_gpusvm.c > index 55515390c53..5cade46234c 100644 > --- a/drivers/gpu/drm/drm_gpusvm.c > +++ b/drivers/gpu/drm/drm_gpusvm.c > @@ -359,7 +359,6 @@ static const struct mmu_interval_notifier_ops > drm_gpusvm_notifier_ops = { > * drm_gpusvm_init() - Initialize the GPU SVM. > * @gpusvm: Pointer to the GPU SVM structure. > * @name: Name of the GPU SVM. > - * @drm: Pointer to the DRM device structure. > * @mm: Pointer to the mm_struct for the address space. > * @mm_start: Start address of GPU SVM. > * @mm_range: Range of the GPU SVM. > @@ -373,7 +372,8 @@ static const struct mmu_interval_notifier_ops > drm_gpusvm_notifier_ops = { > * This function initializes the GPU SVM. > * > * Note: If only using the simple drm_gpusvm_pages API (get/unmap/free), > - * then only @gpusvm, @name, and @drm are expected. However, the same base > + * then only @gpusvm and @name are expected. The struct @drm for dma > + * mappings is now required in drm_gpusvm_get_pages(). However, the same base > * @gpusvm can also be used with both modes together in which case the full > * setup is needed, where the core drm_gpusvm_pages API will simply never use > * the other fields. > @@ -381,7 +381,7 @@ static const struct mmu_interval_notifier_ops > drm_gpusvm_notifier_ops = { > * Return: 0 on success, a negative error code on failure. > */ > int drm_gpusvm_init(struct drm_gpusvm *gpusvm, > - const char *name, struct drm_device *drm, > + const char *name, > struct mm_struct *mm, > unsigned long mm_start, unsigned long mm_range, > unsigned long notifier_size, > @@ -399,7 +399,6 @@ int drm_gpusvm_init(struct drm_gpusvm *gpusvm, > } > > gpusvm->name = name; > - gpusvm->drm = drm; > gpusvm->mm = mm; > gpusvm->mm_start = mm_start; > gpusvm->mm_range = mm_range; > diff --git a/drivers/gpu/drm/xe/xe_svm.c b/drivers/gpu/drm/xe/xe_svm.c > index 33c26df5111..b0b737234ee 100644 > --- a/drivers/gpu/drm/xe/xe_svm.c > +++ b/drivers/gpu/drm/xe/xe_svm.c > @@ -905,7 +905,7 @@ int xe_svm_init(struct xe_vm *vm) > return err; > } > > - err = drm_gpusvm_init(&vm->svm.gpusvm, "Xe SVM", &vm->xe->drm, > + err = drm_gpusvm_init(&vm->svm.gpusvm, "Xe SVM", > current->mm, 0, vm->size, > xe_modparam.svm_notifier_size * SZ_1M, > &gpusvm_ops, fault_chunk_sizes, > @@ -919,7 +919,7 @@ int xe_svm_init(struct xe_vm *vm) > } > } else { > err = drm_gpusvm_init(&vm->svm.gpusvm, "Xe SVM (simple)", > - &vm->xe->drm, NULL, 0, 0, 0, NULL, > + NULL, 0, 0, 0, NULL, > NULL, 0); > } > > diff --git a/drivers/gpu/drm/xe/xe_svm.h b/drivers/gpu/drm/xe/xe_svm.h > index ea73241d3d9..1c5195f5495 100644 > --- a/drivers/gpu/drm/xe/xe_svm.h > +++ b/drivers/gpu/drm/xe/xe_svm.h > @@ -238,7 +238,7 @@ static inline > int xe_svm_init(struct xe_vm *vm) > { > #if IS_ENABLED(CONFIG_DRM_GPUSVM) > - return drm_gpusvm_init(&vm->svm.gpusvm, "Xe SVM (simple)", &vm->xe->drm, > + return drm_gpusvm_init(&vm->svm.gpusvm, "Xe SVM (simple)", > NULL, 0, 0, 0, NULL, NULL, 0); > #else > return 0; > diff --git a/include/drm/drm_gpusvm.h b/include/drm/drm_gpusvm.h > index 250c59f0930..2bea47ee171 100644 > --- a/include/drm/drm_gpusvm.h > +++ b/include/drm/drm_gpusvm.h > @@ -191,7 +191,6 @@ struct drm_gpusvm_range { > * struct drm_gpusvm - GPU SVM structure > * > * @name: Name of the GPU SVM > - * @drm: Pointer to the DRM device structure > * @mm: Pointer to the mm_struct for the address space > * @mm_start: Start address of GPU SVM > * @mm_range: Range of the GPU SVM > @@ -215,7 +214,6 @@ struct drm_gpusvm_range { > */ > struct drm_gpusvm { > const char *name; > - struct drm_device *drm; > struct mm_struct *mm; > unsigned long mm_start; > unsigned long mm_range; > @@ -267,7 +265,7 @@ struct drm_gpusvm_ctx { > }; > > int drm_gpusvm_init(struct drm_gpusvm *gpusvm, > - const char *name, struct drm_device *drm, > + const char *name, > struct mm_struct *mm, > unsigned long mm_start, unsigned long mm_range, > unsigned long notifier_size, > -- > 2.34.1 >
