drm/amdgpu: improve amdgpu_bo_create_kernel
Make allocating the new BO optional. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
ed5b89c69c
commit
53766e5ada
@ -239,15 +239,20 @@ int amdgpu_bo_create_kernel(struct amdgpu_device *adev,
|
|||||||
u32 domain, struct amdgpu_bo **bo_ptr,
|
u32 domain, struct amdgpu_bo **bo_ptr,
|
||||||
u64 *gpu_addr, void **cpu_addr)
|
u64 *gpu_addr, void **cpu_addr)
|
||||||
{
|
{
|
||||||
|
bool free = false;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = amdgpu_bo_create(adev, size, align, true, domain,
|
if (!*bo_ptr) {
|
||||||
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
|
r = amdgpu_bo_create(adev, size, align, true, domain,
|
||||||
AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS,
|
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
|
||||||
NULL, NULL, bo_ptr);
|
AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS,
|
||||||
if (r) {
|
NULL, NULL, bo_ptr);
|
||||||
dev_err(adev->dev, "(%d) failed to allocate kernel bo\n", r);
|
if (r) {
|
||||||
return r;
|
dev_err(adev->dev, "(%d) failed to allocate kernel bo\n",
|
||||||
|
r);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
free = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = amdgpu_bo_reserve(*bo_ptr, false);
|
r = amdgpu_bo_reserve(*bo_ptr, false);
|
||||||
@ -278,7 +283,8 @@ error_unreserve:
|
|||||||
amdgpu_bo_unreserve(*bo_ptr);
|
amdgpu_bo_unreserve(*bo_ptr);
|
||||||
|
|
||||||
error_free:
|
error_free:
|
||||||
amdgpu_bo_unref(bo_ptr);
|
if (free)
|
||||||
|
amdgpu_bo_unref(bo_ptr);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user