mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/
synced 2026-04-18 06:33:43 -04:00
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>
This commit is contained in:
committed by
Alex Deucher
parent
ad2473af27
commit
aa1d562e64
@@ -287,6 +287,35 @@ error_free:
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* amdgpu_bo_free_kernel - free BO for kernel use
|
||||
*
|
||||
* @bo: amdgpu BO to free
|
||||
*
|
||||
* unmaps and unpin a BO for kernel internal use.
|
||||
*/
|
||||
void amdgpu_bo_free_kernel(struct amdgpu_bo **bo, u64 *gpu_addr,
|
||||
void **cpu_addr)
|
||||
{
|
||||
if (*bo == NULL)
|
||||
return;
|
||||
|
||||
if (likely(amdgpu_bo_reserve(*bo, false) == 0)) {
|
||||
if (cpu_addr)
|
||||
amdgpu_bo_kunmap(*bo);
|
||||
|
||||
amdgpu_bo_unpin(*bo);
|
||||
amdgpu_bo_unreserve(*bo);
|
||||
}
|
||||
amdgpu_bo_unref(bo);
|
||||
|
||||
if (gpu_addr)
|
||||
*gpu_addr = 0;
|
||||
|
||||
if (cpu_addr)
|
||||
*cpu_addr = NULL;
|
||||
}
|
||||
|
||||
int amdgpu_bo_create_restricted(struct amdgpu_device *adev,
|
||||
unsigned long size, int byte_align,
|
||||
bool kernel, u32 domain, u64 flags,
|
||||
|
||||
Reference in New Issue
Block a user