On a queue MODIFY (prop->modify) sdma7 init_mqd keeps the context-saved
rptr and uses prop->user_wptr as the wptr, so a re-enabled queue resumes
at the first un-consumed packet. It also forces IB_ENABLE back on, since
ib_cntl reads back IB_ENABLE=0 on a stopped queue.

v3: consume the mqd_prop modify flag inside init_mqd instead of adding a
    separate sdma7 update_mqd callback, per review.

Signed-off-by: Jesse Zhang <[email protected]>
Suggested-by: Alexander Deucher <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c 
b/drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c
index 2068e2e6e3d6..843318158ddc 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c
@@ -902,6 +902,15 @@ static int sdma_v7_0_mqd_init(struct amdgpu_device *adev, 
void *mqd,
        m->sdmax_rlcx_mcu_dbg0 = lower_32_bits(prop->fence_address);
        m->sdmax_rlcx_mcu_dbg1 = upper_32_bits(prop->fence_address);
 
+       if (prop->modify) {
+               /* MODIFY: keep the context-saved rptr, use the live user wptr 
*/
+               m->sdmax_rlcx_rb_wptr = lower_32_bits(prop->user_wptr);
+               m->sdmax_rlcx_rb_wptr_hi = upper_32_bits(prop->user_wptr);
+
+               /* ib_cntl read back IB_ENABLE=0 on the stopped queue; force it 
on */
+               m->sdmax_rlcx_ib_cntl |= SDMA0_QUEUE0_IB_CNTL__IB_ENABLE_MASK;
+       }
+
        return 0;
 }
 
-- 
2.49.0

Reply via email to