<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 2022-07-07 06:28, xinhui pan wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:20220707102800.8035-1-xinhui.pan@amd.com">
      <pre class="moz-quote-pre" wrap="">Queue would be freed when create_queue_cpsch fails
So lets do queue cleanup otherwise various list and memory issues
happen.
</pre>
    </blockquote>
    <p>This bug was introduced when adding MES support, as we used to
      ignore execute_queues_cpsch return value. Cleanup and return error
      to user space looks good to me.</p>
    <p>Reviewed-by: Philip Yang <a class="moz-txt-link-rfc2396E" href="mailto:Philip.Yang@amd.com"><Philip.Yang@amd.com></a><br>
    </p>
    <blockquote type="cite" cite="mid:20220707102800.8035-1-xinhui.pan@amd.com">
      <pre class="moz-quote-pre" wrap="">
Signed-off-by: xinhui pan <a class="moz-txt-link-rfc2396E" href="mailto:xinhui.pan@amd.com"><xinhui.pan@amd.com></a>
---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index 93a0b6995430..e83725a28106 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -1674,14 +1674,13 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
        if (q->properties.is_active) {
                increment_queue_count(dqm, qpd, q);
 
-               if (!dqm->dev->shared_resources.enable_mes) {
+               if (!dqm->dev->shared_resources.enable_mes)
                        retval = execute_queues_cpsch(dqm,
-                                            KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES, 0);
-               } else {
+                                       KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES, 0);
+               else
                        retval = add_queue_mes(dqm, q, qpd);
-                       if (retval)
-                               goto cleanup_queue;
-               }
+               if (retval)
+                       goto cleanup_queue;
        }
 
        /*
</pre>
    </blockquote>
  </body>
</html>