drm/amdgpu/si: stop dma engines on hw fini and suspend
Subsystems (2)
PATCH 1/6 drm/amdgpu/si: stop dma engines on hw fini and suspend
Fixes failure on suspend due to rings not being marked as not ready.
--- drivers/gpu/drm/amd/amdgpu/si_dma.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/gpu/drm/amd/amdgpu/si_dma.c +21 -0
@@ -134,6 +134,23 @@ static void si_dma_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 seq,amdgpu_ring_write (ring,DMA_PACKET (DMA_PACKET_TRAP ,0 ,0 ,0 ,0 )); } +static void si_dma_stop (struct amdgpu_device *adev) +{ +struct amdgpu_ring *ring; +u32 rb_cntl; +unsigned i; + +for (i =0 ; i <2 ; i++) { + ring = &adev->sdma.instance[i].ring; +/* dma0 */ + rb_cntl =RREG32 (DMA_RB_CNTL + sdma_offsets[i]); + rb_cntl &= ~DMA_RB_ENABLE ; +WREG32 (DMA_RB_CNTL + sdma_offsets[i], rb_cntl); + + ring->ready = false; + } +} +static int si_dma_gfx_resume (struct amdgpu_device *adev) {struct amdgpu_ring *ring;
@@ -612,6 +629,10 @@ static int si_dma_hw_init(void *handle)static int si_dma_hw_fini (void *handle) { +struct amdgpu_device *adev = (struct amdgpu_device *)handle; + +si_dma_stop (adev); +return 0 ; }
Signature · 6 lines
2.5.5 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/6 drm/amdgpu/si: simplify si_dma_start
Remove the wrapper that was a left over from porting the code into amdgpu.
--- drivers/gpu/drm/amd/amdgpu/si_dma.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)
drivers/gpu/drm/amd/amdgpu/si_dma.c +1 -18
@@ -151,7 +151,7 @@ static void si_dma_stop(struct amdgpu_device *adev) } } -static int si_dma_gfx_resume (struct amdgpu_device *adev) +static int si_dma_start (struct amdgpu_device *adev) {struct amdgpu_ring *ring;u32 rb_cntl, dma_cntl, ib_cntl, rb_bufsz, reg_offset;
@@ -215,23 +215,6 @@ static int si_dma_gfx_resume(struct amdgpu_device *adev) }/** -* si_dma_start - setup and start the async dma engines -* -* @adev: amdgpu_device pointer -* -* Set up the DMA engines and enable them (VI). -* Returns 0 for success, error for failure. -*/ -static int si_dma_start (struct amdgpu_device *adev) -{ -int r; - - r =si_dma_gfx_resume (adev); - -return r; -} - -/** * si_dma_ring_test_ring - simple async dma engine test * * @ring: amdgpu_ring structure holding ring information
Signature · 6 lines
2.5.5 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/6 drm/amdgpu/si: replace some hardcoded 2s with dma num_instances
In reply to Alex DeucherFix up a few cases that were previously missed.
--- drivers/gpu/drm/amd/amdgpu/si_dma.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/si_dma.c +4 -5
@@ -140,7 +140,7 @@ static void si_dma_stop(struct amdgpu_device *adev)u32 rb_cntl;unsigned i; -for (i =0 ; i <2 ; i++) { +for (i =0 ; i < adev->sdma.num_instances; i++) { ring = &adev->sdma.instance[i].ring;/* dma0 */ rb_cntl =RREG32 (DMA_RB_CNTL + sdma_offsets[i]);
@@ -158,7 +158,7 @@ static int si_dma_start(struct amdgpu_device *adev)int i, r;uint64_t rptr_addr; -for (i =0 ; i <2 ; i++) { +for (i =0 ; i < adev->sdma.num_instances; i++) { ring = &adev->sdma.instance[i].ring; reg_offset = sdma_offsets[i];
@@ -755,13 +755,12 @@ static int si_dma_set_clockgating_state(void *handle,u32 orig, data, offset;int i;bool enable; -struct amdgpu_device *adev = (struct amdgpu_device *)handle; enable = (state ==AMD_CG_STATE_GATE ) ? true : false;if (enable && (adev->cg_flags &AMD_CG_SUPPORT_SDMA_MGCG )) { -for (i =0 ; i <2 ; i++) { +for (i =0 ; i < adev->sdma.num_instances; i++) {if (i ==0 ) offset =DMA0_REGISTER_OFFSET ;else
@@ -773,7 +772,7 @@ static int si_dma_set_clockgating_state(void *handle,WREG32 (DMA_CLK_CTRL + offset,0x00000100 ); } }else { -for (i =0 ; i <2 ; i++) { +for (i =0 ; i < adev->sdma.num_instances; i++) {if (i ==0 ) offset =DMA0_REGISTER_OFFSET ;else
Signature · 6 lines
2.5.5 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/6 drm/amdgpu/si: use dma instance offset array directly
In reply to Alex DeucherNo need for a local variable. Also, fix a few registers that did not have the per instance offset properly added.
--- drivers/gpu/drm/amd/amdgpu/si_dma.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/amdgpu/si_dma.c +14 -15
@@ -154,16 +154,15 @@ static void si_dma_stop(struct amdgpu_device *adev)static int si_dma_start (struct amdgpu_device *adev) {struct amdgpu_ring *ring; -u32 rb_cntl, dma_cntl, ib_cntl, rb_bufsz, reg_offset; +u32 rb_cntl, dma_cntl, ib_cntl, rb_bufsz;int i, r;uint64_t rptr_addr;for (i =0 ; i < adev->sdma.num_instances; i++) { ring = &adev->sdma.instance[i].ring; - reg_offset = sdma_offsets[i]; -WREG32 (DMA_SEM_INCOMPLETE_TIMER_CNTL + reg_offset,0 ); -WREG32 (DMA_SEM_WAIT_FAIL_TIMER_CNTL + reg_offset,0 ); +WREG32 (DMA_SEM_INCOMPLETE_TIMER_CNTL + sdma_offsets[i],0 ); +WREG32 (DMA_SEM_WAIT_FAIL_TIMER_CNTL + sdma_offsets[i],0 );/* Set ring buffer size in dwords */ rb_bufsz =order_base_2 (ring->ring_size /4 );
@@ -171,36 +170,36 @@ static int si_dma_start(struct amdgpu_device *adev)#ifdef __BIG_ENDIAN rb_cntl |=DMA_RB_SWAP_ENABLE |DMA_RPTR_WRITEBACK_SWAP_ENABLE ;#endif -WREG32 (DMA_RB_CNTL + reg_offset, rb_cntl); +WREG32 (DMA_RB_CNTL + sdma_offsets[i], rb_cntl);/* Initialize the ring buffer's read and write pointers */ -WREG32 (DMA_RB_RPTR + reg_offset,0 ); -WREG32 (DMA_RB_WPTR + reg_offset,0 ); +WREG32 (DMA_RB_RPTR + sdma_offsets[i],0 ); +WREG32 (DMA_RB_WPTR + sdma_offsets[i],0 ); rptr_addr = adev->wb.gpu_addr + (ring->rptr_offs *4 ); -WREG32 (DMA_RB_RPTR_ADDR_LO ,lower_32_bits (rptr_addr)); -WREG32 (DMA_RB_RPTR_ADDR_HI ,upper_32_bits (rptr_addr) &0xFF ); +WREG32 (DMA_RB_RPTR_ADDR_LO + sdma_offsets[i],lower_32_bits (rptr_addr)); +WREG32 (DMA_RB_RPTR_ADDR_HI + sdma_offsets[i],upper_32_bits (rptr_addr) &0xFF ); rb_cntl |=DMA_RPTR_WRITEBACK_ENABLE ; -WREG32 (DMA_RB_BASE + reg_offset, ring->gpu_addr >>8 ); +WREG32 (DMA_RB_BASE + sdma_offsets[i], ring->gpu_addr >>8 );/* enable DMA IBs */ ib_cntl =DMA_IB_ENABLE |CMD_VMID_FORCE ;#ifdef __BIG_ENDIAN ib_cntl |=DMA_IB_SWAP_ENABLE ;#endif -WREG32 (DMA_IB_CNTL + reg_offset, ib_cntl); +WREG32 (DMA_IB_CNTL + sdma_offsets[i], ib_cntl); - dma_cntl =RREG32 (DMA_CNTL + reg_offset); + dma_cntl =RREG32 (DMA_CNTL + sdma_offsets[i]); dma_cntl &= ~CTXEMPTY_INT_ENABLE ; -WREG32 (DMA_CNTL + reg_offset, dma_cntl); +WREG32 (DMA_CNTL + sdma_offsets[i], dma_cntl); ring->wptr =0 ; -WREG32 (DMA_RB_WPTR + reg_offset, ring->wptr <<2 ); +WREG32 (DMA_RB_WPTR + sdma_offsets[i], ring->wptr <<2 ); -WREG32 (DMA_RB_CNTL + reg_offset, rb_cntl |DMA_RB_ENABLE ); +WREG32 (DMA_RB_CNTL + sdma_offsets[i], rb_cntl |DMA_RB_ENABLE ); ring->ready = true;
Signature · 6 lines
2.5.5 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/6 drm/amdgpu/si: reduce dma ring size
In reply to Alex DeucherThis was already done for other asics. We don't need a very big ring with the scheduler.
--- drivers/gpu/drm/amd/amdgpu/si_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/si_dma.c +1 -1
@@ -573,7 +573,7 @@ static int si_dma_sw_init(void *handle) ring->ring_obj =NULL ; ring->use_doorbell = false;sprintf (ring->name,"sdma%d" , i); - r = amdgpu_ring_init(adev, ring, 64 * 1024, + r = amdgpu_ring_init(adev, ring, 1024, DMA_PACKET(DMA_PACKET_NOP, 0, 0, 0, 0), 0xf, &adev->sdma.trap_irq, (i == 0) ?
Signature · 6 lines
2.5.5 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/6 drm/amdgpu/si: reduce gfx ring size
In reply to Alex DeucherThis was already done for other asics. We don't need a very big ring with the scheduler.
--- drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +1 -1
@@ -2805,7 +2805,7 @@ static int gfx_v6_0_sw_init(void *handle) ring = &adev->gfx.gfx_ring[i]; ring->ring_obj =NULL ;sprintf (ring->name,"gfx" ); - r =amdgpu_ring_init (adev, ring,1024 *1024 , + r =amdgpu_ring_init (adev, ring,1024 ,0x80000000 ,0xf , &adev->gfx.eop_irq,AMDGPU_CP_IRQ_GFX_EOP ,AMDGPU_RING_TYPE_GFX );
Signature · 6 lines
2.5.5 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Am 20.05.2016 um 23:50 schrieb Alex Deucher:
Quoted 4 lines
Fixes failure on suspend due to rings not being marked as not ready.
Signed-off-by Alex Deucher <[email protected]>
For this series: Reviewed-by: Christian König <[email protected]>
Regards,
Christian.
Quoted 33 lines
--- drivers/gpu/drm/amd/amdgpu/si_dma.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)drivers/gpu/drm/amd/amdgpu/si_dma.c +17
-0@@ -134,6 +134,23 @@ static void si_dma_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 seq,amdgpu_ring_write (ring,DMA_PACKET (DMA_PACKET_TRAP ,0 ,0 ,0 ,0 )); } +static void si_dma_stop (struct amdgpu_device *adev) +{ +struct amdgpu_ring *ring; +u32 rb_cntl; +unsigned i; + +for (i =0 ; i <2 ; i++) { + ring = &adev->sdma.instance[i].ring; +/* dma0 */ + rb_cntl =RREG32 (DMA_RB_CNTL + sdma_offsets[i]); + rb_cntl &= ~DMA_RB_ENABLE ; +WREG32 (DMA_RB_CNTL + sdma_offsets[i], rb_cntl); + + ring->ready = false; + } +} +static int si_dma_gfx_resume (struct amdgpu_device *adev) {struct amdgpu_ring *ring;
drivers/gpu/drm/amd/amdgpu/si_dma.c static int si_dma_hw_init(void *handle) · line 638
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/si_dma.c +4
-0@@ -612,6 +629,10 @@ static int si_dma_hw_init(void *handle)static int si_dma_hw_fini (void *handle) { +struct amdgpu_device *adev = (struct amdgpu_device *)handle; + +si_dma_stop (adev); +return 0 ; }
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel