drm/amdgpu/sdma5.2: initialize sdma mqd
authorJack Xiao <Jack.Xiao@amd.com>
Sun, 22 Mar 2020 05:51:02 +0000 (13:51 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 4 May 2022 14:43:50 +0000 (10:43 -0400)
Initialize sdma mqd according to ring settings.

Signed-off-by: Jack Xiao <Jack.Xiao@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c

index bf2cf95cbf8fbc7dac2b9a3259cd853a1cfee027..f67801c5a6c18eb93131b225b406561c1b65aef7 100644 (file)
@@ -903,6 +903,49 @@ static int sdma_v5_2_start(struct amdgpu_device *adev)
        return r;
 }
 
+static int sdma_v5_2_mqd_init(struct amdgpu_device *adev, void *mqd,
+                             struct amdgpu_mqd_prop *prop)
+{
+       struct v10_sdma_mqd *m = mqd;
+       uint64_t wb_gpu_addr;
+
+       m->sdmax_rlcx_rb_cntl =
+               order_base_2(prop->queue_size / 4) << SDMA0_RLC0_RB_CNTL__RB_SIZE__SHIFT |
+               1 << SDMA0_RLC0_RB_CNTL__RPTR_WRITEBACK_ENABLE__SHIFT |
+               6 << SDMA0_RLC0_RB_CNTL__RPTR_WRITEBACK_TIMER__SHIFT |
+               1 << SDMA0_RLC0_RB_CNTL__RB_PRIV__SHIFT;
+
+       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));
+
+       wb_gpu_addr = prop->wptr_gpu_addr;
+       m->sdmax_rlcx_rb_wptr_poll_addr_lo = lower_32_bits(wb_gpu_addr);
+       m->sdmax_rlcx_rb_wptr_poll_addr_hi = upper_32_bits(wb_gpu_addr);
+
+       wb_gpu_addr = prop->rptr_gpu_addr;
+       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));
+
+       m->sdmax_rlcx_doorbell_offset =
+               prop->doorbell_index << SDMA0_RLC0_DOORBELL_OFFSET__OFFSET__SHIFT;
+
+       m->sdmax_rlcx_doorbell = REG_SET_FIELD(0, SDMA0_RLC0_DOORBELL, ENABLE, 1);
+
+       return 0;
+}
+
+static void sdma_v5_2_set_mqd_funcs(struct amdgpu_device *adev)
+{
+       adev->mqds[AMDGPU_HW_IP_DMA].mqd_size = sizeof(struct v10_sdma_mqd);
+       adev->mqds[AMDGPU_HW_IP_DMA].init_mqd = sdma_v5_2_mqd_init;
+}
+
 /**
  * sdma_v5_2_ring_test_ring - simple async dma engine test
  *
@@ -1233,6 +1276,7 @@ static int sdma_v5_2_early_init(void *handle)
        sdma_v5_2_set_buffer_funcs(adev);
        sdma_v5_2_set_vm_pte_funcs(adev);
        sdma_v5_2_set_irq_funcs(adev);
+       sdma_v5_2_set_mqd_funcs(adev);
 
        return 0;
 }