Skip to contentSkip to conversation

drm/amd/amdgpu:flush ttm delayed work before cancel_sync

PATCH In review YuBiao Wang 3 participants 3 messages Aug 17, 2021 – Aug 18, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/amdgpu:flush ttm delayed work before cancel_sync

[Why]
In some cases when we unload driver, warning call trace
will show up in vram_mgr_fini which claims that LRU is not empty, caused by the ttm bo inside delay deleted queue.

[How]
We should flush delayed work to make sure the delay deleting is done.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -1
index 4d266c40382c..0b5764aa98a4 100644
@@ -3824,8 +3824,10 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)
 {
 	dev_info(adev->dev, "amdgpu: finishing device.\n");
 	flush_delayed_work(&adev->delayed_init_work);
-	if (adev->mman.initialized)
+	if (adev->mman.initialized) {
+		flush_delayed_work(&adev->mman.bdev.wq);
 		ttm_bo_lock_delayed_workqueue(&adev->mman.bdev);
+	}
 	adev->shutdown = true;
 
 	/* make sure IB test finished before entering exclusive mode
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

Looks reasonable to me.

Andrey

Quoted 29 lines · YuBiao Wang

[Why]
In some cases when we unload driver, warning call trace
will show up in vram_mgr_fini which claims that LRU is not empty, caused by the ttm bo inside delay deleted queue.

[How]
We should flush delayed work to make sure the delay deleting is done.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -1
index 4d266c40382c..0b5764aa98a4 100644
@@ -3824,8 +3824,10 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)
  {
  	dev_info(adev->dev, "amdgpu: finishing device.\n");
  	flush_delayed_work(&adev->delayed_init_work);
-	if (adev->mman.initialized)
+	if (adev->mman.initialized) {
+		flush_delayed_work(&adev->mman.bdev.wq);
  		ttm_bo_lock_delayed_workqueue(&adev->mman.bdev);
+	}
  	adev->shutdown = true;
 
  	/* make sure IB test finished before entering exclusive mode
#2 lore raw
In reply to YuBiao Wang

Am 17.08.21 um 11:50 schrieb YuBiao Wang:

Quoted 18 lines

[Why]
In some cases when we unload driver, warning call trace
will show up in vram_mgr_fini which claims that LRU is not empty, caused by the ttm bo inside delay deleted queue.

[How]
We should flush delayed work to make sure the delay deleting is done.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index 4d266c40382c..0b5764aa98a4 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_device_fini_hw(struct amdgpu_device *adev) · line 3830

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -1
@@ -3824,8 +3824,10 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)
  {
  	dev_info(adev->dev, "amdgpu: finishing device.\n");
  	flush_delayed_work(&adev->delayed_init_work);
-	if (adev->mman.initialized)
+	if (adev->mman.initialized) {
+		flush_delayed_work(&adev->mman.bdev.wq);
  		ttm_bo_lock_delayed_workqueue(&adev->mman.bdev);
+	}

If you flush the delayed work you can drop the call to ttm_bo_lock_delayed_workqueue().

It would also be nice to have to wrap this into a ttm_bo_flush_delayed_workqueue() function.

Apart from that looks good to me,
Christian.

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
  	adev->shutdown = true;
 
  	/* make sure IB test finished before entering exclusive mode