drm/amdgpu: add amdgpu_bo_destroy_user helper function
Subsystems (2)
PATCH 1/1 drm/amdgpu: add amdgpu_bo_destroy_user helper function
Implement amdgpu_bo_destroy_user() helper function to simplify amdgpu_bo_user cleanup.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +13 -6
@@ -73,11 +73,22 @@ static void amdgpu_bo_subtract_pin_size(struct amdgpu_bo *bo) } } +static void amdgpu_bo_destroy_user (struct amdgpu_bo *bo) +{ +struct amdgpu_bo_user *ubo; + +if (bo->tbo.type != ttm_bo_type_device) +return ; + + ubo =to_amdgpu_bo_user (bo); +kfree (ubo->metadata); + +} +static void amdgpu_bo_destroy (struct ttm_buffer_object *tbo) {struct amdgpu_device *adev =amdgpu_ttm_adev (tbo->bdev);struct amdgpu_bo *bo =ttm_to_amdgpu_bo (tbo); -struct amdgpu_bo_user *ubo;if (bo->tbo.pin_count >0 )amdgpu_bo_subtract_pin_size (bo);
@@ -94,11 +105,7 @@ static void amdgpu_bo_destroy(struct ttm_buffer_object *tbo)mutex_unlock (&adev->shadow_list_lock); }amdgpu_bo_unref (&bo->parent); - -if (bo->tbo.type == ttm_bo_type_device) { - ubo =to_amdgpu_bo_user (bo); -kfree (ubo->metadata); - } +amdgpu_bo_destroy_user (bo);kfree (bo); }
Signature · 6 lines
2.30.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerAm 09.03.21 um 17:55 schrieb Nirmoy Das:
Quoted 17 lines
Implement
amdgpu_bo_destroy_user()helper function to simplifyamdgpu_bo_usercleanup.Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1
-0@@ -73,11 +73,22 @@ static void amdgpu_bo_subtract_pin_size(struct amdgpu_bo *bo) } } +static void amdgpu_bo_destroy_user (struct amdgpu_bo *bo)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static void amdgpu_bo_subtract_pin_size(struct amdgpu_bo *bo) · line 86
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +10
-0+{ +struct amdgpu_bo_user *ubo; + +if (bo->tbo.type != ttm_bo_type_device) +return ; + + ubo =to_amdgpu_bo_user (bo); +kfree (ubo->metadata); + +}
That was not what I meant.
My thinking was that the user TTM BOs have a separate destroy function.
But this can come later on when we really need this for the VM subsystem.
Christian.
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1
-1+static void amdgpu_bo_destroy (struct ttm_buffer_object *tbo) {struct amdgpu_device *adev =amdgpu_ttm_adev (tbo->bdev);struct amdgpu_bo *bo =ttm_to_amdgpu_bo (tbo); -struct amdgpu_bo_user *ubo;if (bo->tbo.pin_count >0 )amdgpu_bo_subtract_pin_size (bo);@@ -94,11 +105,7 @@ static void amdgpu_bo_destroy(struct ttm_buffer_object *tbo)mutex_unlock (&adev->shadow_list_lock); }
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static void amdgpu_bo_destroy(struct ttm_buffer_object *tbo) · line 111
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1
-5amdgpu_bo_unref (&bo->parent); - -if (bo->tbo.type == ttm_bo_type_device) { - ubo =to_amdgpu_bo_user (bo); -kfree (ubo->metadata); - } +amdgpu_bo_destroy_user (bo);kfree (bo); }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 31 lines · Christian König
Am 09.03.21 um 17:55 schrieb Nirmoy Das:
Quoted 17 lines
Implement
amdgpu_bo_destroy_user()helper function to simplifyamdgpu_bo_usercleanup.Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c| 19 +++++++++++++------1 file changed, 13 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0
-0@@ -73,11 +73,22 @@ static void amdgpu_bo_subtract_pin_size(struct amdgpu_bo *bo) } } +static void amdgpu_bo_destroy_user(struct amdgpu_bo *bo)drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static void amdgpu_bo_subtract_pin_size(struct · line 86
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +10
-0+{ + struct amdgpu_bo_user *ubo; + + if (bo->tbo.type != ttm_bo_type_device) + return; + + ubo = to_amdgpu_bo_user(bo); + kfree(ubo->metadata); + +}That was not what I meant.
Quoted 1 line
My thinking was that the user TTM BOs have a separate destroy function.
Ah okay. I will keep it in my mind.
Thanks,
Nirmoy
Quoted 18 lines
But this can come later on when we really need this for the VM subsystem.
Christian.
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1
-1+ static void amdgpu_bo_destroy(struct ttm_buffer_object *tbo) { struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev); struct amdgpu_bo *bo = ttm_to_amdgpu_bo(tbo); - struct amdgpu_bo_user *ubo; if (bo->tbo.pin_count > 0) amdgpu_bo_subtract_pin_size(bo);@@ -94,11 +105,7 @@ static void amdgpu_bo_destroy(struct ttm_buffer_object *tbo) mutex_unlock(&adev->shadow_list_lock); } amdgpu_bo_unref(&bo->parent);
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static void amdgpu_bo_destroy(struct ttm_buffer_object *tbo) · line 111
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1
-5- - if (bo->tbo.type == ttm_bo_type_device) { - ubo = to_amdgpu_bo_user(bo); - kfree(ubo->metadata); - } + amdgpu_bo_destroy_user(bo); kfree(bo); }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx