浏览代码

Merge tag 'drm-amdkfd-next-fixes-2018-01-15' of git://people.freedesktop.org/~gabbayo/linux into drm-next

- fix NULL pointer dereference
- fix compiler warning on large define values
- remove unnecessary call to execute_queues_cpsch

* tag 'drm-amdkfd-next-fixes-2018-01-15' of git://people.freedesktop.org/~gabbayo/linux:
  drm/amdkfd: Fix potential NULL pointer dereferences
  drm/amdkfd: add ull suffix to 64bit defines
  drm/amdkfd: don't always call execute_queues_cpsch()
  drm/amdkfd: Fix return value 0 when execute_queues_cpsch fails
Dave Airlie 7 年之前
父节点
当前提交
92eb5f0c00

+ 6 - 6
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c

@@ -1013,13 +1013,13 @@ static int destroy_queue_cpsch(struct device_queue_manager *dqm,
 
 
 	list_del(&q->list);
 	list_del(&q->list);
 	qpd->queue_count--;
 	qpd->queue_count--;
-	if (q->properties.is_active)
+	if (q->properties.is_active) {
 		dqm->queue_count--;
 		dqm->queue_count--;
-
-	retval = execute_queues_cpsch(dqm,
+		retval = execute_queues_cpsch(dqm,
 				KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES, 0);
 				KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES, 0);
-	if (retval == -ETIME)
-		qpd->reset_wavefronts = true;
+		if (retval == -ETIME)
+			qpd->reset_wavefronts = true;
+	}
 
 
 	mqd->uninit_mqd(mqd, q->mqd, q->mqd_mem_obj);
 	mqd->uninit_mqd(mqd, q->mqd, q->mqd_mem_obj);
 
 
@@ -1033,7 +1033,7 @@ static int destroy_queue_cpsch(struct device_queue_manager *dqm,
 
 
 	mutex_unlock(&dqm->lock);
 	mutex_unlock(&dqm->lock);
 
 
-	return 0;
+	return retval;
 
 
 failed:
 failed:
 failed_try_destroy_debugged_queue:
 failed_try_destroy_debugged_queue:

+ 3 - 3
drivers/gpu/drm/amd/amdkfd/kfd_priv.h

@@ -41,9 +41,9 @@
 
 
 #define KFD_SYSFS_FILE_MODE 0444
 #define KFD_SYSFS_FILE_MODE 0444
 
 
-#define KFD_MMAP_DOORBELL_MASK 0x8000000000000
-#define KFD_MMAP_EVENTS_MASK 0x4000000000000
-#define KFD_MMAP_RESERVED_MEM_MASK 0x2000000000000
+#define KFD_MMAP_DOORBELL_MASK 0x8000000000000ull
+#define KFD_MMAP_EVENTS_MASK 0x4000000000000ull
+#define KFD_MMAP_RESERVED_MEM_MASK 0x2000000000000ull
 
 
 /*
 /*
  * When working with cp scheduler we should assign the HIQ manually or via
  * When working with cp scheduler we should assign the HIQ manually or via

+ 7 - 1
drivers/gpu/drm/amd/amdkfd/kfd_process.c

@@ -461,7 +461,8 @@ int kfd_bind_processes_to_device(struct kfd_dev *dev)
 	hash_for_each_rcu(kfd_processes_table, temp, p, kfd_processes) {
 	hash_for_each_rcu(kfd_processes_table, temp, p, kfd_processes) {
 		mutex_lock(&p->mutex);
 		mutex_lock(&p->mutex);
 		pdd = kfd_get_process_device_data(dev, p);
 		pdd = kfd_get_process_device_data(dev, p);
-		if (pdd->bound != PDD_BOUND_SUSPENDED) {
+
+		if (WARN_ON(!pdd) || pdd->bound != PDD_BOUND_SUSPENDED) {
 			mutex_unlock(&p->mutex);
 			mutex_unlock(&p->mutex);
 			continue;
 			continue;
 		}
 		}
@@ -501,6 +502,11 @@ void kfd_unbind_processes_from_device(struct kfd_dev *dev)
 		mutex_lock(&p->mutex);
 		mutex_lock(&p->mutex);
 		pdd = kfd_get_process_device_data(dev, p);
 		pdd = kfd_get_process_device_data(dev, p);
 
 
+		if (WARN_ON(!pdd)) {
+			mutex_unlock(&p->mutex);
+			continue;
+		}
+
 		if (pdd->bound == PDD_BOUND)
 		if (pdd->bound == PDD_BOUND)
 			pdd->bound = PDD_BOUND_SUSPENDED;
 			pdd->bound = PDD_BOUND_SUSPENDED;
 		mutex_unlock(&p->mutex);
 		mutex_unlock(&p->mutex);