Skip to contentSkip to conversation

drm/amdgpu: fix prime teardown order

PATCH In review Christian König 2 participants 4 messages Mar 9, 2018 2 messages not in the archive

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

PATCH 1/2 drm/amdgpu: fix prime teardown order

We unmapped imported DMA-bufs when the GEM handle was dropped, not when the hardware was done with the buffere.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c    | 2 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -2
index bb9b21266b67..46b9ea4e6103 100644
@@ -36,8 +36,6 @@ void amdgpu_gem_object_free(struct drm_gem_object *gobj)
 	struct amdgpu_bo *robj = gem_to_amdgpu_bo(gobj);
 
 	if (robj) {
-		if (robj->gem_base.import_attach)
-			drm_prime_gem_destroy(&robj->gem_base, robj->tbo.sg);
 		amdgpu_mn_unregister(robj);
 		amdgpu_bo_unref(&robj);
 	}
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2 -0
index b44b65117e18..48e0115d4f76 100644
@@ -56,6 +56,8 @@ static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo)
 
 	amdgpu_bo_kunmap(bo);
 
+	if (bo->gem_base.import_attach)
+		drm_prime_gem_destroy(&bo->gem_base, bo->tbo.sg);
 	drm_gem_object_release(&bo->gem_base);
 	amdgpu_bo_unref(&bo->parent);
 	if (!list_empty(&bo->shadow_list)) {
Signature · 6 lines
2.14.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20180309134604.2390-1-christian.koenig-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 2/2 drm/radeon: fix prime teardown order

We unmapped imported DMA-bufs when the GEM handle was dropped, not when the hardware was done with the buffere.

---
 drivers/gpu/drm/radeon/radeon_gem.c    | 2 --
 drivers/gpu/drm/radeon/radeon_object.c | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_gem.c +0 -2
index a9962ffba720..27d8e7dd2d06 100644
@@ -34,8 +34,6 @@ void radeon_gem_object_free(struct drm_gem_object *gobj)
 	struct radeon_bo *robj = gem_to_radeon_bo(gobj);
 
 	if (robj) {
-		if (robj->gem_base.import_attach)
-			drm_prime_gem_destroy(&robj->gem_base, robj->tbo.sg);
 		radeon_mn_unregister(robj);
 		radeon_bo_unref(&robj);
 	}
drivers/gpu/drm/radeon/radeon_object.c +2 -0
index 38431f682ed0..edbb4cd519fd 100644
@@ -82,6 +82,8 @@ static void radeon_ttm_bo_destroy(struct ttm_buffer_object *tbo)
 	mutex_unlock(&bo->rdev->gem.mutex);
 	radeon_bo_clear_surface_reg(bo);
 	WARN_ON_ONCE(!list_empty(&bo->va));
+	if (bo->gem_base.import_attach)
+		drm_prime_gem_destroy(&bo->gem_base, bo->tbo.sg);
 	drm_gem_object_release(&bo->gem_base);
 	kfree(bo);
 }
Signature · 6 lines
2.14.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by
#3 lore raw
In reply to a message not in the archive
Quoted 2 lines · Christian König

We unmapped imported DMA-bufs when the GEM handle was dropped, not when the hardware was done with the buffere.

Good catch! I guess that explains some oddities I sometimes saw with PRIME. Both patches are

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): d0c896ef-de5f-ff95-ea2b-14eb51064c4d-otUistvHUpPR7s880joybQ@public.gmane.org

#5 lore raw

Am 09.03.2018 um 15:05 schrieb Michel Dänzer:

Quoted 5 lines · Christian König
Quoted 2 lines

We unmapped imported DMA-bufs when the GEM handle was dropped, not when the hardware was done with the buffere.

Good catch! I guess that explains some oddities I sometimes saw with PRIME. Both patches are

Yeah and it took me a month to hunt that down. Thanks to IOMMU or otherwise I wouldn't have even noticed that something is wrong.

Quoted 1 line

Thanks,
Christian.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx