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

Commit a134943c authored by Jeyaprakash Soundrapandian's avatar Jeyaprakash Soundrapandian Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: camera: mem: Remove lock from get_cpu_buf unless mapping" into dev/msm-4.14-camx

parents a8ddd8ac 61205d00
Loading
Loading
Loading
Loading
+20 −15
Original line number Diff line number Diff line
@@ -244,37 +244,42 @@ int cam_mem_get_cpu_buf(int32_t buf_handle, uint64_t *vaddr_ptr, size_t *len)
	if (!tbl.bufq[idx].active)
		return -EPERM;

	mutex_lock(&tbl.bufq[idx].q_lock);
	if (buf_handle != tbl.bufq[idx].buf_handle) {
		rc = -EINVAL;
		goto exit_func;
	}

	if (!(tbl.bufq[idx].flags & CAM_MEM_FLAG_KMD_ACCESS)) {
		rc = -EINVAL;
		goto exit_func;
	}

	if (!tbl.bufq[idx].kmdvaddr) {
		mutex_lock(&tbl.bufq[idx].q_lock);
		dmabuf = tbl.bufq[idx].dma_buf;
		if (!dmabuf) {
			CAM_ERR(CAM_MEM, "Invalid DMA buffer pointer");
			rc = -EINVAL;
		goto exit_func;
			goto release_mutex;
		}

	if (tbl.bufq[idx].flags & CAM_MEM_FLAG_KMD_ACCESS) {
		if (!tbl.bufq[idx].kmdvaddr) {
		rc = cam_mem_util_map_cpu_va(dmabuf,
			&kvaddr, &klen);
		if (rc)
				goto exit_func;
			goto release_mutex;

		tbl.bufq[idx].kmdvaddr = kvaddr;
		}
	} else {
		rc = -EINVAL;
		goto exit_func;
		mutex_unlock(&tbl.bufq[idx].q_lock);
	}

	*vaddr_ptr = tbl.bufq[idx].kmdvaddr;
	*len = tbl.bufq[idx].len;

exit_func:
	return rc;

release_mutex:
	mutex_unlock(&tbl.bufq[idx].q_lock);
exit_func:
	return rc;
}
EXPORT_SYMBOL(cam_mem_get_cpu_buf);