aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
index fb270c7e7171..a81dfaeeb8c0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
@@ -360,6 +360,18 @@ static void amdgpu_uvd_force_into_uvd_segment(struct amdgpu_bo *abo)
360 } 360 }
361} 361}
362 362
363static u64 amdgpu_uvd_get_addr_from_ctx(struct amdgpu_uvd_cs_ctx *ctx)
364{
365 uint32_t lo, hi;
366 uint64_t addr;
367
368 lo = amdgpu_get_ib_value(ctx->parser, ctx->ib_idx, ctx->data0);
369 hi = amdgpu_get_ib_value(ctx->parser, ctx->ib_idx, ctx->data1);
370 addr = ((uint64_t)lo) | (((uint64_t)hi) << 32);
371
372 return addr;
373}
374
363/** 375/**
364 * amdgpu_uvd_cs_pass1 - first parsing round 376 * amdgpu_uvd_cs_pass1 - first parsing round
365 * 377 *
@@ -372,14 +384,10 @@ static int amdgpu_uvd_cs_pass1(struct amdgpu_uvd_cs_ctx *ctx)
372{ 384{
373 struct amdgpu_bo_va_mapping *mapping; 385 struct amdgpu_bo_va_mapping *mapping;
374 struct amdgpu_bo *bo; 386 struct amdgpu_bo *bo;
375 uint32_t cmd, lo, hi; 387 uint32_t cmd;
376 uint64_t addr; 388 uint64_t addr = amdgpu_uvd_get_addr_from_ctx(ctx);
377 int r = 0; 389 int r = 0;
378 390
379 lo = amdgpu_get_ib_value(ctx->parser, ctx->ib_idx, ctx->data0);
380 hi = amdgpu_get_ib_value(ctx->parser, ctx->ib_idx, ctx->data1);
381 addr = ((uint64_t)lo) | (((uint64_t)hi) << 32);
382
383 mapping = amdgpu_cs_find_mapping(ctx->parser, addr, &bo); 391 mapping = amdgpu_cs_find_mapping(ctx->parser, addr, &bo);
384 if (mapping == NULL) { 392 if (mapping == NULL) {
385 DRM_ERROR("Can't find BO for addr 0x%08Lx\n", addr); 393 DRM_ERROR("Can't find BO for addr 0x%08Lx\n", addr);
@@ -698,18 +706,16 @@ static int amdgpu_uvd_cs_pass2(struct amdgpu_uvd_cs_ctx *ctx)
698{ 706{
699 struct amdgpu_bo_va_mapping *mapping; 707 struct amdgpu_bo_va_mapping *mapping;
700 struct amdgpu_bo *bo; 708 struct amdgpu_bo *bo;
701 uint32_t cmd, lo, hi; 709 uint32_t cmd;
702 uint64_t start, end; 710 uint64_t start, end;
703 uint64_t addr; 711 uint64_t addr = amdgpu_uvd_get_addr_from_ctx(ctx);
704 int r; 712 int r;
705 713
706 lo = amdgpu_get_ib_value(ctx->parser, ctx->ib_idx, ctx->data0);
707 hi = amdgpu_get_ib_value(ctx->parser, ctx->ib_idx, ctx->data1);
708 addr = ((uint64_t)lo) | (((uint64_t)hi) << 32);
709
710 mapping = amdgpu_cs_find_mapping(ctx->parser, addr, &bo); 714 mapping = amdgpu_cs_find_mapping(ctx->parser, addr, &bo);
711 if (mapping == NULL) 715 if (mapping == NULL) {
716 DRM_ERROR("Can't find BO for addr 0x%08Lx\n", addr);
712 return -EINVAL; 717 return -EINVAL;
718 }
713 719
714 start = amdgpu_bo_gpu_offset(bo); 720 start = amdgpu_bo_gpu_offset(bo);
715 721
@@ -893,10 +899,13 @@ int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx)
893 ctx.buf_sizes = buf_sizes; 899 ctx.buf_sizes = buf_sizes;
894 ctx.ib_idx = ib_idx; 900 ctx.ib_idx = ib_idx;
895 901
896 /* first round, make sure the buffers are actually in the UVD segment */ 902 /* first round only required on chips without UVD 64 bit address support */
897 r = amdgpu_uvd_cs_packets(&ctx, amdgpu_uvd_cs_pass1); 903 if (!parser->adev->uvd.address_64_bit) {
898 if (r) 904 /* first round, make sure the buffers are actually in the UVD segment */
899 return r; 905 r = amdgpu_uvd_cs_packets(&ctx, amdgpu_uvd_cs_pass1);
906 if (r)
907 return r;
908 }
900 909
901 /* second round, patch buffer addresses into the command stream */ 910 /* second round, patch buffer addresses into the command stream */
902 r = amdgpu_uvd_cs_packets(&ctx, amdgpu_uvd_cs_pass2); 911 r = amdgpu_uvd_cs_packets(&ctx, amdgpu_uvd_cs_pass2);