drm/amdgpu/uvd: consolidate code for fetching addr from ctx
Subsystems (2)
PATCH 1/2 drm/amdgpu/uvd: consolidate code for fetching addr from ctx
Same code duplicated in both functions.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +16 -12
@@ -360,6 +360,18 @@ static void amdgpu_uvd_force_into_uvd_segment(struct amdgpu_bo *abo) } } +static u64 amdgpu_uvd_get_addr_from_ctx (struct amdgpu_uvd_cs_ctx *ctx) +{ +uint32_t lo, hi; +uint64_t addr; + + lo =amdgpu_get_ib_value (ctx->parser, ctx->ib_idx, ctx->data0); + hi =amdgpu_get_ib_value (ctx->parser, ctx->ib_idx, ctx->data1); + addr = ((uint64_t )lo) | (((uint64_t )hi) <<32 ); + +return addr; +} +/** * amdgpu_uvd_cs_pass1 - first parsing round *
@@ -372,14 +384,10 @@ static int amdgpu_uvd_cs_pass1(struct amdgpu_uvd_cs_ctx *ctx) {struct amdgpu_bo_va_mapping *mapping;struct amdgpu_bo *bo; -uint32_t cmd, lo, hi; -uint64_t addr; +uint32_t cmd; +uint64_t addr =amdgpu_uvd_get_addr_from_ctx (ctx);int r =0 ; - lo =amdgpu_get_ib_value (ctx->parser, ctx->ib_idx, ctx->data0); - hi =amdgpu_get_ib_value (ctx->parser, ctx->ib_idx, ctx->data1); - addr = ((uint64_t )lo) | (((uint64_t )hi) <<32 ); - mapping =amdgpu_cs_find_mapping (ctx->parser, addr, &bo);if (mapping ==NULL ) {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) {struct amdgpu_bo_va_mapping *mapping;struct amdgpu_bo *bo; -uint32_t cmd, lo, hi; +uint32_t cmd;uint64_t start, end; -uint64_t addr; +uint64_t addr =amdgpu_uvd_get_addr_from_ctx (ctx);int r; - lo =amdgpu_get_ib_value (ctx->parser, ctx->ib_idx, ctx->data0); - hi =amdgpu_get_ib_value (ctx->parser, ctx->ib_idx, ctx->data1); - addr = ((uint64_t )lo) | (((uint64_t )hi) <<32 ); - mapping =amdgpu_cs_find_mapping (ctx->parser, addr, &bo);if (mapping ==NULL )return -EINVAL ;
Signature · 6 lines
2.5.5 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1479764260-21647-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org
PATCH 2/2 drm/amdgpu/uvd: reduce IB parsing overhead on UVD5+
UVD 5 and newer do not have the same placement limitations as older chips, so skip the first pass since it's just overhead on chips where we don't have to force placement.
---
Can amdgpu_uvd_cs_pass1() be dropped altogether if we moved the forcing code into pass2? I'm assuming we need to handle all of the forced placements before patching the addresses for some reason?
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +10 -5
@@ -712,8 +712,10 @@ static int amdgpu_uvd_cs_pass2(struct amdgpu_uvd_cs_ctx *ctx)int r; mapping =amdgpu_cs_find_mapping (ctx->parser, addr, &bo); -if (mapping ==NULL ) +if (mapping ==NULL ) { +DRM_ERROR ("Can't find BO for addr 0x%08Lx\n" , addr);return -EINVAL ; + } start =amdgpu_bo_gpu_offset (bo);
@@ -897,10 +899,13 @@ int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx) ctx.buf_sizes = buf_sizes; ctx.ib_idx = ib_idx; -/* first round, make sure the buffers are actually in the UVD segment */ - r =amdgpu_uvd_cs_packets (&ctx, amdgpu_uvd_cs_pass1); -if (r) -return r; +/* first round only required on chips without UVD 64 bit address support */ +if (parser->adev->uvd.address_64_bit) { +/* first round, make sure the buffers are actually in the UVD segment */ + r =amdgpu_uvd_cs_packets (&ctx, amdgpu_uvd_cs_pass1); +if (r) +return r; + }/* second round, patch buffer addresses into the command stream */ r =amdgpu_uvd_cs_packets (&ctx, amdgpu_uvd_cs_pass2);
Signature · 6 lines
2.5.5 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 21.11.2016 um 22:37 schrieb Alex Deucher:
Quoted 3 lines
Same code duplicated in both functions.
Signed-off-by Alex Deucher <[email protected]>
Good catch, series is Reviewed-by: Christian König <[email protected]>.
Quoted 52 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +15
-8@@ -360,6 +360,18 @@ static void amdgpu_uvd_force_into_uvd_segment(struct amdgpu_bo *abo) } } +static u64 amdgpu_uvd_get_addr_from_ctx (struct amdgpu_uvd_cs_ctx *ctx) +{ +uint32_t lo, hi; +uint64_t addr; + + lo =amdgpu_get_ib_value (ctx->parser, ctx->ib_idx, ctx->data0); + hi =amdgpu_get_ib_value (ctx->parser, ctx->ib_idx, ctx->data1); + addr = ((uint64_t )lo) | (((uint64_t )hi) <<32 ); + +return addr; +} +/** * amdgpu_uvd_cs_pass1 - first parsing round * @@ -372,14 +384,10 @@ static int amdgpu_uvd_cs_pass1(struct amdgpu_uvd_cs_ctx *ctx) {struct amdgpu_bo_va_mapping *mapping;struct amdgpu_bo *bo; -uint32_t cmd, lo, hi; -uint64_t addr; +uint32_t cmd; +uint64_t addr =amdgpu_uvd_get_addr_from_ctx (ctx);int r =0 ; - lo =amdgpu_get_ib_value (ctx->parser, ctx->ib_idx, ctx->data0); - hi =amdgpu_get_ib_value (ctx->parser, ctx->ib_idx, ctx->data1); - addr = ((uint64_t )lo) | (((uint64_t )hi) <<32 ); - mapping =amdgpu_cs_find_mapping (ctx->parser, addr, &bo);if (mapping ==NULL ) {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) {struct amdgpu_bo_va_mapping *mapping;struct amdgpu_bo *bo; -uint32_t cmd, lo, hi; +uint32_t cmd;uint64_t start, end; -uint64_t addr;
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c static int amdgpu_uvd_cs_pass2(struct amdgpu_uvd_cs_ctx *ctx) · line 716
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +1
-4+uint64_t addr =amdgpu_uvd_get_addr_from_ctx (ctx);int r; - lo =amdgpu_get_ib_value (ctx->parser, ctx->ib_idx, ctx->data0); - hi =amdgpu_get_ib_value (ctx->parser, ctx->ib_idx, ctx->data1); - addr = ((uint64_t )lo) | (((uint64_t )hi) <<32 ); - mapping =amdgpu_cs_find_mapping (ctx->parser, addr, &bo);if (mapping ==NULL )return -EINVAL ;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx