drm/amdgpu/vcn: Move RDECODE_* to amdgpu_vcn.h
Subsystems (2)
PATCH v2 1/3 drm/amdgpu/vcn: Move RDECODE_* to amdgpu_vcn.h
These defines can be shared.
Signed-off-by Benjamin Cheng <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | 3 +++ drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 3 --- drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 3 --- drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c | 3 --- 4 files changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +3 -0
@@ -57,6 +57,9 @@#define VCN_DEC_SW_CMD_REG_WRITE 0x0000000b#define VCN_DEC_SW_CMD_REG_WAIT 0x0000000c +#define RDECODE_MSG_CREATE 0x00000000 +#define RDECODE_MESSAGE_CREATE 0x00000001 +#define VCN_ENC_CMD_NO_OP 0x00000000#define VCN_ENC_CMD_END 0x00000001#define VCN_ENC_CMD_IB 0x00000002
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +0 -3
@@ -58,9 +58,6 @@#define VCN_INSTANCES_SIENNA_CICHLID 2#define DEC_SW_RING_ENABLED FALSE -#define RDECODE_MSG_CREATE 0x00000000 -#define RDECODE_MESSAGE_CREATE 0x00000001 -static const struct amdgpu_hwip_reg_entry vcn_reg_list_3_0[] = {SOC15_REG_ENTRY_STR (VCN ,0 , mmUVD_POWER_STATUS),SOC15_REG_ENTRY_STR (VCN ,0 , mmUVD_STATUS),
drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c +0 -3
@@ -50,9 +50,6 @@#define VCN_HARVEST_MMSCH 0 -#define RDECODE_MSG_CREATE 0x00000000 -#define RDECODE_MESSAGE_CREATE 0x00000001 -static const struct amdgpu_hwip_reg_entry vcn_reg_list_4_0[] = {SOC15_REG_ENTRY_STR (VCN ,0 , regUVD_POWER_STATUS),SOC15_REG_ENTRY_STR (VCN ,0 , regUVD_STATUS),
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c +0 -3
@@ -50,9 +50,6 @@#define VCN_HARVEST_MMSCH 0 -#define RDECODE_MSG_CREATE 0x00000000 -#define RDECODE_MESSAGE_CREATE 0x00000001 -static const struct amdgpu_hwip_reg_entry vcn_reg_list_4_0_5[] = {SOC15_REG_ENTRY_STR (VCN ,0 , regUVD_POWER_STATUS),SOC15_REG_ENTRY_STR (VCN ,0 , regUVD_STATUS),
Signature · 1 line
2.53.0
PATCH v2 2/3 drm/amdgpu/vcn4.0.5: Remove unused define
As part of the previous cleanup, this was noticed to never be used.
Signed-off-by Benjamin Cheng <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c +0 -2
@@ -48,8 +48,6 @@#define VCN1_VID_SOC_ADDRESS_3_0 (0x48300 + 0x38000)#define VCN1_AON_SOC_ADDRESS_3_0 (0x48000 + 0x38000) -#define VCN_HARVEST_MMSCH 0 -static const struct amdgpu_hwip_reg_entry vcn_reg_list_4_0_5[] = {SOC15_REG_ENTRY_STR (VCN ,0 , regUVD_POWER_STATUS),SOC15_REG_ENTRY_STR (VCN ,0 , regUVD_STATUS),
Signature · 1 line
2.53.0
PATCH v2 3/3 drm/amdgpu/vcn: Factor out vcn_v{3,4}_0_dec_msg
In reply to Benjamin ChengBoth vcn_v3_0 and vcn_v4_0 use the same interface, so unify the code.
Signed-off-by Benjamin Cheng <[email protected]>
---
v2: Moved RDECODE_* defines to header in patch #1.
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 100 +++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | 5 ++ drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 102 +----------------------- drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 101 +---------------------- 4 files changed, 109 insertions(+), 199 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +100 -0
@@ -1641,3 +1641,103 @@ void amdgpu_vcn_print_ip_state(struct amdgpu_ip_block *ip_block, struct drm_prin } } } + +int amdgpu_vcn_dec_msg_limit_sched (struct amdgpu_cs_parser *p, +struct amdgpu_job *job,uint64_t addr, +int (*limit_sched)(struct amdgpu_cs_parser *, +struct amdgpu_job *)) +{ +struct ttm_operation_ctx ctx = { false, false }; +struct amdgpu_device *adev = p->adev; +struct amdgpu_bo_va_mapping *map; +uint32_t *msg, num_buffers, len_dw; +struct amdgpu_bo *bo; +uint64_t start, end; +unsigned int i; +void *ptr; +int r; + + addr &=AMDGPU_GMC_HOLE_MASK ; + r =amdgpu_cs_find_mapping (p, addr, &bo, &map); +if (r) { +DRM_ERROR ("Can't find BO for addr 0x%08llx\n" , addr); +return r; + } + + start = map->start *AMDGPU_GPU_PAGE_SIZE ; + end = (map->last +1 ) *AMDGPU_GPU_PAGE_SIZE ; +if (addr &0x7 ) { +DRM_ERROR ("VCN messages must be 8 byte aligned!\n" ); +return -EINVAL ; + } + +if (end - addr <16 ) { +DRM_ERROR ("VCN messages must be at least 4 DWORDs!\n" ); +return -EINVAL ; + } + + bo->flags |=AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ; +amdgpu_bo_placement_from_domain (bo, bo->allowed_domains); + r =ttm_bo_validate (&bo->tbo, &bo->placement, &ctx); +if (r) { +DRM_ERROR ("Failed validating the VCN message BO (%d)!\n" , r); +return r; + } + + r =amdgpu_bo_kmap (bo, &ptr); +if (r) { +DRM_ERROR ("Failed mapping the VCN message (%d)!\n" , r); +return r; + } + + msg = ptr + addr - start; + +if (msg[1 ] > end - addr) { +DRM_ERROR ("VCN message header does not fit in BO!\n" ); + r = -EINVAL ; + goto out; + } + +if (msg[3 ] !=RDECODE_MSG_CREATE ) + goto out; + + len_dw = msg[1 ] /4 ; + num_buffers = msg[2 ]; + +/* Verify that all indices fit within the claimed length. Each index is 4 DWORDs */ +if (num_buffers > len_dw ||6 + num_buffers *4 > len_dw) { +DRM_ERROR ("VCN message has too many buffers!\n" ); + r = -EINVAL ; + goto out; + } + +for (i =0 , msg = &msg[6 ]; i < num_buffers; ++i, msg +=4 ) { +uint32_t offset, size, *create; + +if (msg[0 ] !=RDECODE_MESSAGE_CREATE ) +continue ; + + offset = msg[1 ]; + size = msg[2 ]; + +if (size <4 || offset + size > end - addr) { +DRM_ERROR ("VCN message buffer exceeds BO bounds!\n" ); + r = -EINVAL ; + goto out; + } + + create = ptr + addr + offset - start; + +/* H264, HEVC and VP9 can run on any instance */ +if (create[0 ] ==0x7 || create[0 ] ==0x10 || create[0 ] ==0x11 ) +continue ; + + r =limit_sched (p, job); +if (r) + goto out; + } + +out: +amdgpu_bo_kunmap (bo); +return r; +}
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +5 -0
@@ -573,4 +573,9 @@ void amdgpu_vcn_print_ip_state(struct amdgpu_ip_block *ip_block, struct drm_prinvoid amdgpu_vcn_get_profile (struct amdgpu_device *adev);void amdgpu_vcn_put_profile (struct amdgpu_device *adev); +int amdgpu_vcn_dec_msg_limit_sched (struct amdgpu_cs_parser *p,struct amdgpu_job *job, +uint64_t addr, +int (*limit_sched)(struct amdgpu_cs_parser *, +struct amdgpu_job *)); +#endif
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +2 -100
114 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c +2 -99
113 lines not on this page · raw message
Signature · 1 line
2.53.0
Christian König
maintainerQuoted 15 lines · Benjamin Cheng
These defines can be shared.
Signed-off-by Benjamin Cheng <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | 3 +++ drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 3 --- drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 3 --- drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c | 3 --- 4 files changed, 3 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h line 62
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +3
-0@@ -57,6 +57,9 @@#define VCN_DEC_SW_CMD_REG_WRITE 0x0000000b#define VCN_DEC_SW_CMD_REG_WAIT 0x0000000c +#define RDECODE_MSG_CREATE 0x00000000 +#define RDECODE_MESSAGE_CREATE 0x00000001 +
As soon as it is in some header it should probably have an VCN_ prefix.
Regards,
Christian.
Quoted 45 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +0
-0#define VCN_ENC_CMD_NO_OP 0x00000000#define VCN_ENC_CMD_END 0x00000001#define VCN_ENC_CMD_IB 0x00000002drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +0
-3@@ -58,9 +58,6 @@#define VCN_INSTANCES_SIENNA_CICHLID 2#define DEC_SW_RING_ENABLED FALSE -#define RDECODE_MSG_CREATE 0x00000000 -#define RDECODE_MESSAGE_CREATE 0x00000001 -static const struct amdgpu_hwip_reg_entry vcn_reg_list_3_0[] = {SOC15_REG_ENTRY_STR (VCN ,0 , mmUVD_POWER_STATUS),SOC15_REG_ENTRY_STR (VCN ,0 , mmUVD_STATUS),drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c +0
-3@@ -50,9 +50,6 @@#define VCN_HARVEST_MMSCH 0 -#define RDECODE_MSG_CREATE 0x00000000 -#define RDECODE_MESSAGE_CREATE 0x00000001 -static const struct amdgpu_hwip_reg_entry vcn_reg_list_4_0[] = {SOC15_REG_ENTRY_STR (VCN ,0 , regUVD_POWER_STATUS),SOC15_REG_ENTRY_STR (VCN ,0 , regUVD_STATUS),drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c +0
-3@@ -50,9 +50,6 @@#define VCN_HARVEST_MMSCH 0 -#define RDECODE_MSG_CREATE 0x00000000 -#define RDECODE_MESSAGE_CREATE 0x00000001 -static const struct amdgpu_hwip_reg_entry vcn_reg_list_4_0_5[] = {SOC15_REG_ENTRY_STR (VCN ,0 , regUVD_POWER_STATUS),SOC15_REG_ENTRY_STR (VCN ,0 , regUVD_STATUS),