Skip to contentSkip to conversation

drm/amdgpu: use CPU to update VM during GPU reset

PATCH In review Lang Yu 2 participants 5 messages Mar 25, 2024 – Apr 2, 2024

Subsystems (2)
lore
Share & tools
lore

Lang Yu

author
#0 lore raw

PATCH 1/2 drm/amdgpu: use CPU to update VM during GPU reset

drm sched is stopped and SDMA mode is not available, while CPU mode worked well in such a case.

Use case,
amdgpu_do_asic_reset
amdgpu_device_ip_late_init
umsch_mm_late_init
umsch_mm_test
amdgpu_vm_init

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -2
index 8af3f0fd3073..af53f9cfcc40 100644
@@ -2404,8 +2404,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 
 	vm->is_compute_context = false;
 
-	vm->use_cpu_for_update = !!(adev->vm_manager.vm_update_mode &
-				    AMDGPU_VM_USE_CPU_FOR_GFX);
+	vm->use_cpu_for_update = !!(amdgpu_in_reset(adev) ||
+		adev->vm_manager.vm_update_mode & AMDGPU_VM_USE_CPU_FOR_GFX);
 
 	DRM_DEBUG_DRIVER("VM update mode is %s\n",
 			 vm->use_cpu_for_update ? "CPU" : "SDMA");
Signature · 1 line
2.25.1
author
#1 lore raw

[AMD Official Use Only - General]

Please ignore this one.

If user space calls amdgpu_vm_init between gpu reset start and end(driver doesn't prevent user space from doing that),

this will change VM update mode and affect user space. That's not expected.

Will find another way to solve this.

Regards,
Lang

Quoted 44 lines

-----Original Message-----
From: Yu, Lang <[email protected]>
Sent: Monday, March 25, 2024 1:36 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Yu, Lang <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: use CPU to update VM during GPU reset

drm sched is stopped and SDMA mode is not available, while CPU mode worked well in such a case.

Use case,
amdgpu_do_asic_reset
amdgpu_device_ip_late_init
umsch_mm_late_init
umsch_mm_test
amdgpu_vm_init

---
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -1
index 8af3f0fd3073..af53f9cfcc40 100644
@@ -2404,8 +2404,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev,
 struct amdgpu_vm *vm,
 
      vm->is_compute_context = false;
 
-      vm->use_cpu_for_update = !!(adev->vm_manager.vm_update_mode

&

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -1
-                                  AMDGPU_VM_USE_CPU_FOR_GFX);
+      vm->use_cpu_for_update = !!(amdgpu_in_reset(adev) ||
+              adev->vm_manager.vm_update_mode &

AMDGPU_VM_USE_CPU_FOR_GFX);

DRM_DEBUG_DRIVER("VM update mode is %s\n",
vm->use_cpu_for_update ? "CPU" : "SDMA");
--
2.25.1

maintainer
#2 lore raw
In reply to Lang Yu

Am 25.03.24 um 06:35 schrieb Lang Yu:

Quoted 9 lines

drm sched is stopped and SDMA mode is not available, while CPU mode worked well in such a case.

Use case,
amdgpu_do_asic_reset
amdgpu_device_ip_late_init
umsch_mm_late_init
umsch_mm_test
amdgpu_vm_init

Well big NAK to that.

The VM updates should just be scheduled and applied as soon as the GPU reset is completed.

The problem is rather that a GPU reset should *never* create a VM to do a test. During GPU reset no memory allocation whatsoever is allowed.

That's why we only do IB and ring tests with a pre-allocated memory pool during a GPU reset.

If the umsch_mm_test abuses the VM tests like this then please remove that code immediately.

Regards,
Christian.

Quoted 21 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -2
index 8af3f0fd3073..af53f9cfcc40 100644
@@ -2404,8 +2404,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 
  	vm->is_compute_context = false;
 
-	vm->use_cpu_for_update = !!(adev->vm_manager.vm_update_mode &
-				    AMDGPU_VM_USE_CPU_FOR_GFX);
+	vm->use_cpu_for_update = !!(amdgpu_in_reset(adev) ||
+		adev->vm_manager.vm_update_mode & AMDGPU_VM_USE_CPU_FOR_GFX);
 
  	DRM_DEBUG_DRIVER("VM update mode is %s\n",
  			 vm->use_cpu_for_update ? "CPU" : "SDMA");
author
#3 lore raw

[AMD Official Use Only - General]

Quoted 19 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Friday, March 29, 2024 7:08 PM
To: Yu, Lang <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: use CPU to update VM during GPU reset

Am 25.03.24 um 06:35 schrieb Lang Yu:

Quoted 9 lines

drm sched is stopped and SDMA mode is not available, while CPU mode worked well in such a case.

Use case,
amdgpu_do_asic_reset
amdgpu_device_ip_late_init
umsch_mm_late_init
umsch_mm_test
amdgpu_vm_init

Quoted 7 lines

Well big NAK to that.

The VM updates should just be scheduled and applied as soon as the GPU reset is completed.

The problem is rather that a GPU reset should *never* create a VM to do a test. During GPU reset no memory allocation whatsoever is allowed.

But user space can still create a VM via open("/dev/dri/card0", ...) during GPU reset, driver doesn't prevent user space from doing that. So is this reasonable? Thanks.

Regards,
Lang

Quoted 35 lines

That's why we only do IB and ring tests with a pre-allocated memory pool during a GPU reset.

If the umsch_mm_test abuses the VM tests like this then please remove that code immediately.

Regards,
Christian.

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_init(struct amdgpu_device

Quoted 12 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
index 8af3f0fd3073..af53f9cfcc40 100644
@@ -2404,8 +2404,8 @@ int amdgpu_vm_init(struct amdgpu_device

*adev,

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -1
 struct amdgpu_vm *vm,
 
     vm->is_compute_context = false;
 
-    vm->use_cpu_for_update = !!(adev->vm_manager.vm_update_mode

&

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -1
-                                AMDGPU_VM_USE_CPU_FOR_GFX);
+    vm->use_cpu_for_update = !!(amdgpu_in_reset(adev) ||
+            adev->vm_manager.vm_update_mode &

AMDGPU_VM_USE_CPU_FOR_GFX);

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
     DRM_DEBUG_DRIVER("VM update mode is %s\n",
                      vm->use_cpu_for_update ? "CPU" : "SDMA");
maintainer
#4 lore raw

Am 02.04.24 um 10:47 schrieb Yu, Lang:

Quoted 22 lines

[AMD Official Use Only - General]

Quoted 20 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Friday, March 29, 2024 7:08 PM
To: Yu, Lang <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: use CPU to update VM during GPU reset

Am 25.03.24 um 06:35 schrieb Lang Yu:

Quoted 9 lines

drm sched is stopped and SDMA mode is not available, while CPU mode worked well in such a case.

Use case,
amdgpu_do_asic_reset
amdgpu_device_ip_late_init
umsch_mm_late_init
umsch_mm_test
amdgpu_vm_init

Well big NAK to that.

Quoted 7 lines
Quoted 5 lines

The VM updates should just be scheduled and applied as soon as the GPU reset is completed.

The problem is rather that a GPU reset should *never* create a VM to do a test. During GPU reset no memory allocation whatsoever is allowed.

But user space can still create a VM via open("/dev/dri/card0", ...) during GPU reset, driver doesn't prevent user space from doing that. So is this reasonable? Thanks.

Yes the UMD can still create VMs during reset, but this is completely unproblematic since all submissions will wait till after the reset before they start executing.

This includes both VM updates as well as userspace submissions.

Regards,
Christian.

Quoted 37 lines

Regards,
Lang

Quoted 33 lines

That's why we only do IB and ring tests with a pre-allocated memory pool during a GPU reset.

If the umsch_mm_test abuses the VM tests like this then please remove that code immediately.

Regards,
Christian.

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_init(struct amdgpu_device

Quoted 11 lines
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
index 8af3f0fd3073..af53f9cfcc40 100644
@@ -2404,8 +2404,8 @@ int amdgpu_vm_init(struct amdgpu_device

*adev,

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -1
 struct amdgpu_vm *vm,
 
      vm->is_compute_context = false;
 
-    vm->use_cpu_for_update = !!(adev->vm_manager.vm_update_mode

&

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -1
-                                AMDGPU_VM_USE_CPU_FOR_GFX);
+    vm->use_cpu_for_update = !!(amdgpu_in_reset(adev) ||
+            adev->vm_manager.vm_update_mode &

AMDGPU_VM_USE_CPU_FOR_GFX);

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
      DRM_DEBUG_DRIVER("VM update mode is %s\n",
                       vm->use_cpu_for_update ? "CPU" : "SDMA");