[PATCH 1/1] drm/amdgpu: add amdgpu_bo_destroy_user helper function
Nirmoy Das
nirmoy.das at amd.com
Tue Mar 9 16:55:18 UTC 2021
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);
+
+}
+
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);
}
--
2.30.1
More information about the amd-gfx
mailing list