AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 1/3] drm/amdgpu: Add vm->notifier_lock
@ 2022-12-20 23:27 Felix Kuehling
  2022-12-20 23:27 ` [RFC PATCH 2/3] drm/amdgpu: Add range param to amdgpu_vm_update_range Felix Kuehling
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Felix Kuehling @ 2022-12-20 23:27 UTC (permalink / raw)
  To: amd-gfx; +Cc: philip.yang, christian.koenig

This points to a mutex to serialize with MMU notifiers during page table
updates. For graphics contexts, the notifier lock is per adev. For compute
contexts the lock is per process.

Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 3 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c           | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h           | 3 +++
 3 files changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index b15091d8310d..7aaa844a8284 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -1325,9 +1325,12 @@ static int init_kfd_vm(struct amdgpu_vm *vm, void **process_info,
 
 		*process_info = info;
 		*ef = dma_fence_get(&info->eviction_fence->base);
+	} else {
+		info = *process_info;
 	}
 
 	vm->process_info = *process_info;
+	vm->notifier_lock = &info->notifier_lock;
 
 	/* Validate page directory and attach eviction fence */
 	ret = amdgpu_bo_reserve(vm->root.bo, true);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index dc379dc22c77..a04f7aef4ca9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -2075,6 +2075,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 
 	mutex_init(&vm->eviction_lock);
 	vm->evicting = false;
+	vm->notifier_lock = &adev->notifier_lock;
 
 	r = amdgpu_vm_pt_create(adev, vm, adev->vm_manager.root_level,
 				false, &root);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index 094bb4807303..07af80df812b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -251,6 +251,9 @@ struct amdgpu_vm {
 	bool			evicting;
 	unsigned int		saved_flags;
 
+	/* Pointer to notifier lock used when updating PTEs */
+	struct mutex		*notifier_lock;
+
 	/* Lock to protect vm_bo add/del/move on all lists of vm */
 	spinlock_t		status_lock;
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-01-03  8:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-20 23:27 [RFC PATCH 1/3] drm/amdgpu: Add vm->notifier_lock Felix Kuehling
2022-12-20 23:27 ` [RFC PATCH 2/3] drm/amdgpu: Add range param to amdgpu_vm_update_range Felix Kuehling
2023-01-03  8:27   ` Christian König
2022-12-20 23:27 ` [RFC PATCH 3/3] drm/amdkfd: Use per-process notifier_lock for SVM Felix Kuehling
2023-01-02 16:01 ` [RFC PATCH 1/3] drm/amdgpu: Add vm->notifier_lock Christian König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox