[PATCH] drm/amdgpu: add option param of specify vmhub to set reserved vmid.

Chong Li chongli2 at amd.com
Wed May 17 10:30:25 UTC 2023


Using reserved vmid for the specify vmhub.

Signed-off-by: Chong Li <chongli2 at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 9 +++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c  | 4 ++++
 3 files changed, 14 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index ce196badf42d..062381d542dc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -174,6 +174,7 @@ extern int amdgpu_vm_fragment_size;
 extern int amdgpu_vm_fault_stop;
 extern int amdgpu_vm_debug;
 extern int amdgpu_vm_update_mode;
+extern int amdgpu_vmhub_reserve_vmid;
 extern int amdgpu_exp_hw_support;
 extern int amdgpu_dc;
 extern int amdgpu_sched_jobs;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 3d91e123f9bd..66f0139b4d33 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -973,6 +973,15 @@ MODULE_PARM_DESC(
 						4 = AMDGPU_CPX_PARTITION_MODE)");
 module_param_named(user_partt_mode, amdgpu_user_partt_mode, uint, 0444);
 
+
+/**
+ * DOC: amdgpu_vmhub_reserve_vmid (int)
+ * using reserved vmid for the specify vmhub.
+ */
+int amdgpu_vmhub_reserve_vmid = -1;
+module_param(amdgpu_vmhub_reserve_vmid, int, 0444);
+MODULE_PARM_DESC(amdgpu_vmhub_reserve_vmid, "specify vmhub ((0, AMDGPU_MAX_VMHUBS - 1)) = On, -1 = Off (Default))");
+
 /* These devices are not supported by amdgpu.
  * They are supported by the mach64, r128, radeon drivers
  */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index ea3d0be152fc..3dcbae201ed2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -2114,6 +2114,10 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 	vm->va = RB_ROOT_CACHED;
 	for (i = 0; i < AMDGPU_MAX_VMHUBS; i++)
 		vm->reserved_vmid[i] = NULL;
+
+	if (amdgpu_vmhub_reserve_vmid >= 0 && amdgpu_vmhub_reserve_vmid < AMDGPU_MAX_VMHUBS)
+		amdgpu_vmid_alloc_reserved(adev, vm, amdgpu_vmhub_reserve_vmid);
+
 	INIT_LIST_HEAD(&vm->evicted);
 	INIT_LIST_HEAD(&vm->relocated);
 	INIT_LIST_HEAD(&vm->moved);
-- 
2.34.1



More information about the amd-gfx mailing list