drm/amdkfd: Fix sdma queue map issue
authorOak Zeng <Oak.Zeng@amd.com>
Fri, 8 Feb 2019 21:44:35 +0000 (15:44 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 24 May 2019 17:21:02 +0000 (12:21 -0500)
Previous codes assumes there are two sdma engines.
This is not true e.g., Raven only has 1 SDMA engine.
Fix the issue by using sdma engine number info in
device_info.

Signed-off-by: Oak Zeng <Oak.Zeng@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c

index bac1f36..d41045d 100644 (file)
@@ -1212,12 +1212,17 @@ int amdkfd_fence_wait_timeout(unsigned int *fence_addr,
        return 0;
 }
 
-static int unmap_sdma_queues(struct device_queue_manager *dqm,
-                               unsigned int sdma_engine)
+static int unmap_sdma_queues(struct device_queue_manager *dqm)
 {
-       return pm_send_unmap_queue(&dqm->packets, KFD_QUEUE_TYPE_SDMA,
-                       KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES, 0, false,
-                       sdma_engine);
+       int i, retval = 0;
+
+       for (i = 0; i < dqm->dev->device_info->num_sdma_engines; i++) {
+               retval = pm_send_unmap_queue(&dqm->packets, KFD_QUEUE_TYPE_SDMA,
+                       KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES, 0, false, i);
+               if (retval)
+                       return retval;
+       }
+       return retval;
 }
 
 /* dqm->lock mutex has to be locked before calling this function */
@@ -1256,10 +1261,8 @@ static int unmap_queues_cpsch(struct device_queue_manager *dqm,
        pr_debug("Before destroying queues, sdma queue count is : %u\n",
                dqm->sdma_queue_count);
 
-       if (dqm->sdma_queue_count > 0) {
-               unmap_sdma_queues(dqm, 0);
-               unmap_sdma_queues(dqm, 1);
-       }
+       if (dqm->sdma_queue_count > 0)
+               unmap_sdma_queues(dqm);
 
        retval = pm_send_unmap_queue(&dqm->packets, KFD_QUEUE_TYPE_COMPUTE,
                        filter, filter_param, false, 0);