diff options
author | Junwei Zhang <Jerry.Zhang@amd.com> | 2016-09-07 22:13:32 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2016-09-14 15:10:26 -0400 |
commit | aa1d562e645d2542b48bdd42903726adfc87efb3 (patch) | |
tree | 7f3d07a3afa835a5ebfe30bd649398caca796daf /drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |
parent | ad2473af273b81cf184d6e43a395a128d4db7b87 (diff) |
drm/amdgpu: add a new helper to free a BO in kernel allocations
Free the BO allocated by amdgpu_bo_create_kernel()
Signed-off-by: Junwei Zhang <Jerry.Zhang@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_object.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index b17734e0ecc8..162411bd8145 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |||
@@ -287,6 +287,35 @@ error_free: | |||
287 | return r; | 287 | return r; |
288 | } | 288 | } |
289 | 289 | ||
290 | /** | ||
291 | * amdgpu_bo_free_kernel - free BO for kernel use | ||
292 | * | ||
293 | * @bo: amdgpu BO to free | ||
294 | * | ||
295 | * unmaps and unpin a BO for kernel internal use. | ||
296 | */ | ||
297 | void amdgpu_bo_free_kernel(struct amdgpu_bo **bo, u64 *gpu_addr, | ||
298 | void **cpu_addr) | ||
299 | { | ||
300 | if (*bo == NULL) | ||
301 | return; | ||
302 | |||
303 | if (likely(amdgpu_bo_reserve(*bo, false) == 0)) { | ||
304 | if (cpu_addr) | ||
305 | amdgpu_bo_kunmap(*bo); | ||
306 | |||
307 | amdgpu_bo_unpin(*bo); | ||
308 | amdgpu_bo_unreserve(*bo); | ||
309 | } | ||
310 | amdgpu_bo_unref(bo); | ||
311 | |||
312 | if (gpu_addr) | ||
313 | *gpu_addr = 0; | ||
314 | |||
315 | if (cpu_addr) | ||
316 | *cpu_addr = NULL; | ||
317 | } | ||
318 | |||
290 | int amdgpu_bo_create_restricted(struct amdgpu_device *adev, | 319 | int amdgpu_bo_create_restricted(struct amdgpu_device *adev, |
291 | unsigned long size, int byte_align, | 320 | unsigned long size, int byte_align, |
292 | bool kernel, u32 domain, u64 flags, | 321 | bool kernel, u32 domain, u64 flags, |