Commit Graph

64 Commits

Author SHA1 Message Date
Shravya Samala
011cc16eb5 msm: camera: sync: Restructure sync device structure
Currently sync_device structure size allocated is nearly 424kb
which is leading to more than accepted page size order.
Sync table row which is array of 2048 is accounting
nearly 90% of total size of sync_device. To fix this
sync_table_row is made pointer based and allocated memory.

CRs-Fixed: 3558545
Change-Id: I0c8093c91ac7fec9f52613012b139192b827b8d9
Signed-off-by: Shravya Samala <quic_shravyas@quicinc.com>
2023-07-28 10:48:45 -07:00
Karthik Anantha Ram
fadf0e5db2 msm: camera: sync: Update synx handle state
On signaling the synx handle, mark the row as signaled.

CRs-Fixed: 3565287
Change-Id: I88f0d6a8455eecf62ffb084c0a540179d41fa64c
Signed-off-by: Karthik Anantha Ram <quic_kartanan@quicinc.com>
2023-07-26 15:59:21 -07:00
Wang Kan
56e0bcc8ee msm: camera: common: Fix isp log errs and format errs
Fix isp log errs and format errs.

CRs-Fixed: 3499636
Change-Id: Ieb5b81b95dea440b1da17cb5bc9be86f75b7c4f6
Signed-off-by: Wang Kan <quic_wkan@quicinc.com>
2023-05-26 18:36:22 -07:00
Karthik Anantha Ram
267f259a72 msm: camera: sync: Add support to invoke synx recover
If ICP FW is to be redowloaded, issue a synx recover for
this ICP core so that IPC/synx for the previous session
can be cleaned up prior to the next ICP cold boot.

CRs-Fixed: 3448052
Change-Id: I9f8f772730f7e4a8873b6dbdcf7a896ad6193150
Signed-off-by: Karthik Anantha Ram <quic_kartanan@quicinc.com>
2023-04-28 17:36:10 -07:00
Karthik Anantha Ram
da94e6eb75 msm: camera: sync: Update timeout for synx async wait
With the update in the synx driver for async wait, clients
are expected to register the callback with no specific
timeout value.

CRs-Fixed: 3434716
Change-Id: Ie9a5a88f9fddc9512b249919c843e2367de7db4e
Signed-off-by: Karthik Anantha Ram <quic_kartanan@quicinc.com>
2023-03-28 21:36:06 -07:00
Haochen Yang
e399dbcea6 msm: camera: sync: Update size checking for fence cmd args
This change modifies the size checking for fence_cmd_args
when allocating the fence_input_info.

CRs-Fixed: 3350863
Change-Id: I16b2898e867d2af11e32c55cfb4e87316352b642
Signed-off-by: Haochen Yang <quic_haocyang@quicinc.com>
2023-03-21 18:06:39 -07:00
Haochen Yang
18b9847377 msm: camera: sync: Add support for putting dma fence
This change will put dma fence no matter what the value
of row->ext_dma_fence is when closing it.

CRs-Fixed: 3423230
Change-Id: Iaf3faad970ad226bebaed41305f70afa9e5858f7
Signed-off-by: Haochen Yang <quic_haocyang@quicinc.com>
2023-03-21 18:06:34 -07:00
Karthik Anantha Ram
84607f072a msm: camera: sync: Ensure dma fence is signaled prior to release
The change ensures the dma fence is always signaled prior
to release.

CRs-Fixed: 3423230
Change-Id: I6063b49c23451fc5053dde6436776b8a42d0fd02
Signed-off-by: Karthik Anantha Ram <quic_kartanan@quicinc.com>
Signed-off-by: Haochen Yang <quic_haocyang@quicinc.com>
2023-03-21 18:06:27 -07:00
Haochen Yang
28439b686e msm: camera: sync: Handle dangling pointers in monitor dump
This change appropriately handles dangling pointer generated
by sync/dma/synx when closing the drivers.

CRs-Fixed: 3350863
Change-Id: Id5353814f4908f17706cebc04b3f02ccc1488813
Signed-off-by: Haochen Yang <quic_haocyang@quicinc.com>
2023-03-20 13:46:18 -07:00
Haochen Yang
ae91bc4768 msm: camera: sync: Add extra support for monitor dump
Add monitor dump when dma/synx is already in signaled
state or has registered a cb, and when sync fails to
signal its corresponding dma/synx.

CRs-Fixed: 3350863
Change-Id: I4b52647f1d3f53eff119df1ab143be6848dd0d5d
Signed-off-by: Haochen Yang <quic_haocyang@quicinc.com>
2023-03-09 23:36:05 -08:00
Atiya Kailany
b5af93e730 msm: camera: sync: Sync Driver Null Pointer Fix
Fixed null pointer dereference and uninitialized index variable.

CRs-Fixed: 3394193
Change-Id: I4a77060e227a9b39bb127c041515481549a99a42
Signed-off-by: Atiya Kailany <quic_akailany@quicinc.com>
2023-02-24 21:06:22 -08:00
Karthik Dillibabu
c4993c3b77 msm: camera: common: workq delay debug
Added log to print wq_name and callback info to understand
which task is delayed and to aid in debugging.

CRs-Fixed: 3381768
Change-Id: I74f1f5d3312c9163cfbafa4bc15a96c973ef2ba5
Signed-off-by: Karthik Dillibabu <quic_kard@quicinc.com>
2023-02-17 16:36:12 -08:00
Karthik Anantha Ram
d4731aa3fb msm: camera: sync: Enhance synx/dma fence drivers
The change addresses race conditions stemming from releasing
internal row lock prior to invoking synx APIs. The change
also deregisters dma/synx callbacks if the corresponding
fences are signaled when the associated sync object is signaled.
The change also cleans up & reorganizes functions.

CRs-Fixed: 3403341
Change-Id: I32995900e31ba73eac6b44d2238808f8e6c23f9a
Signed-off-by: Karthik Anantha Ram <quic_kartanan@quicinc.com>
2023-02-16 18:36:11 -08:00
Haochen Yang
26dfb39090 msm: camera: sync: Fix bugs related to monitor information
Release spinlock before calling synx APIs.

CRs-Fixed: 3350863
Change-Id: I156a70b18c76f4a2f30de70c23d44032bdf8f571
Signed-off-by: Haochen Yang <quic_haocyang@quicinc.com>
2023-02-15 19:06:39 -08:00
Pavan Kumar Chilamkurthi
07b3c215a1 msm: camera: sync: Add monitor information for sync objects
Monitor sync object operations such as create, register callback,
signal, unregister callback which is useful in debugging. Introduce
debugfs to dynamically set the monitor mask. Apply dump on error
when CAM_GENERIC_FENCE_TYPE_xx is set in cam_sync_monitor_mask and
apply dump on release when CAM_GENERIC_FENCE_TYPE_xx_DUMP is also set
at the same time. Apply dynamic memory allocation for monitor data
in synx and dma. Refactor APIs into generic ones and add memory
checkings.

CRs-Fixed: 3350863
Change-Id: I70cfdc1215be5f6bf564c672a874e6ba7997cdfa
Signed-off-by: Pavan Kumar Chilamkurthi <quic_pchilamk@quicinc.com>
Signed-off-by: Haochen Yang <quic_haocyang@quicinc.com>
2023-02-08 20:06:10 -08:00
Karthik Anantha Ram
3ed7ff9aa7 msm: camera: sync: Release spinlock prior to calling synx APIs
When sync signal triggers synx signal, unlock sync obj row lock
prior to signaling synx.

CRs-Fixed: 3391761
Change-Id: Ia01858f3a33ee2e95347bc5f88756265d816a08d
Signed-off-by: Karthik Anantha Ram <quic_kartanan@quicinc.com>
2023-02-07 11:41:09 -08:00
Karthik Anantha Ram
8b2265fe1f msm: camera: sync: Release spinlock prior to calling synx
Mutex is the synchronization primitive used in synx, which
can sleep. Holding the spin lock and invoking synx APIs could
deadlock the system. Release spin lock and invoke synx driver.

CRs-Fixed: 3365172
Change-Id: I01291fdd96df772f4cb1d87a44d79dd4a62fdc26
Signed-off-by: Karthik Anantha Ram <quic_kartanan@quicinc.com>
2023-01-05 17:36:09 -08:00
Karthik Anantha Ram
e39cae73bd msm: camera: sync: Update validation checks
Update validation checks to ensure copy from user does not
go beyond assigned memory. The change also adds dma fence ref
count prior to signaling sync object.

CRs-Fixed: 3327260
Change-Id: I9e2a57ecd686d2b9125789f7532812de647af7a5
Signed-off-by: Karthik Anantha Ram <quic_kartanan@quicinc.com>
2022-12-16 18:06:39 -08:00
Karthik Anantha Ram
c8ee871fdf msm: camera: sync: Update global synx property
Currently all synx handles need to be global. Update
synx create params accordingly.

CRs-Fixed: 3351015
Change-Id: I58d6f927b5a7c1508a34a64c916ca3c9fbb1de49
Signed-off-by: Karthik Anantha Ram <quic_kartanan@quicinc.com>
2022-12-06 11:36:47 -08:00
Karthik Anantha Ram
b997fec06f msm: camera: sync: Fix synx compilation issues
Fix synx compilation dependencies for pineapple.

CRs-Fixed: 3343701
Change-Id: Ie7d69b1bd70de4354af12a0cb0a2c44ecaf79135
Signed-off-by: Karthik Anantha Ram <quic_kartanan@quicinc.com>
2022-11-29 17:36:49 -08:00
Karthik Anantha Ram
6d53b197fb msm: camera: sync: Increase max synx handles
Increase max sync handles that can be created per
camera synx session to 256.

CRs-Fixed: 3343701
Change-Id: I5c02e6693056df302d1c0fe7005f3278ae752f45
Signed-off-by: Karthik Anantha Ram <quic_kartanan@quicinc.com>
2022-11-29 17:36:44 -08:00
Petar Nedev
f22f48c91f msm: camera: sync: Add support for synx objects
Add support to create, release, signal and import a synx object
using the existing generic fence operations. Handle signaling of
underlying synx object when a sync object is signaled & vice versa.

CRs-Fixed: 3317280
Change-Id: Ia6fac6eb732ed7091ec62f04875bdb30d88c8676
Signed-off-by: Petar Nedev <quic_pnedev@quicinc.com>
2022-10-27 17:06:36 -07:00
Joshua Florez
80f048e0b7 msm: camera: sync: Fix out-of-bounds access in sync create and release
Fixes an out-of-bounds access caused by pointer casting in sync create
and sync release functions.

CRs-Fixed: 3309201
Change-Id: I2e206eeab59f627d0f724362483899cdecd14324
Signed-off-by: Joshua Florez <quic_jflorez@quicinc.com>
2022-10-13 16:06:37 -07:00
zhuo
a0ca9a026c msm: camera: common: Fix some compile errors
This change fix unannotated fall-through between switch labels error,
also fix unused label error.

CRs-Fixed: 3247171
Change-Id: Ida29c08eed0cebec05b36e0ebac3d55ce8c6a014
Signed-off-by: zhuo <quic_zhuo@quicinc.com>
2022-09-19 18:36:22 -07:00
Karthik Anantha Ram
167437bdeb msm: camera: sync: Avoid use after free
There is a narrow window, in which the critical section is
not fully protected which possibly could lead to use after free.
To avoid this, hold the row lock and validate the state prior
to processing the dma fence.

CRs-Fixed: 3273450
Change-Id: Ib1f09e62a5060a38b5cd8f3d4594bce2e533b3d3
Signed-off-by: Karthik Anantha Ram <quic_kartanan@quicinc.com>
2022-09-13 16:07:33 -07:00
Sokchetra Eung
d2a1f0c968 msm: camera: common: memset usage optimization
Remove unnecessary memsets of the structure variables
whose fields are assigned prior to their usage or they
are dynamically allocated with calls that set the memory
to 0. This memset usage optimization is to improve
performance.

CRs-Fixed: 3228092
Change-Id: Iec68c6d072863627959ce603cff28afd26a1c408
Signed-off-by: Sokchetra Eung <quic_eung@quicinc.com>
2022-07-26 11:03:32 -07:00
Karthik Anantha Ram
07afaf5e79 msm: camera: sync: Remove third party copyright update for 2021
Update sync headers to remove third party update for year 2021.

CRs-Fixed: 3207212
Change-Id: I30d029d5755d4fb129c256f9771b20c115970388
Signed-off-by: Karthik Anantha Ram <quic_kartanan@quicinc.com>
2022-06-09 16:39:21 -07:00
Karthik Anantha Ram
a130199cd3 msm: camera: sync: Add support for dma fences
Add support to create, release, signal and import
a dma fence. When a sync object is imported for a dma fence
signal the dma fence when signaling the sync object with
appropriate status. This is achieved by implementing
generic fence scheme. The change also adds support
for batched fences.

CRs-Fixed: 3207212
Change-Id: I23fbc0992281cfee0303e213a30bce138ae7bdff
Signed-off-by: Karthik Anantha Ram <quic_kartanan@quicinc.com>
2022-06-08 13:06:40 -07:00
Anand Ravi
cbe499e9eb msm: camera: common: create a common root folder for debugfs
Create common root folder under debugfs root named camera at probe. Add
utility functions to create subdirectories under the common camera root.

CRs-Fixed: 3093049
Change-Id: Ia4cefb5d2263ecabf1b9d70deefa1ee624b04f07
Signed-off-by: Anand Ravi <quic_ananravi@quicinc.com>
2021-12-22 16:43:42 -08:00
Karthik Jayakumar
9716446091 msm: camera: common: Remove return from debugfs_create_bool
Remove return checks from debugfs_create_bool, as the API changed in
kernel 5.15+.

CRs-Fixed: 3048249
Change-Id: I2351776615a5fb17db1c54d285be2bf8e55443ab
Signed-off-by: Karthik Jayakumar <kjayakum@codeaurora.org>
2021-11-01 13:15:33 -07:00
Trishansh Bhardwaj
0d847c06fe msm: camera: sync: Prevent OOB access of sync name
Issue:
strlcpy calls strlen on src ptr. If src is not NULL terminated then OOB
access will occur in below stack.
  strlen
  strlcpy
  cam_sync_init_row
  cam_sync_handle_create
  cam_sync_dev_ioctl

Fix:
Pad user-space supplied name with NULL.

CRs-Fixed: 3010262
Change-Id: Ib5c2fbfe395025ec05e0bb2980f86111e95ff54c
Signed-off-by: Trishansh Bhardwaj <tbhardwa@codeaurora.org>
2021-08-31 10:24:05 -07:00
Ayush Kumar
8554f46816 msm: camera: core: Add delay detection support
This changes is to detect workqueue and tasklet
scheduling and execution delay.

CRs-Fixed: 2977775
Change-Id: Ia4b4845a067c22bd1f24bd63a971d103fcfc049c
Signed-off-by: Ayush Kumar <ayushkr@codeaurora.org>
2021-08-11 22:18:10 +05:30
Camera Software Integration
32701c91b2 Merge "msm: camera: sync: Append sync obj's name in log" into camera-kernel.lnx.5.0 2021-07-28 20:37:52 -07:00
Sokchetra Eung
56706b93b3 msm: camera: sync: Append sync obj's name in log
Append sync obj's name to logs to help debugging.

CRs-Fixed: 2998236
Change-Id: I461865b72e49b11267c2dc20176985b4545a42e8
Signed-off-by: Sokchetra Eung <eung@codeaurora.org>
2021-07-26 19:56:28 -07:00
Sokchetra Eung
ba664cddff msm: camera: common: Append workq name in log
Append workq name in workq delay detect API to identify
which workq is scheduled late. Create workq name macros for
cci and cpas to pass to workq delay detect API.

CRs-Fixed: 2994927
Change-Id: Iebc14520b918272e92b59c900de5fe17f38a2406
Signed-off-by: Sokchetra Eung <eung@codeaurora.org>
2021-07-26 17:43:37 -07:00
Gaurav Jindal
bc400e47fa msm: camera: common: Add common wait and poll interface
In current implementation, each driver call wait_for_completion_timeout
and readl_poll_timeout with own timeout values.
In case of slow environments like presil, lot of hacks are needed to
change the timeouts for each driver. It needs multiple code changes
and compilations, thus consuming time.
This commit implements a common interface to call
wait_for_completion_timeout and readl_poll_timeout.
Debug variable is also introduced to
change the timeout value. This will help to change the timeout
without compilations and changes at multiple places.

Change-Id: Iba51e0805a49ed325147a12688c2fe6619bb68e6
CRs-Fixed: 2830502
Signed-off-by: Gaurav Jindal <gjindal@codeaurora.org>
2021-03-02 14:17:09 +05:30
Karthik Jayakumar
8615106476 msm: camera: req_mgr: Update V4L2 enum names for Waipio
V4L2 driver macro VFL_TYPE_GRABBER has been renamed to VFL_TYPE_VIDEO
in linux kernel 5.8+.

CRs-Fixed: 2835738
Change-Id: Iaddec45b3532094a110e386c6462f08c36a5fd21
Signed-off-by: Karthik Jayakumar <kjayakum@codeaurora.org>
Signed-off-by: Jeyaprakash Soundrapandian <jsoundra@codeaurora.org>
Signed-off-by: Karthik Jayakumar <kjayakum@codeaurora.org>
2021-01-22 10:22:38 -08:00
Shravya Samala
41cdb719fd msm: camera: sync: Increase V4l2 queue size to 250
For MFHDR plus EIS case, both long and short exposure
input ports will be connected. Thus overall connected
ports for EIS will be 8, resulting in V4L2 queue
depth to 240.

CRs-Fixed: 2794286
Change-Id: I12a1ae4129ccb7e3b7211a22891016ecd769b949
Signed-off-by: Shravya Samala <shravyas@codeaurora.org>
2020-10-20 22:37:50 -07:00
Tejas Prajapati
4574450a12 msm: camera: common: Merge camera-kernel.3.1 changes in camera-kernel.4.0
msm: camera: cdm: Fix dangling pointer issue
msm: camera: cdm: change work record to atomic variable
msm: camera: utils: Adding device type to track device handles
msm: camera: tfe: Reduce stack footprint during bw vote
msm: camera: req_mgr: Thread switch delay detection mechanisms
msm: camera: cdm: Avoid submitting BL if FIFO is full
msm: camera: tfe: check cdm hang in the tfe config timeout
msm: camera: req_mgr: Delay detection mechanism
msm: camera: cdm: Debug info in case of cdm page fault
msm: camera: isp: Max context reduction for TFE in isp driver
msm: camera: ope: Maintain current clock value during acquire
msm: camera: req_mgr: Limit CAM_ERR log in case of no empty task
msm: camera: cdm: Decrement write-count only after Bl commit
msm: camera: isp: Added CSID recovery mechanism.

CRs-Fixed: 2792394
Change-Id: I1c7a903ae15b572acf3f6318cda7394cb6549c8d
Signed-off-by: Tejas Prajapati <tpraja@codeaurora.org>
2020-10-13 12:08:01 +05:30
Karthik Jayakumar
8f95314e74 msm: camera: sync: Fix imports for types
Fix the order of imports for to resolve cam_sync
typedef for kernel CFI.

CRs-Fixed: 2772200
Change-Id: I4e5e642e6b45412904585aaa68c0ef77fedeee2d
Signed-off-by: Karthik Jayakumar <kjayakum@codeaurora.org>
2020-09-18 16:11:21 -07:00
Alok Chauhan
baf2d520ed msm: camera: sync: Rearrange sync reason events
Rearrange sync error reason code for better code
readability.

CRs-Fixed: 2750553
Change-Id: Ia64694155921c074946167763815a87beb856b35
Signed-off-by: Alok Chauhan <alokc@codeaurora.org>
2020-08-24 13:48:40 +05:30
Alok Chauhan
1d1edb7030 msm: camera: sync: Add SYNC_V4L_EVENT_V2 support in sync driver
Add SYNC_V4L_EVENT_V2 support in sync driver. As part of this
change, added the reason code field as part of sync event header.
This failure reason code is filled by camera kernel driver and
propagate to userspace.

CRs-Fixed: 2750553
Change-Id: I206d0d51c38cfe4214814b89d241f51c1f50605b
Signed-off-by: Alok Chauhan <alokc@codeaurora.org>
2020-08-16 11:14:20 +05:30
Karthik Jayakumar
7c8204a42d msm: camera: common: Enable debugfs compile check
Guards debugfs features in camera driver to only be compiled when
CONFIG_DEBUG_FS is enabled.

CRs-Fixed: 2717236
Change-Id: I0de77741301d259cbec64e8a2e27830981b2b69d
Signed-off-by: Karthik Jayakumar <kjayakum@codeaurora.org>
2020-07-01 10:59:24 -07:00
Jigarkumar Zala
279dfebf8c msm: camera: common: Fixes the exit module code flow
Fixes exit call flow as a part of rmmod.

CRs-Fixed: 2675526
Change-Id: I47111a737cb06d9bb3d0a417a471c5c9fb545999
Signed-off-by: Jigarkumar Zala <jzala@codeaurora.org>
2020-06-09 12:08:22 -07:00
Camera Software Integration
f458d8e16a Merge "msm: camera: sync: Increase number of fences in sync" into camera-kernel.lnx.4.0 2020-05-26 13:14:29 -07:00
Pavan Kumar Chilamkurthi
74410fea6b msm: camera: sync: Add SYNC_CANCEL support in sync driver
Add SYNC_CANCEL definition and signal CANCEL instead of
ERROR in flush cases.

CRs-Fixed: 2673810
Change-Id: I1bd83e382f9b38f5f020a5af3b883083e211e3d2
Signed-off-by: Pavan Kumar Chilamkurthi <pchilamk@codeaurora.org>
2020-05-20 12:48:36 -07:00
Mukund Madhusudan Atre
bfdaaba4eb msm: camera: sync: Increase number of fences in sync
Some mfhdr usecases require more than 1024 fences because of
delayed request processing and bypass. Increase maximum number
of fences or sync objects to 2048.

CRs-Fixed: 2598592
Change-Id: If11fa2986fce0cd97c14370d29a117230134d6f5
Signed-off-by: Mukund Madhusudan Atre <matre@codeaurora.org>
2020-05-11 14:26:17 -07:00
Karthik Jayakumar
28be26b740 msm: camera: sync: Fix kbuild config checks for synx driver
External configs should be checked by using IS_REACHABLE/IS_ENABLED
macro's to check if the config option is set for the build target.

CRs-Fixed: 2584631
Change-Id: I07a0d95391a83a2264f826e2935d67686d295317
Signed-off-by: Karthik Jayakumar <kjayakum@codeaurora.org>
2020-04-22 10:43:31 -07:00
Ayush Kumar
320ae57bb9 msm: camera: core: Fix context release timing issue
When sync object is invalid and num_in_map > 1,
it will lead to context ref leak. Check sync
object first, then register sync call back.

CRs-Fixed: 2594185
Change-Id: I2d39ce3ea43bbe7bc05420b86b37fdfba4aa795a
Signed-off-by: Ayush Kumar <ayushkr@codeaurora.org>
2020-03-13 12:16:46 -07:00
Mukund Madhusudan Atre
0a649b3063 msm: camera: common: Fix failures in v4l2 unregister during error
Missing video unregister was causing list delete corruption.
Also, there were double free errors in Sync and CRM driver. Fix
v4l2 issues by adding the missing unregister calls and changing
release callback to empty, because we are freeing it during
cleanup. Improve logging during bind/unbind to better reflect what
is happening.

CRs-Fixed: 2584631
Change-Id: Idc5db655d22df54e8bdb470d29896e10f6987796
Signed-off-by: Mukund Madhusudan Atre <matre@codeaurora.org>
2020-02-28 16:02:56 -08:00