drm/amdgpu: define vcn jpeg ring
Subsystems (3)
PATCH 1/18 drm/amdgpu: define vcn jpeg ring
From: Boyuan Zhang <[email protected]>
Add AMDGPU_RING_TYPE_VCN_JPEG ring define
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2 -1
@@ -53,7 +53,8 @@ enum amdgpu_ring_type {AMDGPU_RING_TYPE_KIQ ,AMDGPU_RING_TYPE_UVD_ENC ,AMDGPU_RING_TYPE_VCN_DEC , - AMDGPU_RING_TYPE_VCN_ENC +AMDGPU_RING_TYPE_VCN_ENC , + AMDGPU_RING_TYPE_VCN_JPEG };struct amdgpu_device ;
Signature · 6 lines
2.7.4 _______________________________________________ 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): 1527712053-15027-1-git-send-email-boyuan.zhang-5C7GfCeVMHo@public.gmane.org
PATCH 2/18 drm/amdgpu: add vcn jpeg ring
From: Boyuan Zhang <[email protected]>
Add jpeg to amdgpu_vcn
v2: remove unnecessary scheduler entity
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +1 -0
@@ -66,6 +66,7 @@ struct amdgpu_vcn {const struct firmware *fw;/* VCN firmware */ struct amdgpu_ring ring_dec;struct amdgpu_ring ring_enc[AMDGPU_VCN_MAX_ENC_RINGS ]; +struct amdgpu_ring ring_jpeg;struct amdgpu_irq_src irq;unsigned num_enc_rings; };
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/18 drm/amdgpu: add jpeg packet defines to soc15d.h
In reply to a message not in the archiveFrom: Boyuan Zhang <[email protected]>
Add new packet for vcn jpeg, including condition checks, types and packet
--- drivers/gpu/drm/amd/amdgpu/soc15d.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/gpu/drm/amd/amdgpu/soc15d.h +23 -0
@@ -53,6 +53,29 @@#define PACKET3_COMPUTE (op, n) (PACKET3(op, n) | 1 << 1) +#define PACKETJ_CONDITION_CHECK0 0 +#define PACKETJ_CONDITION_CHECK1 1 +#define PACKETJ_CONDITION_CHECK2 2 +#define PACKETJ_CONDITION_CHECK3 3 +#define PACKETJ_CONDITION_CHECK4 4 +#define PACKETJ_CONDITION_CHECK5 5 +#define PACKETJ_CONDITION_CHECK6 6 +#define PACKETJ_CONDITION_CHECK7 7 + +#define PACKETJ_TYPE0 0 +#define PACKETJ_TYPE1 1 +#define PACKETJ_TYPE2 2 +#define PACKETJ_TYPE3 3 +#define PACKETJ_TYPE4 4 +#define PACKETJ_TYPE5 5 +#define PACKETJ_TYPE6 6 +#define PACKETJ_TYPE7 7 + +#define PACKETJ (reg, r, cond, type) ((reg & 0x3FFFF) | \ + ((r & 0x3F) << 18) | \ + ((cond & 0xF) << 24) | \ + ((type & 0xF) << 28)) +/* Packet 3 types */ #define PACKET3_NOP 0x10#define PACKET3_SET_BASE 0x11
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/18 drm/amdgpu: add more jpeg register offset headers
In reply to a message not in the archiveFrom: Boyuan Zhang <[email protected]>
Add more jpeg registers defines that are needed for jpeg ring functions
--- .../drm/amd/include/asic_reg/vcn/vcn_1_0_offset.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/gpu/drm/amd/include/asic_reg/vcn/vcn_1_0_offset.h +20 -0
@@ -89,6 +89,8 @@#define mmUVD_JPEG_RB_SIZE_BASE_IDX 1#define mmUVD_JPEG_ADDR_CONFIG 0x021f#define mmUVD_JPEG_ADDR_CONFIG_BASE_IDX 1 +#define mmUVD_JPEG_PITCH 0x0222 +#define mmUVD_JPEG_PITCH_BASE_IDX 1#define mmUVD_JPEG_GPCOM_CMD 0x022c#define mmUVD_JPEG_GPCOM_CMD_BASE_IDX 1#define mmUVD_JPEG_GPCOM_DATA0 0x022d
@@ -203,6 +205,8 @@#define mmUVD_RB_WPTR4_BASE_IDX 1#define mmUVD_JRBC_RB_RPTR 0x0457#define mmUVD_JRBC_RB_RPTR_BASE_IDX 1 +#define mmUVD_LMI_JPEG_VMID 0x045d +#define mmUVD_LMI_JPEG_VMID_BASE_IDX 1#define mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH 0x045e#define mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH_BASE_IDX 1#define mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW 0x045f
@@ -231,6 +235,8 @@#define mmUVD_LMI_JRBC_IB_64BIT_BAR_HIGH_BASE_IDX 1#define mmUVD_LMI_JRBC_IB_VMID 0x0507#define mmUVD_LMI_JRBC_IB_VMID_BASE_IDX 1 +#define mmUVD_LMI_JRBC_RB_VMID 0x0508 +#define mmUVD_LMI_JRBC_RB_VMID_BASE_IDX 1#define mmUVD_JRBC_RB_WPTR 0x0509#define mmUVD_JRBC_RB_WPTR_BASE_IDX 1#define mmUVD_JRBC_RB_CNTL 0x050a
@@ -239,6 +245,20 @@#define mmUVD_JRBC_IB_SIZE_BASE_IDX 1#define mmUVD_JRBC_LMI_SWAP_CNTL 0x050d#define mmUVD_JRBC_LMI_SWAP_CNTL_BASE_IDX 1 +#define mmUVD_LMI_JRBC_RB_MEM_WR_64BIT_BAR_LOW 0x050e +#define mmUVD_LMI_JRBC_RB_MEM_WR_64BIT_BAR_LOW_BASE_IDX 1 +#define mmUVD_LMI_JRBC_RB_MEM_WR_64BIT_BAR_HIGH 0x050f +#define mmUVD_LMI_JRBC_RB_MEM_WR_64BIT_BAR_HIGH_BASE_IDX 1 +#define mmUVD_LMI_JRBC_RB_MEM_RD_64BIT_BAR_LOW 0x0510 +#define mmUVD_LMI_JRBC_RB_MEM_RD_64BIT_BAR_LOW_BASE_IDX 1 +#define mmUVD_LMI_JRBC_RB_MEM_RD_64BIT_BAR_HIGH 0x0511 +#define mmUVD_LMI_JRBC_RB_MEM_RD_64BIT_BAR_HIGH_BASE_IDX 1 +#define mmUVD_JRBC_RB_REF_DATA 0x0512 +#define mmUVD_JRBC_RB_REF_DATA_BASE_IDX 1 +#define mmUVD_JRBC_RB_COND_RD_TIMER 0x0513 +#define mmUVD_JRBC_RB_COND_RD_TIMER_BASE_IDX 1 +#define mmUVD_JRBC_EXTERNAL_REG_BASE 0x0517 +#define mmUVD_JRBC_EXTERNAL_REG_BASE_BASE_IDX 1#define mmUVD_JRBC_SOFT_RESET 0x0519#define mmUVD_JRBC_SOFT_RESET_BASE_IDX 1#define mmUVD_JRBC_STATUS 0x051a
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/18 drm/amdgpu: implement jpeg ring functions
In reply to a message not in the archiveFrom: Boyuan Zhang <[email protected]>
Implement all ring functions needed for jpeg ring
v2: remove unnecessary mem read function.
--- drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 286 ++++++++++++++++++++++++++++++++++ 1 file changed, 286 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +286 -0
@@ -1126,6 +1126,292 @@ static void vcn_v1_0_enc_ring_emit_wreg(struct amdgpu_ring *ring,amdgpu_ring_write (ring, val); } + +/** +* vcn_v1_0_jpeg_ring_get_rptr - get read pointer +* +* @ring: amdgpu_ring pointer +* +* Returns the current hardware read pointer +*/ +static uint64_t vcn_v1_0_jpeg_ring_get_rptr (struct amdgpu_ring *ring) +{ +struct amdgpu_device *adev = ring->adev; + +return RREG32_SOC15 (UVD ,0 , mmUVD_JRBC_RB_RPTR); +} + +/** +* vcn_v1_0_jpeg_ring_get_wptr - get write pointer +* +* @ring: amdgpu_ring pointer +* +* Returns the current hardware write pointer +*/ +static uint64_t vcn_v1_0_jpeg_ring_get_wptr (struct amdgpu_ring *ring) +{ +struct amdgpu_device *adev = ring->adev; + +return RREG32_SOC15 (UVD ,0 , mmUVD_JRBC_RB_WPTR); +} + +/** +* vcn_v1_0_jpeg_ring_set_wptr - set write pointer +* +* @ring: amdgpu_ring pointer +* +* Commits the write pointer to the hardware +*/ +static void vcn_v1_0_jpeg_ring_set_wptr (struct amdgpu_ring *ring) +{ +struct amdgpu_device *adev = ring->adev; + +WREG32_SOC15 (UVD ,0 , mmUVD_JRBC_RB_WPTR,lower_32_bits (ring->wptr)); +} + +/** +* vcn_v1_0_jpeg_ring_insert_start - insert a start command +* +* @ring: amdgpu_ring pointer +* +* Write a start command to the ring. +*/ +static void vcn_v1_0_jpeg_ring_insert_start (struct amdgpu_ring *ring) +{ +struct amdgpu_device *adev = ring->adev; + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_EXTERNAL_REG_BASE),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring,0x68e04 ); + +amdgpu_ring_write (ring,PACKETJ (0 ,0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring,0x80010000 ); +} + +/** +* vcn_v1_0_jpeg_ring_insert_end - insert a end command +* +* @ring: amdgpu_ring pointer +* +* Write a end command to the ring. +*/ +static void vcn_v1_0_jpeg_ring_insert_end (struct amdgpu_ring *ring) +{ +struct amdgpu_device *adev = ring->adev; + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_EXTERNAL_REG_BASE),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring,0x68e04 ); + +amdgpu_ring_write (ring,PACKETJ (0 ,0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring,0x00010000 ); +} + +/** +* vcn_v1_0_jpeg_ring_emit_fence - emit an fence & trap command +* +* @ring: amdgpu_ring pointer +* @fence: fence to emit +* +* Write a fence and a trap command to the ring. +*/ +static void vcn_v1_0_jpeg_ring_emit_fence (struct amdgpu_ring *ring,u64 addr,u64 seq, +unsigned flags) +{ +struct amdgpu_device *adev = ring->adev; + +WARN_ON (flags &AMDGPU_FENCE_FLAG_64BIT ); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JPEG_GPCOM_DATA0),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring, seq); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JPEG_GPCOM_DATA1),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring, seq); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_LMI_JRBC_RB_MEM_WR_64BIT_BAR_LOW),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring,lower_32_bits (addr)); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_LMI_JRBC_RB_MEM_WR_64BIT_BAR_HIGH),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring,upper_32_bits (addr)); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JPEG_GPCOM_CMD),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring,0x8 ); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JPEG_GPCOM_CMD),0 ,PACKETJ_CONDITION_CHECK0 ,PACKETJ_TYPE4 )); +amdgpu_ring_write (ring,0 ); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_RB_COND_RD_TIMER),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring,0x01400200 ); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_RB_REF_DATA),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring, seq); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_LMI_JRBC_RB_MEM_RD_64BIT_BAR_LOW),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring,lower_32_bits (addr)); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_LMI_JRBC_RB_MEM_RD_64BIT_BAR_HIGH),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring,upper_32_bits (addr)); + +amdgpu_ring_write (ring, +PACKETJ (0 ,0 ,PACKETJ_CONDITION_CHECK3 ,PACKETJ_TYPE2 )); +amdgpu_ring_write (ring,0xffffffff ); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_EXTERNAL_REG_BASE),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring,0x3fbc ); + +amdgpu_ring_write (ring, +PACKETJ (0 ,0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring,0x1 ); +} + +/** +* vcn_v1_0_jpeg_ring_emit_ib - execute indirect buffer +* +* @ring: amdgpu_ring pointer +* @ib: indirect buffer to execute +* +* Write ring commands to execute the indirect buffer. +*/ +static void vcn_v1_0_jpeg_ring_emit_ib (struct amdgpu_ring *ring, +struct amdgpu_ib *ib, +unsigned vmid,bool ctx_switch) +{ +struct amdgpu_device *adev = ring->adev; + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_LMI_JRBC_IB_VMID),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring, (vmid | (vmid <<4 ))); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_LMI_JPEG_VMID),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring, (vmid | (vmid <<4 ))); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_LMI_JRBC_IB_64BIT_BAR_LOW),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring,lower_32_bits (ib->gpu_addr)); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_LMI_JRBC_IB_64BIT_BAR_HIGH),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring,upper_32_bits (ib->gpu_addr)); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_IB_SIZE),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring, ib->length_dw); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_LMI_JRBC_RB_MEM_RD_64BIT_BAR_LOW),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring,lower_32_bits (ring->gpu_addr)); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_LMI_JRBC_RB_MEM_RD_64BIT_BAR_HIGH),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring,upper_32_bits (ring->gpu_addr)); + +amdgpu_ring_write (ring, +PACKETJ (0 ,0 ,PACKETJ_CONDITION_CHECK0 ,PACKETJ_TYPE2 )); +amdgpu_ring_write (ring,0 ); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_RB_COND_RD_TIMER),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring,0x01400200 ); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_RB_REF_DATA),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring,0x2 ); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_STATUS),0 ,PACKETJ_CONDITION_CHECK3 ,PACKETJ_TYPE3 )); +amdgpu_ring_write (ring,0x2 ); +} + +static void vcn_v1_0_jpeg_ring_emit_reg_wait (struct amdgpu_ring *ring, +uint32_t reg,uint32_t val, +uint32_t mask) +{ +struct amdgpu_device *adev = ring->adev; +uint32_t reg_offset = (reg <<2 ); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_RB_COND_RD_TIMER),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring,0x01400200 ); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_RB_REF_DATA),0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring, val); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_EXTERNAL_REG_BASE),0 ,0 ,PACKETJ_TYPE0 )); +if (((reg_offset >=0x1f800 ) && (reg_offset <=0x21fff )) || + ((reg_offset >=0x1e000 ) && (reg_offset <=0x1e1ff ))) { +amdgpu_ring_write (ring,0 ); +amdgpu_ring_write (ring, +PACKETJ ((reg_offset >>2 ),0 ,0 ,PACKETJ_TYPE3 )); + }else { +amdgpu_ring_write (ring, reg_offset); +amdgpu_ring_write (ring, +PACKETJ (0 ,0 ,0 ,PACKETJ_TYPE3 )); + } +amdgpu_ring_write (ring, mask); +} + +static void vcn_v1_0_jpeg_ring_emit_vm_flush (struct amdgpu_ring *ring, +unsigned vmid,uint64_t pd_addr) +{ +struct amdgpu_vmhub *hub = &ring->adev->vmhub[ring->funcs->vmhub]; +uint32_t data0, data1, mask; + + pd_addr =amdgpu_gmc_emit_flush_gpu_tlb (ring, vmid, pd_addr); + +/* wait for register write */ + data0 = hub->ctx0_ptb_addr_lo32 + vmid *2 ; + data1 =lower_32_bits (pd_addr); + mask =0xffffffff ; +vcn_v1_0_jpeg_ring_emit_reg_wait (ring, data0, data1, mask); +} + +static void vcn_v1_0_jpeg_ring_emit_wreg (struct amdgpu_ring *ring, +uint32_t reg,uint32_t val) +{ +struct amdgpu_device *adev = ring->adev; +uint32_t reg_offset = (reg <<2 ); + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_EXTERNAL_REG_BASE),0 ,0 ,PACKETJ_TYPE0 )); +if (((reg_offset >=0x1f800 ) && (reg_offset <=0x21fff )) || + ((reg_offset >=0x1e000 ) && (reg_offset <=0x1e1ff ))) { +amdgpu_ring_write (ring,0 ); +amdgpu_ring_write (ring, +PACKETJ ((reg_offset >>2 ),0 ,0 ,PACKETJ_TYPE0 )); + }else { +amdgpu_ring_write (ring, reg_offset); +amdgpu_ring_write (ring, +PACKETJ (0 ,0 ,0 ,PACKETJ_TYPE0 )); + } +amdgpu_ring_write (ring, val); +} + +static void vcn_v1_0_jpeg_ring_nop (struct amdgpu_ring *ring,uint32_t count) +{ +int i; + +WARN_ON (ring->wptr %2 || count %2 ); + +for (i =0 ; i < count /2 ; i++) { +amdgpu_ring_write (ring,PACKETJ (0 ,0 ,0 ,PACKETJ_TYPE6 )); +amdgpu_ring_write (ring,0 ); + } +} + static int vcn_v1_0_set_interrupt_state(struct amdgpu_device *adev, struct amdgpu_irq_src *source, unsigned type,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/18 drm/amdgpu: set jpeg ring functions
In reply to a message not in the archiveFrom: Boyuan Zhang <[email protected]>
Set all vcn jpeg ring function pointers.
--- drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +40 -0
@@ -38,6 +38,7 @@static int vcn_v1_0_stop (struct amdgpu_device *adev);static void vcn_v1_0_set_dec_ring_funcs (struct amdgpu_device *adev);static void vcn_v1_0_set_enc_ring_funcs (struct amdgpu_device *adev); +static void vcn_v1_0_set_jpeg_ring_funcs (struct amdgpu_device *adev);static void vcn_v1_0_set_irq_funcs (struct amdgpu_device *adev);/**
@@ -55,6 +56,7 @@ static int vcn_v1_0_early_init(void *handle)vcn_v1_0_set_dec_ring_funcs (adev);vcn_v1_0_set_enc_ring_funcs (adev); +vcn_v1_0_set_jpeg_ring_funcs (adev);vcn_v1_0_set_irq_funcs (adev);return 0 ;
@@ -1559,6 +1561,38 @@ static const struct amdgpu_ring_funcs vcn_v1_0_enc_ring_vm_funcs = { .emit_reg_write_reg_wait = amdgpu_ring_emit_reg_write_reg_wait_helper, }; +static const struct amdgpu_ring_funcs vcn_v1_0_jpeg_ring_vm_funcs = { + .type =AMDGPU_RING_TYPE_VCN_JPEG , + .align_mask =0xf , + .nop =PACKET0 (0x81ff ,0 ), + .support_64bit_ptrs = false, + .vmhub =AMDGPU_MMHUB , + .get_rptr = vcn_v1_0_jpeg_ring_get_rptr, + .get_wptr = vcn_v1_0_jpeg_ring_get_wptr, + .set_wptr = vcn_v1_0_jpeg_ring_set_wptr, + .emit_frame_size = +6 +6 +/* hdp invalidate / flush */ +SOC15_FLUSH_GPU_TLB_NUM_WREG *6 + +SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT *8 + +8 +/* vcn_v1_0_dec_ring_emit_vm_flush */ +14 +14 +/* vcn_v1_0_dec_ring_emit_fence x2 vm fence */ +6 , + .emit_ib_size =22 ,/* vcn_v1_0_dec_ring_emit_ib */ + .emit_ib = vcn_v1_0_jpeg_ring_emit_ib, + .emit_fence = vcn_v1_0_jpeg_ring_emit_fence, + .emit_vm_flush = vcn_v1_0_jpeg_ring_emit_vm_flush, +//.test_ring +//.test_ib + .insert_nop = vcn_v1_0_jpeg_ring_nop, + .insert_start = vcn_v1_0_jpeg_ring_insert_start, + .insert_end = vcn_v1_0_jpeg_ring_insert_end, + .pad_ib = amdgpu_ring_generic_pad_ib, + .begin_use = amdgpu_vcn_ring_begin_use, + .end_use = amdgpu_vcn_ring_end_use, + .emit_wreg = vcn_v1_0_jpeg_ring_emit_wreg, + .emit_reg_wait = vcn_v1_0_jpeg_ring_emit_reg_wait, +}; +static void vcn_v1_0_set_dec_ring_funcs (struct amdgpu_device *adev) { adev->vcn.ring_dec.funcs = &vcn_v1_0_dec_ring_vm_funcs;
@@ -1575,6 +1609,12 @@ static void vcn_v1_0_set_enc_ring_funcs(struct amdgpu_device *adev)DRM_INFO ("VCN encode is enabled in VM mode\n" ); } +static void vcn_v1_0_set_jpeg_ring_funcs (struct amdgpu_device *adev) +{ + adev->vcn.ring_jpeg.funcs = &vcn_v1_0_jpeg_ring_vm_funcs; +DRM_INFO ("VCN jpeg decode is enabled in VM mode\n" ); +} +static const struct amdgpu_irq_src_funcs vcn_v1_0_irq_funcs = { .set = vcn_v1_0_set_interrupt_state, .process = vcn_v1_0_process_interrupt,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/18 drm/amdgpu: add vcn jpeg irq support
In reply to a message not in the archiveFrom: Boyuan Zhang <[email protected]>
Add vcn jpeg irq support.
--- drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +8 -0
@@ -88,6 +88,11 @@ static int vcn_v1_0_sw_init(void *handle)return r; } +/* VCN JPEG TRAP */ + r =amdgpu_irq_add_id (adev,SOC15_IH_CLIENTID_VCN ,126 , &adev->vcn.irq); +if (r) +return r; + r =amdgpu_vcn_sw_init (adev);if (r)return r;
@@ -1438,6 +1443,9 @@ static int vcn_v1_0_process_interrupt(struct amdgpu_device *adev,case 120 :amdgpu_fence_process (&adev->vcn.ring_enc[1 ]);break ; +case 126 : +amdgpu_fence_process (&adev->vcn.ring_jpeg); +break ;default :DRM_ERROR ("Unhandled interrupt: %d %d\n" , entry->src_id, entry->src_data[0 ]);
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 8/18 drm/amdgpu: initialize vcn jpeg ring
In reply to a message not in the archiveFrom: Boyuan Zhang <[email protected]>
Add implementations for vcn jpeg ring initialization
--- drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +23 -0
@@ -115,6 +115,12 @@ static int vcn_v1_0_sw_init(void *handle)return r; } + ring = &adev->vcn.ring_jpeg; +sprintf (ring->name,"vcn_jpeg" ); + r =amdgpu_ring_init (adev, ring,512 , &adev->vcn.irq,0 ); +if (r) +return r; +return r; }
@@ -169,6 +175,14 @@ static int vcn_v1_0_hw_init(void *handle) } } + ring = &adev->vcn.ring_jpeg; + ring->ready = true; + r =amdgpu_ring_test_ring (ring); +if (r) { + ring->ready = false; + goto done; + } + done:if (!r)DRM_INFO ("VCN decode and encode initialized successfully.\n" );
@@ -736,6 +750,15 @@ static int vcn_v1_0_start(struct amdgpu_device *adev)WREG32_SOC15 (UVD ,0 , mmUVD_RB_BASE_HI2,upper_32_bits (ring->gpu_addr));WREG32_SOC15 (UVD ,0 , mmUVD_RB_SIZE2, ring->ring_size /4 ); + ring = &adev->vcn.ring_jpeg; +WREG32_SOC15 (UVD ,0 , mmUVD_LMI_JRBC_RB_VMID,0 ); +WREG32_SOC15 (UVD ,0 , mmUVD_JRBC_RB_CNTL, (0x00000001L |0x00000002L )); +WREG32_SOC15 (UVD ,0 , mmUVD_LMI_JRBC_RB_64BIT_BAR_LOW,lower_32_bits (ring->gpu_addr)); +WREG32_SOC15 (UVD ,0 , mmUVD_LMI_JRBC_RB_64BIT_BAR_HIGH,upper_32_bits (ring->gpu_addr)); +WREG32_SOC15 (UVD ,0 , mmUVD_JRBC_RB_RPTR,0 ); +WREG32_SOC15 (UVD ,0 , mmUVD_JRBC_RB_WPTR,0 ); +WREG32_SOC15 (UVD ,0 , mmUVD_JRBC_RB_CNTL,0x00000002L ); +return 0 ; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 9/18 drm/amdgpu: implement patch for fixing a known bug
In reply to a message not in the archiveFrom: Boyuan Zhang <[email protected]>
Implement a patch to maunally reset read pointer
v2: using ring assignment instead of amdgpu_ring_write. adding comments for each steps in the patch function.
--- drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 92 +++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +92 -0
@@ -40,6 +40,7 @@ static void vcn_v1_0_set_dec_ring_funcs(struct amdgpu_device *adev);static void vcn_v1_0_set_enc_ring_funcs (struct amdgpu_device *adev);static void vcn_v1_0_set_jpeg_ring_funcs (struct amdgpu_device *adev);static void vcn_v1_0_set_irq_funcs (struct amdgpu_device *adev); +static void vcn_v1_0_jpeg_ring_set_patch_ring (struct amdgpu_ring *ring,uint32_t ptr);/** * vcn_v1_0_early_init - set function pointers
@@ -1442,6 +1443,97 @@ static void vcn_v1_0_jpeg_ring_nop(struct amdgpu_ring *ring, uint32_t count) } } +static void vcn_v1_0_jpeg_ring_patch_wreg (struct amdgpu_ring *ring,uint32_t ptr,uint32_t reg_offset,uint32_t val) +{ +struct amdgpu_device *adev = ring->adev; + ring->ring[ptr++] =PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_EXTERNAL_REG_BASE),0 ,0 ,PACKETJ_TYPE0 ); +if (((reg_offset >=0x1f800 ) && (reg_offset <=0x21fff )) || + ((reg_offset >=0x1e000 ) && (reg_offset <=0x1e1ff ))) { + ring->ring[ptr++] =0 ; + ring->ring[ptr++] =PACKETJ ((reg_offset >>2 ),0 ,0 ,PACKETJ_TYPE0 ); + }else { + ring->ring[ptr++] = reg_offset; + ring->ring[ptr++] =PACKETJ (0 ,0 ,0 ,PACKETJ_TYPE0 ); + } + ring->ring[ptr++] = val; +} + +static void vcn_v1_0_jpeg_ring_set_patch_ring (struct amdgpu_ring *ring,uint32_t ptr) +{ +struct amdgpu_device *adev = ring->adev; + +uint32_t reg, reg_offset, val, mask, i; + +// 1st: program mmUVD_LMI_JRBC_RB_MEM_RD_64BIT_BAR_LOW + reg =SOC15_REG_OFFSET (UVD ,0 , mmUVD_LMI_JRBC_RB_MEM_RD_64BIT_BAR_LOW); + reg_offset = (reg <<2 ); + val =lower_32_bits (ring->gpu_addr); +vcn_v1_0_jpeg_ring_patch_wreg (ring, ptr, reg_offset, val); + +// 2nd: program mmUVD_LMI_JRBC_RB_MEM_RD_64BIT_BAR_HIGH + reg =SOC15_REG_OFFSET (UVD ,0 , mmUVD_LMI_JRBC_RB_MEM_RD_64BIT_BAR_HIGH); + reg_offset = (reg <<2 ); + val =upper_32_bits (ring->gpu_addr); +vcn_v1_0_jpeg_ring_patch_wreg (ring, ptr, reg_offset, val); + +// 3rd to 5th: issue MEM_READ commands +for (i =0 ; i <=2 ; i++) { + ring->ring[ptr++] =PACKETJ (0 ,0 ,0 ,PACKETJ_TYPE2 ); + ring->ring[ptr++] =0 ; + } + +// 6th: program mmUVD_JRBC_RB_CNTL register to enable NO_FETCH and RPTR write ability + reg =SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_RB_CNTL); + reg_offset = (reg <<2 ); + val =0x13 ; +vcn_v1_0_jpeg_ring_patch_wreg (ring, ptr, reg_offset, val); + +// 7th: program mmUVD_JRBC_RB_REF_DATA + reg =SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_RB_REF_DATA); + reg_offset = (reg <<2 ); + val =0x1 ; +vcn_v1_0_jpeg_ring_patch_wreg (ring, ptr, reg_offset, val); + +// 8th: issue conditional register read mmUVD_JRBC_RB_CNTL + reg =SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_RB_CNTL); + reg_offset = (reg <<2 ); + val =0x1 ; + mask =0x1 ; + + ring->ring[ptr++] =PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_RB_COND_RD_TIMER),0 ,0 ,PACKETJ_TYPE0 ); + ring->ring[ptr++] =0x01400200 ; + ring->ring[ptr++] =PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_RB_REF_DATA),0 ,0 ,PACKETJ_TYPE0 ); + ring->ring[ptr++] = val; + ring->ring[ptr++] =PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_EXTERNAL_REG_BASE),0 ,0 ,PACKETJ_TYPE0 ); +if (((reg_offset >=0x1f800 ) && (reg_offset <=0x21fff )) || + ((reg_offset >=0x1e000 ) && (reg_offset <=0x1e1ff ))) { + ring->ring[ptr++] =0 ; + ring->ring[ptr++] =PACKETJ ((reg_offset >>2 ),0 ,0 ,PACKETJ_TYPE3 ); + }else { + ring->ring[ptr++] = reg_offset; + ring->ring[ptr++] =PACKETJ (0 ,0 ,0 ,PACKETJ_TYPE3 ); + } + ring->ring[ptr++] = mask; + +//9th to 21st: insert no-op +for (i =0 ; i <=12 ; i++) { + ring->ring[ptr++] =PACKETJ (0 ,0 ,0 ,PACKETJ_TYPE6 ); + ring->ring[ptr++] =0 ; + } + +//22nd: reset mmUVD_JRBC_RB_RPTR + reg =SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_RB_RPTR); + reg_offset = (reg <<2 ); + val =0 ; +vcn_v1_0_jpeg_ring_patch_wreg (ring, ptr, reg_offset, val); + +//23rd: program mmUVD_JRBC_RB_CNTL to disable no_fetch + reg =SOC15_REG_OFFSET (UVD ,0 , mmUVD_JRBC_RB_CNTL); + reg_offset = (reg <<2 ); + val =0x12 ; +vcn_v1_0_jpeg_ring_patch_wreg (ring, ptr, reg_offset, val); +} + static int vcn_v1_0_set_interrupt_state(struct amdgpu_device *adev, struct amdgpu_irq_src *source, unsigned type,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 10/18 drm/amdgpu: define and add extra dword for jpeg ring
In reply to a message not in the archiveFrom: Boyuan Zhang <[email protected]>
Define extra dword for jpeg ring. Jpeg ring will allocate extra dword to store the patch commands for fixing the known issue.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 1 + drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1 -1
@@ -304,7 +304,7 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, 0xffffffffffffffff : ring->buf_mask;/* Allocate ring buffer */ if (ring->ring_obj ==NULL ) { - r = amdgpu_bo_create_kernel(adev, ring->ring_size, PAGE_SIZE, + r = amdgpu_bo_create_kernel(adev, ring->ring_size + ring->funcs->extra_dw, PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT, &ring->ring_obj, &ring->gpu_addr,
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +1 -0
@@ -113,6 +113,7 @@ struct amdgpu_ring_funcs {u32 nop;bool support_64bit_ptrs;unsigned vmhub; +unsigned extra_dw;/* ring read/write ptr handling */ u64 (*get_rptr)(struct amdgpu_ring *ring);
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +3 -0
@@ -1626,6 +1626,7 @@ static const struct amdgpu_ring_funcs vcn_v1_0_dec_ring_vm_funcs = { .align_mask = 0xf, .support_64bit_ptrs = false, .vmhub = AMDGPU_MMHUB, + .extra_dw = 0, .get_rptr = vcn_v1_0_dec_ring_get_rptr, .get_wptr = vcn_v1_0_dec_ring_get_wptr, .set_wptr = vcn_v1_0_dec_ring_set_wptr,
@@ -1659,6 +1660,7 @@ static const struct amdgpu_ring_funcs vcn_v1_0_enc_ring_vm_funcs = { .nop = VCN_ENC_CMD_NO_OP, .support_64bit_ptrs = false, .vmhub = AMDGPU_MMHUB, + .extra_dw = 0, .get_rptr = vcn_v1_0_enc_ring_get_rptr, .get_wptr = vcn_v1_0_enc_ring_get_wptr, .set_wptr = vcn_v1_0_enc_ring_set_wptr,
@@ -1690,6 +1692,7 @@ static const struct amdgpu_ring_funcs vcn_v1_0_jpeg_ring_vm_funcs = { .nop = PACKET0(0x81ff, 0), .support_64bit_ptrs = false, .vmhub = AMDGPU_MMHUB, + .extra_dw = 64, .get_rptr = vcn_v1_0_jpeg_ring_get_rptr, .get_wptr = vcn_v1_0_jpeg_ring_get_wptr, .set_wptr = vcn_v1_0_jpeg_ring_set_wptr,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 11/18 drm/amdgpu: add patch to jpeg ring
In reply to a message not in the archiveFrom: Boyuan Zhang <[email protected]>
Add patch commands to jepg ring by calling set patch ring function.
v2: remove modifications on max_dw, buf_mask and ptr_mask, since we are now using extra_dw for jpeg ring.
--- drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +7 -0
@@ -760,6 +760,13 @@ static int vcn_v1_0_start(struct amdgpu_device *adev)WREG32_SOC15 (UVD ,0 , mmUVD_JRBC_RB_WPTR,0 );WREG32_SOC15 (UVD ,0 , mmUVD_JRBC_RB_CNTL,0x00000002L ); +/* initialize wptr */ + ring->wptr =RREG32_SOC15 (UVD ,0 , mmUVD_JRBC_RB_WPTR); + +/* copy patch commands to the jpeg ring */ +vcn_v1_0_jpeg_ring_set_patch_ring (ring, + (ring->wptr + ring->max_dw * amdgpu_sched_hw_submission)); +return 0 ; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 12/18 drm/amdgpu: add vcn jpeg sw finish
In reply to a message not in the archiveFrom: Boyuan Zhang <[email protected]>
Add software finish for vcn jpeg ring.
v2: remove unnecessary scheduler entity.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +2 -0
@@ -118,6 +118,8 @@ int amdgpu_vcn_sw_fini(struct amdgpu_device *adev)for (i =0 ; i < adev->vcn.num_enc_rings; ++i)amdgpu_ring_fini (&adev->vcn.ring_enc[i]); +amdgpu_ring_fini (&adev->vcn.ring_jpeg); +release_firmware (adev->vcn.fw);return 0 ;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 13/18 drm/amdgpu: add vcn jpeg ring test
In reply to a message not in the archiveFrom: Boyuan Zhang <[email protected]>
Add a ring test for vcn jpeg.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 40 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | 2 ++ drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 2 +- 3 files changed, 43 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +40 -0
@@ -577,3 +577,43 @@ int amdgpu_vcn_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout)dma_fence_put (fence);return r; } + +int amdgpu_vcn_jpeg_ring_test_ring (struct amdgpu_ring *ring) +{ +struct amdgpu_device *adev = ring->adev; +uint32_t tmp =0 ; +unsigned i; +int r; + +WREG32 (SOC15_REG_OFFSET (UVD ,0 , mmUVD_CONTEXT_ID),0xCAFEDEAD ); + r =amdgpu_ring_alloc (ring,3 ); + +if (r) { +DRM_ERROR ("amdgpu: cp failed to lock ring %d (%d).\n" , + ring->idx, r); +return r; + } + +amdgpu_ring_write (ring, +PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_CONTEXT_ID),0 ,0 ,0 )); +amdgpu_ring_write (ring,0xDEADBEEF ); +amdgpu_ring_commit (ring); + +for (i =0 ; i < adev->usec_timeout; i++) { + tmp =RREG32 (SOC15_REG_OFFSET (UVD ,0 , mmUVD_CONTEXT_ID)); +if (tmp ==0xDEADBEEF ) +break ; +DRM_UDELAY (1 ); + } + +if (i < adev->usec_timeout) { +DRM_DEBUG ("ring test on %d succeeded in %d usecs\n" , + ring->idx, i); + }else { +DRM_ERROR ("amdgpu: ring %d test failed (0x%08X)\n" , + ring->idx, tmp); + r = -EINVAL ; + } + +return r; +}
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +2 -0
@@ -84,4 +84,6 @@ int amdgpu_vcn_dec_ring_test_ib(struct amdgpu_ring *ring, long timeout);int amdgpu_vcn_enc_ring_test_ring (struct amdgpu_ring *ring);int amdgpu_vcn_enc_ring_test_ib (struct amdgpu_ring *ring,long timeout); +int amdgpu_vcn_jpeg_ring_test_ring (struct amdgpu_ring *ring); +#endif
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +1 -1
@@ -1714,7 +1714,7 @@ static const struct amdgpu_ring_funcs vcn_v1_0_jpeg_ring_vm_funcs = { .emit_ib = vcn_v1_0_jpeg_ring_emit_ib, .emit_fence = vcn_v1_0_jpeg_ring_emit_fence, .emit_vm_flush = vcn_v1_0_jpeg_ring_emit_vm_flush, -//.test_ring + .test_ring = amdgpu_vcn_jpeg_ring_test_ring,//.test_ib .insert_nop = vcn_v1_0_jpeg_ring_nop, .insert_start = vcn_v1_0_jpeg_ring_insert_start,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 14/18 drm/amdgpu: add vcn jpeg ib test
In reply to a message not in the archiveFrom: Boyuan Zhang <[email protected]>
Add an ib test for vcn jpeg.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 86 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | 1 + drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 2 +- 3 files changed, 88 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +86 -0
@@ -617,3 +617,89 @@ int amdgpu_vcn_jpeg_ring_test_ring(struct amdgpu_ring *ring)return r; } + +static int amdgpu_vcn_jpeg_set_reg (struct amdgpu_ring *ring,uint32_t handle, +struct dma_fence **fence) +{ +struct amdgpu_device *adev = ring->adev; +struct amdgpu_job *job; +struct amdgpu_ib *ib; +struct dma_fence *f =NULL ; +const unsigned ib_size_dw =16 ; +int i, r; + + r =amdgpu_job_alloc_with_ib (ring->adev, ib_size_dw *4 , &job); +if (r) +return r; + + ib = &job->ibs[0 ]; + + ib->ptr[0 ] =PACKETJ (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JPEG_PITCH),0 ,0 ,PACKETJ_TYPE0 ); + ib->ptr[1 ] =0xDEADBEEF ; +for (i =2 ; i <16 ; i +=2 ) { + ib->ptr[i] =PACKETJ (0 ,0 ,0 ,PACKETJ_TYPE6 ); + ib->ptr[i+1 ] =0 ; + } + ib->length_dw =16 ; + + r =amdgpu_ib_schedule (ring,1 , ib,NULL , &f); + job->fence =dma_fence_get (f); +if (r) + goto err; + +amdgpu_job_free (job); +if (fence) + *fence =dma_fence_get (f); +dma_fence_put (f); + +return 0 ; + +err: +amdgpu_job_free (job); +return r; +} + +int amdgpu_vcn_jpeg_ring_test_ib (struct amdgpu_ring *ring,long timeout) +{ +struct amdgpu_device *adev = ring->adev; +uint32_t tmp =0 ; +unsigned i; +struct dma_fence *fence =NULL ; +long r =0 ; + + r =amdgpu_vcn_jpeg_set_reg (ring,1 , &fence); +if (r) { +DRM_ERROR ("amdgpu: failed to set jpeg register (%ld).\n" , r); + goto error; + } + + r =dma_fence_wait_timeout (fence, false, timeout); +if (r ==0 ) { +DRM_ERROR ("amdgpu: IB test timed out.\n" ); + r = -ETIMEDOUT ; + goto error; + }else if (r <0 ) { +DRM_ERROR ("amdgpu: fence wait failed (%ld).\n" , r); + goto error; + }else + r =0 ; + +for (i =0 ; i < adev->usec_timeout; i++) { + tmp =RREG32 (SOC15_REG_OFFSET (UVD ,0 , mmUVD_JPEG_PITCH)); +if (tmp ==0xDEADBEEF ) +break ; +DRM_UDELAY (1 ); + } + +if (i < adev->usec_timeout) +DRM_DEBUG ("ib test on ring %d succeeded\n" , ring->idx); +else { +DRM_ERROR ("ib test failed (0x%08X)\n" , tmp); + r = -EINVAL ; + } + +dma_fence_put (fence); + +error: +return r; +}
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +1 -0
@@ -85,5 +85,6 @@ int amdgpu_vcn_enc_ring_test_ring(struct amdgpu_ring *ring);int amdgpu_vcn_enc_ring_test_ib (struct amdgpu_ring *ring,long timeout);int amdgpu_vcn_jpeg_ring_test_ring (struct amdgpu_ring *ring); +int amdgpu_vcn_jpeg_ring_test_ib (struct amdgpu_ring *ring,long timeout);#endif
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +1 -1
@@ -1715,7 +1715,7 @@ static const struct amdgpu_ring_funcs vcn_v1_0_jpeg_ring_vm_funcs = { .emit_fence = vcn_v1_0_jpeg_ring_emit_fence, .emit_vm_flush = vcn_v1_0_jpeg_ring_emit_vm_flush, .test_ring = amdgpu_vcn_jpeg_ring_test_ring, -//.test_ib + .test_ib = amdgpu_vcn_jpeg_ring_test_ib, .insert_nop = vcn_v1_0_jpeg_ring_nop, .insert_start = vcn_v1_0_jpeg_ring_insert_start, .insert_end = vcn_v1_0_jpeg_ring_insert_end,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 15/18 drm/amdgpu: enable vcn jpeg ib test
In reply to a message not in the archiveFrom: Boyuan Zhang <[email protected]>
Enable vcn jpeg ib ring test in amdgpu_ib.c
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +2 -1
@@ -353,7 +353,8 @@ int amdgpu_ib_ring_tests(struct amdgpu_device *adev) ring->funcs->type ==AMDGPU_RING_TYPE_VCE || ring->funcs->type ==AMDGPU_RING_TYPE_UVD_ENC || ring->funcs->type ==AMDGPU_RING_TYPE_VCN_DEC || - ring->funcs->type == AMDGPU_RING_TYPE_VCN_ENC) + ring->funcs->type ==AMDGPU_RING_TYPE_VCN_ENC || + ring->funcs->type == AMDGPU_RING_TYPE_VCN_JPEG) tmo = tmo_mm; else tmo = tmo_gfx;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 16/18 uapi/drm: add AMDGPU_HW_IP_VCN_JPEG for jpeg CS
In reply to a message not in the archiveFrom: Boyuan Zhang <[email protected]>
Add AMDGPU_HW_IP_VCN_JPEG define for jpeg CS
--- include/uapi/drm/amdgpu_drm.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/uapi/drm/amdgpu_drm.h +2 -1
@@ -486,7 +486,8 @@ struct drm_amdgpu_gem_va {#define AMDGPU_HW_IP_UVD_ENC 5#define AMDGPU_HW_IP_VCN_DEC 6#define AMDGPU_HW_IP_VCN_ENC 7 -#define AMDGPU_HW_IP_NUM 8 +#define AMDGPU_HW_IP_VCN_JPEG 8 +#define AMDGPU_HW_IP_NUM 9#define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 17/18 drm/amdgpu: add AMDGPU_HW_IP_VCN_JPEG to info query
In reply to a message not in the archiveFrom: Boyuan Zhang <[email protected]>
Add AMDGPU_HW_IP_VCN_JPEG to info query
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +7 -0
@@ -383,6 +383,12 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file ib_start_alignment =AMDGPU_GPU_PAGE_SIZE ; ib_size_alignment =1 ;break ; +case AMDGPU_HW_IP_VCN_JPEG : + type =AMD_IP_BLOCK_TYPE_VCN ; + ring_mask = adev->vcn.ring_jpeg.ready ?1 :0 ; + ib_start_alignment =AMDGPU_GPU_PAGE_SIZE ; + ib_size_alignment =16 ; +break ;default :return -EINVAL ; }
@@ -427,6 +433,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_filebreak ;case AMDGPU_HW_IP_VCN_DEC :case AMDGPU_HW_IP_VCN_ENC : +case AMDGPU_HW_IP_VCN_JPEG : type =AMD_IP_BLOCK_TYPE_VCN ;break ;default :
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 18/18 drm/amdgpu: add AMDGPU_HW_IP_VCN_JPEG to queue mgr
In reply to a message not in the archiveFrom: Boyuan Zhang <[email protected]>
Add AMDGPU_HW_IP_VCN_JPEG to queue mgr
--- drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c +7 -0
@@ -96,6 +96,9 @@ static int amdgpu_identity_map(struct amdgpu_device *adev,case AMDGPU_HW_IP_VCN_ENC : *out_ring = &adev->vcn.ring_enc[ring];break ; +case AMDGPU_HW_IP_VCN_JPEG : + *out_ring = &adev->vcn.ring_jpeg; +break ;default : *out_ring =NULL ;DRM_ERROR ("unknown HW IP type: %d\n" , mapper->hw_ip);
@@ -260,6 +263,9 @@ int amdgpu_queue_mgr_map(struct amdgpu_device *adev,case AMDGPU_HW_IP_VCN_ENC : ip_num_rings = adev->vcn.num_enc_rings;break ; +case AMDGPU_HW_IP_VCN_JPEG : + ip_num_rings =1 ; +break ;default :DRM_DEBUG ("unknown ip type: %d\n" , hw_ip);return -EINVAL ;
@@ -287,6 +293,7 @@ int amdgpu_queue_mgr_map(struct amdgpu_device *adev,case AMDGPU_HW_IP_UVD_ENC :case AMDGPU_HW_IP_VCN_DEC :case AMDGPU_HW_IP_VCN_ENC : +case AMDGPU_HW_IP_VCN_JPEG : r =amdgpu_identity_map (adev, mapper, ring, out_ring);break ;case AMDGPU_HW_IP_DMA :
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Patches #1 - #8 and patches #11-#18 are Reviewed-by: Christian König <[email protected]>.
Patch #9:
Quoted 1 line
static void
vcn_v1_0_jpeg_ring_patch_wreg(struct amdgpu_ring *ring, uint32_t ptr, uint32_t reg_offset, uint32_t val)
That you don't pass ptr by reference here looks like a bug to me.
Patch #10:
Review
Quoted 1 line
(quoted diff) +1
-0+ .extra_dw = 0,
I think we should either drop that or add it to all the other rings as well. I certainly prefer to just drop it, cause it's less maintenance work.
Apart from that the patch is Reviewed-by: Christian König <[email protected]> as well.
Thanks,
Christian.
Am 30.05.2018 um 22:27 schrieb [email protected]:
Quoted 14 lines
From: Boyuan Zhang <[email protected]>
Add
AMDGPU_RING_TYPE_VCN_JPEGring defineSigned-off-by Boyuan Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h enum amdgpu_ring_type { · line 60
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2
-1@@ -53,7 +53,8 @@ enum amdgpu_ring_type {AMDGPU_RING_TYPE_KIQ ,AMDGPU_RING_TYPE_UVD_ENC ,AMDGPU_RING_TYPE_VCN_DEC , - AMDGPU_RING_TYPE_VCN_ENC +AMDGPU_RING_TYPE_VCN_ENC , + AMDGPU_RING_TYPE_VCN_JPEG };struct amdgpu_device ;
_______________________________________________
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): 3879a8c9-1460-4106-e447-7376e6344967-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 6 lines · Christian König
Patches #1 - #8 and patches #11-#18 are Reviewed-by: Christian König <[email protected]>.
Patch #9:
Quoted 1 line
static void
vcn_v1_0_jpeg_ring_patch_wreg(struct amdgpu_ring *ring, uint32_t ptr, uint32_t reg_offset, uint32_t val)That you don't pass ptr by reference here looks like a bug to me.
Sorry for the confusion, I shouldn't call it "ptr" because this is actually an index to the ring->ring[]. I will re-name it to sth like "idx"
Quoted 4 lines
Patch #10:
Quoted 1 line
+ .extra_dw = 0,
I think we should either drop that or add it to all the other rings as well. I certainly prefer to just drop it, cause it's less maintenance work.
Thanks for the review. I will drop it accordingly.
Regards,
Boyuan
Quoted 16 lines
Apart from that the patch is Reviewed-by: Christian König <[email protected]> as well.
Thanks,
Christian.Am 30.05.2018 um 22:27 schrieb [email protected]:
Quoted 9 lines
From: Boyuan Zhang <[email protected]>
Add
AMDGPU_RING_TYPE_VCN_JPEGring defineSigned-off-by Boyuan Zhang <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h enum amdgpu_ring_type { · line 59
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2
-1@@ -53,7 +53,8 @@ enum amdgpu_ring_type { AMDGPU_RING_TYPE_KIQ, AMDGPU_RING_TYPE_UVD_ENC, AMDGPU_RING_TYPE_VCN_DEC, - AMDGPU_RING_TYPE_VCN_ENC + AMDGPU_RING_TYPE_VCN_ENC, + AMDGPU_RING_TYPE_VCN_JPEG }; struct amdgpu_device;
_______________________________________________
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): 24eb9a6f-4cac-76f6-79c4-20680b70e040-5C7GfCeVMHo@public.gmane.org
Quoted 11 lines · Boyuan Zhang
Quoted 6 lines · Christian König
Patches #1 - #8 and patches #11-#18 are Reviewed-by: Christian König <[email protected]>.
Patch #9:
Quoted 1 line
static void
vcn_v1_0_jpeg_ring_patch_wreg(struct amdgpu_ring *ring, uint32_t ptr, uint32_t reg_offset, uint32_t val)That you don't pass ptr by reference here looks like a bug to me.
Sorry for the confusion, I shouldn't call it "ptr" because this is actually an index to the ring->ring[]. I will re-name it to sth like "idx"
Oops, I misunderstand your comments. Will fix accordingly.
Thanks,
Boyuan
Quoted 42 lines
Quoted 5 lines
Patch #10:
Quoted 1 line
+ .extra_dw = 0,
I think we should either drop that or add it to all the other rings as well. I certainly prefer to just drop it, cause it's less maintenance work.
Thanks for the review. I will drop it accordingly.
Regards,
BoyuanQuoted 30 lines
Apart from that the patch is Reviewed-by: Christian König <[email protected]> as well.
Thanks,
Christian.Am 30.05.2018 um 22:27 schrieb [email protected]:
Quoted 22 lines
From: Boyuan Zhang <[email protected]>
Add
AMDGPU_RING_TYPE_VCN_JPEGring defineSigned-off-by Boyuan Zhang <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2
-1@@ -53,7 +53,8 @@ enum amdgpu_ring_type { AMDGPU_RING_TYPE_KIQ, AMDGPU_RING_TYPE_UVD_ENC, AMDGPU_RING_TYPE_VCN_DEC, - AMDGPU_RING_TYPE_VCN_ENC + AMDGPU_RING_TYPE_VCN_ENC, + AMDGPU_RING_TYPE_VCN_JPEG }; struct amdgpu_device;
_______________________________________________
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): 16d8a7fd-cce7-37e2-3109-1845094328ec-5C7GfCeVMHo@public.gmane.org
Quoted 5 lines · Boyuan Zhang
Quoted 2 lines · Boyuan Zhang
Quoted 7 lines
Quoted 7 lines · Christian König
Quoted 6 lines
Patches #1 - #8 and patches #11-#18 are Reviewed-by: Christian König <[email protected]>.
Patch #9:
Quoted 1 line
static void
vcn_v1_0_jpeg_ring_patch_wreg(struct amdgpu_ring *ring, uint32_t ptr, uint32_t reg_offset, uint32_t val)That you don't pass ptr by reference here looks like a bug to me.
Thanks a lot for catching this typo bug. Just sent out Patch#9 v3 and Patch#10 v2.
Regards,
Boyuan
Quoted 28 lines
Quoted 28 lines
Quoted 6 lines
Patch #10:
Quoted 1 line
+ .extra_dw = 0,
I think we should either drop that or add it to all the other rings as well. I certainly prefer to just drop it, cause it's less maintenance work.
Thanks for the review. I will drop it accordingly.
Regards,
BoyuanQuoted 16 lines
Apart from that the patch is Reviewed-by: Christian König <[email protected]> as well.
Thanks,
Christian.Am 30.05.2018 um 22:27 schrieb [email protected]:
Quoted 9 lines
From: Boyuan Zhang <[email protected]>
Add
AMDGPU_RING_TYPE_VCN_JPEGring defineSigned-off-by Boyuan Zhang <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 16 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +0
-0@@ -53,7 +53,8 @@ enum amdgpu_ring_type { AMDGPU_RING_TYPE_KIQ,Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h enum amdgpu_ring_type { · line 59
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2
-1AMDGPU_RING_TYPE_UVD_ENC, AMDGPU_RING_TYPE_VCN_DEC, - AMDGPU_RING_TYPE_VCN_ENC + AMDGPU_RING_TYPE_VCN_ENC, + AMDGPU_RING_TYPE_VCN_JPEG }; struct amdgpu_device;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx