Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2eb4c0dd authored by Vamsi Krishna Gattupalli's avatar Vamsi Krishna Gattupalli
Browse files

msm: adsprpc: Fix race condition in internal_control



Protect add and update qos request with mutex to
avoid race condition when multiple threads try to add
or update request simultaneously.

Change-Id: Id33b81bf85246ec69c72bad59cca068e627bb21d
Acked-by: default avatarAnand Kulkarni <anankulk@qti.qualcomm.com>
Signed-off-by: default avatarVamsi Krishna Gattupalli <quic_vgattupa@quicinc.com>
parent 114c9c6c
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -472,6 +472,7 @@ struct fastrpc_file {
	struct mutex perf_mutex;
	struct pm_qos_request pm_qos_req;
	int qos_request;
	struct mutex pm_qos_mutex;
	struct mutex map_mutex;
	struct mutex internal_map_mutex;
	/* Identifies the device (MINOR_NUM_DEV / MINOR_NUM_SECURE_DEV) */
@@ -3859,6 +3860,7 @@ static int fastrpc_file_free(struct fastrpc_file *fl)
	mutex_destroy(&fl->perf_mutex);
	mutex_destroy(&fl->map_mutex);
	mutex_destroy(&fl->internal_map_mutex);
	mutex_destroy(&fl->pm_qos_mutex);
	kfree(fl);
	return 0;
}
@@ -4232,6 +4234,7 @@ static int fastrpc_device_open(struct inode *inode, struct file *filp)
	hlist_add_head(&fl->hn, &me->drivers);
	spin_unlock(&me->hlock);
	mutex_init(&fl->perf_mutex);
	mutex_init(&fl->pm_qos_mutex);
	init_completion(&fl->shutdown);
	return 0;
}
@@ -4359,12 +4362,14 @@ static int fastrpc_internal_control(struct fastrpc_file *fl,
		fl->pm_qos_req.type = PM_QOS_REQ_AFFINE_CORES;
		cpumask_copy(&fl->pm_qos_req.cpus_affine, &mask);

		mutex_lock(&fl->pm_qos_mutex);
		if (!fl->qos_request) {
			pm_qos_add_request(&fl->pm_qos_req,
				PM_QOS_CPU_DMA_LATENCY, latency);
			fl->qos_request = 1;
		} else
			pm_qos_update_request(&fl->pm_qos_req, latency);
		mutex_unlock(&fl->pm_qos_mutex);

		/* Ensure CPU feature map updated to DSP for early WakeUp */
		fastrpc_send_cpuinfo_to_dsp(fl);