<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Calibri;font-size:10pt;color:#0000FF;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[AMD Official Use Only - AMD Internal Distribution Only]<br>
</p>
<br>
<div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Thanks Felix. Declaring err inside the if block is better. I have submitted patch, could you please help to review it?</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" id="Signature">
<p>Thanks.</p>
<p> </p>
<p>Best regard,</p>
<p>Yifan Zha</p>
<p> </p>
</div>
<div id="appendonsend"></div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<hr style="display: inline-block; width: 98%;">
<div id="divRplyFwdMsg" dir="ltr"><span style="font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);"><b>From:</b> Kuehling, Felix <Felix.Kuehling@amd.com><br>
<b>Sent:</b> Saturday, March 8, 2025 5:00 AM<br>
<b>To:</b> Zha, YiFan(Even) <Yifan.Zha@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com><br>
<b>Cc:</b> Chang, HaiJun <HaiJun.Chang@amd.com>; Chen, Horace <Horace.Chen@amd.com>; Yin, ZhenGuo (Chris) <ZhenGuo.Yin@amd.com><br>
<b>Subject:</b> Re: [PATCH v2] drm/amd/amdkfd: Evict all queues even HWS remove queue failed</span>
<div> </div>
</div>
<div style="font-size: 11pt;"><br>
On 2025-03-07 03:53, Yifan Zha wrote:<br>
> [Why]<br>
> If reset is detected and kfd need to evict working queues, HWS moving queue will be failed.<br>
> Then remaining queues are not evicted and in active state.<br>
><br>
> After reset done, kfd uses HWS to termination remaining activated queues but HWS is resetted.<br>
> So remove queue will be failed again.<br>
><br>
> [How]<br>
> Keep removing all queues even if HWS returns failed.<br>
> It will not affect cpsch as it checks reset_domain->sem.<br>
><br>
> v2: If any queue failed, evict queue returns error.<br>
><br>
> Signed-off-by: Yifan Zha <Yifan.Zha@amd.com><br>
> ---<br>
>   drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 8 ++++----<br>
>   1 file changed, 4 insertions(+), 4 deletions(-)<br>
><br>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c<br>
> index f3f2fd6ee65c..b647745ee0a5 100644<br>
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c<br>
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c<br>
> @@ -1189,7 +1189,7 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm,<br>
>        struct queue *q;<br>
>        struct device *dev = dqm->dev->adev->dev;<br>
>        struct kfd_process_device *pdd;<br>
> -     int retval = 0;<br>
> +     int retval, err = 0;<br>
<br>
You should still initialize retval to 0, otherwise the function may<br>
return an uninitialized value if there are no MES queues. err does not<br>
need to be initialized because you're always assigning a value just<br>
before checking it below.<br>
<br>
In fact, you could declare err inside the if-block below, since it is<br>
only needed in that scope. It is preferred to declare variables in a<br>
more limited scope if they are not needed outside.<br>
<br>
Regards,<br>
   Felix<br>
<br>
<br>
>  <br>
>        dqm_lock(dqm);<br>
>        if (qpd->evicted++ > 0) /* already evicted, do nothing */<br>
> @@ -1219,11 +1219,11 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm,<br>
>                decrement_queue_count(dqm, qpd, q);<br>
>  <br>
>                if (dqm->dev->kfd->shared_resources.enable_mes) {<br>
> -                     retval = remove_queue_mes(dqm, q, qpd);<br>
> -                     if (retval) {<br>
> +                     err = remove_queue_mes(dqm, q, qpd);<br>
> +                     if (err) {<br>
>                                dev_err(dev, "Failed to evict queue %d\n",<br>
>                                        q->properties.queue_id);<br>
> -                             goto out;<br>
> +                             retval = err;<br>
>                        }<br>
>                }<br>
>        }</div>
</div>
</body>
</html>