drm/amd/amdkfd: Evict all queues even HWS remove queue failed
Subsystems (3)
PATCH v2 1/1 drm/amd/amdkfd: Evict all queues even HWS remove queue failed
[Why]
If reset is detected and kfd need to evict working queues, HWS moving queue will be failed. Then remaining queues are not evicted and in active state.
After reset done, kfd uses HWS to termination remaining activated queues but HWS is resetted. So remove queue will be failed again.
[How]
Keep removing all queues even if HWS returns failed. It will not affect cpsch as it checks reset_domain->sem.
v2: If any queue failed, evict queue returns error.
--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +4 -4
@@ -1189,7 +1189,7 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm,struct queue *q;struct device *dev = dqm->dev->adev->dev;struct kfd_process_device *pdd; -int retval =0 ; +int retval, err =0 ;dqm_lock (dqm);if (qpd->evicted++ >0 )/* already evicted, do nothing */
@@ -1219,11 +1219,11 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm,decrement_queue_count (dqm, qpd, q);if (dqm->dev->kfd->shared_resources.enable_mes) { - retval =remove_queue_mes (dqm, q, qpd); -if (retval) { + err =remove_queue_mes (dqm, q, qpd); +if (err) {dev_err (dev,"Failed to evict queue %d\n" , q->properties.queue_id); - goto out; + retval = err; } } }
Signature · 1 line
2.25.1
Felix Kuehling
maintainerQuoted 23 lines · Yifan Zha
[Why]
If reset is detected and kfd need to evict working queues, HWS moving queue will be failed. Then remaining queues are not evicted and in active state.After reset done, kfd uses HWS to termination remaining activated queues but HWS is resetted. So remove queue will be failed again.
[How]
Keep removing all queues even if HWS returns failed. It will not affect cpsch as it checksreset_domain->sem.v2: If any queue failed, evict queue returns error.
Signed-off-by Yifan Zha <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static int evict_process_queues_cpsch(struct device_queue_manager *dqm, · line 1192
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1
-1@@ -1189,7 +1189,7 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm,struct queue *q;struct device *dev = dqm->dev->adev->dev;struct kfd_process_device *pdd; -int retval =0 ; +int retval, err =0 ;
You should still initialize retval to 0, otherwise the function may return an uninitialized value if there are no MES queues. err does not need to be initialized because you're always assigning a value just before checking it below.
In fact, you could declare err inside the if-block below, since it is only needed in that scope. It is preferred to declare variables in a more limited scope if they are not needed outside.
Regards,
Felix
Quoted 18 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +3
-3dqm_lock (dqm);if (qpd->evicted++ >0 )/* already evicted, do nothing */ @@ -1219,11 +1219,11 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm,decrement_queue_count (dqm, qpd, q);if (dqm->dev->kfd->shared_resources.enable_mes) { - retval =remove_queue_mes (dqm, q, qpd); -if (retval) { + err =remove_queue_mes (dqm, q, qpd); +if (err) {dev_err (dev,"Failed to evict queue %d\n" , q->properties.queue_id); - goto out; + retval = err; } } }
[AMD Official Use Only - AMD Internal Distribution Only]
Thanks Felix. Declaring err inside the if block is better. I have submitted patch, could you please help to review it?
Thanks.
Best regard,
Yifan Zha
________________________________
From: Kuehling, Felix <[email protected]>
Sent: Saturday, March 8, 2025 5:00 AM
To: Zha, YiFan(Even) <[email protected]>; [email protected] <[email protected]>; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>
Cc: Chang, HaiJun <[email protected]>; Chen, Horace <[email protected]>; Yin, ZhenGuo (Chris) <[email protected]>
Subject: Re: [PATCH v2] drm/amd/amdkfd: Evict all queues even HWS remove queue failed
Quoted 23 lines · Yifan Zha
[Why]
If reset is detected and kfd need to evict working queues, HWS moving queue will be failed. Then remaining queues are not evicted and in active state.After reset done, kfd uses HWS to termination remaining activated queues but HWS is resetted. So remove queue will be failed again.
[How]
Keep removing all queues even if HWS returns failed. It will not affect cpsch as it checksreset_domain->sem.v2: If any queue failed, evict queue returns error.
Signed-off-by Yifan Zha <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static int evict_process_queues_cpsch(struct device_queue_manager *dqm, · line 1192
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1
-1@@ -1189,7 +1189,7 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm,struct queue *q;struct device *dev = dqm->dev->adev->dev;struct kfd_process_device *pdd; -int retval =0 ; +int retval, err =0 ;
You should still initialize retval to 0, otherwise the function may return an uninitialized value if there are no MES queues. err does not need to be initialized because you're always assigning a value just before checking it below.
In fact, you could declare err inside the if-block below, since it is only needed in that scope. It is preferred to declare variables in a more limited scope if they are not needed outside.
Regards,
Felix
Quoted 18 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +3
-3dqm_lock (dqm);if (qpd->evicted++ >0 )/* already evicted, do nothing */ @@ -1219,11 +1219,11 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm,decrement_queue_count (dqm, qpd, q);if (dqm->dev->kfd->shared_resources.enable_mes) { - retval =remove_queue_mes (dqm, q, qpd); -if (retval) { + err =remove_queue_mes (dqm, q, qpd); +if (err) {dev_err (dev,"Failed to evict queue %d\n" , q->properties.queue_id); - goto out; + retval = err; } } }