On 2018-06-26 09:42 PM, Zhang, Jerry (Junwei) wrote: > > 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. 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 > > Jerry > >> >> Regards, >> Â Â Felix >> >>> Â Â Â Â Â ret = amdgpu_bo_kmap(bo, kptr); >>> Â Â Â Â Â if (ret) { >>> Â Â Â Â Â Â Â Â Â pr_err("Failed to map bo to kernel. ret %d\n", ret); >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c >>> index cb88d7e..3079ea8 100644 >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c >>> @@ -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); >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c >>> index 036b6f7..7d6a36b 100644 >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c >>> @@ -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); >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c >>> index 462b7a1..cd68a2e 100644 >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c >>> @@ -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) { >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> index 79cdbf1..7f7c221 100644 >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >>> @@ -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); >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c >>> index 622affc..d6eeea1 100644 >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c >>> @@ -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); >>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c >>> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c >>> index 31652c1e..d433428 100644 >>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c >>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c >>> @@ -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); >>