drm/amdgpu: Add fence flag AMDGPU_FENCE_FLAG_CLEAR_PREEMPT
Subsystems (2)
PATCH 1/6 drm/amdgpu: Add fence flag AMDGPU_FENCE_FLAG_CLEAR_PREEMPT
when emit fence with this flag, driver will de-assert IB_PREEMPTION
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +1 -0
@@ -43,6 +43,7 @@#define AMDGPU_FENCE_FLAG_64BIT (1 << 0)#define AMDGPU_FENCE_FLAG_INT (1 << 1)#define AMDGPU_FENCE_FLAG_TC_WB_ONLY (1 << 2) +#define AMDGPU_FENCE_FLAG_CLEAR_PREEMPT (1<<3)#define to_amdgpu_ring (s) container_of((s), struct amdgpu_ring, sched)
Signature · 6 lines
1.9.1 _______________________________________________ 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): 1540988736-14311-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org
PATCH 2/6 drm/amdgpu: report more sdma amdgpu_fence_info
This can help checking MCBP feature on sdma.
If preemption occurred in the
previous IB the address is adjusted by 2 DWs.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +2 -1
@@ -679,7 +679,8 @@ static int amdgpu_debugfs_fence_info(struct seq_file *m, void *data)seq_printf (m,"Last emitted 0x%08x\n" , ring->fence_drv.sync_seq); -if (ring->funcs->type !=AMDGPU_RING_TYPE_GFX ) +if (ring->funcs->type !=AMDGPU_RING_TYPE_GFX && + ring->funcs->type !=AMDGPU_RING_TYPE_SDMA )continue ;/* set in CP_VMID_PREEMPT and preemption occurred */
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/6 drm/amdgpu: Add helper function to get sdma index
In reply to a message not in the archiveGet the sdma index from sdma ring
--- drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 16 ++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h | 1 + 2 files changed, 17 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +16 -0
@@ -40,3 +40,19 @@ struct amdgpu_sdma_instance * amdgpu_get_sdma_instance(struct amdgpu_ring *ring)return NULL ; } + +int amdgpu_get_sdma_index (struct amdgpu_ring *ring,uint32_t *index) +{ +struct amdgpu_device *adev = ring->adev; +int i; + +for (i =0 ; i < adev->sdma.num_instances; i++) { +if (ring == &adev->sdma.instance[i].ring || + ring == &adev->sdma.instance[i].page) { + *index = i; +return 0 ; + } + } + +return -EINVAL ; +}
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +1 -0
@@ -96,5 +96,6 @@ struct amdgpu_buffer_funcs {struct amdgpu_sdma_instance *amdgpu_get_sdma_instance (struct amdgpu_ring *ring); +int amdgpu_get_sdma_index (struct amdgpu_ring *ring,uint32_t *index);#endif
Signature · 6 lines
1.9.1 _______________________________________________ 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): 1540988736-14311-3-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 3/6] drm/amdgpu: Add helper function to get sdma index
Quoted 14 lines · Rex Zhu
Get the sdma index from sdma ring
Signed-off-by Rex Zhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 16 ++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h | 1 + 2 files changed, 17 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c struct amdgpu_sdma_instance * amdgpu_get_sdma_instance(struct amdgpu_ring *ring) · line 44
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +2
-0@@ -40,3 +40,19 @@ struct amdgpu_sdma_instance * amdgpu_get_sdma_instance(struct amdgpu_ring *ring)return NULL ; } + +int amdgpu_get_sdma_index (struct amdgpu_ring *ring,uint32_t *index)
For consistency with other files, call this function something like amdgpu_sdma_get_index_from_ring(). We should also update amdgpu_get_sdma_instance() to amdgpu_sdma_get_instance().
Alex
Quoted 28 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +14
-0+{ +struct amdgpu_device *adev = ring->adev; +int i; + +for (i =0 ; i < adev->sdma.num_instances; i++) { +if (ring == &adev->sdma.instance[i].ring || + ring == &adev->sdma.instance[i].page) { + *index = i; +return 0 ; + } + } + +return -EINVAL ; +}drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +1
-1@@ -96,5 +96,6 @@ struct amdgpu_buffer_funcs {struct amdgpu_sdma_instance *amdgpu_get_sdma_instance (struct amdgpu_ring *ring); +int amdgpu_get_sdma_index (struct amdgpu_ring *ring,uint32_t *index);#endif --1.9.1
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
PATCH 4/6 drm/amdgpu: Add sdma ib preempt clear when emit fence
In reply to a message not in the archiveneed to clear ib preempt in a proper time
--- drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 12 ++++++++++++ 2 files changed, 25 insertions(+)
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +13 -0
@@ -484,7 +484,11 @@ static void sdma_v3_0_ring_emit_hdp_flush(struct amdgpu_ring *ring)static void sdma_v3_0_ring_emit_fence (struct amdgpu_ring *ring,u64 addr,u64 seq,unsigned flags) { +struct amdgpu_device *adev = ring->adev;bool write64bit = flags &AMDGPU_FENCE_FLAG_64BIT ; +bool clear_preempt = flags &AMDGPU_FENCE_FLAG_CLEAR_PREEMPT ; +u32 index =0 ; +/* write the fence */ amdgpu_ring_write (ring,SDMA_PKT_HEADER_OP (SDMA_OP_FENCE ));amdgpu_ring_write (ring,lower_32_bits (addr));
@@ -500,6 +504,15 @@ static void sdma_v3_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 seamdgpu_ring_write (ring,upper_32_bits (seq)); } +if (!amdgpu_sriov_vf (adev) && adev->gpu_preemption && clear_preempt) { +if (!amdgpu_get_sdma_index (ring, &index)) { +amdgpu_ring_alloc (ring,4 ); +amdgpu_ring_emit_wreg (ring, index ==0 ? + mmSDMA0_GFX_PREEMPT : + mmSDMA1_GFX_PREEMPT,0 ); + } + } +/* generate an interrupt */ amdgpu_ring_write (ring,SDMA_PKT_HEADER_OP (SDMA_OP_TRAP ));amdgpu_ring_write (ring,SDMA_PKT_TRAP_INT_CONTEXT_INT_CONTEXT (0 ));
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +12 -0
@@ -591,7 +591,10 @@ static void sdma_v4_0_ring_emit_hdp_flush(struct amdgpu_ring *ring)static void sdma_v4_0_ring_emit_fence (struct amdgpu_ring *ring,u64 addr,u64 seq,unsigned flags) { +struct amdgpu_device *adev = ring->adev;bool write64bit = flags &AMDGPU_FENCE_FLAG_64BIT ; +bool clear_preempt = flags &AMDGPU_FENCE_FLAG_CLEAR_PREEMPT ; +u32 index =0 ;/* write the fence */ amdgpu_ring_write (ring,SDMA_PKT_HEADER_OP (SDMA_OP_FENCE ));/* zero in first two bits */
@@ -611,6 +614,15 @@ static void sdma_v4_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 seamdgpu_ring_write (ring,upper_32_bits (seq)); } +if (!amdgpu_sriov_vf (adev) && adev->gpu_preemption && clear_preempt) { +if (!amdgpu_get_sdma_index (ring, &index)) { +amdgpu_ring_alloc (ring,4 ); +amdgpu_ring_emit_wreg (ring, index ==0 ? + mmSDMA0_GFX_PREEMPT : + mmSDMA1_GFX_PREEMPT,0 ); + } + } +/* generate an interrupt */ amdgpu_ring_write (ring,SDMA_PKT_HEADER_OP (SDMA_OP_TRAP ));amdgpu_ring_write (ring,SDMA_PKT_TRAP_INT_CONTEXT_INT_CONTEXT (0 ));
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/6 drm/amdgpu: Add new ring interface ib_preempt
In reply to a message not in the archiveUsed to trigger preemtption
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +1 -0
@@ -172,6 +172,7 @@ struct amdgpu_ring_funcs { enum drm_sched_priority priority);/* Try to soft recover the ring to make the fence signal */ void (*soft_recovery)(struct amdgpu_ring *ring,unsigned vmid); +void (*ib_preempt)(struct amdgpu_ring *ring); };struct amdgpu_ring {
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/6 drm/amdgpu: Implement ib_preemmpt interface for sdma
In reply to a message not in the archivesdma can be preempted via this interface
--- drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 14 ++++++++++++++ drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 15 +++++++++++++++ 2 files changed, 29 insertions(+)
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +14 -0
@@ -545,6 +545,19 @@ static void sdma_v3_0_ring_patch_cond_exec(struct amdgpu_ring *ring, unsigned of ring->ring[offset] = (ring->ring_size>>2 ) - offset + cur; } +static void sdma_v3_0_ring_ib_preempt (struct amdgpu_ring *ring) +{ +struct amdgpu_device *adev = ring->adev; +u32 index =0 ; + +if (!amdgpu_sriov_vf (adev) && adev->gpu_preemption) { +amdgpu_ring_alloc (ring,16 ); +amdgpu_ring_set_preempt_cond_exec (ring, true); +WREG32 (index ==0 ? mmSDMA0_GFX_PREEMPT : mmSDMA1_GFX_PREEMPT,0x1 ); +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr+8 ,0xff ,AMDGPU_FENCE_FLAG_CLEAR_PREEMPT ); +amdgpu_ring_commit (ring); + } +}/** * sdma_v3_0_gfx_stop - stop the gfx async dma engines
@@ -1660,6 +1673,7 @@ static void sdma_v3_0_get_clockgating_state(void *handle, u32 *flags) .emit_wreg = sdma_v3_0_ring_emit_wreg, .init_cond_exec = sdma_v3_0_ring_init_cond_exec, .patch_cond_exec = sdma_v3_0_ring_patch_cond_exec, + .ib_preempt = sdma_v3_0_ring_ib_preempt, };static void sdma_v3_0_set_ring_funcs (struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +15 -0
@@ -654,6 +654,20 @@ static void sdma_v4_0_ring_patch_cond_exec(struct amdgpu_ring *ring, unsigned of ring->ring[offset] = (ring->ring_size>>2 ) - offset + cur; } +static void sdma_v4_0_ring_ib_preempt (struct amdgpu_ring *ring) +{ +struct amdgpu_device *adev = ring->adev; +u32 index =0 ; + +if (!amdgpu_sriov_vf (adev) && adev->gpu_preemption) { +amdgpu_ring_alloc (ring,16 ); +amdgpu_ring_set_preempt_cond_exec (ring, true); +WREG32 (index ==0 ? mmSDMA0_GFX_PREEMPT : mmSDMA1_GFX_PREEMPT,0x1 ); +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr+8 ,0xff ,AMDGPU_FENCE_FLAG_CLEAR_PREEMPT ); +amdgpu_ring_commit (ring); + } +} +/** * sdma_v4_0_gfx_stop - stop the gfx async dma engines *
@@ -1996,6 +2010,7 @@ static void sdma_v4_0_get_clockgating_state(void *handle, u32 *flags) .emit_reg_write_reg_wait = amdgpu_ring_emit_reg_write_reg_wait_helper, .init_cond_exec = sdma_v4_0_ring_init_cond_exec, .patch_cond_exec = sdma_v4_0_ring_patch_cond_exec, + .ib_preempt = sdma_v4_0_ring_ib_preempt, };static const struct amdgpu_ring_funcs sdma_v4_0_page_ring_funcs = {
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx