drm/amdgpu: separate gpu address from bo pin
Subsystems (4)
PATCH 1/3 drm/amdgpu: separate gpu address from bo pin
It could be got by amdgpu_bo_gpu_offset() if need
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 6 ++---- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 6 ++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 ++--- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 5 ++--- drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 6 ++---- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 17 ++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 5 ++--- drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 6 ++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 10 +++++----- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 10 +++++----- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 10 +++++----- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 10 +++++----- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++- 17 files changed, 50 insertions(+), 57 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +2 -4
@@ -251,7 +251,6 @@ int alloc_gtt_mem(struct kgd_dev *kgd, size_t size,struct amdgpu_bo *bo =NULL ;struct amdgpu_bo_param bp;int r; -uint64_t gpu_addr_tmp =0 ;void *cpu_ptr_tmp =NULL ;memset (&bp,0 ,sizeof (bp));
@@ -275,8 +274,7 @@ int alloc_gtt_mem(struct kgd_dev *kgd, size_t size, goto allocate_mem_reserve_bo_failed; } - r =amdgpu_bo_pin (bo,AMDGPU_GEM_DOMAIN_GTT , - &gpu_addr_tmp); + r =amdgpu_bo_pin (bo,AMDGPU_GEM_DOMAIN_GTT );if (r) {dev_err (adev->dev,"(%d) failed to pin bo for amdkfd\n" , r); goto allocate_mem_pin_bo_failed;
@@ -290,7 +288,7 @@ int alloc_gtt_mem(struct kgd_dev *kgd, size_t size, } *mem_obj = bo; - *gpu_addr = gpu_addr_tmp; + *gpu_addr =amdgpu_bo_gpu_offset (bo); *cpu_ptr = cpu_ptr_tmp;amdgpu_bo_unreserve (bo);
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
@@ -1587,7 +1587,7 @@ int amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(struct kgd_dev *kgd, goto bo_reserve_failed; } - ret =amdgpu_bo_pin (bo,AMDGPU_GEM_DOMAIN_GTT ,NULL ); + ret =amdgpu_bo_pin (bo,AMDGPU_GEM_DOMAIN_GTT );if (ret) {pr_err ("Failed to pin bo. ret %d\n" , ret); goto pin_failed;
drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c +4 -2
@@ -95,7 +95,8 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size, r =amdgpu_bo_reserve (sobj, false);if (unlikely (r !=0 )) goto out_cleanup; - r =amdgpu_bo_pin (sobj, sdomain, &saddr); + r =amdgpu_bo_pin (sobj, sdomain); + saddr =amdgpu_bo_gpu_offset (sobj);amdgpu_bo_unreserve (sobj);if (r) { goto out_cleanup;
@@ -108,7 +109,8 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size, r =amdgpu_bo_reserve (dobj, false);if (unlikely (r !=0 )) goto out_cleanup; - r =amdgpu_bo_pin (dobj, ddomain, &daddr); + r =amdgpu_bo_pin (dobj, ddomain); + daddr =amdgpu_bo_gpu_offset (dobj);amdgpu_bo_unreserve (dobj);if (r) { goto out_cleanup;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -3
@@ -2736,11 +2736,10 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)struct amdgpu_bo *aobj =gem_to_amdgpu_bo (amdgpu_crtc->cursor_bo); r =amdgpu_bo_reserve (aobj, true);if (r ==0 ) { - r =amdgpu_bo_pin (aobj, -AMDGPU_GEM_DOMAIN_VRAM , - &amdgpu_crtc->cursor_addr); + r =amdgpu_bo_pin (aobj,AMDGPU_GEM_DOMAIN_VRAM );if (r !=0 )DRM_ERROR ("Failed to pin cursor BO (%d)\n" , r); + amdgpu_crtc->cursor_addr =amdgpu_bo_gpu_offset (aobj);amdgpu_bo_unreserve (aobj); } }
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +2 -3
@@ -157,7 +157,6 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc,struct amdgpu_bo *new_abo;unsigned long flags;u64 tiling_flags; -u64 base;int i, r; work =kzalloc (sizeof *work,GFP_KERNEL );
@@ -189,7 +188,7 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc, goto cleanup; } - r =amdgpu_bo_pin (new_abo,amdgpu_display_supported_domains (adev), &base); + r =amdgpu_bo_pin (new_abo,amdgpu_display_supported_domains (adev));if (unlikely (r !=0 )) {DRM_ERROR ("failed to pin new abo buffer before flip\n" ); goto unreserve;
@@ -206,7 +205,7 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc,amdgpu_bo_get_tiling_flags (new_abo, &tiling_flags);amdgpu_bo_unreserve (new_abo); - work->base = base; + work->base =amdgpu_bo_gpu_offset (new_abo); work->target_vblank = target - (uint32_t )drm_crtc_vblank_count (crtc) +amdgpu_get_vblank_counter_kms (dev, work->crtc_id);
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +1 -1
@@ -168,7 +168,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev, } - ret =amdgpu_bo_pin (abo, domain,NULL ); + ret =amdgpu_bo_pin (abo, domain);if (ret) {amdgpu_bo_unreserve (abo); goto out_unref;
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +2 -4
@@ -143,14 +143,12 @@ int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev)*/ int amdgpu_gart_table_vram_pin (struct amdgpu_device *adev) { -uint64_t gpu_addr;int r; r =amdgpu_bo_reserve (adev->gart.robj, false);if (unlikely (r !=0 ))return r; - r =amdgpu_bo_pin (adev->gart.robj, -AMDGPU_GEM_DOMAIN_VRAM , &gpu_addr); + r =amdgpu_bo_pin (adev->gart.robj,AMDGPU_GEM_DOMAIN_VRAM );if (r) {amdgpu_bo_unreserve (adev->gart.robj);return r;
@@ -159,7 +157,7 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev)if (r)amdgpu_bo_unpin (adev->gart.robj);amdgpu_bo_unreserve (adev->gart.robj); - adev->gart.table_addr = gpu_addr; + adev->gart.table_addr =amdgpu_bo_gpu_offset (adev->gart.robj);return r; }
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +6 -11
@@ -252,11 +252,13 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev, goto error_free; } - r =amdgpu_bo_pin (*bo_ptr, domain, gpu_addr); + r =amdgpu_bo_pin (*bo_ptr, domain);if (r) {dev_err (adev->dev,"(%d) kernel bo pin failed\n" , r); goto error_unreserve; } +if (gpu_addr) + *gpu_addr =amdgpu_bo_gpu_offset (*bo_ptr);if (cpu_addr) { r =amdgpu_bo_kmap (*bo_ptr, cpu_addr);
@@ -817,7 +819,6 @@ void amdgpu_bo_unref(struct amdgpu_bo **bo)* @domain: domain to be pinned to * @min_offset: the start of requested address range * @max_offset: the end of requested address range -* @gpu_addr: GPU offset of the &amdgpu_bo buffer object * * Pins the buffer object according to requested domain and address range. If * the memory is unbound gart memory, binds the pages into gart table. Adjusts
@@ -835,8 +836,7 @@ void amdgpu_bo_unref(struct amdgpu_bo **bo)* 0 for success or a negative error code on failure. */ int amdgpu_bo_pin_restricted (struct amdgpu_bo *bo,u32 domain, -u64 min_offset,u64 max_offset, -u64 *gpu_addr) +u64 min_offset,u64 max_offset) {struct amdgpu_device *adev =amdgpu_ttm_adev (bo->tbo.bdev);struct ttm_operation_ctx ctx = { false, false };
@@ -868,8 +868,6 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,return -EINVAL ; bo->pin_count++; -if (gpu_addr) - *gpu_addr =amdgpu_bo_gpu_offset (bo);if (max_offset !=0 ) {u64 domain_start = bo->tbo.bdev->man[mem_type].gpu_offset;
@@ -912,8 +910,6 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, } bo->pin_count =1 ; -if (gpu_addr !=NULL ) - *gpu_addr =amdgpu_bo_gpu_offset (bo); domain =amdgpu_mem_type_to_domain (bo->tbo.mem.mem_type);if (domain ==AMDGPU_GEM_DOMAIN_VRAM ) {
@@ -931,7 +927,6 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,* amdgpu_bo_pin - pin an &amdgpu_bo buffer object * @bo: &amdgpu_bo buffer object to be pinned * @domain: domain to be pinned to -* @gpu_addr: GPU offset of the &amdgpu_bo buffer object * * A simple wrapper to amdgpu_bo_pin_restricted(). * Provides a simpler API for buffers that do not have any strict restrictions
@@ -940,9 +935,9 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,* Returns: * 0 for success or a negative error code on failure. */ -int amdgpu_bo_pin (struct amdgpu_bo *bo,u32 domain,u64 *gpu_addr) +int amdgpu_bo_pin (struct amdgpu_bo *bo,u32 domain) { -return amdgpu_bo_pin_restricted (bo, domain,0 ,0 , gpu_addr); +return amdgpu_bo_pin_restricted (bo, domain,0 ,0 ); }/**
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +2 -3
@@ -252,10 +252,9 @@ void amdgpu_bo_free_kernel(struct amdgpu_bo **bo, u64 *gpu_addr,void amdgpu_bo_kunmap (struct amdgpu_bo *bo);struct amdgpu_bo *amdgpu_bo_ref (struct amdgpu_bo *bo);void amdgpu_bo_unref (struct amdgpu_bo **bo); -int amdgpu_bo_pin (struct amdgpu_bo *bo,u32 domain,u64 *gpu_addr); +int amdgpu_bo_pin (struct amdgpu_bo *bo,u32 domain);int amdgpu_bo_pin_restricted (struct amdgpu_bo *bo,u32 domain, -u64 min_offset,u64 max_offset, -u64 *gpu_addr); +u64 min_offset,u64 max_offset);int amdgpu_bo_unpin (struct amdgpu_bo *bo);int amdgpu_bo_evict_vram (struct amdgpu_device *adev);int amdgpu_bo_init (struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +1 -1
@@ -234,7 +234,7 @@ static int amdgpu_gem_map_attach(struct dma_buf *dma_buf, }/* pin buffer into GTT */ - r =amdgpu_bo_pin (bo,AMDGPU_GEM_DOMAIN_GTT ,NULL ); + r =amdgpu_bo_pin (bo,AMDGPU_GEM_DOMAIN_GTT );if (r) goto error_unreserve;
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +4 -2
@@ -75,11 +75,12 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) r =amdgpu_bo_reserve (vram_obj, false);if (unlikely (r !=0 )) goto out_unref; - r =amdgpu_bo_pin (vram_obj,AMDGPU_GEM_DOMAIN_VRAM , &vram_addr); + r =amdgpu_bo_pin (vram_obj,AMDGPU_GEM_DOMAIN_VRAM );if (r) {DRM_ERROR ("Failed to pin VRAM object\n" ); goto out_unres; } + vram_addr =amdgpu_bo_gpu_offset (vram_obj);for (i =0 ; i < n; i++) {void *gtt_map, *vram_map;void **gart_start, **gart_end;
@@ -96,11 +97,12 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) r =amdgpu_bo_reserve (gtt_obj[i], false);if (unlikely (r !=0 )) goto out_lclean_unref; - r =amdgpu_bo_pin (gtt_obj[i],AMDGPU_GEM_DOMAIN_GTT , &gart_addr); + r =amdgpu_bo_pin (gtt_obj[i],AMDGPU_GEM_DOMAIN_GTT );if (r) {DRM_ERROR ("Failed to pin GTT object %d\n" , i); goto out_lclean_unres; } + gart_addr =amdgpu_bo_gpu_offset (gtt_obj[i]); r =amdgpu_bo_kmap (gtt_obj[i], >t_map);if (r) {
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
@@ -1695,7 +1695,7 @@ static int amdgpu_ttm_fw_reserve_vram_init(struct amdgpu_device *adev)AMDGPU_GEM_DOMAIN_VRAM , adev->fw_vram_usage.start_offset, (adev->fw_vram_usage.start_offset + - adev->fw_vram_usage.size), NULL); + adev->fw_vram_usage.size));if (r) goto error_pin; r = amdgpu_bo_kmap(adev->fw_vram_usage.reserved_bo,
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +5 -5
@@ -1855,15 +1855,14 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,if (unlikely (r !=0 ))return r; -if (atomic) { - fb_location =amdgpu_bo_gpu_offset (abo); - }else { - r =amdgpu_bo_pin (abo,AMDGPU_GEM_DOMAIN_VRAM , &fb_location); +if (!atomic) { + r =amdgpu_bo_pin (abo,AMDGPU_GEM_DOMAIN_VRAM );if (unlikely (r !=0 )) {amdgpu_bo_unreserve (abo);return -EINVAL ; } } + fb_location =amdgpu_bo_gpu_offset (abo);amdgpu_bo_get_tiling_flags (abo, &tiling_flags);amdgpu_bo_unreserve (abo);
@@ -2370,13 +2369,14 @@ static int dce_v10_0_crtc_cursor_set2(struct drm_crtc *crtc,return ret; } - ret =amdgpu_bo_pin (aobj,AMDGPU_GEM_DOMAIN_VRAM , &amdgpu_crtc->cursor_addr); + ret =amdgpu_bo_pin (aobj,AMDGPU_GEM_DOMAIN_VRAM );amdgpu_bo_unreserve (aobj);if (ret) {DRM_ERROR ("Failed to pin new cursor BO (%d)\n" , ret);drm_gem_object_put_unlocked (obj);return ret; } + amdgpu_crtc->cursor_addr =amdgpu_bo_gpu_offset (aobj);dce_v10_0_lock_cursor (crtc, true);
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +5 -5
@@ -1897,15 +1897,14 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,if (unlikely (r !=0 ))return r; -if (atomic) { - fb_location =amdgpu_bo_gpu_offset (abo); - }else { - r =amdgpu_bo_pin (abo,AMDGPU_GEM_DOMAIN_VRAM , &fb_location); +if (!atomic) { + r =amdgpu_bo_pin (abo,AMDGPU_GEM_DOMAIN_VRAM );if (unlikely (r !=0 )) {amdgpu_bo_unreserve (abo);return -EINVAL ; } } + fb_location =amdgpu_bo_gpu_offset (abo);amdgpu_bo_get_tiling_flags (abo, &tiling_flags);amdgpu_bo_unreserve (abo);
@@ -2449,13 +2448,14 @@ static int dce_v11_0_crtc_cursor_set2(struct drm_crtc *crtc,return ret; } - ret =amdgpu_bo_pin (aobj,AMDGPU_GEM_DOMAIN_VRAM , &amdgpu_crtc->cursor_addr); + ret =amdgpu_bo_pin (aobj,AMDGPU_GEM_DOMAIN_VRAM );amdgpu_bo_unreserve (aobj);if (ret) {DRM_ERROR ("Failed to pin new cursor BO (%d)\n" , ret);drm_gem_object_put_unlocked (obj);return ret; } + amdgpu_crtc->cursor_addr =amdgpu_bo_gpu_offset (aobj);dce_v11_0_lock_cursor (crtc, true);
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +5 -5
@@ -1811,15 +1811,14 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,if (unlikely (r !=0 ))return r; -if (atomic) { - fb_location =amdgpu_bo_gpu_offset (abo); - }else { - r =amdgpu_bo_pin (abo,AMDGPU_GEM_DOMAIN_VRAM , &fb_location); +if (!atomic) { + r =amdgpu_bo_pin (abo,AMDGPU_GEM_DOMAIN_VRAM );if (unlikely (r !=0 )) {amdgpu_bo_unreserve (abo);return -EINVAL ; } } + fb_location =amdgpu_bo_gpu_offset (abo);amdgpu_bo_get_tiling_flags (abo, &tiling_flags);amdgpu_bo_unreserve (abo);
@@ -2263,13 +2262,14 @@ static int dce_v6_0_crtc_cursor_set2(struct drm_crtc *crtc,return ret; } - ret =amdgpu_bo_pin (aobj,AMDGPU_GEM_DOMAIN_VRAM , &amdgpu_crtc->cursor_addr); + ret =amdgpu_bo_pin (aobj,AMDGPU_GEM_DOMAIN_VRAM );amdgpu_bo_unreserve (aobj);if (ret) {DRM_ERROR ("Failed to pin new cursor BO (%d)\n" , ret);drm_gem_object_put_unlocked (obj);return ret; } + amdgpu_crtc->cursor_addr =amdgpu_bo_gpu_offset (aobj);dce_v6_0_lock_cursor (crtc, true);
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +5 -5
@@ -1786,15 +1786,14 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,if (unlikely (r !=0 ))return r; -if (atomic) { - fb_location =amdgpu_bo_gpu_offset (abo); - }else { - r =amdgpu_bo_pin (abo,AMDGPU_GEM_DOMAIN_VRAM , &fb_location); +if (!atomic) { + r =amdgpu_bo_pin (abo,AMDGPU_GEM_DOMAIN_VRAM );if (unlikely (r !=0 )) {amdgpu_bo_unreserve (abo);return -EINVAL ; } } + fb_location =amdgpu_bo_gpu_offset (abo);amdgpu_bo_get_tiling_flags (abo, &tiling_flags);amdgpu_bo_unreserve (abo);
@@ -2274,13 +2273,14 @@ static int dce_v8_0_crtc_cursor_set2(struct drm_crtc *crtc,return ret; } - ret =amdgpu_bo_pin (aobj,AMDGPU_GEM_DOMAIN_VRAM , &amdgpu_crtc->cursor_addr); + ret =amdgpu_bo_pin (aobj,AMDGPU_GEM_DOMAIN_VRAM );amdgpu_bo_unreserve (aobj);if (ret) {DRM_ERROR ("Failed to pin new cursor BO (%d)\n" , ret);drm_gem_object_put_unlocked (obj);return ret; } + amdgpu_crtc->cursor_addr =amdgpu_bo_gpu_offset (aobj);dce_v8_0_lock_cursor (crtc, true);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
@@ -3109,7 +3109,7 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,else domain =AMDGPU_GEM_DOMAIN_VRAM ; - r =amdgpu_bo_pin (rbo, domain, &afb->address); + r =amdgpu_bo_pin (rbo, domain);amdgpu_bo_unreserve (rbo);if (unlikely (r !=0 )) {
@@ -3117,6 +3117,7 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,DRM_ERROR ("Failed to pin framebuffer with error %d\n" , r);return r; } + afb->address =amdgpu_bo_gpu_offset (rbo);amdgpu_bo_ref (rbo);
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/3 drm/amdgpu: allocate gart memory when it's required (v2)
In reply to a message not in the archiveInstead of calling gart memory on every bo pin,
allocates it on demand
v2: fix error handling
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 14 ++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 8 ++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 15 +++++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 5 +++++ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 13 +++++++++++-- 8 files changed, 63 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +6 -0
@@ -280,6 +280,12 @@ int alloc_gtt_mem(struct kgd_dev *kgd, size_t size, goto allocate_mem_pin_bo_failed; } + r =amdgpu_ttm_alloc_gart (&bo->tbo); +if (r) { +dev_err (adev->dev,"%p bind failed\n" , bo); + goto allocate_mem_kmap_bo_failed; + } + r =amdgpu_bo_kmap (bo, &cpu_ptr_tmp);if (r) { dev_err(adev->dev,
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +6 -0
@@ -1593,6 +1593,12 @@ int amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(struct kgd_dev *kgd, goto pin_failed; } + ret =amdgpu_ttm_alloc_gart (&bo->tbo); +if (ret) { +pr_err ("%p bind failed\n" , bo); + goto kmap_failed; + } + ret =amdgpu_bo_kmap (bo, kptr);if (ret) {pr_err ("Failed to map bo to kernel. ret %d\n" , ret);
drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c +12 -2
@@ -96,11 +96,16 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size,if (unlikely (r !=0 )) goto out_cleanup; r =amdgpu_bo_pin (sobj, sdomain); - saddr =amdgpu_bo_gpu_offset (sobj); +if (r) { +amdgpu_bo_unreserve (sobj); + goto out_cleanup; + } + r =amdgpu_ttm_alloc_gart (&sobj->tbo);amdgpu_bo_unreserve (sobj);if (r) { goto out_cleanup; } + saddr =amdgpu_bo_gpu_offset (sobj); bp.domain = ddomain; r =amdgpu_bo_create (adev, &bp, &dobj);if (r) {
@@ -110,11 +115,16 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size,if (unlikely (r !=0 )) goto out_cleanup; r =amdgpu_bo_pin (dobj, ddomain); - daddr =amdgpu_bo_gpu_offset (dobj); +if (r) { +amdgpu_bo_unreserve (sobj); + goto out_cleanup; + } + r =amdgpu_ttm_alloc_gart (&dobj->tbo);amdgpu_bo_unreserve (dobj);if (r) { goto out_cleanup; } + daddr =amdgpu_bo_gpu_offset (dobj);if (adev->mman.buffer_funcs) { time =amdgpu_benchmark_do_move (adev, size, saddr, daddr, n);
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +6 -0
@@ -194,6 +194,12 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc, goto unreserve; } + r =amdgpu_ttm_alloc_gart (&new_abo->tbo); +if (unlikely (r !=0 )) { +DRM_ERROR ("%p bind failed\n" , new_abo); + goto unpin; + } + r =reservation_object_get_fences_rcu (new_abo->tbo.resv, &work->excl, &work->shared_count, &work->shared);
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +8 -0
@@ -173,6 +173,14 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,amdgpu_bo_unreserve (abo); goto out_unref; } + + ret =amdgpu_ttm_alloc_gart (&abo->tbo); +if (ret) { +amdgpu_bo_unreserve (abo); +dev_err (adev->dev,"%p bind failed\n" , abo); + goto out_unref; + } + ret =amdgpu_bo_kmap (abo,NULL );amdgpu_bo_unreserve (abo);if (ret) {
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +9 -6
@@ -257,6 +257,13 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,dev_err (adev->dev,"(%d) kernel bo pin failed\n" , r); goto error_unreserve; } + + r =amdgpu_ttm_alloc_gart (&(*bo_ptr)->tbo); +if (r) { +dev_err (adev->dev,"%p bind failed\n" , *bo_ptr); + goto error_unpin; + } +if (gpu_addr) *gpu_addr =amdgpu_bo_gpu_offset (*bo_ptr);
@@ -270,6 +277,8 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,return 0 ; +error_unpin: +amdgpu_bo_unpin (*bo_ptr); error_unreserve:amdgpu_bo_unreserve (*bo_ptr);
@@ -903,12 +912,6 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, goto error; } - r =amdgpu_ttm_alloc_gart (&bo->tbo); -if (unlikely (r)) { -dev_err (adev->dev,"%p bind failed\n" , bo); - goto error; - } - bo->pin_count =1 ; domain =amdgpu_mem_type_to_domain (bo->tbo.mem.mem_type);
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +5 -0
@@ -102,6 +102,11 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)DRM_ERROR ("Failed to pin GTT object %d\n" , i); goto out_lclean_unres; } + r =amdgpu_ttm_alloc_gart (>t_obj[i]->tbo); +if (r) { +DRM_ERROR ("%p bind failed\n" , gtt_obj[i]); + goto out_lclean_unpin; + } gart_addr =amdgpu_bo_gpu_offset (gtt_obj[i]); r =amdgpu_bo_kmap (gtt_obj[i], >t_map);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +11 -2
@@ -3110,13 +3110,22 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane, domain =AMDGPU_GEM_DOMAIN_VRAM ; r =amdgpu_bo_pin (rbo, domain); -amdgpu_bo_unreserve (rbo); -if (unlikely (r !=0 )) {if (r != -ERESTARTSYS )DRM_ERROR ("Failed to pin framebuffer with error %d\n" , r); +amdgpu_bo_unreserve (rbo); +return r; + } + + r =amdgpu_ttm_alloc_gart (&rbo->tbo); +if (unlikely (r !=0 )) { +amdgpu_bo_unpin (rbo); +amdgpu_bo_unreserve (rbo); +DRM_ERROR ("%p bind failed\n" , rbo);return r; } +amdgpu_bo_unreserve (rbo); + afb->address =amdgpu_bo_gpu_offset (rbo);amdgpu_bo_ref (rbo);
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/3 drm/amdgpu: fix kmap error handling for bo creations
In reply to a message not in the archivekmap happens after bo pin, so unpin is required on error
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -1
@@ -271,7 +271,7 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev, r =amdgpu_bo_kmap (*bo_ptr, cpu_addr);if (r) {dev_err (adev->dev,"(%d) kernel bo map failed\n" , r); - goto error_unreserve; + goto error_unpin; } }
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 2/3] drm/amdgpu: allocate gart memory when it's required (v2)
In reply to a message not in the archiveComments inline [FK]
Quoted 39 lines · Junwei Zhang
Instead of calling gart memory on every bo pin,
allocates it on demandv2: fix error handling
Signed-off-by Junwei Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 14 ++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 8 ++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 15 +++++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 5 +++++ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 13 +++++++++++-- 8 files changed, 63 insertions(+), 10 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +6
-0@@ -280,6 +280,12 @@ int alloc_gtt_mem(struct kgd_dev *kgd, size_t size, goto allocate_mem_pin_bo_failed; } + r =amdgpu_ttm_alloc_gart (&bo->tbo); +if (r) { +dev_err (adev->dev,"%p bind failed\n" , bo); + goto allocate_mem_kmap_bo_failed; + } + r =amdgpu_bo_kmap (bo, &cpu_ptr_tmp);if (r) { dev_err(adev->dev,drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(struct kgd_dev *kgd, · line 1601
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +6
-0@@ -1593,6 +1593,12 @@ int amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(struct kgd_dev *kgd, goto pin_failed; } + ret =amdgpu_ttm_alloc_gart (&bo->tbo); +if (ret) { +pr_err ("%p bind failed\n" , bo); + goto kmap_failed; + } +
[FK] I think think in this case we don't need the GART mapping. This function doesn't query the GPU address of the pinned buffer. The only reason we pin the BO here is to keep the kernel mapping valid.
Regards,
Felix
Quoted 154 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0ret =amdgpu_bo_kmap (bo, kptr);if (ret) {pr_err ("Failed to map bo to kernel. ret %d\n" , ret);drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c +12
-2@@ -96,11 +96,16 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size,if (unlikely (r !=0 )) goto out_cleanup; r =amdgpu_bo_pin (sobj, sdomain); - saddr =amdgpu_bo_gpu_offset (sobj); +if (r) { +amdgpu_bo_unreserve (sobj); + goto out_cleanup; + } + r =amdgpu_ttm_alloc_gart (&sobj->tbo);amdgpu_bo_unreserve (sobj);if (r) { goto out_cleanup; } + saddr =amdgpu_bo_gpu_offset (sobj); bp.domain = ddomain; r =amdgpu_bo_create (adev, &bp, &dobj);if (r) {@@ -110,11 +115,16 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size,if (unlikely (r !=0 )) goto out_cleanup; r =amdgpu_bo_pin (dobj, ddomain); - daddr =amdgpu_bo_gpu_offset (dobj); +if (r) { +amdgpu_bo_unreserve (sobj); + goto out_cleanup; + } + r =amdgpu_ttm_alloc_gart (&dobj->tbo);amdgpu_bo_unreserve (dobj);if (r) { goto out_cleanup; } + daddr =amdgpu_bo_gpu_offset (dobj);if (adev->mman.buffer_funcs) { time =amdgpu_benchmark_do_move (adev, size, saddr, daddr, n);drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +6
-0@@ -194,6 +194,12 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc, goto unreserve; } + r =amdgpu_ttm_alloc_gart (&new_abo->tbo); +if (unlikely (r !=0 )) { +DRM_ERROR ("%p bind failed\n" , new_abo); + goto unpin; + } + r =reservation_object_get_fences_rcu (new_abo->tbo.resv, &work->excl, &work->shared_count, &work->shared);drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +8
-0@@ -173,6 +173,14 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,amdgpu_bo_unreserve (abo); goto out_unref; } + + ret =amdgpu_ttm_alloc_gart (&abo->tbo); +if (ret) { +amdgpu_bo_unreserve (abo); +dev_err (adev->dev,"%p bind failed\n" , abo); + goto out_unref; + } + ret =amdgpu_bo_kmap (abo,NULL );amdgpu_bo_unreserve (abo);if (ret) {drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +9
-6@@ -257,6 +257,13 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,dev_err (adev->dev,"(%d) kernel bo pin failed\n" , r); goto error_unreserve; } + + r =amdgpu_ttm_alloc_gart (&(*bo_ptr)->tbo); +if (r) { +dev_err (adev->dev,"%p bind failed\n" , *bo_ptr); + goto error_unpin; + } +if (gpu_addr) *gpu_addr =amdgpu_bo_gpu_offset (*bo_ptr);@@ -270,6 +277,8 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,return 0 ; +error_unpin: +amdgpu_bo_unpin (*bo_ptr); error_unreserve:amdgpu_bo_unreserve (*bo_ptr);@@ -903,12 +912,6 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, goto error; } - r =amdgpu_ttm_alloc_gart (&bo->tbo); -if (unlikely (r)) { -dev_err (adev->dev,"%p bind failed\n" , bo); - goto error; - } - bo->pin_count =1 ; domain =amdgpu_mem_type_to_domain (bo->tbo.mem.mem_type);drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +5
-0@@ -102,6 +102,11 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)DRM_ERROR ("Failed to pin GTT object %d\n" , i); goto out_lclean_unres; } + r =amdgpu_ttm_alloc_gart (>t_obj[i]->tbo); +if (r) { +DRM_ERROR ("%p bind failed\n" , gtt_obj[i]); + goto out_lclean_unpin; + } gart_addr =amdgpu_bo_gpu_offset (gtt_obj[i]); r =amdgpu_bo_kmap (gtt_obj[i], >t_map);drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +6
-2@@ -3110,13 +3110,22 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane, domain =AMDGPU_GEM_DOMAIN_VRAM ; r =amdgpu_bo_pin (rbo, domain); -amdgpu_bo_unreserve (rbo); -if (unlikely (r !=0 )) {if (r != -ERESTARTSYS )DRM_ERROR ("Failed to pin framebuffer with error %d\n" , r); +amdgpu_bo_unreserve (rbo); +return r; + } + + r =amdgpu_ttm_alloc_gart (&rbo->tbo); +if (unlikely (r !=0 )) {
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_plane_helper_prepare_fb(struct drm_plane *plane, · line 3131
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +5
-0+amdgpu_bo_unpin (rbo); +amdgpu_bo_unreserve (rbo); +DRM_ERROR ("%p bind failed\n" , rbo);return r; } +amdgpu_bo_unreserve (rbo); + afb->address =amdgpu_bo_gpu_offset (rbo);amdgpu_bo_ref (rbo);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 2/3] drm/amdgpu: allocate gart memory when it's required (v2)
In reply to a message not in the archiveQuoted 46 lines · Felix Kuehling
Comments inline [FK]
Quoted 42 lines · Junwei Zhang
Instead of calling gart memory on every bo pin,
allocates it on demandv2: fix error handling
Signed-off-by Junwei Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 14 ++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 8 ++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 15 +++++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 5 +++++ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 13 +++++++++++-- 8 files changed, 63 insertions(+), 10 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +6
-0@@ -280,6 +280,12 @@ int alloc_gtt_mem(struct kgd_dev *kgd, size_t size, goto allocate_mem_pin_bo_failed; } + r =amdgpu_ttm_alloc_gart (&bo->tbo); +if (r) { +dev_err (adev->dev,"%p bind failed\n" , bo); + goto allocate_mem_kmap_bo_failed; + } + r =amdgpu_bo_kmap (bo, &cpu_ptr_tmp);if (r) { dev_err(adev->dev,drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0@@ -1593,6 +1593,12 @@ int amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(struct kgd_dev *kgd, goto pin_failed; }
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(struct kgd_dev *kgd, · line 1601
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +6
-0+ ret =amdgpu_ttm_alloc_gart (&bo->tbo); +if (ret) { +pr_err ("%p bind failed\n" , bo); + goto kmap_failed; + } +[FK] I think think in this case we don't need the GART mapping. This function doesn't query the GPU address of the pinned buffer. The only reason we pin the BO here is to keep the kernel mapping valid.
Felix, thanks for your comments.
Check the code again, it seems to get GTT bo for kernel execution from user event or process. if so, that's really not needed.
Going to remove it in v3.
BTW, kfd2kgd_calls kfd2kgd looks duplicated in amdkfd_gfx_v7/8/9.c we may initialize it in a common place(at least for common members). If it has other purpose, please ignore that.
Jerry
Quoted 167 lines
Regards,
FelixQuoted 163 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0ret =amdgpu_bo_kmap (bo, kptr);if (ret) {pr_err ("Failed to map bo to kernel. ret %d\n" , ret);drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c +12
-2@@ -96,11 +96,16 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size,if (unlikely (r !=0 )) goto out_cleanup; r =amdgpu_bo_pin (sobj, sdomain); - saddr =amdgpu_bo_gpu_offset (sobj); +if (r) { +amdgpu_bo_unreserve (sobj); + goto out_cleanup; + } + r =amdgpu_ttm_alloc_gart (&sobj->tbo);amdgpu_bo_unreserve (sobj);if (r) { goto out_cleanup; } + saddr =amdgpu_bo_gpu_offset (sobj); bp.domain = ddomain; r =amdgpu_bo_create (adev, &bp, &dobj);if (r) {@@ -110,11 +115,16 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size,if (unlikely (r !=0 )) goto out_cleanup; r =amdgpu_bo_pin (dobj, ddomain); - daddr =amdgpu_bo_gpu_offset (dobj); +if (r) { +amdgpu_bo_unreserve (sobj); + goto out_cleanup; + } + r =amdgpu_ttm_alloc_gart (&dobj->tbo);amdgpu_bo_unreserve (dobj);if (r) { goto out_cleanup; } + daddr =amdgpu_bo_gpu_offset (dobj);if (adev->mman.buffer_funcs) { time =amdgpu_benchmark_do_move (adev, size, saddr, daddr, n);drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +6
-0@@ -194,6 +194,12 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc, goto unreserve; } + r =amdgpu_ttm_alloc_gart (&new_abo->tbo); +if (unlikely (r !=0 )) { +DRM_ERROR ("%p bind failed\n" , new_abo); + goto unpin; + } + r =reservation_object_get_fences_rcu (new_abo->tbo.resv, &work->excl, &work->shared_count, &work->shared);drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +8
-0@@ -173,6 +173,14 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,amdgpu_bo_unreserve (abo); goto out_unref; } + + ret =amdgpu_ttm_alloc_gart (&abo->tbo); +if (ret) { +amdgpu_bo_unreserve (abo); +dev_err (adev->dev,"%p bind failed\n" , abo); + goto out_unref; + } + ret =amdgpu_bo_kmap (abo,NULL );amdgpu_bo_unreserve (abo);if (ret) {drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +9
-6@@ -257,6 +257,13 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,dev_err (adev->dev,"(%d) kernel bo pin failed\n" , r); goto error_unreserve; } + + r =amdgpu_ttm_alloc_gart (&(*bo_ptr)->tbo); +if (r) { +dev_err (adev->dev,"%p bind failed\n" , *bo_ptr); + goto error_unpin; + } +if (gpu_addr) *gpu_addr =amdgpu_bo_gpu_offset (*bo_ptr);@@ -270,6 +277,8 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,return 0 ; +error_unpin: +amdgpu_bo_unpin (*bo_ptr); error_unreserve:amdgpu_bo_unreserve (*bo_ptr);@@ -903,12 +912,6 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, goto error; } - r =amdgpu_ttm_alloc_gart (&bo->tbo); -if (unlikely (r)) { -dev_err (adev->dev,"%p bind failed\n" , bo); - goto error; - } - bo->pin_count =1 ; domain =amdgpu_mem_type_to_domain (bo->tbo.mem.mem_type);drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +5
-0@@ -102,6 +102,11 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)DRM_ERROR ("Failed to pin GTT object %d\n" , i); goto out_lclean_unres; } + r =amdgpu_ttm_alloc_gart (>t_obj[i]->tbo); +if (r) { +DRM_ERROR ("%p bind failed\n" , gtt_obj[i]); + goto out_lclean_unpin; + } gart_addr =amdgpu_bo_gpu_offset (gtt_obj[i]); r =amdgpu_bo_kmap (gtt_obj[i], >t_map);drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +11
-2@@ -3110,13 +3110,22 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane, domain =AMDGPU_GEM_DOMAIN_VRAM ; r =amdgpu_bo_pin (rbo, domain); -amdgpu_bo_unreserve (rbo); -if (unlikely (r !=0 )) {if (r != -ERESTARTSYS )DRM_ERROR ("Failed to pin framebuffer with error %d\n" , r); +amdgpu_bo_unreserve (rbo); +return r; + } + + r =amdgpu_ttm_alloc_gart (&rbo->tbo); +if (unlikely (r !=0 )) { +amdgpu_bo_unpin (rbo); +amdgpu_bo_unreserve (rbo); +DRM_ERROR ("%p bind failed\n" , rbo);return r; } +amdgpu_bo_unreserve (rbo); + afb->address =amdgpu_bo_gpu_offset (rbo);
Quoted 2 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_plane_helper_prepare_fb(struct drm_plane *plane, · line 3131
Quoted 1 line
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0amdgpu_bo_ref (rbo);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 2/3] drm/amdgpu: allocate gart memory when it's required (v2)
In reply to a message not in the archiveQuoted 4 lines · Jerry (Junwei)
BTW,
kfd2kgd_callskfd2kgd looks duplicated in amdkfd_gfx_v7/8/9.c we may initialize it in a common place(at least for common members). If it has other purpose, please ignore that.
Some of the function pointers in kfd2kgd_calls are HW-specific (static functions implemented in amdgpu_amdkfd_gfx_v[789].c). Therefore they are not really duplicates. They may look the same in the source code, but they'll end up pointing to different functions.
Regards,
Felix
Quoted 189 lines
Jerry
Quoted 186 lines
Regards,
FelixQuoted 181 lines
ret =
amdgpu_bo_kmap(bo, kptr);
if (ret) {
pr_err("Failed to map bo to kernel. ret %d\n", ret);drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c +6
-1@@ -96,11 +96,16 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size, if (unlikely(r != 0)) goto out_cleanup; r = amdgpu_bo_pin(sobj, sdomain); - saddr = amdgpu_bo_gpu_offset(sobj); + if (r) { + amdgpu_bo_unreserve(sobj); + goto out_cleanup; + } + r = amdgpu_ttm_alloc_gart(&sobj->tbo); amdgpu_bo_unreserve(sobj); if (r) { goto out_cleanup; } + saddr = amdgpu_bo_gpu_offset(sobj); bp.domain = ddomain; r = amdgpu_bo_create(adev, &bp, &dobj);if (r) {
drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c +6
-1@@ -110,11 +115,16 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size, if (unlikely(r != 0)) goto out_cleanup; r = amdgpu_bo_pin(dobj, ddomain); - daddr = amdgpu_bo_gpu_offset(dobj); + if (r) { + amdgpu_bo_unreserve(sobj); + goto out_cleanup; + } + r = amdgpu_ttm_alloc_gart(&dobj->tbo); amdgpu_bo_unreserve(dobj); if (r) { goto out_cleanup; } + daddr = amdgpu_bo_gpu_offset(dobj); if (adev->mman.buffer_funcs) {time =
amdgpu_benchmark_do_move(adev, size, saddr, daddr, n);drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +6
-0@@ -194,6 +194,12 @@ int amdgpu_display_crtc_page_flip_target(structdrm_crtc *crtc, goto unreserve; } + r = amdgpu_ttm_alloc_gart(&new_abo->tbo); + if (unlikely(r != 0)) { + DRM_ERROR("%p bind failed\n", new_abo); + goto unpin; + } + r = reservation_object_get_fences_rcu(new_abo->tbo.resv, &work->excl,
&work->shared_count,
&work->shared);drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +8
-0@@ -173,6 +173,14 @@ static int amdgpufb_create_pinned_object(structamdgpu_fbdev *rfbdev, amdgpu_bo_unreserve(abo); goto out_unref; } + + ret = amdgpu_ttm_alloc_gart(&abo->tbo); + if (ret) { + amdgpu_bo_unreserve(abo); + dev_err(adev->dev, "%p bind failed\n", abo); + goto out_unref; + } + ret = amdgpu_bo_kmap(abo, NULL); amdgpu_bo_unreserve(abo);if (ret) {
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +9
-0@@ -257,6 +257,13 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev, dev_err(adev->dev, "(%d) kernel bo pin failed\n", r); goto error_unreserve; } + + r = amdgpu_ttm_alloc_gart(&(*bo_ptr)->tbo); + if (r) { + dev_err(adev->dev, "%p bind failed\n", *bo_ptr); + goto error_unpin; + } + if (gpu_addr) *gpu_addr = amdgpu_bo_gpu_offset(*bo_ptr);@@ -270,6 +277,8 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev, return 0; +error_unpin: + amdgpu_bo_unpin(*bo_ptr);
error_unreserve:
amdgpu_bo_unreserve(*bo_ptr);drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0
-6@@ -903,12 +912,6 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, goto error; } - r = amdgpu_ttm_alloc_gart(&bo->tbo); - if (unlikely(r)) { - dev_err(adev->dev, "%p bind failed\n", bo); - goto error; - } - bo->pin_count = 1;domain =
amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type);drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +5
-0@@ -102,6 +102,11 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) DRM_ERROR("Failed to pin GTT object %d\n", i); goto out_lclean_unres; } + r = amdgpu_ttm_alloc_gart(>t_obj[i]->tbo); + if (r) { + DRM_ERROR("%p bind failed\n", gtt_obj[i]); + goto out_lclean_unpin; + } gart_addr = amdgpu_bo_gpu_offset(gtt_obj[i]);r =
amdgpu_bo_kmap(gtt_obj[i], >t_map);drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +11
-2@@ -3110,13 +3110,22 @@ static int dm_plane_helper_prepare_fb(structdrm_plane *plane, domain = AMDGPU_GEM_DOMAIN_VRAM; r = amdgpu_bo_pin(rbo, domain); - amdgpu_bo_unreserve(rbo); - if (unlikely(r != 0)) { if (r != -ERESTARTSYS) DRM_ERROR("Failed to pin framebuffer with error %d\n", r); + amdgpu_bo_unreserve(rbo); + return r; + } + + r = amdgpu_ttm_alloc_gart(&rbo->tbo); + if (unlikely(r != 0)) { + amdgpu_bo_unpin(rbo); + amdgpu_bo_unreserve(rbo); + DRM_ERROR("%p bind failed\n", rbo); return r; } + amdgpu_bo_unreserve(rbo); + afb->address = amdgpu_bo_gpu_offset(rbo);
amdgpu_bo_ref(rbo);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 2/3] drm/amdgpu: allocate gart memory when it's required (v2)
In reply to a message not in the archiveQuoted 10 lines · Felix Kuehling
Quoted 4 lines · Jerry (Junwei)
BTW,
kfd2kgd_callskfd2kgd looks duplicated in amdkfd_gfx_v7/8/9.c we may initialize it in a common place(at least for common members). If it has other purpose, please ignore that.Some of the function pointers in
kfd2kgd_callsare HW-specific (static functions implemented in amdgpu_amdkfd_gfx_v[789].c). Therefore they are not really duplicates. They may look the same in the source code, but they'll end up pointing to different functions.
Thanks for your explanation.
I see.
Just a suggestion. In this case, we may add the version for each func to clarify the different HW support, e.g. kgd_program_sh_mem_settings_v9. Then the common func would be identified clearly, like alloc_gtt_mem() for all HWs. So do HW-specific func.
(seems to talk too much regardless of this thread, thanks for your discussion)
Jerry
Quoted 194 lines
Regards,
FelixQuoted 189 lines
Jerry
Quoted 186 lines
Regards,
FelixQuoted 181 lines
ret = amdgpu_bo_kmap(bo, kptr); if (ret) { pr_err("Failed to map bo to kernel. ret %d\n", ret);drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c +6
-1@@ -96,11 +96,16 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size, if (unlikely(r != 0)) goto out_cleanup; r =amdgpu_bo_pin (sobj, sdomain); - saddr =amdgpu_bo_gpu_offset (sobj); +if (r) { +amdgpu_bo_unreserve (sobj); + goto out_cleanup; + } + r =amdgpu_ttm_alloc_gart (&sobj->tbo);amdgpu_bo_unreserve (sobj);if (r) { goto out_cleanup; } + saddr =amdgpu_bo_gpu_offset (sobj); bp.domain = ddomain; r =amdgpu_bo_create (adev, &bp, &dobj);if (r) {drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c +6
-1@@ -110,11 +115,16 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size, if (unlikely(r != 0)) goto out_cleanup; r =amdgpu_bo_pin (dobj, ddomain); - daddr =amdgpu_bo_gpu_offset (dobj); +if (r) { +amdgpu_bo_unreserve (sobj); + goto out_cleanup; + } + r =amdgpu_ttm_alloc_gart (&dobj->tbo);amdgpu_bo_unreserve (dobj);if (r) { goto out_cleanup; } + daddr =amdgpu_bo_gpu_offset (dobj);if (adev->mman.buffer_funcs) {time = amdgpu_benchmark_do_move(adev, size, saddr, daddr, n);drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +6
-0@@ -194,6 +194,12 @@ int amdgpu_display_crtc_page_flip_target(structdrm_crtc *crtc, goto unreserve; } + r =amdgpu_ttm_alloc_gart (&new_abo->tbo); +if (unlikely (r !=0 )) { +DRM_ERROR ("%p bind failed\n" , new_abo); + goto unpin; + } + r = reservation_object_get_fences_rcu(new_abo->tbo.resv, &work->excl,&work->shared_count, &work->shared);drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +8
-0@@ -173,6 +173,14 @@ static int amdgpufb_create_pinned_object(structamdgpu_fbdev *rfbdev,amdgpu_bo_unreserve (abo ); goto out_unref; } + + ret =amdgpu_ttm_alloc_gart (&abo->tbo); +if (ret) { +amdgpu_bo_unreserve (abo); +dev_err (adev->dev,"%p bind failed\n" , abo); + goto out_unref; + } + ret =amdgpu_bo_kmap (abo,NULL );amdgpu_bo_unreserve (abo);if (ret) {drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +9
-6@@ -257,6 +257,13 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,dev_err (adev->dev,"(%d) kernel bo pin failed\n" , r); goto error_unreserve; } + + r =amdgpu_ttm_alloc_gart (&(*bo_ptr)->tbo); +if (r) { +dev_err (adev->dev,"%p bind failed\n" , *bo_ptr); + goto error_unpin; + } +if (gpu_addr) *gpu_addr =amdgpu_bo_gpu_offset (*bo_ptr);@@ -270,6 +277,8 @@ int amdgpu_bo_create_reserved(structamdgpu_device *adev, return 0; +error_unpin: +amdgpu_bo_unpin (*bo_ptr); error_unreserve:amdgpu_bo_unreserve (*bo_ptr);@@ -903,12 +912,6 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, goto error; } - r =amdgpu_ttm_alloc_gart (&bo->tbo); -if (unlikely (r)) { -dev_err (adev->dev,"%p bind failed\n" , bo); - goto error; - } - bo->pin_count =1 ;domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type);drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +5
-0@@ -102,6 +102,11 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) DRM_ERROR("Failed to pin GTT object %d\n", i); goto out_lclean_unres; } + r =amdgpu_ttm_alloc_gart (>t_obj[i]->tbo); +if (r) { +DRM_ERROR ("%p bind failed\n" , gtt_obj[i]); + goto out_lclean_unpin; + } gart_addr =amdgpu_bo_gpu_offset (gtt_obj[i]);r = amdgpu_bo_kmap(gtt_obj[i], >t_map);drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +11
-2@@ -3110,13 +3110,22 @@ static int dm_plane_helper_prepare_fb(structdrm_plane *plane, domain =AMDGPU_GEM_DOMAIN_VRAM ; r =amdgpu_bo_pin (rbo, domain); -amdgpu_bo_unreserve (rbo); -if (unlikely (r !=0 )) {if (r != -ERESTARTSYS )DRM_ERROR ("Failed to pin framebuffer with error %d\n" , r); +amdgpu_bo_unreserve (rbo); +return r; + } + + r =amdgpu_ttm_alloc_gart (&rbo->tbo); +if (unlikely (r !=0 )) { +amdgpu_bo_unpin (rbo); +amdgpu_bo_unreserve (rbo); +DRM_ERROR ("%p bind failed\n" , rbo);return r; } +amdgpu_bo_unreserve (rbo); + afb->address =amdgpu_bo_gpu_offset (rbo);amdgpu_bo_ref(rbo);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 26.06.2018 um 10:35 schrieb Junwei Zhang:
Quoted 4 lines
It could be got by
amdgpu_bo_gpu_offset()if needSigned-off-by Junwei Zhang <[email protected]>Reviewed-by Michel Dänzer <[email protected]>
Patches #1 and #3 are Reviewed-by: Christian König <[email protected]>.
Christian.
Quoted 498 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 6 ++---- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 6 ++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 ++--- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 5 ++--- drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 6 ++---- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 17 ++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 5 ++--- drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 6 ++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 10 +++++----- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 10 +++++----- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 10 +++++----- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 10 +++++----- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++- 17 files changed, 50 insertions(+), 57 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +2
-4@@ -251,7 +251,6 @@ int alloc_gtt_mem(struct kgd_dev *kgd, size_t size,struct amdgpu_bo *bo =NULL ;struct amdgpu_bo_param bp;int r; -uint64_t gpu_addr_tmp =0 ;void *cpu_ptr_tmp =NULL ;memset (&bp,0 ,sizeof (bp));@@ -275,8 +274,7 @@ int alloc_gtt_mem(struct kgd_dev *kgd, size_t size, goto allocate_mem_reserve_bo_failed; } - r =amdgpu_bo_pin (bo,AMDGPU_GEM_DOMAIN_GTT , - &gpu_addr_tmp); + r =amdgpu_bo_pin (bo,AMDGPU_GEM_DOMAIN_GTT );if (r) {dev_err (adev->dev,"(%d) failed to pin bo for amdkfd\n" , r); goto allocate_mem_pin_bo_failed;@@ -290,7 +288,7 @@ int alloc_gtt_mem(struct kgd_dev *kgd, size_t size, } *mem_obj = bo; - *gpu_addr = gpu_addr_tmp; + *gpu_addr =amdgpu_bo_gpu_offset (bo); *cpu_ptr = cpu_ptr_tmp;amdgpu_bo_unreserve (bo);drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1
-1@@ -1587,7 +1587,7 @@ int amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(struct kgd_dev *kgd, goto bo_reserve_failed; } - ret =amdgpu_bo_pin (bo,AMDGPU_GEM_DOMAIN_GTT ,NULL ); + ret =amdgpu_bo_pin (bo,AMDGPU_GEM_DOMAIN_GTT );if (ret) {pr_err ("Failed to pin bo. ret %d\n" , ret); goto pin_failed;drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c +4
-2@@ -95,7 +95,8 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size, r =amdgpu_bo_reserve (sobj, false);if (unlikely (r !=0 )) goto out_cleanup; - r =amdgpu_bo_pin (sobj, sdomain, &saddr); + r =amdgpu_bo_pin (sobj, sdomain); + saddr =amdgpu_bo_gpu_offset (sobj);amdgpu_bo_unreserve (sobj);if (r) { goto out_cleanup;@@ -108,7 +109,8 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size, r =amdgpu_bo_reserve (dobj, false);if (unlikely (r !=0 )) goto out_cleanup; - r =amdgpu_bo_pin (dobj, ddomain, &daddr); + r =amdgpu_bo_pin (dobj, ddomain); + daddr =amdgpu_bo_gpu_offset (dobj);amdgpu_bo_unreserve (dobj);if (r) { goto out_cleanup;drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-3@@ -2736,11 +2736,10 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)struct amdgpu_bo *aobj =gem_to_amdgpu_bo (amdgpu_crtc->cursor_bo); r =amdgpu_bo_reserve (aobj, true);if (r ==0 ) { - r =amdgpu_bo_pin (aobj, -AMDGPU_GEM_DOMAIN_VRAM , - &amdgpu_crtc->cursor_addr); + r =amdgpu_bo_pin (aobj,AMDGPU_GEM_DOMAIN_VRAM );if (r !=0 )DRM_ERROR ("Failed to pin cursor BO (%d)\n" , r); + amdgpu_crtc->cursor_addr =amdgpu_bo_gpu_offset (aobj);amdgpu_bo_unreserve (aobj); } }drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +2
-3@@ -157,7 +157,6 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc,struct amdgpu_bo *new_abo;unsigned long flags;u64 tiling_flags; -u64 base;int i, r; work =kzalloc (sizeof *work,GFP_KERNEL );@@ -189,7 +188,7 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc, goto cleanup; } - r =amdgpu_bo_pin (new_abo,amdgpu_display_supported_domains (adev), &base); + r =amdgpu_bo_pin (new_abo,amdgpu_display_supported_domains (adev));if (unlikely (r !=0 )) {DRM_ERROR ("failed to pin new abo buffer before flip\n" ); goto unreserve;@@ -206,7 +205,7 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc,amdgpu_bo_get_tiling_flags (new_abo, &tiling_flags);amdgpu_bo_unreserve (new_abo); - work->base = base; + work->base =amdgpu_bo_gpu_offset (new_abo); work->target_vblank = target - (uint32_t )drm_crtc_vblank_count (crtc) +amdgpu_get_vblank_counter_kms (dev, work->crtc_id);drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +1
-1@@ -168,7 +168,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev, } - ret =amdgpu_bo_pin (abo, domain,NULL ); + ret =amdgpu_bo_pin (abo, domain);if (ret) {amdgpu_bo_unreserve (abo); goto out_unref;drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +2
-4@@ -143,14 +143,12 @@ int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev)*/ int amdgpu_gart_table_vram_pin (struct amdgpu_device *adev) { -uint64_t gpu_addr;int r; r =amdgpu_bo_reserve (adev->gart.robj, false);if (unlikely (r !=0 ))return r; - r =amdgpu_bo_pin (adev->gart.robj, -AMDGPU_GEM_DOMAIN_VRAM , &gpu_addr); + r =amdgpu_bo_pin (adev->gart.robj,AMDGPU_GEM_DOMAIN_VRAM );if (r) {amdgpu_bo_unreserve (adev->gart.robj);return r;@@ -159,7 +157,7 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev)if (r)amdgpu_bo_unpin (adev->gart.robj);amdgpu_bo_unreserve (adev->gart.robj); - adev->gart.table_addr = gpu_addr; + adev->gart.table_addr =amdgpu_bo_gpu_offset (adev->gart.robj);return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +6
-11@@ -252,11 +252,13 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev, goto error_free; } - r =amdgpu_bo_pin (*bo_ptr, domain, gpu_addr); + r =amdgpu_bo_pin (*bo_ptr, domain);if (r) {dev_err (adev->dev,"(%d) kernel bo pin failed\n" , r); goto error_unreserve; } +if (gpu_addr) + *gpu_addr =amdgpu_bo_gpu_offset (*bo_ptr);if (cpu_addr) { r =amdgpu_bo_kmap (*bo_ptr, cpu_addr);@@ -817,7 +819,6 @@ void amdgpu_bo_unref(struct amdgpu_bo **bo)* @domain: domain to be pinned to * @min_offset: the start of requested address range * @max_offset: the end of requested address range -* @gpu_addr: GPU offset of the &amdgpu_bo buffer object * * Pins the buffer object according to requested domain and address range. If * the memory is unbound gart memory, binds the pages into gart table. Adjusts @@ -835,8 +836,7 @@ void amdgpu_bo_unref(struct amdgpu_bo **bo)* 0 for success or a negative error code on failure. */ int amdgpu_bo_pin_restricted (struct amdgpu_bo *bo,u32 domain, -u64 min_offset,u64 max_offset, -u64 *gpu_addr) +u64 min_offset,u64 max_offset) {struct amdgpu_device *adev =amdgpu_ttm_adev (bo->tbo.bdev);struct ttm_operation_ctx ctx = { false, false };@@ -868,8 +868,6 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,return -EINVAL ; bo->pin_count++; -if (gpu_addr) - *gpu_addr =amdgpu_bo_gpu_offset (bo);if (max_offset !=0 ) {u64 domain_start = bo->tbo.bdev->man[mem_type].gpu_offset;@@ -912,8 +910,6 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, } bo->pin_count =1 ; -if (gpu_addr !=NULL ) - *gpu_addr =amdgpu_bo_gpu_offset (bo); domain =amdgpu_mem_type_to_domain (bo->tbo.mem.mem_type);if (domain ==AMDGPU_GEM_DOMAIN_VRAM ) {@@ -931,7 +927,6 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,* amdgpu_bo_pin - pin an &amdgpu_bo buffer object * @bo: &amdgpu_bo buffer object to be pinned * @domain: domain to be pinned to -* @gpu_addr: GPU offset of the &amdgpu_bo buffer object * * A simple wrapper to amdgpu_bo_pin_restricted(). * Provides a simpler API for buffers that do not have any strict restrictions @@ -940,9 +935,9 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,* Returns: * 0 for success or a negative error code on failure. */ -int amdgpu_bo_pin (struct amdgpu_bo *bo,u32 domain,u64 *gpu_addr) +int amdgpu_bo_pin (struct amdgpu_bo *bo,u32 domain) { -return amdgpu_bo_pin_restricted (bo, domain,0 ,0 , gpu_addr); +return amdgpu_bo_pin_restricted (bo, domain,0 ,0 ); }/** drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +2
-3@@ -252,10 +252,9 @@ void amdgpu_bo_free_kernel(struct amdgpu_bo **bo, u64 *gpu_addr,void amdgpu_bo_kunmap (struct amdgpu_bo *bo);struct amdgpu_bo *amdgpu_bo_ref (struct amdgpu_bo *bo);void amdgpu_bo_unref (struct amdgpu_bo **bo); -int amdgpu_bo_pin (struct amdgpu_bo *bo,u32 domain,u64 *gpu_addr); +int amdgpu_bo_pin (struct amdgpu_bo *bo,u32 domain);int amdgpu_bo_pin_restricted (struct amdgpu_bo *bo,u32 domain, -u64 min_offset,u64 max_offset, -u64 *gpu_addr); +u64 min_offset,u64 max_offset);int amdgpu_bo_unpin (struct amdgpu_bo *bo);int amdgpu_bo_evict_vram (struct amdgpu_device *adev);int amdgpu_bo_init (struct amdgpu_device *adev);drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +1
-1@@ -234,7 +234,7 @@ static int amdgpu_gem_map_attach(struct dma_buf *dma_buf, }/* pin buffer into GTT */ - r =amdgpu_bo_pin (bo,AMDGPU_GEM_DOMAIN_GTT ,NULL ); + r =amdgpu_bo_pin (bo,AMDGPU_GEM_DOMAIN_GTT );if (r) goto error_unreserve;drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +4
-2@@ -75,11 +75,12 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) r =amdgpu_bo_reserve (vram_obj, false);if (unlikely (r !=0 )) goto out_unref; - r =amdgpu_bo_pin (vram_obj,AMDGPU_GEM_DOMAIN_VRAM , &vram_addr); + r =amdgpu_bo_pin (vram_obj,AMDGPU_GEM_DOMAIN_VRAM );if (r) {DRM_ERROR ("Failed to pin VRAM object\n" ); goto out_unres; } + vram_addr =amdgpu_bo_gpu_offset (vram_obj);for (i =0 ; i < n; i++) {void *gtt_map, *vram_map;void **gart_start, **gart_end;@@ -96,11 +97,12 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) r =amdgpu_bo_reserve (gtt_obj[i], false);if (unlikely (r !=0 )) goto out_lclean_unref; - r =amdgpu_bo_pin (gtt_obj[i],AMDGPU_GEM_DOMAIN_GTT , &gart_addr); + r =amdgpu_bo_pin (gtt_obj[i],AMDGPU_GEM_DOMAIN_GTT );if (r) {DRM_ERROR ("Failed to pin GTT object %d\n" , i); goto out_lclean_unres; } + gart_addr =amdgpu_bo_gpu_offset (gtt_obj[i]); r =amdgpu_bo_kmap (gtt_obj[i], >t_map);if (r) {drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1
-1@@ -1695,7 +1695,7 @@ static int amdgpu_ttm_fw_reserve_vram_init(struct amdgpu_device *adev)AMDGPU_GEM_DOMAIN_VRAM , adev->fw_vram_usage.start_offset, (adev->fw_vram_usage.start_offset + - adev->fw_vram_usage.size), NULL); + adev->fw_vram_usage.size));if (r) goto error_pin; r = amdgpu_bo_kmap(adev->fw_vram_usage.reserved_bo,drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +5
-5@@ -1855,15 +1855,14 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,if (unlikely (r !=0 ))return r; -if (atomic) { - fb_location =amdgpu_bo_gpu_offset (abo); - }else { - r =amdgpu_bo_pin (abo,AMDGPU_GEM_DOMAIN_VRAM , &fb_location); +if (!atomic) { + r =amdgpu_bo_pin (abo,AMDGPU_GEM_DOMAIN_VRAM );if (unlikely (r !=0 )) {amdgpu_bo_unreserve (abo);return -EINVAL ; } } + fb_location =amdgpu_bo_gpu_offset (abo);amdgpu_bo_get_tiling_flags (abo, &tiling_flags);amdgpu_bo_unreserve (abo);@@ -2370,13 +2369,14 @@ static int dce_v10_0_crtc_cursor_set2(struct drm_crtc *crtc,return ret; } - ret =amdgpu_bo_pin (aobj,AMDGPU_GEM_DOMAIN_VRAM , &amdgpu_crtc->cursor_addr); + ret =amdgpu_bo_pin (aobj,AMDGPU_GEM_DOMAIN_VRAM );amdgpu_bo_unreserve (aobj);if (ret) {DRM_ERROR ("Failed to pin new cursor BO (%d)\n" , ret);drm_gem_object_put_unlocked (obj);return ret; } + amdgpu_crtc->cursor_addr =amdgpu_bo_gpu_offset (aobj);dce_v10_0_lock_cursor (crtc, true);drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +5
-5@@ -1897,15 +1897,14 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,if (unlikely (r !=0 ))return r; -if (atomic) { - fb_location =amdgpu_bo_gpu_offset (abo); - }else { - r =amdgpu_bo_pin (abo,AMDGPU_GEM_DOMAIN_VRAM , &fb_location); +if (!atomic) { + r =amdgpu_bo_pin (abo,AMDGPU_GEM_DOMAIN_VRAM );if (unlikely (r !=0 )) {amdgpu_bo_unreserve (abo);return -EINVAL ; } } + fb_location =amdgpu_bo_gpu_offset (abo);amdgpu_bo_get_tiling_flags (abo, &tiling_flags);amdgpu_bo_unreserve (abo);@@ -2449,13 +2448,14 @@ static int dce_v11_0_crtc_cursor_set2(struct drm_crtc *crtc,return ret; } - ret =amdgpu_bo_pin (aobj,AMDGPU_GEM_DOMAIN_VRAM , &amdgpu_crtc->cursor_addr); + ret =amdgpu_bo_pin (aobj,AMDGPU_GEM_DOMAIN_VRAM );amdgpu_bo_unreserve (aobj);if (ret) {DRM_ERROR ("Failed to pin new cursor BO (%d)\n" , ret);drm_gem_object_put_unlocked (obj);return ret; } + amdgpu_crtc->cursor_addr =amdgpu_bo_gpu_offset (aobj);dce_v11_0_lock_cursor (crtc, true);drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +5
-5@@ -1811,15 +1811,14 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,if (unlikely (r !=0 ))return r; -if (atomic) { - fb_location =amdgpu_bo_gpu_offset (abo); - }else { - r =amdgpu_bo_pin (abo,AMDGPU_GEM_DOMAIN_VRAM , &fb_location); +if (!atomic) { + r =amdgpu_bo_pin (abo,AMDGPU_GEM_DOMAIN_VRAM );if (unlikely (r !=0 )) {amdgpu_bo_unreserve (abo);return -EINVAL ; } } + fb_location =amdgpu_bo_gpu_offset (abo);amdgpu_bo_get_tiling_flags (abo, &tiling_flags);amdgpu_bo_unreserve (abo);@@ -2263,13 +2262,14 @@ static int dce_v6_0_crtc_cursor_set2(struct drm_crtc *crtc,return ret; } - ret =amdgpu_bo_pin (aobj,AMDGPU_GEM_DOMAIN_VRAM , &amdgpu_crtc->cursor_addr); + ret =amdgpu_bo_pin (aobj,AMDGPU_GEM_DOMAIN_VRAM );amdgpu_bo_unreserve (aobj);if (ret) {DRM_ERROR ("Failed to pin new cursor BO (%d)\n" , ret);drm_gem_object_put_unlocked (obj);return ret; } + amdgpu_crtc->cursor_addr =amdgpu_bo_gpu_offset (aobj);dce_v6_0_lock_cursor (crtc, true);drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +5
-5@@ -1786,15 +1786,14 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,if (unlikely (r !=0 ))return r; -if (atomic) { - fb_location =amdgpu_bo_gpu_offset (abo); - }else { - r =amdgpu_bo_pin (abo,AMDGPU_GEM_DOMAIN_VRAM , &fb_location); +if (!atomic) { + r =amdgpu_bo_pin (abo,AMDGPU_GEM_DOMAIN_VRAM );if (unlikely (r !=0 )) {amdgpu_bo_unreserve (abo);return -EINVAL ; } } + fb_location =amdgpu_bo_gpu_offset (abo);amdgpu_bo_get_tiling_flags (abo, &tiling_flags);amdgpu_bo_unreserve (abo);@@ -2274,13 +2273,14 @@ static int dce_v8_0_crtc_cursor_set2(struct drm_crtc *crtc,return ret; } - ret =amdgpu_bo_pin (aobj,AMDGPU_GEM_DOMAIN_VRAM , &amdgpu_crtc->cursor_addr); + ret =amdgpu_bo_pin (aobj,AMDGPU_GEM_DOMAIN_VRAM );amdgpu_bo_unreserve (aobj);if (ret) {DRM_ERROR ("Failed to pin new cursor BO (%d)\n" , ret);drm_gem_object_put_unlocked (obj);return ret; } + amdgpu_crtc->cursor_addr =amdgpu_bo_gpu_offset (aobj);dce_v8_0_lock_cursor (crtc, true);drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1@@ -3109,7 +3109,7 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,else domain =AMDGPU_GEM_DOMAIN_VRAM ; - r =amdgpu_bo_pin (rbo, domain, &afb->address); + r =amdgpu_bo_pin (rbo, domain);amdgpu_bo_unreserve (rbo);if (unlikely (r !=0 )) {
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_plane_helper_prepare_fb(struct drm_plane *plane, · line 3123
Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-0@@ -3117,6 +3117,7 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,DRM_ERROR ("Failed to pin framebuffer with error %d\n" , r);return r; } + afb->address =amdgpu_bo_gpu_offset (rbo);amdgpu_bo_ref (rbo);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx