drm/amdgpu: use fence_context to judge ctx switch v2
Subsystems (2)
PATCH 1/1 drm/amdgpu: use fence_context to judge ctx switch v2
From: Christian König <[email protected]>
Use of the ctx pointer is not safe, because they are likely already be assigned to another ctx when doing comparing.
v2: recreate from scratch, avoid all unnecessary changes.
Signed-off-by Christian König <[email protected]>
Reviewed-by Monk.Liu <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -2
@@ -743,7 +743,7 @@ struct amdgpu_ib {struct amdgpu_user_fence *user;unsigned vm_id;uint64_t vm_pd_addr; -struct amdgpu_ctx *ctx; +uint64_t ctx;uint32_t gds_base, gds_size;uint32_t gws_base, gws_size;uint32_t oa_base, oa_size;
@@ -806,7 +806,7 @@ struct amdgpu_ring {unsigned wptr_offs;unsigned next_rptr_offs;unsigned fence_offs; -struct amdgpu_ctx *current_ctx; +uint64_t current_ctx;enum amdgpu_ring_type type;char name[16 ];unsigned cond_exe_offs;
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -1
@@ -741,7 +741,7 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev, ib->length_dw = chunk_ib->ib_bytes /4 ; ib->flags = chunk_ib->flags; - ib->ctx = parser->ctx; + ib->ctx = parser->ctx->rings[ring->idx].entity.fence_context; j++; }
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +1 -1
@@ -121,7 +121,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, {struct amdgpu_device *adev = ring->adev;struct amdgpu_ib *ib = &ibs[0 ]; -struct amdgpu_ctx *ctx, *old_ctx; +uint64_t ctx, old_ctx;struct fence *hwf;struct amdgpu_vm *vm =NULL ;unsigned i, patch_offset = ~0 ;
Signature · 6 lines
2.5.5 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 amdgpu/uvd: separate context buffer from DPB
From: Sonny Jiang <[email protected]>
Updated to handle latest UVD ucode.
Signed-off-by Sonny Jiang <[email protected]>
Reviewed-by Christian König <[email protected]>
Reviewed-by Alex Deucher <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 62 +++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +59 -3
@@ -41,6 +41,8 @@/* 1 second timeout */ #define UVD_IDLE_TIMEOUT_MS 1000 +/* Polaris10/11 firmware version */ +#define FW_1_66_16 ((1 << 24) | (66 << 16) | (16 << 8))/* Firmware Names */ #ifdef CONFIG_DRM_AMDGPU_CIK
@@ -174,6 +176,12 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev) adev->uvd.fw_version = ((version_major <<24 ) | (version_minor <<16 ) | (family_id <<8 )); +if ((adev->asic_type ==CHIP_POLARIS10 || + adev->asic_type ==CHIP_POLARIS11 ) && + (adev->uvd.fw_version <FW_1_66_16 )) +DRM_ERROR ("POLARIS10/11 UVD firmware version %hu.%hu is too old.\n" , + version_major, version_minor); +/* * Limit the number of UVD handles depending on microcode major * and minor versions. The firmware version which has 40 UVD
@@ -412,7 +420,8 @@ static int amdgpu_uvd_cs_pass1(struct amdgpu_uvd_cs_ctx *ctx)* * Peek into the decode message and calculate the necessary buffer sizes. */ -static int amdgpu_uvd_cs_msg_decode (uint32_t *msg,unsigned buf_sizes[]) +static int amdgpu_uvd_cs_msg_decode (struct amdgpu_device *adev,uint32_t *msg, +unsigned buf_sizes[]) {unsigned stream_type = msg[4 ];unsigned width = msg[6 ];
@@ -434,7 +443,6 @@ static int amdgpu_uvd_cs_msg_decode(uint32_t *msg, unsigned buf_sizes[])switch (stream_type) {case 0 :/* H264 */ -case 7 :/* H264 Perf */ switch (level) {case 30 : num_dpb_buffer =8100 / fs_in_mb;
@@ -512,6 +520,54 @@ static int amdgpu_uvd_cs_msg_decode(uint32_t *msg, unsigned buf_sizes[]) min_dpb_size +=ALIGN (width_in_mb * height_in_mb *32 ,64 );break ; +case 7 :/* H264 Perf */ +switch (level) { +case 30 : + num_dpb_buffer =8100 / fs_in_mb; +break ; +case 31 : + num_dpb_buffer =18000 / fs_in_mb; +break ; +case 32 : + num_dpb_buffer =20480 / fs_in_mb; +break ; +case 41 : + num_dpb_buffer =32768 / fs_in_mb; +break ; +case 42 : + num_dpb_buffer =34816 / fs_in_mb; +break ; +case 50 : + num_dpb_buffer =110400 / fs_in_mb; +break ; +case 51 : + num_dpb_buffer =184320 / fs_in_mb; +break ; +default : + num_dpb_buffer =184320 / fs_in_mb; +break ; + } + num_dpb_buffer++; +if (num_dpb_buffer >17 ) + num_dpb_buffer =17 ; + +/* reference picture buffer */ + min_dpb_size = image_size * num_dpb_buffer; + +if (adev->asic_type <CHIP_POLARIS10 ){ +/* macroblock context buffer */ + min_dpb_size += + width_in_mb * height_in_mb * num_dpb_buffer *192 ; + +/* IT surface buffer */ + min_dpb_size += width_in_mb * height_in_mb *32 ; + }else { +/* macroblock context buffer */ + min_ctx_size = + width_in_mb * height_in_mb * num_dpb_buffer *192 ; + } +break ; +case 16 :/* H265 */ image_size = (ALIGN (width,16 ) *ALIGN (height,16 ) *3 ) /2 ; image_size =ALIGN (image_size,256 );
@@ -607,7 +663,7 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx,case 1 :/* it's a decode msg, calc buffer sizes */ - r =amdgpu_uvd_cs_msg_decode (msg, ctx->buf_sizes); + r =amdgpu_uvd_cs_msg_decode (adev, msg, ctx->buf_sizes);amdgpu_bo_kunmap (bo);if (r)return r;
Signature · 6 lines
2.5.5 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel