Przeglądaj źródła

qcacld-3.0: Fix use of spinlock for pSchedContext->affinity_lock

In existing implementation, affinity lock is implemented as a spinlock.
The set_cpus_allowed_ptr API under the spinlock can cause the processor to go to
sleep. This is incorrect and causes a KERNEL bug when invoked.

Correct the issue by replacing spinlock with a mutex.

Change-Id: I844c19d18e6f71916592c4b35ff5f1a2b6cdbaa0
CRs-Fixed: 1046463
Mohit Khanna 8 lat temu
rodzic
commit
b0886d6918
2 zmienionych plików z 8 dodań i 8 usunięć
  1. 1 1
      core/cds/inc/cds_sched.h
  2. 7 7
      core/cds/src/cds_sched.c

+ 1 - 1
core/cds/inc/cds_sched.h

@@ -203,7 +203,7 @@ typedef struct _cds_sched_context {
 	struct notifier_block *cpu_hot_plug_notifier;
 
 	/* affinity lock */
-	spinlock_t affinity_lock;
+	struct mutex affinity_lock;
 
 	/* rx thread affinity cpu */
 	unsigned long rx_thread_cpu;

+ 7 - 7
core/cds/src/cds_sched.c

@@ -270,15 +270,15 @@ int cds_sched_handle_cpu_hot_plug(void)
 	if (cds_is_load_or_unload_in_progress())
 		return 0;
 
-	spin_lock_bh(&pSchedContext->affinity_lock);
+	mutex_lock(&pSchedContext->affinity_lock);
 	if (cds_sched_find_attach_cpu(pSchedContext,
 		pSchedContext->high_throughput_required)) {
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
 			"%s: handle hot plug fail", __func__);
-		spin_unlock_bh(&pSchedContext->affinity_lock);
+		mutex_unlock(&pSchedContext->affinity_lock);
 		return 1;
 	}
-	spin_unlock_bh(&pSchedContext->affinity_lock);
+	mutex_unlock(&pSchedContext->affinity_lock);
 	return 0;
 }
 
@@ -308,15 +308,15 @@ int cds_sched_handle_throughput_req(bool high_tput_required)
 		return 0;
 	}
 
-	spin_lock_bh(&pSchedContext->affinity_lock);
+	mutex_lock(&pSchedContext->affinity_lock);
 	pSchedContext->high_throughput_required = high_tput_required;
 	if (cds_sched_find_attach_cpu(pSchedContext, high_tput_required)) {
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
 			"%s: handle throughput req fail", __func__);
-		spin_unlock_bh(&pSchedContext->affinity_lock);
+		mutex_unlock(&pSchedContext->affinity_lock);
 		return 1;
 	}
-	spin_unlock_bh(&pSchedContext->affinity_lock);
+	mutex_unlock(&pSchedContext->affinity_lock);
 	return 0;
 }
 
@@ -510,7 +510,7 @@ QDF_STATUS cds_sched_open(void *p_cds_context,
 	}
 	register_hotcpu_notifier(&cds_cpu_hotplug_notifier);
 	pSchedContext->cpu_hot_plug_notifier = &cds_cpu_hotplug_notifier;
-	spin_lock_init(&pSchedContext->affinity_lock);
+	mutex_init(&pSchedContext->affinity_lock);
 	pSchedContext->high_throughput_required = false;
 #endif
 	gp_cds_sched_context = pSchedContext;