AMD General Ok , sounds good to me . you can add me as acked-by
Regards Shaoyun.liu -----Original Message----- From: Liang, Prike <[email protected]> Sent: Monday, November 16, 2026 8:59 PM To: Liu, Shaoyun <[email protected]>; [email protected] Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Chen, Michael <[email protected]> Subject: RE: [PATCH 1/6] drm/amdgpu/mes: pass the process context slot to SET_SHADER_DEBUGGER AMD General Yes, I plan to enable MES context index loading for GFX11 first. How about we handle GFX12 and GFX13 in a separate follow-up patch series? Regards, Prike > -----Original Message----- > From: Liu, Shaoyun <[email protected]> > Sent: Monday, November 16, 2026 11:39 PM > To: Liang, Prike <[email protected]>; [email protected] > Cc: Deucher, Alexander <[email protected]>; Koenig, Christian > <[email protected]>; Chen, Michael <[email protected]> > Subject: RE: [PATCH 1/6] drm/amdgpu/mes: pass the process context slot > to SET_SHADER_DEBUGGER > > AMD General > > Please also copy process_context_array_index in mes_v12_0.c and mes_v12_1.c. > The v12 API has the field. > > Regards > Shaoyun.liu > > -----Original Message----- > From: Liang, Prike <[email protected]> > Sent: Tuesday, November 10, 2026 8:05 AM > To: [email protected] > Cc: Deucher, Alexander <[email protected]>; Koenig, Christian > <[email protected]>; Chen, Michael <[email protected]>; Liu, > Shaoyun <[email protected]>; Liang, Prike <[email protected]> > Subject: [PATCH 1/6] drm/amdgpu/mes: pass the process context slot to > SET_SHADER_DEBUGGER > > With MES RS64 process/gang context loading, MES keeps the process > contexts in an array in its local memory and looks them up by the slot index > the driver passes. > SET_SHADER_DEBUGGER has a process_context_array_index field for this, > but > amdgpu_mes_set_shader_debugger() and > amdgpu_mes_flush_shader_debugger() > only pass the process context address, so MES always gets slot 0. > > KFD sends the flush variant of this packet for every process that > exits (kfd_process_dequeue_from_device()). In RS64 mode the flush > therefore hits slot 0, which belongs to whichever process allocated it > first, instead of the exiting process's > slot: > - the owner of slot 0 loses its process context while its queues are > still running, so its next GPU accesses fault; > - the exiting process's slot is never flushed, so the next process > that gets it starts with a stale context. > > So the KFDIPCTest.BasicTest failure on Navi3x was caused on the case > when parent holds slot 0, the child's exit flush wipes the parent's > process context, and the parent's next access to the shared IPC buffer faults. > > Fixes: e32b68c6b135 ("drm/amdkfd: enable rs64mem for kfd queue") > Assisted-by: Copilot:claude-opus-5.5 > Signed-off-by: Prike Liang <[email protected]> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 6 ++++++ > drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 5 ++++- > drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 2 ++ > drivers/gpu/drm/amd/amdkfd/kfd_debug.c | 3 ++- > drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 1 + > 5 files changed, 15 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c > index 7864afab5b40..99b803f95c56 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c > @@ -763,6 +763,7 @@ int amdgpu_mes_hdp_flush(struct amdgpu_device > *adev) > > int amdgpu_mes_set_shader_debugger(struct amdgpu_device *adev, > uint64_t process_context_addr, > + uint32_t process_context_array_index, > uint32_t spi_gdbg_per_vmid_cntl, > const uint32_t *tcp_watch_cntl, > const uint64_t *watch_addresses, @@ > -782,6 +783,8 @@ int amdgpu_mes_set_shader_debugger(struct amdgpu_device > *adev, > op_input.xcc_id = xcc_id; > op_input.op = MES_MISC_OP_SET_SHADER_DEBUGGER; > op_input.set_shader_debugger.process_context_addr = > process_context_addr; > + op_input.set_shader_debugger.process_context_array_index = > + process_context_array_index; > op_input.set_shader_debugger.flags.u32all = flags; > > /* use amdgpu mes_flush_shader_debugger instead */ @@ -811,6 > +814,7 @@ int amdgpu_mes_set_shader_debugger(struct amdgpu_device > *adev, > > int amdgpu_mes_flush_shader_debugger(struct amdgpu_device *adev, > uint64_t process_context_addr, > + uint32_t > + process_context_array_index, > uint32_t xcc_id) { > struct mes_misc_op_input op_input = {0}; @@ -825,6 +829,8 @@ > int amdgpu_mes_flush_shader_debugger(struct amdgpu_device *adev, > op_input.xcc_id = xcc_id; > op_input.op = MES_MISC_OP_SET_SHADER_DEBUGGER; > op_input.set_shader_debugger.process_context_addr = > process_context_addr; > + op_input.set_shader_debugger.process_context_array_index = > + process_context_array_index; > op_input.set_shader_debugger.flags.process_ctx_flush = true; > > amdgpu_mes_lock(&adev->mes); > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h > b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h > index e5dbcf8ef890..9358090165aa 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h > @@ -450,6 +450,7 @@ struct mes_misc_op_input { > uint32_t tcp_watch_cntl[4]; > uint64_t watch_addresses[4]; > uint32_t trap_en; > + uint32_t process_context_array_index; > } set_shader_debugger; > > struct { > @@ -653,6 +654,7 @@ int amdgpu_mes_reg_write_reg_wait(struct > amdgpu_device *adev, int amdgpu_mes_hdp_flush(struct amdgpu_device > *adev); int amdgpu_mes_set_shader_debugger(struct amdgpu_device *adev, > uint64_t process_context_addr, > + uint32_t process_context_array_index, > uint32_t spi_gdbg_per_vmid_cntl, > const uint32_t *tcp_watch_cntl, > const uint64_t *watch_addresses, @@ > -660,7 +662,8 @@ int amdgpu_mes_set_shader_debugger(struct amdgpu_device > *adev, > bool trap_en, > uint32_t xcc_id); int > amdgpu_mes_flush_shader_debugger(struct amdgpu_device *adev, > - uint64_t process_context_addr, uint32_t > xcc_id); > + uint64_t process_context_addr, > + uint32_t process_context_array_index, > + uint32_t xcc_id); > > uint32_t amdgpu_mes_get_aggregated_doorbell_index(struct > amdgpu_device *adev, > enum > amdgpu_mes_priority_level prio); diff --git > a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c > b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c > index 60b27278a598..2617c2b7f101 100644 > --- a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c > @@ -1043,6 +1043,8 @@ static int mes_v11_0_misc_op(struct amdgpu_mes *mes, > > upper_32_bits(input->set_shader_debugger.watch_addresses[i]) > & 0xffff; > } > misc_pkt.set_shader_debugger.trap_en = input- > >set_shader_debugger.trap_en; > + > + misc_pkt.set_shader_debugger.process_context_array_index = > + > + input->set_shader_debugger.process_context_array_index; > break; > case MES_MISC_OP_CHANGE_CONFIG: > if ((mes->adev->mes.sched_version & > AMDGPU_MES_VERSION_MASK) < 0x63) { diff --git > a/drivers/gpu/drm/amd/amdkfd/kfd_debug.c > b/drivers/gpu/drm/amd/amdkfd/kfd_debug.c > index 71b34a57c2cc..cb830f985536 100644 > --- a/drivers/gpu/drm/amd/amdkfd/kfd_debug.c > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_debug.c > @@ -373,7 +373,8 @@ 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->proc_ctx_gpu_addr, > + pdd->proc_ctx_array_index, > + spi_dbg_cntl, > pdd->watch_points, > pdd->watch_addresses, > flags, sq_trap_en, diff --git > a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c > b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c > index b68e884b1c37..d3149e6d40e4 100644 > --- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c > @@ -96,6 +96,7 @@ void kfd_process_dequeue_from_device(struct > kfd_process_device *pdd) > down_read_trylock(&dev->adev->reset_domain->sem)) { > amdgpu_mes_flush_shader_debugger(dev->adev, > > pdd->proc_ctx_gpu_addr, > + > + pdd->proc_ctx_array_index, > ffs(pdd->dev->xcc_mask) - 1); > up_read(&dev->adev->reset_domain->sem); > } > -- > 2.34.1 >
