drm/amdkfd: fix add queue process context clear for hsa non-init cases
Subsystems (3)
PATCH 1/1 drm/amdkfd: fix add queue process context clear for hsa non-init cases
There are cases where HSA is not initialized when adding queues and the ADD_QUEUE API should clear the MES process context instead of SET_SHADER_DEBUGGER.
The only time ADD_QUEUE.skip_process_ctx_clear is required is for debugger use cases and a debugged process is always runtime enabled when adding a queue.
--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +4 -2
@@ -227,8 +227,10 @@ static int add_queue_mes(struct device_queue_manager *dqm, struct queue *q, queue_input.tba_addr = qpd->tba_addr; queue_input.tma_addr = qpd->tma_addr; queue_input.trap_en = !kfd_dbg_has_cwsr_workaround (q->device); - queue_input.skip_process_ctx_clear = qpd->pqm->process->debug_trap_enabled || -kfd_dbg_has_ttmps_always_setup (q->device); + queue_input.skip_process_ctx_clear = + qpd->pqm->process->runtime_info.runtime_state ==DEBUG_RUNTIME_STATE_ENABLED && + (qpd->pqm->process->debug_trap_enabled || +kfd_dbg_has_ttmps_always_setup (q->device)); queue_type =convert_to_mes_queue_type (q->properties.type);if (queue_type <0 ) {
Signature · 1 line
2.34.1
[Public]
+ Eric
Quoted 51 lines
-----Original Message-----
From: Kim, Jonathan <[email protected]>
Sent: Tuesday, September 12, 2023 8:17 AM
To: [email protected]
Cc: Ji, Ruili <[email protected]>; Guo, Shikai <[email protected]>; [email protected]; Kuehling, Felix <[email protected]>; Kim, Jonathan <[email protected]>; Guo, Shikai <[email protected]>; Kim, Jonathan <[email protected]>
Subject: [PATCH] drm/amdkfd: fix add queue process context clear for hsa non-init casesThere are cases where HSA is not initialized when adding queues and the
ADD_QUEUEAPI should clear the MES process context instead ofSET_SHADER_DEBUGGER.The only time ADD_QUEUE.skip_process_ctx_clear is required is for debugger use cases and a debugged process is always runtime enabled when adding a queue.
Tested-by Shikai Guo <[email protected]>Signed-off-by Jonathan Kim <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-1@@ -227,8 +227,10 @@ static int add_queue_mes(struct device_queue_manager *dqm, struct queue *q, queue_input.tba_addr = qpd->tba_addr; queue_input.tma_addr = qpd->tma_addr; queue_input.trap_en = !kfd_dbg_has_cwsr_workaround (q->device); - queue_input.skip_process_ctx_clear = qpd->pqm->process-Quoted 1 line
debug_trap_enabled||-
kfd_dbg_has_ttmps_always_setup(q->device);drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +2
-0+ queue_input.skip_process_ctx_clear = + qpd->pqm->process->runtime_info.runtime_state ==
DEBUG_RUNTIME_STATE_ENABLED&&
+ (qpd->pqm->process-Quoted 1 line
debug_trap_enabled||+
kfd_dbg_has_ttmps_always_setup(q->device));queue_type = convert_to_mes_queue_type(q->properties.type); if (queue_type < 0) {--
2.34.1
Felix Kuehling
maintainerQuoted 1 line · Jonathan Kim
There are cases where HSA is not initialized when adding queues
This statement doesn't make sense to me. If HSA is not initialized, it means user mode hasn't opened the KFD device. So it can't create queues. What do you really mean here?
Regards,
Felix
Quoted 31 lines
and
theADD_QUEUEAPI should clear the MES process context instead ofSET_SHADER_DEBUGGER.The only time ADD_QUEUE.skip_process_ctx_clear is required is for debugger use cases and a debugged process is always runtime enabled when adding a queue.
Tested-by Shikai Guo <[email protected]>Signed-off-by Jonathan Kim <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +4
-2@@ -227,8 +227,10 @@ static int add_queue_mes(struct device_queue_manager *dqm, struct queue *q, queue_input.tba_addr = qpd->tba_addr; queue_input.tma_addr = qpd->tma_addr; queue_input.trap_en = !kfd_dbg_has_cwsr_workaround (q->device); - queue_input.skip_process_ctx_clear = qpd->pqm->process->debug_trap_enabled || -kfd_dbg_has_ttmps_always_setup (q->device); + queue_input.skip_process_ctx_clear = + qpd->pqm->process->runtime_info.runtime_state ==DEBUG_RUNTIME_STATE_ENABLED && + (qpd->pqm->process->debug_trap_enabled || +kfd_dbg_has_ttmps_always_setup (q->device)); queue_type =convert_to_mes_queue_type (q->properties.type);if (queue_type <0 ) {
[Public]
Quoted 9 lines
-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Tuesday, September 12, 2023 8:36 PM
To: Kim, Jonathan <[email protected]>; [email protected]
Cc: Ji, Ruili <[email protected]>; Guo, Shikai <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdkfd: fix add queue process context clear for hsa non-init cases
Quoted 6 lines
Quoted 1 line · Jonathan Kim
There are cases where HSA is not initialized when adding queues
This statement doesn't make sense to me. If HSA is not initialized, it means user mode hasn't opened the KFD device. So it can't create queues. What do you really mean here?
I meant the call to runtime enable e.g. KFD test can add a queue without runtime enable call.
Thanks,
Jon
Quoted 43 lines
Regards,
FelixQuoted 8 lines
and
theADD_QUEUEAPI should clear the MES process context instead ofSET_SHADER_DEBUGGER.The only time ADD_QUEUE.skip_process_ctx_clear is required is for debugger use cases and a debugged process is always runtime enabled when adding a queue.
Review
Quoted 7 lines
Tested-by Shikai Guo <[email protected]>Signed-off-by Jonathan Kim <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.cdrivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static int add_queue_mes(struct
Quoted 4 lines
index
6d07a5dd2648..77159b03a422100644drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0@@ -227,8 +227,10 @@ static int add_queue_mes(struct
device_queue_manager*dqm, struct queue *q,Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-1queue_input.tba_addr = qpd->tba_addr; queue_input.tma_addr = qpd->tma_addr; queue_input.trap_en = !kfd_dbg_has_cwsr_workaround (q->device); - queue_input.skip_process_ctx_clear = qpd->pqm->process-
debug_trap_enabled||
-
kfd_dbg_has_ttmps_always_setup(q->device);drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +2
-0+ queue_input.skip_process_ctx_clear = + qpd->pqm->process->runtime_info.runtime_state ==
DEBUG_RUNTIME_STATE_ENABLED&&Quoted 3 lines
+ (qpd->pqm->process-
debug_trap_enabled||
+
kfd_dbg_has_ttmps_always_setup(q->device));Quoted 3 lines
queue_type = convert_to_mes_queue_type(q->properties.type); if (queue_type < 0) {
Felix Kuehling
maintainerQuoted 11 lines · Jonathan
[Public]
Quoted 9 lines
-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Tuesday, September 12, 2023 8:36 PM
To: Kim, Jonathan <[email protected]>; [email protected]
Cc: Ji, Ruili <[email protected]>; Guo, Shikai <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdkfd: fix add queue process context clear for hsa non-init cases
Quoted 6 lines
Quoted 5 lines · Jonathan Kim
Quoted 1 line
There are cases where HSA is not initialized when adding queues
This statement doesn't make sense to me. If HSA is not initialized, it means user mode hasn't opened the KFD device. So it can't create queues. What do you really mean here?
I meant the call to runtime enable e.g. KFD test can add a queue without runtime enable call.
OK, this can also happen when you run an older version of the HSA runtime that doesn't support the ROCm debugger yet. Please update the patch description accordingly.
Thanks,
Felix
Quoted 46 lines
Thanks,
Jon
Quoted 41 lines
Regards,
FelixQuoted 8 lines
and
theADD_QUEUEAPI should clear the MES process context instead ofSET_SHADER_DEBUGGER.The only time ADD_QUEUE.skip_process_ctx_clear is required is for debugger use cases and a debugged process is always runtime enabled when adding a queue.
Review
Quoted 7 lines
Tested-by Shikai Guo <[email protected]>Signed-off-by Jonathan Kim <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.cdrivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static int add_queue_mes(struct
Quoted 4 lines
index
6d07a5dd2648..77159b03a422100644drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0@@ -227,8 +227,10 @@ static int add_queue_mes(struct
device_queue_manager*dqm, struct queue *q,Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-1queue_input.tba_addr = qpd->tba_addr; queue_input.tma_addr = qpd->tma_addr; queue_input.trap_en = !kfd_dbg_has_cwsr_workaround (q->device); - queue_input.skip_process_ctx_clear = qpd->pqm->process-
debug_trap_enabled||
-
kfd_dbg_has_ttmps_always_setup(q->device);drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +2
-0+ queue_input.skip_process_ctx_clear = + qpd->pqm->process->runtime_info.runtime_state ==
DEBUG_RUNTIME_STATE_ENABLED&&Quoted 3 lines
+ (qpd->pqm->process-
debug_trap_enabled||
+
kfd_dbg_has_ttmps_always_setup(q->device));Quoted 2 lines
queue_type = convert_to_mes_queue_type(q->properties.type); if (queue_type < 0) {
[Public]
Quoted 28 lines
-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Tuesday, September 12, 2023 9:01 PM
To: Kim, Jonathan <[email protected]>; [email protected]
Cc: Ji, Ruili <[email protected]>; Guo, Shikai <[email protected]>; Huang, JinHuiEric <[email protected]>
Subject: Re: [PATCH] drm/amdkfd: fix add queue process context clear for hsa non-init casesQuoted 6 lines · Jonathan
[Public]
Quoted 4 lines
-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Tuesday, September 12, 2023 8:36 PM
To: Kim, Jonathan <[email protected]>; amd-Quoted 3 lines
Quoted 3 lines
Cc: Ji, Ruili <[email protected]>; Guo, Shikai <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdkfd: fix add queue process context clear forhsa
Quoted 7 lines
Quoted 7 lines
non-init cases
Quoted 1 line · Jonathan Kim
There are cases where HSA is not initialized when adding queues
This statement doesn't make sense to me. If HSA is not initialized, it means user mode hasn't opened the KFD device. So it can't create queues. What do you really mean here?
Quoted 6 lines
Quoted 1 line
I meant the call to runtime enable e.g. KFD test can add a queue without
runtime enable call.
OK, this can also happen when you run an older version of the HSA runtime that doesn't support the ROCm debugger yet. Please update the patch description accordingly.
Ok will do thanks. Sorry for the confusing description.
For some reason I forgot that HSA was umbrella term and doesn't only refer to the ROCr component.
Thanks,
Jon
Quoted 51 lines
Thanks,
FelixQuoted 46 lines
Thanks,
Jon
Quoted 41 lines
Regards,
FelixQuoted 8 lines
and
theADD_QUEUEAPI should clear the MES process context instead ofSET_SHADER_DEBUGGER.The only time ADD_QUEUE.skip_process_ctx_clear is required is for debugger use cases and a debugged process is always runtime enabled when adding a queue.
Review
Quoted 7 lines
Tested-by Shikai Guo <[email protected]>Signed-off-by Jonathan Kim <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.cdrivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static int add_queue_mes(struct
Quoted 4 lines
index
6d07a5dd2648..77159b03a422100644drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0@@ -227,8 +227,10 @@ static int add_queue_mes(struct
device_queue_manager*dqm, struct queue *q,Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-1queue_input.tba_addr = qpd->tba_addr; queue_input.tma_addr = qpd->tma_addr; queue_input.trap_en = !kfd_dbg_has_cwsr_workaround (q->device); - queue_input.skip_process_ctx_clear = qpd->pqm->process-
debug_trap_enabled||
-
kfd_dbg_has_ttmps_always_setup(q->device);drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +2
-0+ queue_input.skip_process_ctx_clear = + qpd->pqm->process->runtime_info.runtime_state ==
DEBUG_RUNTIME_STATE_ENABLED&&Quoted 3 lines
+ (qpd->pqm->process-
debug_trap_enabled||
+
kfd_dbg_has_ttmps_always_setup(q->device));Quoted 2 lines
queue_type = convert_to_mes_queue_type(q->properties.type); if (queue_type < 0) {