drm/amdkfd: add watch_addresses to set_shader_debugger interface
Subsystems (3)
PATCH 1/3 drm/amdkfd: add watch_addresses to set_shader_debugger interface
Pass watchpoint addresses through amdgpu_mes_set_shader_debugger() so MES programs TCP_WATCH registers at dispatch time.
Assisted-by claude-code:claude-sonnet-4
Signed-off-by David Belanger <[email protected]>
Reviewed-by Michael Chen <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 2 ++ drivers/gpu/drm/amd/amdkfd/kfd_debug.c | 6 +++++- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 1 + 4 files changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +3 -0
@@ -695,6 +695,7 @@ int amdgpu_mes_set_shader_debugger(struct amdgpu_device *adev,uint64_t process_context_addr, uint32_t spi_gdbg_per_vmid_cntl, const uint32_t *tcp_watch_cntl, + const uint64_t *watch_addresses, uint32_t flags, bool trap_en, uint32_t xcc_id)
@@ -720,6 +721,8 @@ int amdgpu_mes_set_shader_debugger(struct amdgpu_device *adev, op_input.set_shader_debugger.spi_gdbg_per_vmid_cntl = spi_gdbg_per_vmid_cntl;memcpy (op_input.set_shader_debugger.tcp_watch_cntl, tcp_watch_cntl,sizeof (op_input.set_shader_debugger.tcp_watch_cntl)); +memcpy (op_input.set_shader_debugger.watch_addresses, watch_addresses, +sizeof (op_input.set_shader_debugger.watch_addresses));if (((adev->mes.sched_version &AMDGPU_MES_API_VERSION_MASK ) >>AMDGPU_MES_API_VERSION_SHIFT ) >=14 )
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h +2 -0
@@ -435,6 +435,7 @@ struct mes_misc_op_input { } flags;uint32_t spi_gdbg_per_vmid_cntl;uint32_t tcp_watch_cntl[4 ]; +uint64_t watch_addresses[4 ];uint32_t trap_en; } set_shader_debugger;
@@ -623,6 +624,7 @@ int amdgpu_mes_set_shader_debugger(struct amdgpu_device *adev,uint64_t process_context_addr, uint32_t spi_gdbg_per_vmid_cntl, const uint32_t *tcp_watch_cntl, + const uint64_t *watch_addresses, uint32_t flags, bool trap_en, uint32_t xcc_id);
drivers/gpu/drm/amd/amdkfd/kfd_debug.c +5 -1
@@ -374,7 +374,9 @@ int kfd_dbg_set_mes_debug_mode(struct kfd_process_device *pdd, bool sq_trap_en)return amdgpu_mes_set_shader_debugger (pdd->dev->adev, pdd->proc_ctx_gpu_addr, spi_dbg_cntl, - pdd->watch_points, flags, sq_trap_en, + pdd->watch_points, + pdd->watch_addresses, + flags, sq_trap_en,ffs (pdd->dev->xcc_mask) -1 ); }
@@ -449,6 +451,7 @@ int kfd_dbg_trap_clear_dev_address_watch(struct kfd_process_device *pdd, pdd->watch_points[watch_id] = pdd->dev->kfd2kgd->clear_address_watch ( pdd->dev->adev, watch_id); + pdd->watch_addresses[watch_id] =0 ;amdgpu_gfx_off_ctrl (pdd->dev->adev, true);if (!pdd->dev->kfd->shared_resources.enable_mes)
@@ -485,6 +488,7 @@ int kfd_dbg_trap_set_dev_address_watch(struct kfd_process_device *pdd, }amdgpu_gfx_off_ctrl (pdd->dev->adev, false); + pdd->watch_addresses[*watch_id] = watch_address;for_each_inst (xcc_id, xcc_mask) pdd->watch_points[*watch_id] = pdd->dev->kfd2kgd->set_address_watch( pdd->dev->adev,
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +1 -0
@@ -870,6 +870,7 @@ struct kfd_process_device {uint32_t spi_dbg_override;uint32_t spi_dbg_launch_mode;uint32_t watch_points[4 ]; +uint64_t watch_addresses[4 ];uint32_t alloc_watch_ids;/*
Signature · 1 line
2.55.0
PATCH 2/3 drm/amdkfd: pass watchpoint addresses to MES for GFX11
Update SET_SHADER_DEBUGGER packet with tcp_watch_addr_lo/hi fields. Remove direct TCP_WATCH register writes from set_address_watch().
Assisted-by claude-code:claude-sonnet-4
Signed-off-by David Belanger <[email protected]>
Reviewed-by Michael Chen <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v11.c | 12 ------------ drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 6 ++++++ drivers/gpu/drm/amd/include/mes_v11_api_def.h | 3 +++ 3 files changed, 9 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v11.c +0 -12
@@ -747,13 +747,9 @@ static uint32_t kgd_gfx_v11_set_address_watch(struct amdgpu_device *adev,uint32_t debug_vmid, uint32_t inst) { - uint32_t watch_address_high; -uint32_t watch_address_low; uint32_t watch_address_cntl; watch_address_cntl =0 ; - watch_address_low =lower_32_bits (watch_address); - watch_address_high =upper_32_bits (watch_address) &0xffff ; watch_address_cntl = REG_SET_FIELD(watch_address_cntl, TCP_WATCH0_CNTL,
@@ -770,14 +766,6 @@ static uint32_t kgd_gfx_v11_set_address_watch(struct amdgpu_device *adev,VALID , 1); -WREG32_RLC ((SOC15_REG_OFFSET (GC ,0 , regTCP_WATCH0_ADDR_H) + - (watch_id *TCP_WATCH_STRIDE )), - watch_address_high); - -WREG32_RLC ((SOC15_REG_OFFSET (GC ,0 , regTCP_WATCH0_ADDR_L) + - (watch_id *TCP_WATCH_STRIDE )), - watch_address_low); -return watch_address_cntl; }
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +6 -0
@@ -1028,6 +1028,12 @@ static int mes_v11_0_misc_op(struct amdgpu_mes *mes,memcpy (misc_pkt.set_shader_debugger.tcp_watch_cntl, input->set_shader_debugger.tcp_watch_cntl,sizeof (misc_pkt.set_shader_debugger.tcp_watch_cntl)); +for (int i =0 ; i <4 ; i++) { + misc_pkt.set_shader_debugger.tcp_watch_addr_lo[i] = +lower_32_bits (input->set_shader_debugger.watch_addresses[i]); + misc_pkt.set_shader_debugger.tcp_watch_addr_hi[i] = +upper_32_bits (input->set_shader_debugger.watch_addresses[i]) &0xffff ; + } misc_pkt.set_shader_debugger.trap_en = input->set_shader_debugger.trap_en;break ;case MES_MISC_OP_CHANGE_CONFIG :
drivers/gpu/drm/amd/include/mes_v11_api_def.h +3 -0
@@ -676,6 +676,9 @@ struct SET_SHADER_DEBUGGER {uint32_t spi_gdbg_per_vmid_cntl;uint32_t tcp_watch_cntl[4 ];/* TCP_WATCHx_CNTL */ uint32_t trap_en; +uint32_t tcp_watch_addr_lo[4 ];/* TCP_WATCHx_ADDR_L */ +uint32_t tcp_watch_addr_hi[4 ];/* TCP_WATCHx_ADDR_H */ +uint32_t process_context_array_index; };enum MESAPI_MISC__CHANGE_CONFIG_OPTION {
Signature · 1 line
2.55.0
PATCH 3/3 drm/amdkfd: pass watchpoint addresses to MES for GFX12
In reply to David BelangerUpdate SET_SHADER_DEBUGGER packet with tcp_watch_addr_lo/hi fields. Remove direct TCP_WATCH register writes from set_address_watch().
v2: Add missing code for mes_v12_1.c
Assisted-by claude-code:claude-sonnet-4
Signed-off-by David Belanger <[email protected]>
Reviewed-by Michael Chen <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v12.c | 12 ------------ drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v12_1.c | 12 ------------ drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/mes_v12_1.c | 6 ++++++ drivers/gpu/drm/amd/include/mes_v12_api_def.h | 3 +++ 5 files changed, 15 insertions(+), 24 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v12.c +0 -12
@@ -322,13 +322,9 @@ static uint32_t kgd_gfx_v12_set_address_watch(struct amdgpu_device *adev,uint32_t debug_vmid, uint32_t inst) { - uint32_t watch_address_high; -uint32_t watch_address_low; uint32_t watch_address_cntl; watch_address_cntl =0 ; - watch_address_low =lower_32_bits (watch_address); - watch_address_high =upper_32_bits (watch_address) &0xffff ; watch_address_cntl = REG_SET_FIELD(watch_address_cntl, TCP_WATCH0_CNTL,
@@ -345,14 +341,6 @@ static uint32_t kgd_gfx_v12_set_address_watch(struct amdgpu_device *adev,VALID , 1); -WREG32_RLC ((SOC15_REG_OFFSET (GC ,0 , regTCP_WATCH0_ADDR_H) + - (watch_id *TCP_WATCH_STRIDE )), - watch_address_high); - -WREG32_RLC ((SOC15_REG_OFFSET (GC ,0 , regTCP_WATCH0_ADDR_L) + - (watch_id *TCP_WATCH_STRIDE )), - watch_address_low); -return watch_address_cntl; }
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v12_1.c +0 -12
@@ -325,13 +325,9 @@ static uint32_t kgd_gfx_v12_1_set_address_watch(struct amdgpu_device *adev,uint32_t debug_vmid, uint32_t inst) { - uint32_t watch_address_high; -uint32_t watch_address_low; uint32_t watch_address_cntl; watch_address_cntl =0 ; - watch_address_low =lower_32_bits (watch_address); - watch_address_high =upper_32_bits (watch_address) &0x1ffffff ; watch_address_cntl = REG_SET_FIELD(watch_address_cntl, TCP_WATCH0_CNTL,
@@ -348,14 +344,6 @@ static uint32_t kgd_gfx_v12_1_set_address_watch(struct amdgpu_device *adev,VALID , 1); -WREG32_XCC ((SOC15_REG_OFFSET (GC ,GET_INST (GC , inst), regTCP_WATCH0_ADDR_H) + - (watch_id *TCP_WATCH_STRIDE )), - watch_address_high, inst); - -WREG32_XCC ((SOC15_REG_OFFSET (GC ,GET_INST (GC , inst), regTCP_WATCH0_ADDR_L) + - (watch_id *TCP_WATCH_STRIDE )), - watch_address_low, inst); -return watch_address_cntl; }
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +6 -0
@@ -981,6 +981,12 @@ static int mes_v12_0_misc_op(struct amdgpu_mes *mes,memcpy (misc_pkt.set_shader_debugger.tcp_watch_cntl, input->set_shader_debugger.tcp_watch_cntl,sizeof (misc_pkt.set_shader_debugger.tcp_watch_cntl)); +for (int i =0 ; i <4 ; i++) { + misc_pkt.set_shader_debugger.tcp_watch_addr_lo[i] = +lower_32_bits (input->set_shader_debugger.watch_addresses[i]); + misc_pkt.set_shader_debugger.tcp_watch_addr_hi[i] = +upper_32_bits (input->set_shader_debugger.watch_addresses[i]) &0xffff ; + } misc_pkt.set_shader_debugger.trap_en = input->set_shader_debugger.trap_en;break ;case MES_MISC_OP_CHANGE_CONFIG :
drivers/gpu/drm/amd/amdgpu/mes_v12_1.c +6 -0
@@ -622,6 +622,12 @@ static int mes_v12_1_misc_op(struct amdgpu_mes *mes,memcpy (misc_pkt.set_shader_debugger.tcp_watch_cntl, input->set_shader_debugger.tcp_watch_cntl,sizeof (misc_pkt.set_shader_debugger.tcp_watch_cntl)); +for (int i =0 ; i <4 ; i++) { + misc_pkt.set_shader_debugger.tcp_watch_addr_lo[i] = +lower_32_bits (input->set_shader_debugger.watch_addresses[i]); + misc_pkt.set_shader_debugger.tcp_watch_addr_hi[i] = +upper_32_bits (input->set_shader_debugger.watch_addresses[i]) &0xffff ; + } misc_pkt.set_shader_debugger.trap_en = input->set_shader_debugger.trap_en;break ;case MES_MISC_OP_CHANGE_CONFIG :
drivers/gpu/drm/amd/include/mes_v12_api_def.h +3 -0
@@ -805,6 +805,9 @@ struct SET_SHADER_DEBUGGER {uint32_t spi_gdbg_per_vmid_cntl;uint32_t tcp_watch_cntl[4 ];// TCP_WATCHx_CNTL uint32_t trap_en; +uint32_t tcp_watch_addr_lo[4 ];// TCP_WATCHx_ADDR_L +uint32_t tcp_watch_addr_hi[4 ];// TCP_WATCHx_ADDR_H +uint32_t process_context_array_index; };struct SET_GANG_SUBMIT {
Signature · 1 line
2.55.0