Skip to contentSkip to conversation

drm/amdgpu: implement patch for fixing a known bug

PATCH In review [email protected] 4 participants 5 messages Jun 1, 2018 2 messages not in the archive

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

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

From: 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.

v3: fixing a typo bug.

---
 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
index ea1d677..e8d24a6 100644
@@ -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

A message that is not in the archive (sent off-list or not yet received): 1527870937-11036-1-git-send-email-boyuan.zhang-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 10/18 drm/amdgpu: define and add extra dword for jpeg ring

From: 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.

v2: dropping extra_dw for rings other than jpeg.

---
 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    | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1 -1
index c6850b6..19e45a3 100644
@@ -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
index a3908ef..a293f4e 100644
@@ -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 +1 -0
index e8d24a6..8d9f2222 100644
@@ -1690,6 +1690,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
#3 lore raw
In reply to a message not in the archive
Quoted 42 lines · On Fri, Jun 1, 2018 at 12:35 PM, <[email protected]> wrote:

From: 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.

v3: fixing a typo bug.

---
 drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 92 +++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +13 -0
index ea1d677..e8d24a6 100644
@@ -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);
+       }

drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c static void vcn_v1_0_jpeg_ring_nop(struct amdgpu_ring *ring, uint32_t count) · line 1467

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +10 -0
+       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

Please switch to C style /* */ comments before committing.

Alex

Quoted 75 lines
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +69 -1
+       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,
--

2.7.4

Quoted 4 lines

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

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

#4 lore raw
In reply to a message not in the archive

Am 01.06.2018 um 18:35 schrieb [email protected]:

Quoted 27 lines

From: 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.

v3: fixing a typo bug.

---
  drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 92 +++++++++++++++++++++++++++++++++++
  1 file changed, 92 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +1 -0
index ea1d677..e8d24a6 100644
@@ -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

drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c static void vcn_v1_0_jpeg_ring_nop(struct amdgpu_ring *ring, uint32_t count) · line 1446

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +1 -0
@@ -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)

&ptr only works in C++, you need to use *ptr here :)

But apart from that the patch now looks good to me, Christian.

Quoted 83 lines
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +83 -0
+{
+	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);
+

drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c static void vcn_v1_0_jpeg_ring_nop(struct amdgpu_ring *ring, uint32_t count) · line 1539

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +7 -0
+	//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,

_______________________________________________
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): 77d5540d-2871-1480-0138-1ee1ed3ea675-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#6 lore raw
Quoted 37 lines · Christian König

Am 01.06.2018 um 18:35 schrieb [email protected]:

Quoted 29 lines

From: 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.

v3: fixing a typo bug.

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

  1 file changed, 92 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +1 -0
index ea1d677..e8d24a6 100644
@@ -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

drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c static void vcn_v1_0_jpeg_ring_nop(struct · line 1446

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +0 -0
@@ -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)

&ptr only works in C++, you need to use *ptr here :)

Quoted 2 lines

But apart from that the patch now looks good to me, Christian.

Oops, sorry my fault. I've no idea why I made this obvious mistake. This is totally accidental... Anyways, just sent out patch#9 v4.

Quoted 96 lines
Quoted 96 lines
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +15 -0
+{
+    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)

drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +7 -0
+{
+    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);

drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +8 -0
+
+    // 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);

drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +14 -0
+
+    // 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;

drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +15 -0
+
+    //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);
Quoted 9 lines
Quoted 8 lines

+    reg_offset = (reg << 2);
+    val = 0x12;
+    vcn_v1_0_jpeg_ring_patch_wreg(ring, ptr, reg_offset, val);

drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +2 -0
+}
+

  static int vcn_v1_0_set_interrupt_state(struct amdgpu_device *adev, struct amdgpu_irq_src *source, unsigned type,

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