Skip to contentSkip to conversation

drm/amdgpu/sdma5: don't access registers in MQD setup

PATCH New Alex Deucher 1 participant 5 messages Oct 19

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/5 drm/amdgpu/sdma5: don't access registers in MQD setup

No need to read the register state from the hardware, just program the settings explicitly. This could also cause problems when gfx is powered off.

---
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +7 -4
index 1a1427d2dd20e..883f558eb79dd 100644
@@ -932,6 +932,7 @@ static int sdma_v5_0_mqd_init(struct amdgpu_device *adev, void *mqd,
 {
 	struct v10_sdma_mqd *m = mqd;
 	uint64_t wb_gpu_addr;
+	u32 tmp;
 
 	m->sdmax_rlcx_rb_cntl =
 		order_base_2(prop->queue_size / 4) << SDMA0_RLC0_RB_CNTL__RB_SIZE__SHIFT |
@@ -942,8 +943,9 @@ static int sdma_v5_0_mqd_init(struct amdgpu_device *adev, void *mqd,
 	m->sdmax_rlcx_rb_base = lower_32_bits(prop->hqd_base_gpu_addr >> 8);
 	m->sdmax_rlcx_rb_base_hi = upper_32_bits(prop->hqd_base_gpu_addr >> 8);
 
-	m->sdmax_rlcx_rb_wptr_poll_cntl = RREG32(sdma_v5_0_get_reg_offset(adev, 0,
-						  mmSDMA0_GFX_RB_WPTR_POLL_CNTL));
+	tmp = REG_SET_FIELD(0, SDMA0_RLC0_RB_WPTR_POLL_CNTL, FREQUENCY, 0x100);
+	tmp = REG_SET_FIELD(tmp, SDMA0_RLC0_RB_WPTR_POLL_CNTL, IDLE_POLL_COUNT, 0x40);
+	m->sdmax_rlcx_rb_wptr_poll_cntl = tmp;
 
 	wb_gpu_addr = prop->wptr_gpu_addr;
 	m->sdmax_rlcx_rb_wptr_poll_addr_lo = lower_32_bits(wb_gpu_addr);
@@ -953,8 +955,9 @@ static int sdma_v5_0_mqd_init(struct amdgpu_device *adev, void *mqd,
 	m->sdmax_rlcx_rb_rptr_addr_lo = lower_32_bits(wb_gpu_addr);
 	m->sdmax_rlcx_rb_rptr_addr_hi = upper_32_bits(wb_gpu_addr);
 
-	m->sdmax_rlcx_ib_cntl = RREG32(sdma_v5_0_get_reg_offset(adev, 0,
-							mmSDMA0_GFX_IB_CNTL));
+	tmp = REG_SET_FIELD(0, SDMA0_RLC0_IB_CNTL, IB_ENABLE, 1);
+	tmp = REG_SET_FIELD(tmp, SDMA0_RLC0_IB_CNTL, SWITCH_INSIDE_IB, 1);
+	m->sdmax_rlcx_ib_cntl = tmp;
 
 	m->sdmax_rlcx_doorbell_offset =
 		prop->doorbell_index << SDMA0_RLC0_DOORBELL_OFFSET__OFFSET__SHIFT;
Signature · 1 line
2.56.0
author maintainer
#1 lore raw

PATCH 2/5 drm/amdgpu/sdma5.2: don't access registers in MQD setup

No need to read the register state from the hardware, just program the settings explicitly. This could also cause problems when gfx is powered off.

---
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +7 -4
index b3692d22fb6ad..43a8f0a85cca7 100644
@@ -832,6 +832,7 @@ static int sdma_v5_2_mqd_init(struct amdgpu_device *adev, void *mqd,
 {
 	struct v10_sdma_mqd *m = mqd;
 	uint64_t wb_gpu_addr;
+	u32 tmp;
 
 	m->sdmax_rlcx_rb_cntl =
 		order_base_2(prop->queue_size / 4) << SDMA0_RLC0_RB_CNTL__RB_SIZE__SHIFT |
@@ -842,8 +843,9 @@ static int sdma_v5_2_mqd_init(struct amdgpu_device *adev, void *mqd,
 	m->sdmax_rlcx_rb_base = lower_32_bits(prop->hqd_base_gpu_addr >> 8);
 	m->sdmax_rlcx_rb_base_hi = upper_32_bits(prop->hqd_base_gpu_addr >> 8);
 
-	m->sdmax_rlcx_rb_wptr_poll_cntl = RREG32(sdma_v5_2_get_reg_offset(adev, 0,
-						  mmSDMA0_GFX_RB_WPTR_POLL_CNTL));
+	tmp = REG_SET_FIELD(0, SDMA0_RLC0_RB_WPTR_POLL_CNTL, FREQUENCY, 0x100);
+	tmp = REG_SET_FIELD(tmp, SDMA0_RLC0_RB_WPTR_POLL_CNTL, IDLE_POLL_COUNT, 0x40);
+	m->sdmax_rlcx_rb_wptr_poll_cntl = tmp;
 
 	wb_gpu_addr = prop->wptr_gpu_addr;
 	m->sdmax_rlcx_rb_wptr_poll_addr_lo = lower_32_bits(wb_gpu_addr);
@@ -853,8 +855,9 @@ static int sdma_v5_2_mqd_init(struct amdgpu_device *adev, void *mqd,
 	m->sdmax_rlcx_rb_rptr_addr_lo = lower_32_bits(wb_gpu_addr);
 	m->sdmax_rlcx_rb_rptr_addr_hi = upper_32_bits(wb_gpu_addr);
 
-	m->sdmax_rlcx_ib_cntl = RREG32(sdma_v5_2_get_reg_offset(adev, 0,
-							mmSDMA0_GFX_IB_CNTL));
+	tmp = REG_SET_FIELD(0, SDMA0_RLC0_IB_CNTL, IB_ENABLE, 1);
+	tmp = REG_SET_FIELD(tmp, SDMA0_RLC0_IB_CNTL, SWITCH_INSIDE_IB, 1);
+	m->sdmax_rlcx_ib_cntl = tmp;
 
 	m->sdmax_rlcx_doorbell_offset =
 		prop->doorbell_index << SDMA0_RLC0_DOORBELL_OFFSET__OFFSET__SHIFT;
Signature · 1 line
2.56.0
author maintainer
#2 lore raw

PATCH 3/5 drm/amdgpu/sdma6: don't access registers in MQD setup

In reply to Alex Deucher

No need to read the register state from the hardware, just program the settings explicitly. This could also cause problems when gfx is powered off.

---
 drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +4 -2
index 7c8ddc4ff3ce5..e8684e4afc0e5 100644
@@ -821,6 +821,7 @@ static int sdma_v6_0_mqd_init(struct amdgpu_device *adev, void *mqd,
 {
 	struct v11_sdma_mqd *m = mqd;
 	uint64_t wb_gpu_addr;
+	u32 tmp;
 
 	m->sdmax_rlcx_rb_cntl =
 		order_base_2(prop->queue_size / 4) << SDMA0_QUEUE0_RB_CNTL__RB_SIZE__SHIFT |
@@ -839,8 +840,9 @@ static int sdma_v6_0_mqd_init(struct amdgpu_device *adev, void *mqd,
 	m->sdmax_rlcx_rb_rptr_addr_lo = lower_32_bits(wb_gpu_addr);
 	m->sdmax_rlcx_rb_rptr_addr_hi = upper_32_bits(wb_gpu_addr);
 
-	m->sdmax_rlcx_ib_cntl = RREG32_SOC15_IP(GC, sdma_v6_0_get_reg_offset(adev, 0,
-							regSDMA0_QUEUE0_IB_CNTL));
+	tmp = REG_SET_FIELD(0, SDMA0_QUEUE0_IB_CNTL, IB_ENABLE, 1);
+	tmp = REG_SET_FIELD(tmp, SDMA0_QUEUE0_IB_CNTL, SWITCH_INSIDE_IB, 1);
+	m->sdmax_rlcx_ib_cntl = tmp;
 
 	m->sdmax_rlcx_doorbell_offset =
 		prop->doorbell_index << SDMA0_QUEUE0_DOORBELL_OFFSET__OFFSET__SHIFT;
Signature · 1 line
2.56.0
author maintainer
#3 lore raw

PATCH 4/5 drm/amdgpu/sdma7: don't access registers in MQD setup

In reply to Alex Deucher

No need to read the register state from the hardware, just program the settings explicitly. This could also cause problems when gfx is powered off.

---
 drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c +4 -2
index 62d432b23cbc6..2c61ab015982f 100644
@@ -867,6 +867,7 @@ static int sdma_v7_0_mqd_init(struct amdgpu_device *adev, void *mqd,
 {
 	struct v12_sdma_mqd *m = mqd;
 	uint64_t wb_gpu_addr;
+	u32 tmp;
 
 	m->sdmax_rlcx_rb_cntl =
 		order_base_2(prop->queue_size / 4) << SDMA0_QUEUE0_RB_CNTL__RB_SIZE__SHIFT |
@@ -885,8 +886,9 @@ static int sdma_v7_0_mqd_init(struct amdgpu_device *adev, void *mqd,
 	m->sdmax_rlcx_rb_rptr_addr_lo = lower_32_bits(wb_gpu_addr);
 	m->sdmax_rlcx_rb_rptr_addr_hi = upper_32_bits(wb_gpu_addr);
 
-	m->sdmax_rlcx_ib_cntl = RREG32_SOC15_IP(GC, sdma_v7_0_get_reg_offset(adev, 0,
-							regSDMA0_QUEUE0_IB_CNTL));
+	tmp = REG_SET_FIELD(0, SDMA0_QUEUE0_IB_CNTL, IB_ENABLE, 1);
+	tmp = REG_SET_FIELD(tmp, SDMA0_QUEUE0_IB_CNTL, SWITCH_INSIDE_IB, 1);
+	m->sdmax_rlcx_ib_cntl = tmp;
 
 	m->sdmax_rlcx_doorbell_offset =
 		prop->doorbell_index << SDMA0_QUEUE0_DOORBELL_OFFSET__OFFSET__SHIFT;
Signature · 1 line
2.56.0
author maintainer
#4 lore raw

PATCH 5/5 drm/amdgpu/sdma7.1: don't access registers in MQD setup

In reply to Alex Deucher

No need to read the register state from the hardware, just program the settings explicitly. This could also cause problems when gfx is powered off.

---
 drivers/gpu/drm/amd/amdgpu/sdma_v7_1.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v7_1.c +4 -2
index 73c60d928fa85..ed2928b26a0ed 100644
@@ -860,6 +860,7 @@ static int sdma_v7_1_mqd_init(struct amdgpu_device *adev, void *mqd,
 {
 	struct v12_1_sdma_mqd *m = mqd;
 	uint64_t wb_gpu_addr;
+	u32 tmp;
 
 	m->sdmax_queuen_rb_cntl =
 		order_base_2(prop->queue_size / 4) << SDMA0_SDMA_QUEUE0_RB_CNTL__RB_SIZE__SHIFT |
@@ -878,8 +879,9 @@ static int sdma_v7_1_mqd_init(struct amdgpu_device *adev, void *mqd,
 	m->sdmax_queuen_rb_rptr_addr_lo = lower_32_bits(wb_gpu_addr);
 	m->sdmax_queuen_rb_rptr_addr_hi = upper_32_bits(wb_gpu_addr);
 
-	m->sdmax_queuen_ib_cntl = RREG32_SOC15_IP(GC, sdma_v7_1_get_reg_offset(adev, 0,
-							regSDMA0_SDMA_QUEUE0_IB_CNTL));
+	tmp = REG_SET_FIELD(0, SDMA0_SDMA_QUEUE0_IB_CNTL, IB_ENABLE, 1);
+	tmp = REG_SET_FIELD(tmp, SDMA0_SDMA_QUEUE0_IB_CNTL, SWITCH_INSIDE_IB, 1);
+	m->sdmax_queuen_ib_cntl = tmp;
 
 	m->sdmax_queuen_doorbell_offset =
 		prop->doorbell_index << SDMA0_SDMA_QUEUE0_DOORBELL_OFFSET__OFFSET__SHIFT;
Signature · 1 line
2.56.0