Skip to contentSkip to conversation

drm/amdgpu: define vcn jpeg ring

PATCH In review [email protected] 5 participants 23 messages May 24, 2018 – May 30, 2018 7 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/17 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
index 1d0d250..4961be1 100644
@@ -50,7 +50,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): 1527192929-2480-1-git-send-email-boyuan.zhang-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 2/17 drm/amdgpu: add vcn jpeg ring

From: Boyuan Zhang <[email protected]>

Add jpeg to amdgpu_vcn

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +2 -0
index 2fd7db8..648f662 100644
@@ -55,9 +55,11 @@ 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;
 	struct drm_sched_entity entity_dec;
 	struct drm_sched_entity entity_enc;
+	struct drm_sched_entity entity_jpeg;
 	unsigned		num_enc_rings;
 };
 
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): 1527192929-2480-2-git-send-email-boyuan.zhang-5C7GfCeVMHo@public.gmane.org

#4 lore raw

Re: [PATCH 02/17] drm/amdgpu: add vcn jpeg ring

Am 24.05.2018 um 22:15 schrieb [email protected]:

Quoted 14 lines

From: Boyuan Zhang <[email protected]>

Add jpeg to amdgpu_vcn

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | 2 ++
  1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +0 -0
index 2fd7db8..648f662 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h struct amdgpu_vcn { · line 62

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +2 -0
@@ -55,9 +55,11 @@ 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;
  	struct drm_sched_entity entity_dec;
  	struct drm_sched_entity entity_enc;
+	struct drm_sched_entity entity_jpeg;

Why do you need the entity here? I thought the JPEG ring is stateles?

Christian.

drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h struct amdgpu_vcn { · line 65

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +0 -0
  	unsigned		num_enc_rings;
  };
 

_______________________________________________
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): dda40ec4-8011-55eb-5f4f-adf6e9a25159-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#6 lore raw

Re: [PATCH 02/17] drm/amdgpu: add vcn jpeg ring

Quoted 10 lines · Christian König

Am 24.05.2018 um 22:15 schrieb [email protected]:

Quoted 9 lines

From: Boyuan Zhang <[email protected]>

Add jpeg to amdgpu_vcn

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | 2 ++

  1 file changed, 2 insertions(+)
Quoted 15 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +0 -0
index 2fd7db8..648f662 100644
@@ -55,9 +55,11 @@ struct amdgpu_vcn {
Quoted 8 lines

      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;
      struct drm_sched_entity entity_dec;
      struct drm_sched_entity entity_enc;
+    struct drm_sched_entity entity_jpeg;

Why do you need the entity here? I thought the JPEG ring is stateles?

Right. We don't even need them for dec and enc. I think there is a copy-over from legacy UVD/VCE stuff with handles limitation, for that we need scheduler involved to send a destroy message.

I will come up a patch to remove those entities for dec and enc.

Regards,
Leo

Quoted 6 lines

Christian.

Quoted 2 lines

      unsigned        num_enc_rings;
  };

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#7 lore raw

PATCH 3/17 drm/amdgpu: add jpeg packet defines to soc15d.h

In reply to a message not in the archive

From: 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
index 7f408f8..7f208e7 100644
@@ -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
#8 lore raw

PATCH 4/17 drm/amdgpu: add more jpeg register offset headers

In reply to a message not in the archive

From: 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
index 18a3247..fe0cbaa 100644
@@ -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
#9 lore raw

PATCH 5/17 drm/amdgpu: implement jpeg ring functions

In reply to a message not in the archive

From: Boyuan Zhang <[email protected]>

---
 drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 293 ++++++++++++++++++++++++++++++++++
 1 file changed, 293 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +293 -0
index 8c13267..3ddab07 100644
@@ -1015,6 +1015,299 @@ 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_mem_read(struct amdgpu_ring *ring)
+{
+	amdgpu_ring_write(ring,
+		PACKETJ(0, 0, 0, PACKETJ_TYPE2));
+	amdgpu_ring_write(ring, 0);
+}
+
+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
#10 lore raw

PATCH 6/17 drm/amdgpu: set jpeg ring functions

In reply to a message not in the archive

From: Boyuan Zhang <[email protected]>

Set all vcn jpeg ring function pointers

---
 drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 41 +++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +41 -0
index 3ddab07..0dde424 100644
@@ -39,6 +39,7 @@ static int vcn_v1_0_start(struct amdgpu_device *adev);
 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);
 
 /**
@@ -56,6 +57,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;
@@ -147,6 +149,7 @@ static int vcn_v1_0_hw_init(void *handle)
 	int i, r;
 
 	r = vcn_v1_0_start(adev);
+
 	if (r)
 		goto done;
 
@@ -1434,6 +1437,38 @@ static const struct amdgpu_ring_funcs vcn_v1_0_enc_ring_vm_funcs = {
 	.emit_reg_wait = vcn_v1_0_enc_ring_emit_reg_wait,
 };
 
+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;
@@ -1450,6 +1485,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
#11 lore raw

PATCH 7/17 drm/amdgpu: add vcn jpeg irq support

In reply to a message not in the archive

From: 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
index 0dde424..9a04a9a 100644
@@ -89,6 +89,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;
@@ -1335,6 +1340,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
#12 lore raw

PATCH 8/17 drm/amdgpu: initialize vcn jpeg ring

In reply to a message not in the archive

From: 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
index 9a04a9a..34699f8 100644
@@ -116,6 +116,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;
 }
 
@@ -175,6 +181,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");
@@ -655,6 +669,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
#13 lore raw

PATCH 9/17 drm/amdgpu: implement patch for fixing a known bug

In reply to a message not in the archive

From: Boyuan Zhang <[email protected]>

Implement a patch to maunally reset read pointer

---
 drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 43 +++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +43 -0
index 34699f8..dcd1a9a 100644
@@ -41,6 +41,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);
 
 /**
  * vcn_v1_0_early_init - set function pointers
@@ -1339,6 +1340,48 @@ static void vcn_v1_0_jpeg_ring_nop(struct amdgpu_ring *ring, uint32_t count)
 	}
 }
 
+static void vcn_v1_0_jpeg_ring_set_patch_ring(struct amdgpu_ring *ring)
+{
+	struct amdgpu_device *adev = ring->adev;
+
+	uint32_t reg, val, mask, i;
+
+	reg = SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_JRBC_RB_MEM_RD_64BIT_BAR_LOW);
+	val = lower_32_bits(ring->gpu_addr);
+	vcn_v1_0_jpeg_ring_emit_wreg(ring, reg, val);
+
+	reg = SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_JRBC_RB_MEM_RD_64BIT_BAR_HIGH);
+	val = upper_32_bits(ring->gpu_addr);
+	vcn_v1_0_jpeg_ring_emit_wreg(ring, reg, val);
+
+	for (i = 0; i <= 2; i++)
+		vcn_v1_0_jpeg_ring_mem_read(ring);
+
+	reg = SOC15_REG_OFFSET(UVD, 0, mmUVD_JRBC_RB_CNTL);
+	val = 0x13;
+	vcn_v1_0_jpeg_ring_emit_wreg(ring, reg, val);
+
+	reg = SOC15_REG_OFFSET(UVD, 0, mmUVD_JRBC_RB_REF_DATA);
+	val = 0x1;
+	vcn_v1_0_jpeg_ring_emit_wreg(ring, reg, val);
+
+	reg = SOC15_REG_OFFSET(UVD, 0, mmUVD_JRBC_RB_CNTL);
+	val = 0x1;
+	mask = 0x1;
+	vcn_v1_0_jpeg_ring_emit_reg_wait(ring, reg, val, mask);
+
+	for (i = 0; i <= 12; i++)
+		vcn_v1_0_jpeg_ring_nop(ring, 2);
+
+	reg = SOC15_REG_OFFSET(UVD, 0, mmUVD_JRBC_RB_RPTR);
+	val = 0;
+	vcn_v1_0_jpeg_ring_emit_wreg(ring, reg, val);
+
+	reg = SOC15_REG_OFFSET(UVD, 0, mmUVD_JRBC_RB_CNTL);
+	val = 0x12;
+	vcn_v1_0_jpeg_ring_emit_wreg(ring, reg, 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
#14 lore raw

PATCH 10/17 drm/amdgpu: add patch for fixing a known bug

In reply to a message not in the archive

From: Boyuan Zhang <[email protected]>

Allocate extra space in vcn jpeg ring buffer and store the jpeg ring patch

---
 drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +26 -1
index dcd1a9a..2e4bd26 100644
@@ -119,7 +119,8 @@ static int vcn_v1_0_sw_init(void *handle)
 
 	ring = &adev->vcn.ring_jpeg;
 	sprintf(ring->name, "vcn_jpeg");
-	r = amdgpu_ring_init(adev, ring, 512, &adev->vcn.irq, 0);
+	/* allocate extra dw in ring buffer for storing patch commands */
+	r = amdgpu_ring_init(adev, ring, 512 + 64, &adev->vcn.irq, 0);
 	if (r)
 		return r;
 
@@ -679,6 +680,30 @@ 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);
 
+	/* set wptr to the extra allocated space in ring buffer */
+	ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR);
+	ring->wptr += ring->max_dw * amdgpu_sched_hw_submission;
+
+	/* increase mask to allow to write to the extra space */
+	ring->buf_mask += 64 * 4;
+	ring->ptr_mask += 64 * 4;
+
+	/* allocate extra space */
+	r = amdgpu_ring_alloc(ring, 64);
+	if (r) {
+		DRM_ERROR("amdgpu: cp failed to lock ring %d (%d).\n",
+				  ring->idx, r);
+		return r;
+	}
+
+	/* copy patch commands to the extra space */
+	vcn_v1_0_jpeg_ring_set_patch_ring(ring);
+
+	/* reset wptr and mask */
+	ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR);
+	ring->buf_mask -= 0x100;
+	ring->ptr_mask -= 0x100;
+
 	return 0;
 }
 
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): 1527192929-2480-10-git-send-email-boyuan.zhang-5C7GfCeVMHo@public.gmane.org

#16 lore raw

Re: [PATCH 10/17] drm/amdgpu: add patch for fixing a known bug

Am 24.05.2018 um 22:15 schrieb [email protected]:

Quoted 24 lines

From: Boyuan Zhang <[email protected]>

Allocate extra space in vcn jpeg ring buffer and store the jpeg ring patch

---
  drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 27 ++++++++++++++++++++++++++-
  1 file changed, 26 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +2 -1
index dcd1a9a..2e4bd26 100644
@@ -119,7 +119,8 @@ static int vcn_v1_0_sw_init(void *handle)
 
  	ring = &adev->vcn.ring_jpeg;
  	sprintf(ring->name, "vcn_jpeg");
-	r = amdgpu_ring_init(adev, ring, 512, &adev->vcn.irq, 0);
+	/* allocate extra dw in ring buffer for storing patch commands */
+	r = amdgpu_ring_init(adev, ring, 512 + 64, &adev->vcn.irq, 0);
  	if (r)
  		return r;
 

drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c static int vcn_v1_0_start(struct amdgpu_device *adev) · line 689

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +7 -0
@@ -679,6 +680,30 @@ 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);
 
+	/* set wptr to the extra allocated space in ring buffer */
+	ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR);
+	ring->wptr += ring->max_dw * amdgpu_sched_hw_submission;
+
+	/* increase mask to allow to write to the extra space */
+	ring->buf_mask += 64 * 4;
+	ring->ptr_mask += 64 * 4;

Well that is rather ugly. buf_mask and ptr_mask are bit masks, you could set them to 0xffffffff but what you do here might not work as expected.

drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c static int vcn_v1_0_start(struct amdgpu_device *adev) · line 700

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +11 -0
+
+	/* allocate extra space */
+	r = amdgpu_ring_alloc(ring, 64);
+	if (r) {
+		DRM_ERROR("amdgpu: cp failed to lock ring %d (%d).\n",
+				  ring->idx, r);
+		return r;
+	}
+
+	/* copy patch commands to the extra space */
+	vcn_v1_0_jpeg_ring_set_patch_ring(ring);

Can't vcn_v1_0_jpeg_ring_set_patch_ring() just patch the command directly to he end of the ring buffer?

In other words why do we need to use amdgpu_ring_write() in vcn_v1_0_jpeg_ring_set_patch_ring()?

Christian.

drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c static int vcn_v1_0_start(struct amdgpu_device *adev) · line 709

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +6 -0
+
+	/* reset wptr and mask */
+	ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR);
+	ring->buf_mask -= 0x100;
+	ring->ptr_mask -= 0x100;
+
  	return 0;
  }
 

_______________________________________________
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): 621d4f85-39f8-b998-6b6c-b8e55c93a8c9-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#18 lore raw

Re: [PATCH 10/17] drm/amdgpu: add patch for fixing a known bug

Quoted 26 lines · Christian König

Am 24.05.2018 um 22:15 schrieb [email protected]:

Quoted 25 lines

From: Boyuan Zhang <[email protected]>

Allocate extra space in vcn jpeg ring buffer and store the jpeg ring patch

---
  drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 27 ++++++++++++++++++++++++++-

  1 file changed, 26 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +2 -1
index dcd1a9a..2e4bd26 100644
@@ -119,7 +119,8 @@ static int vcn_v1_0_sw_init(void *handle)
         ring = &adev->vcn.ring_jpeg;
       sprintf(ring->name, "vcn_jpeg");
-    r = amdgpu_ring_init(adev, ring, 512, &adev->vcn.irq, 0);
+    /* allocate extra dw in ring buffer for storing patch commands */
+    r = amdgpu_ring_init(adev, ring, 512 + 64, &adev->vcn.irq, 0);
       if (r)
           return r;
   @@ -679,6 +680,30 @@ 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); +    /* set wptr to the extra allocated space in ring buffer */

Quoted 8 lines
Quoted 6 lines

+    ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR); +    ring->wptr += ring->max_dw * amdgpu_sched_hw_submission; +
+    /* increase mask to allow to write to the extra space */ +    ring->buf_mask += 64 * 4;
+    ring->ptr_mask += 64 * 4;

Well that is rather ugly. buf_mask and ptr_mask are bit masks, you could set them to 0xffffffff but what you do here might not work as expected.

OK, so maybe setting both mask to 0xffffffff temporarily to allow writing to extra space as mu as needed, then later on set them back?

Quoted 15 lines

drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c static int vcn_v1_0_start(struct amdgpu_device *adev) · line 700

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +11 -0
+
+    /* allocate extra space */
+    r = amdgpu_ring_alloc(ring, 64);
+    if (r) {
+        DRM_ERROR("amdgpu: cp failed to lock ring %d (%d).\n",
+                  ring->idx, r);
+        return r;
+    }
+
+    /* copy patch commands to the extra space */
+    vcn_v1_0_jpeg_ring_set_patch_ring(ring);

Can't vcn_v1_0_jpeg_ring_set_patch_ring() just patch the command directly to he end of the ring buffer?

Quoted 3 lines

In other words why do we need to use amdgpu_ring_write() in vcn_v1_0_jpeg_ring_set_patch_ring()?

Christian.

Could you give me some more detailed info on how to do that? I thought amdgpu_ring_write() is the best way to write commands to the ring, what is the other/better way to do it in this case? Could you point me to a simple example how to write command directly to the end of ring (without ring_write)?

Thanks,
Boyuan

Quoted 10 lines
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +6 -0
+
+    /* reset wptr and mask */
+    ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR);
+    ring->buf_mask -= 0x100;
+    ring->ptr_mask -= 0x100;
+

      return 0;
  }

_______________________________________________
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): 74ba52c7-7fee-fa61-02b1-46daaf55a085-5C7GfCeVMHo@public.gmane.org

#20 lore raw

Re: [PATCH 10/17] drm/amdgpu: add patch for fixing a known bug

Am 25.05.2018 um 17:33 schrieb Boyuan Zhang:

Quoted 14 lines · Christian König
Quoted 11 lines

Am 24.05.2018 um 22:15 schrieb [email protected]:

Quoted 10 lines

From: Boyuan Zhang <[email protected]>

Allocate extra space in vcn jpeg ring buffer and store the jpeg ring patch

---
  drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 27
++++++++++++++++++++++++++-

  1 file changed, 26 insertions(+), 1 deletion(-)
Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c static int vcn_v1_0_sw_init(void *handle) · line 122

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +2 -1
index dcd1a9a..2e4bd26 100644
@@ -119,7 +119,8 @@ static int vcn_v1_0_sw_init(void *handle)
         ring = &adev->vcn.ring_jpeg;
       sprintf(ring->name, "vcn_jpeg");
-    r = amdgpu_ring_init(adev, ring, 512, &adev->vcn.irq, 0);
+    /* allocate extra dw in ring buffer for storing patch commands */
+    r = amdgpu_ring_init(adev, ring, 512 + 64, &adev->vcn.irq, 0);

Taking a closer look that hack might not work after all. E.g. you need to overwrite max_dw, buf_mask and ptr_mask after initialization.

Maybe add an "extra_dw" field into amdgpu_ring_funcs and use that in amdgpu_ring_init().

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +0 -0
       if (r)
           return r;
   @@ -679,6 +680,30 @@ 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); +    /* set wptr to the extra allocated space in ring buffer */ +    ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR); +    ring->wptr += ring->max_dw * amdgpu_sched_hw_submission; +
+    /* increase mask to allow to write to the extra space */ +    ring->buf_mask += 64 * 4;
+    ring->ptr_mask += 64 * 4;

Quoted 3 lines
Quoted 1 line

Well that is rather ugly. buf_mask and ptr_mask are bit masks, you could set them to 0xffffffff but what you do here might not work as expected.

OK, so maybe setting both mask to 0xffffffff temporarily to allow writing to extra space as mu as needed, then later on set them back?

Yeah, that should at least work as expected.  I would also add a comment here why we actually do all this.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

+
+    /* allocate extra space */
+    r = amdgpu_ring_alloc(ring, 64);
+    if (r) {
+        DRM_ERROR("amdgpu: cp failed to lock ring %d (%d).\n", +                  ring->idx, r);
+        return r;
+    }

Would be nice if we could avoid that call as well, cause this is really not ring buffer operation but rather setting up the environment.

Quoted 11 lines
Quoted 9 lines
Quoted 3 lines

+
+    /* copy patch commands to the extra space */
+    vcn_v1_0_jpeg_ring_set_patch_ring(ring);

Can't vcn_v1_0_jpeg_ring_set_patch_ring() just patch the command directly to he end of the ring buffer?

In other words why do we need to use amdgpu_ring_write() in vcn_v1_0_jpeg_ring_set_patch_ring()?

Christian.

Could you give me some more detailed info on how to do that? I thought amdgpu_ring_write() is the best way to write commands to the ring, what is the other/better way to do it in this case? Could you point me to a simple example how to write command directly to the end of ring (without ring_write)?

Well something like this should work:

/* pointer to the end of the ring buffer */
i = ring->max_dw * amdgpu_sched_hw_submission;
ring->ring[i++] = ....
ring->ring[i++] = ....
ring->ring[i++] = ....
ring->ring[i++] = ....

Regards,
Christian.

Quoted 15 lines

Thanks,
Boyuan

Quoted 10 lines
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +6 -0
+
+    /* reset wptr and mask */
+    ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR);
+    ring->buf_mask -= 0x100;
+    ring->ptr_mask -= 0x100;
+

      return 0;
  }

_______________________________________________
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): 16127024-e33a-af3b-bbb9-0199ab359dc6-5C7GfCeVMHo@public.gmane.org

#22 lore raw

Re: [PATCH 10/17] drm/amdgpu: add patch for fixing a known bug

Quoted 28 lines · Christian König

Am 25.05.2018 um 17:33 schrieb Boyuan Zhang:

Quoted 14 lines · Christian König
Quoted 11 lines

Am 24.05.2018 um 22:15 schrieb [email protected]:

Quoted 10 lines

From: Boyuan Zhang <[email protected]>

Allocate extra space in vcn jpeg ring buffer and store the jpeg ring patch

---
  drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 27
++++++++++++++++++++++++++-

  1 file changed, 26 insertions(+), 1 deletion(-)
Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c static int vcn_v1_0_sw_init(void *handle) · line 122

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +2 -1
index dcd1a9a..2e4bd26 100644
@@ -119,7 +119,8 @@ static int vcn_v1_0_sw_init(void *handle)
         ring = &adev->vcn.ring_jpeg;
       sprintf(ring->name, "vcn_jpeg");
-    r = amdgpu_ring_init(adev, ring, 512, &adev->vcn.irq, 0);
+    /* allocate extra dw in ring buffer for storing patch commands */
+    r = amdgpu_ring_init(adev, ring, 512 + 64, &adev->vcn.irq, 0);

Taking a closer look that hack might not work after all. E.g. you need to overwrite max_dw, buf_mask and ptr_mask after initialization.

Quoted 1 line

Maybe add an "extra_dw" field into amdgpu_ring_funcs and use that in amdgpu_ring_init().

Agree. I removed all of this and add an extra_dw field. Please see new patch set (0010 and 0011) just I sent out.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +0 -0
       if (r)
           return r;
   @@ -679,6 +680,30 @@ 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); +    /* set wptr to the extra allocated space in ring buffer */ +    ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR); +    ring->wptr += ring->max_dw * amdgpu_sched_hw_submission; +
+    /* increase mask to allow to write to the extra space */ +    ring->buf_mask += 64 * 4;
+    ring->ptr_mask += 64 * 4;

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Well that is rather ugly. buf_mask and ptr_mask are bit masks, you could set them to 0xffffffff but what you do here might not work as expected.

OK, so maybe setting both mask to 0xffffffff temporarily to allow writing to extra space as mu as needed, then later on set them back?

Yeah, that should at least work as expected.  I would also add a comment here why we actually do all this.

Same as above, this part is not needed after adding extra_dw. Please see new patch set (0010 and 0011)

Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

+
+    /* allocate extra space */
+    r = amdgpu_ring_alloc(ring, 64);
+    if (r) {
+        DRM_ERROR("amdgpu: cp failed to lock ring %d (%d).\n", +                  ring->idx, r);
+        return r;
+    }

Quoted 1 line

Would be nice if we could avoid that call as well, cause this is really not ring buffer operation but rather setting up the environment.

Same as above, this is removed as well.

Quoted 22 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

+
+    /* copy patch commands to the extra space */
+    vcn_v1_0_jpeg_ring_set_patch_ring(ring);

Quoted 7 lines
Quoted 5 lines

Can't vcn_v1_0_jpeg_ring_set_patch_ring() just patch the command directly to he end of the ring buffer?

In other words why do we need to use amdgpu_ring_write() in vcn_v1_0_jpeg_ring_set_patch_ring()?

Christian.

Could you give me some more detailed info on how to do that? I thought amdgpu_ring_write() is the best way to write commands to the ring, what is the other/better way to do it in this case? Could you point me to a simple example how to write command directly to the end of ring (without ring_write)?

Well something like this should work:

/* pointer to the end of the ring buffer */
i = ring->max_dw * amdgpu_sched_hw_submission;
ring->ring[i++] = ....
ring->ring[i++] = ....
ring->ring[i++] = ....
ring->ring[i++] = ....

Quoted 2 lines

Regards,
Christian.

Yes, direct assignment seems better than using amdgpu_ring_write() for the patch. Removed all amdgpu_ring_write() and replaced with assignments. Please see the new 0009 patch.

Quoted 6 lines
Quoted 6 lines

Thanks,
Boyuan

Quoted 1 line
Quoted 11 lines
Quoted 10 lines
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +6 -0
+
+    /* reset wptr and mask */
+    ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR);
+    ring->buf_mask -= 0x100;
+    ring->ptr_mask -= 0x100;
+

      return 0;
  }

All changes have been marked as v2 in new patch sets that just send out.

Regards,
Boyuan

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#23 lore raw

PATCH 11/17 drm/amdgpu: add vcn jpeg sw init and fini

In reply to a message not in the archive

From: Boyuan Zhang <[email protected]>

Add software initializationa and finish for vcn jpeg ring

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +13 -0
index 58e4953..190728f 100644
@@ -120,6 +120,15 @@ int amdgpu_vcn_sw_init(struct amdgpu_device *adev)
 		return r;
 	}
 
+	ring = &adev->vcn.ring_jpeg;
+	rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL];
+	r = drm_sched_entity_init(&ring->sched, &adev->vcn.entity_jpeg,
+				  rq, amdgpu_sched_jobs, NULL);
+	if (r != 0) {
+		DRM_ERROR("Failed setting up VCN jpeg run queue.\n");
+		return r;
+	}
+
 	return 0;
 }
 
@@ -133,6 +142,8 @@ int amdgpu_vcn_sw_fini(struct amdgpu_device *adev)
 
 	drm_sched_entity_fini(&adev->vcn.ring_enc[0].sched, &adev->vcn.entity_enc);
 
+	drm_sched_entity_fini(&adev->vcn.ring_jpeg.sched, &adev->vcn.entity_jpeg);
+
 	amdgpu_bo_free_kernel(&adev->vcn.vcpu_bo,
 			      &adev->vcn.gpu_addr,
 			      (void **)&adev->vcn.cpu_addr);
@@ -142,6 +153,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
#24 lore raw

PATCH 12/17 drm/amdgpu: add vcn jpeg ring test

In reply to a message not in the archive

From: 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
index 190728f..123ad5d 100644
@@ -612,3 +612,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
index 648f662..c746dae 100644
@@ -76,4 +76,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
index 2e4bd26..5654771 100644
@@ -1556,7 +1556,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
#25 lore raw

PATCH 13/17 drm/amdgpu: add vcn jpeg ib test

In reply to a message not in the archive

From: 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
index 123ad5d..ab5970b 100644
@@ -652,3 +652,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
index c746dae..294f8d5 100644
@@ -77,5 +77,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
index 5654771..be397ef 100644
@@ -1557,7 +1557,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
#26 lore raw

PATCH 14/17 drm/amdgpu: enable vcn jpeg ib test

In reply to a message not in the archive

From: 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
index 311589e..04164a6 100644
@@ -349,7 +349,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
#27 lore raw

PATCH 15/17 uapi/drm: add AMDGPU_HW_IP_VCN_JPEG for jpeg CS

In reply to a message not in the archive

From: 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
index 393d183..4381dcc 100644
@@ -476,7 +476,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
#28 lore raw

PATCH 16/17 drm/amdgpu: add AMDGPU_HW_IP_VCN_JPEG to info query

In reply to a message not in the archive

From: 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
index 51a4b08..dfe4399 100644
@@ -359,6 +359,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;
 		}
@@ -403,6 +409,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
 			break;
 		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
#29 lore raw

PATCH 17/17 drm/amdgpu: add AMDGPU_HW_IP_VCN_JPEG to queue mgr

In reply to a message not in the archive

From: 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
index 262c126..a0c7e92 100644
@@ -91,6 +91,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);
@@ -254,6 +257,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;
@@ -281,6 +287,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