diff options
author | Christian König <christian.koenig@amd.com> | 2017-07-27 11:08:54 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-08-15 14:45:56 -0400 |
commit | 9d903cbd9995bd63e04d71362a8b59ce49437544 (patch) | |
tree | ba638c53454431ea47e732401ab05c435a8a8e99 /drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |
parent | 53766e5adac75872e9d413cdbfd0e47ae40701f9 (diff) |
drm/amdgpu: add amdgpu_bo_create_reserved
Same as amdgpu_bo_create_kernel, but keeps the BO reserved.
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 | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 81d40e3bfbdb..494b79374828 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |||
@@ -220,7 +220,7 @@ static void amdgpu_fill_placement_to_bo(struct amdgpu_bo *bo, | |||
220 | } | 220 | } |
221 | 221 | ||
222 | /** | 222 | /** |
223 | * amdgpu_bo_create_kernel - create BO for kernel use | 223 | * amdgpu_bo_create_reserved - create reserved BO for kernel use |
224 | * | 224 | * |
225 | * @adev: amdgpu device object | 225 | * @adev: amdgpu device object |
226 | * @size: size for the new BO | 226 | * @size: size for the new BO |
@@ -230,14 +230,15 @@ static void amdgpu_fill_placement_to_bo(struct amdgpu_bo *bo, | |||
230 | * @gpu_addr: GPU addr of the pinned BO | 230 | * @gpu_addr: GPU addr of the pinned BO |
231 | * @cpu_addr: optional CPU address mapping | 231 | * @cpu_addr: optional CPU address mapping |
232 | * | 232 | * |
233 | * Allocates and pins a BO for kernel internal use. | 233 | * Allocates and pins a BO for kernel internal use, and returns it still |
234 | * reserved. | ||
234 | * | 235 | * |
235 | * Returns 0 on success, negative error code otherwise. | 236 | * Returns 0 on success, negative error code otherwise. |
236 | */ | 237 | */ |
237 | int amdgpu_bo_create_kernel(struct amdgpu_device *adev, | 238 | int amdgpu_bo_create_reserved(struct amdgpu_device *adev, |
238 | unsigned long size, int align, | 239 | unsigned long size, int align, |
239 | u32 domain, struct amdgpu_bo **bo_ptr, | 240 | u32 domain, struct amdgpu_bo **bo_ptr, |
240 | u64 *gpu_addr, void **cpu_addr) | 241 | u64 *gpu_addr, void **cpu_addr) |
241 | { | 242 | { |
242 | bool free = false; | 243 | bool free = false; |
243 | int r; | 244 | int r; |
@@ -275,8 +276,6 @@ int amdgpu_bo_create_kernel(struct amdgpu_device *adev, | |||
275 | } | 276 | } |
276 | } | 277 | } |
277 | 278 | ||
278 | amdgpu_bo_unreserve(*bo_ptr); | ||
279 | |||
280 | return 0; | 279 | return 0; |
281 | 280 | ||
282 | error_unreserve: | 281 | error_unreserve: |
@@ -290,6 +289,39 @@ error_free: | |||
290 | } | 289 | } |
291 | 290 | ||
292 | /** | 291 | /** |
292 | * amdgpu_bo_create_kernel - create BO for kernel use | ||
293 | * | ||
294 | * @adev: amdgpu device object | ||
295 | * @size: size for the new BO | ||
296 | * @align: alignment for the new BO | ||
297 | * @domain: where to place it | ||
298 | * @bo_ptr: resulting BO | ||
299 | * @gpu_addr: GPU addr of the pinned BO | ||
300 | * @cpu_addr: optional CPU address mapping | ||
301 | * | ||
302 | * Allocates and pins a BO for kernel internal use. | ||
303 | * | ||
304 | * Returns 0 on success, negative error code otherwise. | ||
305 | */ | ||
306 | int amdgpu_bo_create_kernel(struct amdgpu_device *adev, | ||
307 | unsigned long size, int align, | ||
308 | u32 domain, struct amdgpu_bo **bo_ptr, | ||
309 | u64 *gpu_addr, void **cpu_addr) | ||
310 | { | ||
311 | int r; | ||
312 | |||
313 | r = amdgpu_bo_create_reserved(adev, size, align, domain, bo_ptr, | ||
314 | gpu_addr, cpu_addr); | ||
315 | |||
316 | if (r) | ||
317 | return r; | ||
318 | |||
319 | amdgpu_bo_unreserve(*bo_ptr); | ||
320 | |||
321 | return 0; | ||
322 | } | ||
323 | |||
324 | /** | ||
293 | * amdgpu_bo_free_kernel - free BO for kernel use | 325 | * amdgpu_bo_free_kernel - free BO for kernel use |
294 | * | 326 | * |
295 | * @bo: amdgpu BO to free | 327 | * @bo: amdgpu BO to free |