Skip to contentSkip to conversation

drm/amdgpu: fix a call trace when unload amdgpu driver

PATCH Superseded Asher Song 3 participants 4 messages Sep 3, 2024 – Sep 4, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Asher Song

author
#0 lore raw

PATCH 1/1 drm/amdgpu: fix a call trace when unload amdgpu driver

In some APUs, the bo type of GART page table is ttm_bo_type_sg. Those type BOs is released by bo->delayed_delete which is added in ttm_device->wq, not released immediately.

To make sure all the ttm_resource is released before ttm_resource_manager is finilized, drain the workqueue in ttm_device.

Fixes d99fbd9aab62 ("drm/ttm: Always take the bo delayed cleanup path for imported bos")
---
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -0
index 0a5c8d97787a..99017e426618 100644
@@ -2216,6 +2216,7 @@ static int gmc_v9_0_sw_fini(void *handle)
 	if (!adev->gmc.real_vram_size) {
 		dev_info(adev->dev, "Put GART in system memory for APU free\n");
 		amdgpu_gart_table_ram_free(adev);
+		drain_workqueue(adev->mman.bdev.wq);
 	} else {
 		amdgpu_gart_table_vram_free(adev);
 	}
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Asher Song

In some APUs, the bo type of GART page table is ttm_bo_type_sg. Those type BOs is released by bo->delayed_delete which is added in ttm_device->wq, not released immediately.

To make sure all the ttm_resource is released before ttm_resource_manager is finilized, drain the workqueue in ttm_device.

Fixes d99fbd9aab62 ("drm/ttm: Always take the bo delayed cleanup path for imported bos")

Thanks,
Lijo

Quoted 16 lines
---
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -0
index 0a5c8d97787a..99017e426618 100644
@@ -2216,6 +2216,7 @@ static int gmc_v9_0_sw_fini(void *handle)
 	if (!adev->gmc.real_vram_size) {
 		dev_info(adev->dev, "Put GART in system memory for APU free\n");
 		amdgpu_gart_table_ram_free(adev);
+		drain_workqueue(adev->mman.bdev.wq);
 	} else {
 		amdgpu_gart_table_vram_free(adev);
 	}
maintainer
#2 lore raw
In reply to Asher Song

Am 03.09.24 um 14:31 schrieb Asher Song:

Quoted 9 lines

In some APUs, the bo type of GART page table is ttm_bo_type_sg. Those type BOs is released by bo->delayed_delete which is added in ttm_device->wq, not released immediately.

To make sure all the ttm_resource is released before ttm_resource_manager is finilized, drain the workqueue in ttm_device.

Fixes d99fbd9aab62 ("drm/ttm: Always take the bo delayed cleanup path for imported bos")

The correct tag is Suggested-by.

Quoted 10 lines
---
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
index 0a5c8d97787a..99017e426618 100644

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_sw_fini(void *handle) · line 2219

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -0
@@ -2216,6 +2216,7 @@ static int gmc_v9_0_sw_fini(void *handle)
  	if (!adev->gmc.real_vram_size) {
  		dev_info(adev->dev, "Put GART in system memory for APU free\n");
  		amdgpu_gart_table_ram_free(adev);
+		drain_workqueue(adev->mman.bdev.wq);

That is certainly incorrectly placed in the gmc_v9_0_sw_fini(). That should be somewhere in amdgpu_ttm.c

Regards,
Christian.

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
  	} else {
  		amdgpu_gart_table_vram_free(adev);
  	}
#3 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

On Tuesday, September 3, 2024 9:29 PM wrote by Koenig, Christian

Quoted 28 lines

Am 03.09.24 um 14:31 schrieb Asher Song:

Quoted 10 lines

In some APUs, the bo type of GART page table is ttm_bo_type_sg. Those type BOs is released by bo->delayed_delete which is added in ttm_device->wq, not released immediately.

To make sure all the ttm_resource is released before ttm_resource_manager is finilized, drain the workqueue in ttm_device.

Fixes d99fbd9aab62 ("drm/ttm: Always take the bo delayed cleanup path

for imported bos")

The correct tag is Suggested-by.

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_sw_fini(void *handle) · line 2217

Quoted 13 lines
---
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
index 0a5c8d97787a..99017e426618 100644
@@ -2216,6 +2216,7 @@ static int gmc_v9_0_sw_fini(void *handle)
    if (!adev->gmc.real_vram_size) {
            dev_info(adev->dev, "Put GART in system memory for APU

free\n");

Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_sw_fini(void *handle) · line 2219

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -0
            amdgpu_gart_table_ram_free(adev);
+           drain_workqueue(adev->mman.bdev.wq);

That is certainly incorrectly placed in the gmc_v9_0_sw_fini(). That should be somewhere in amdgpu_ttm.c

Regards,
Christian.

Thank you. Will send v2 to place drain_workqueue in amdgpu_ttm.c

Best Regards,
Asher

Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
    } else {
            amdgpu_gart_table_vram_free(adev);
    }