diff options
author | Christian König <christian.koenig@amd.com> | 2017-07-27 08:52:53 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-08-15 14:45:55 -0400 |
commit | 53766e5adac75872e9d413cdbfd0e47ae40701f9 (patch) | |
tree | 42c68e850200e19c3a630b72172a0e0b18b374fb /drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |
parent | ed5b89c69cb037c5803c36050377c4b233fbf0b6 (diff) |
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>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_object.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 8fddea4bc146..81d40e3bfbdb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |||
@@ -239,15 +239,20 @@ int amdgpu_bo_create_kernel(struct amdgpu_device *adev, | |||
239 | u32 domain, struct amdgpu_bo **bo_ptr, | 239 | u32 domain, struct amdgpu_bo **bo_ptr, |
240 | u64 *gpu_addr, void **cpu_addr) | 240 | u64 *gpu_addr, void **cpu_addr) |
241 | { | 241 | { |
242 | bool free = false; | ||
242 | int r; | 243 | int r; |
243 | 244 | ||
244 | r = amdgpu_bo_create(adev, size, align, true, domain, | 245 | if (!*bo_ptr) { |
245 | AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | | 246 | r = amdgpu_bo_create(adev, size, align, true, domain, |
246 | AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, | 247 | AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | |
247 | NULL, NULL, bo_ptr); | 248 | AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, |
248 | if (r) { | 249 | NULL, NULL, bo_ptr); |
249 | dev_err(adev->dev, "(%d) failed to allocate kernel bo\n", r); | 250 | if (r) { |
250 | return r; | 251 | dev_err(adev->dev, "(%d) failed to allocate kernel bo\n", |
252 | r); | ||
253 | return r; | ||
254 | } | ||
255 | free = true; | ||
251 | } | 256 | } |
252 | 257 | ||
253 | r = amdgpu_bo_reserve(*bo_ptr, false); | 258 | r = amdgpu_bo_reserve(*bo_ptr, false); |
@@ -278,7 +283,8 @@ error_unreserve: | |||
278 | amdgpu_bo_unreserve(*bo_ptr); | 283 | amdgpu_bo_unreserve(*bo_ptr); |
279 | 284 | ||
280 | error_free: | 285 | error_free: |
281 | amdgpu_bo_unref(bo_ptr); | 286 | if (free) |
287 | amdgpu_bo_unref(bo_ptr); | ||
282 | 288 | ||
283 | return r; | 289 | return r; |
284 | } | 290 | } |