[bug report] drm/amdkfd: Add SDMA user-mode queues support to QCM

Dan Carpenter dan.carpenter at oracle.com
Tue Jul 11 20:03:31 UTC 2017


Hello Ben Goz,

The patch bcea30817574: "drm/amdkfd: Add SDMA user-mode queues
support to QCM" from Jan 3, 2015, leads to the following static
checker warning:

	drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c:191 create_queue_nocpsch()
	error: uninitialized symbol 'retval'.

drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
   155  static int create_queue_nocpsch(struct device_queue_manager *dqm,
   156                                  struct queue *q,
   157                                  struct qcm_process_device *qpd,
   158                                  int *allocated_vmid)
   159  {
   160          int retval;
                    ^^^^^^
   161  
   162          BUG_ON(!dqm || !q || !qpd || !allocated_vmid);
   163  
   164          pr_debug("kfd: In func %s\n", __func__);
   165          print_queue(q);
   166  
   167          mutex_lock(&dqm->lock);
   168  
   169          if (dqm->total_queue_count >= max_num_of_queues_per_device) {
   170                  pr_warn("amdkfd: Can't create new usermode queue because %d queues were already created\n",
   171                                  dqm->total_queue_count);
   172                  mutex_unlock(&dqm->lock);
   173                  return -EPERM;
   174          }
   175  
   176          if (list_empty(&qpd->queues_list)) {
   177                  retval = allocate_vmid(dqm, qpd, q);
   178                  if (retval != 0) {
   179                          mutex_unlock(&dqm->lock);
   180                          return retval;
   181                  }
   182          }
   183          *allocated_vmid = qpd->vmid;
   184          q->properties.vmid = qpd->vmid;
   185  
   186          if (q->properties.type == KFD_QUEUE_TYPE_COMPUTE)
   187                  retval = create_compute_queue_nocpsch(dqm, q, qpd);
   188          if (q->properties.type == KFD_QUEUE_TYPE_SDMA)
   189                  retval = create_sdma_queue_nocpsch(dqm, q, qpd);


There are a couple other options besides KFD_QUEUE_TYPE_COMPUTE and
KFD_QUEUE_TYPE_SDMA.  We should just add an:

	else
		retval = -EINVAL;

to future proof the code, if nothing else.

   190  
   191          if (retval != 0) {
   192                  if (list_empty(&qpd->queues_list)) {
   193                          deallocate_vmid(dqm, qpd, q);
   194                          *allocated_vmid = 0;
   195                  }
   196                  mutex_unlock(&dqm->lock);
   197                  return retval;
   198          }

regards,
dan carpenter


More information about the amd-gfx mailing list