Skip to content

Commit 460d527

Browse files
Camera Software IntegrationGerrit - the friendly Code Review server
authored andcommitted
Merge "msm: camera: common: synchronization in CRM close and subdev register" into camera-kernel.qclinux.1.0
2 parents 163b184 + f9ff368 commit 460d527

4 files changed

Lines changed: 24 additions & 0 deletions

File tree

camera/drivers/cam_req_mgr/cam_req_mgr_dev.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,13 @@ static int cam_req_mgr_close(struct file *filep)
214214

215215
cam_req_mgr_rwsem_write_op(CAM_SUBDEV_LOCK);
216216

217+
mutex_lock(&g_dev.subdev_lock);
217218
mutex_lock(&g_dev.cam_lock);
218219

219220
if (g_dev.open_cnt <= 0) {
220221
CAM_WARN(CAM_CRM, "open_cnt <= 0 in close!");
221222
mutex_unlock(&g_dev.cam_lock);
223+
mutex_unlock(&g_dev.subdev_lock);
222224
cam_req_mgr_rwsem_write_op(CAM_SUBDEV_UNLOCK);
223225
return -EINVAL;
224226
}
@@ -255,6 +257,7 @@ static int cam_req_mgr_close(struct file *filep)
255257
cam_req_mgr_util_free_hdls();
256258
cam_mem_mgr_deinit();
257259
mutex_unlock(&g_dev.cam_lock);
260+
mutex_unlock(&g_dev.subdev_lock);
258261

259262
cam_req_mgr_rwsem_write_op(CAM_SUBDEV_UNLOCK);
260263

@@ -920,6 +923,7 @@ int cam_register_subdev(struct cam_subdev *csd)
920923
return -EINVAL;
921924
}
922925

926+
mutex_lock(&g_dev.subdev_lock);
923927
mutex_lock(&g_dev.dev_lock);
924928

925929
sd = &csd->sd;
@@ -969,6 +973,7 @@ int cam_register_subdev(struct cam_subdev *csd)
969973
reg_fail:
970974
invalid_val_fail:
971975
mutex_unlock(&g_dev.dev_lock);
976+
mutex_unlock(&g_dev.subdev_lock);
972977
return rc;
973978
}
974979

@@ -979,10 +984,12 @@ int cam_unregister_subdev(struct cam_subdev *csd)
979984
return -ENODEV;
980985
}
981986

987+
mutex_lock(&g_dev.subdev_lock);
982988
mutex_lock(&g_dev.dev_lock);
983989
v4l2_device_unregister_subdev(&csd->sd);
984990
g_dev.count--;
985991
mutex_unlock(&g_dev.dev_lock);
992+
mutex_unlock(&g_dev.subdev_lock);
986993

987994
return 0;
988995
}
@@ -1012,6 +1019,7 @@ static int cam_req_mgr_component_master_bind(struct device *dev)
10121019

10131020
g_dev.open_cnt = 0;
10141021
g_dev.shutdown_state = false;
1022+
mutex_init(&g_dev.subdev_lock);
10151023
mutex_init(&g_dev.cam_lock);
10161024
spin_lock_init(&g_dev.cam_eventq_lock);
10171025
mutex_init(&g_dev.dev_lock);
@@ -1070,6 +1078,7 @@ static int cam_req_mgr_component_master_bind(struct device *dev)
10701078
req_mgr_util_fail:
10711079
mutex_destroy(&g_dev.dev_lock);
10721080
mutex_destroy(&g_dev.cam_lock);
1081+
mutex_destroy(&g_dev.subdev_lock);
10731082
cam_video_device_cleanup();
10741083
video_setup_fail:
10751084
cam_media_device_cleanup();
@@ -1093,6 +1102,7 @@ static void cam_req_mgr_component_master_unbind(struct device *dev)
10931102
cam_v4l2_device_cleanup();
10941103
cam_req_mgr_destroy_timer_slab();
10951104
mutex_destroy(&g_dev.dev_lock);
1105+
mutex_destroy(&g_dev.subdev_lock);
10961106
g_dev.state = false;
10971107
}
10981108

camera/drivers/cam_req_mgr/cam_req_mgr_dev.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0-only */
22
/*
33
* Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
4+
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
45
*/
56

67
#ifndef _CAM_REQ_MGR_DEV_H_
@@ -34,6 +35,7 @@ struct cam_req_mgr_device {
3435
struct v4l2_fh *cam_eventq;
3536
spinlock_t cam_eventq_lock;
3637
bool shutdown_state;
38+
struct mutex subdev_lock;
3739
};
3840

3941
#define CAM_REQ_MGR_GET_PAYLOAD_PTR(ev, type) \

camera_kt/drivers/cam_req_mgr/cam_req_mgr_dev.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,13 @@ static int cam_req_mgr_close(struct file *filep)
202202

203203
cam_req_mgr_rwsem_write_op(CAM_SUBDEV_LOCK);
204204

205+
mutex_lock(&g_dev.subdev_lock);
205206
mutex_lock(&g_dev.cam_lock);
206207

207208
if (g_dev.open_cnt <= 0) {
208209
CAM_WARN(CAM_CRM, "open_cnt <= 0 in close!");
209210
mutex_unlock(&g_dev.cam_lock);
211+
mutex_unlock(&g_dev.subdev_lock);
210212
cam_req_mgr_rwsem_write_op(CAM_SUBDEV_UNLOCK);
211213
return -EINVAL;
212214
}
@@ -243,6 +245,7 @@ static int cam_req_mgr_close(struct file *filep)
243245
cam_req_mgr_util_free_hdls();
244246
cam_mem_mgr_deinit();
245247
mutex_unlock(&g_dev.cam_lock);
248+
mutex_unlock(&g_dev.subdev_lock);
246249

247250
cam_req_mgr_rwsem_write_op(CAM_SUBDEV_UNLOCK);
248251

@@ -810,6 +813,7 @@ int cam_register_subdev(struct cam_subdev *csd)
810813
return -EINVAL;
811814
}
812815

816+
mutex_lock(&g_dev.subdev_lock);
813817
mutex_lock(&g_dev.dev_lock);
814818

815819
sd = &csd->sd;
@@ -860,6 +864,7 @@ int cam_register_subdev(struct cam_subdev *csd)
860864
reg_fail:
861865
invalid_val_fail:
862866
mutex_unlock(&g_dev.dev_lock);
867+
mutex_unlock(&g_dev.subdev_lock);
863868
return rc;
864869
}
865870

@@ -870,10 +875,12 @@ int cam_unregister_subdev(struct cam_subdev *csd)
870875
return -ENODEV;
871876
}
872877

878+
mutex_lock(&g_dev.subdev_lock);
873879
mutex_lock(&g_dev.dev_lock);
874880
v4l2_device_unregister_subdev(&csd->sd);
875881
g_dev.count--;
876882
mutex_unlock(&g_dev.dev_lock);
883+
mutex_unlock(&g_dev.subdev_lock);
877884

878885
return 0;
879886
}
@@ -892,6 +899,7 @@ static int cam_req_mgr_component_master_bind(struct device *dev)
892899
mutex_init(&g_dev.cam_lock);
893900
spin_lock_init(&g_dev.cam_eventq_lock);
894901
mutex_init(&g_dev.dev_lock);
902+
mutex_init(&g_dev.subdev_lock);
895903

896904
rc = cam_req_mgr_util_init();
897905
if (rc) {
@@ -960,6 +968,7 @@ static int cam_req_mgr_component_master_bind(struct device *dev)
960968
cam_v4l2_device_cleanup();
961969
mutex_destroy(&g_dev.dev_lock);
962970
mutex_destroy(&g_dev.cam_lock);
971+
mutex_destroy(&g_dev.subdev_lock);
963972
g_dev.state = false;
964973
return rc;
965974
}
@@ -977,6 +986,7 @@ static void cam_req_mgr_component_master_unbind(struct device *dev)
977986
cam_video_device_cleanup();
978987
cam_v4l2_device_cleanup();
979988
mutex_destroy(&g_dev.dev_lock);
989+
mutex_destroy(&g_dev.subdev_lock);
980990
g_dev.state = false;
981991
}
982992

camera_kt/drivers/cam_req_mgr/cam_req_mgr_dev.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0-only */
22
/*
33
* Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
4+
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
45
*/
56

67
#ifndef _CAM_REQ_MGR_DEV_H_
@@ -32,6 +33,7 @@ struct cam_req_mgr_device {
3233
struct v4l2_fh *cam_eventq;
3334
spinlock_t cam_eventq_lock;
3435
bool shutdown_state;
36+
struct mutex subdev_lock;
3537
};
3638

3739
#define CAM_REQ_MGR_GET_PAYLOAD_PTR(ev, type) \

0 commit comments

Comments
 (0)