[PATCH 1/1] drm/amdgpu: add amdgpu_bo_destroy_user helper function
Christian König
christian.koenig at amd.com
Tue Mar 9 17:43:29 UTC 2021
Am 09.03.21 um 17:55 schrieb Nirmoy Das:
> Implement amdgpu_bo_destroy_user() helper function to simplify
> amdgpu_bo_user cleanup.
>
> Signed-off-by: Nirmoy Das <nirmoy.das at amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 19 +++++++++++++------
> 1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index ac0e1cd83858..cdd5d02e7b26 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -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);
> +
> +}
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.
> +
> 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);
> }
More information about the amd-gfx
mailing list