Skip to contentSkip to conversation

drm/amdgpu: flush delete wq after wait fence

PATCH In review Yiqing Yao 4 participants 4 messages May 5, 2022

Subsystems (2)
lore
Share & tools
lore

Yiqing Yao

author
#0 lore raw

PATCH 1/1 drm/amdgpu: flush delete wq after wait fence

[why]
lru_list not empty warning in sw fini during repeated device bind unbind. There should be a amdgpu_fence_wait_empty() before the flush_delayed_work() call as sugested.

[how]
Do flush_delayed_work for ttm bo delayed delete wq after fence_driver_hw_fini.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5 -4
index 14c5ccf81e80..92e5ed3ed345 100644
@@ -4003,10 +4003,6 @@ 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) {
-		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
@@ -4029,6 +4025,11 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)
 	}
 	amdgpu_fence_driver_hw_fini(adev);
 
+	if (adev->mman.initialized) {
+		flush_delayed_work(&adev->mman.bdev.wq);
+		ttm_bo_lock_delayed_workqueue(&adev->mman.bdev);
+	}
+
 	if (adev->pm_sysfs_en)
 		amdgpu_pm_sysfs_fini(adev);
 	if (adev->ucode_sysfs_en)
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Am 05.05.22 um 08:35 schrieb Yiqing Yao:

Quoted 9 lines

[why]
lru_list not empty warning in sw fini during repeated device bind unbind. There should be a amdgpu_fence_wait_empty() before the flush_delayed_work() call as sugested.

[how]
Do flush_delayed_work for ttm bo delayed delete wq after fence_driver_hw_fini.

Sounds reasonable to me now, let's just hope that we haven't missed any other dependency.

Quoted 31 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 +++++----
  1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5 -4
index 14c5ccf81e80..92e5ed3ed345 100644
@@ -4003,10 +4003,6 @@ 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) {
-		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
@@ -4029,6 +4025,11 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)
  	}
  	amdgpu_fence_driver_hw_fini(adev);
 
+	if (adev->mman.initialized) {
+		flush_delayed_work(&adev->mman.bdev.wq);
+		ttm_bo_lock_delayed_workqueue(&adev->mman.bdev);
+	}
+
  	if (adev->pm_sysfs_en)
  		amdgpu_pm_sysfs_fini(adev);
  	if (adev->ucode_sysfs_en)
#2 lore raw
In reply to Yiqing Yao

Dear Yiging,

Thank you for your patch.

Am 05.05.22 um 08:35 schrieb Yiqing Yao:

Quoted 4 lines

[why]
lru_list not empty warning in sw fini during repeated device bind unbind. There should be a amdgpu_fence_wait_empty() before the flush_delayed_work() call as sugested.

sug*g*ested

Suggested by whom? Or do you mean suggested in this diff?

Quoted 13 lines

[how]
Do flush_delayed_work for ttm bo delayed delete wq after fence_driver_hw_fini.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 +++++----
  1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index 14c5ccf81e80..92e5ed3ed345 100644

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

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -4
@@ -4003,10 +4003,6 @@ 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) {
-		flush_delayed_work(&adev->mman.bdev.wq);
-		ttm_bo_lock_delayed_workqueue(&adev->mman.bdev);
-	}

From the commit message, it’s not clear, that you remove this here.

Kind regards,

Paul

Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5 -0
  	adev->shutdown = true;
 
  	/* make sure IB test finished before entering exclusive mode
@@ -4029,6 +4025,11 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)
  	}
  	amdgpu_fence_driver_hw_fini(adev);
 
+	if (adev->mman.initialized) {
+		flush_delayed_work(&adev->mman.bdev.wq);
+		ttm_bo_lock_delayed_workqueue(&adev->mman.bdev);
+	}
+
  	if (adev->pm_sysfs_en)
  		amdgpu_pm_sysfs_fini(adev);
  	if (adev->ucode_sysfs_en)
#3 lore raw

Dear Paul,

Patch edited:

[why]
lru_list not empty warning in sw fini during repeated device bind unbind. There should be a amdgpu_fence_wait_empty() before the flush_delayed_work() call as Christian suggested.

[how]
Move to do flush_delayed_work for ttm bo delayed delete wq after fence_driver_hw_fini.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 +++++----

 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index 14c5ccf81e80..92e5ed3ed345 100644
@@ -4003,10 +4003,6 @@ 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) {
-        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 @@ -4029,6 +4025,11 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev) }
     amdgpu_fence_driver_hw_fini(adev);

+    if (adev->mman.initialized) {
+        flush_delayed_work(&adev->mman.bdev.wq); +        ttm_bo_lock_delayed_workqueue(&adev->mman.bdev); +    }
+
     if (adev->pm_sysfs_en) amdgpu_pm_sysfs_fini(adev);
     if (adev->ucode_sysfs_en)

Signature · 1 line
2.25.1
Quoted 8 lines · Paul Menzel
Quoted 8 lines

[how]
Do flush_delayed_work for ttm bo delayed delete wq after fence_driver_hw_fini.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 +++++----

  1 file changed, 5 insertions(+), 4 deletions(-)
Quoted 16 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_device_fini_hw(struct · line 4010

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -4
index 14c5ccf81e80..92e5ed3ed345 100644
@@ -4003,10 +4003,6 @@ 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) {
-        flush_delayed_work(&adev->mman.bdev.wq);
-        ttm_bo_lock_delayed_workqueue(&adev->mman.bdev);
-    }

From the commit message, it’s not clear, that you remove this here.

This part is moved to be done later.

Thank you for advice,

Yiqing