diff options
author | Alex Deucher <alexander.deucher@amd.com> | 2016-11-21 16:24:37 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2016-11-23 15:08:47 -0500 |
commit | 80983e4df7196b0f300242bcd8e9df6370869438 (patch) | |
tree | 9a4e537b3ae7fbf476dfea55aef13daf6d3a3539 | |
parent | 7b1e8cad1f3612d8059e1dfd870f4928a68691fa (diff) |
drm/amdgpu/uvd: consolidate code for fetching addr from ctx
Same code duplicated in both functions.
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c index fb270c7e7171..330c4749b32c 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 | ||
363 | static 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,15 +706,11 @@ 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) |
712 | return -EINVAL; | 716 | return -EINVAL; |