msm: camera: reqmgr: reader writer locks to avoid memory faults

Shared memory is initialized by CRM and used by
other drivers; with CRM not active other drivers
would fail to access the shared memory if
memory manager is deinit. Reader Writer locks can
prevent the open/close/ioctl calls from other drivers
if CRM open/close is already being processed.

Issue observed with the below sequence if drivers
are opened from UMD directly without this change.
CRM Open successful,ICP open successful,
CRM close in progress, ICP open successful,
mem mgr deinit and CRM close successful,
ICP tries to access HFI memory and result in crash.

This change helps to serialze the calls and prevents
issue.

CRs-Fixed: 3019488
Change-Id: I84d50918713686a067c0e3deb64c9c6ae9edfcb5
Signed-off-by: Tejas Prajapati <quic_tpraja@quicinc.com>
This commit is contained in:
Tejas Prajapati
2021-11-18 17:07:47 +05:30
committed by Camera Software Integration
parent e63d6d6cb3
commit 2827395809
16 changed files with 109 additions and 0 deletions

View File

@@ -95,10 +95,12 @@ static const struct of_device_id cam_jpeg_dt_match[] = {
static int cam_jpeg_subdev_open(struct v4l2_subdev *sd,
struct v4l2_subdev_fh *fh)
{
cam_req_mgr_rwsem_read_op(CAM_SUBDEV_LOCK);
mutex_lock(&g_jpeg_dev.jpeg_mutex);
g_jpeg_dev.open_cnt++;
mutex_unlock(&g_jpeg_dev.jpeg_mutex);
cam_req_mgr_rwsem_read_op(CAM_SUBDEV_UNLOCK);
return 0;
}