driver core: Add iommu_group tracking to struct device

IOMMU groups allow IOMMU drivers to represent DMA visibility
and isolation of devices.  Multiple devices may be grouped
together for the purposes of DMA.  Placing a pointer on
struct device enable easy access for things like streaming
DMA programming and drivers like VFIO.

Change-Id: I0a92a94aea0ac699676914a033477243a70dd0b0
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
msm: camera: Send VFE_REG_UPDATE_CMD while enabling liveshot.

Sometimes, especially with YUV sensors, snapshot frame is
not received in time when liveshot is triggered.

CRs-Fixed: 501466
Change-Id: Ib92929ebe82eadb92492d899b2077832fab02842

Signed-off-by: Sai Kumar Sanagavarapu <ssanagav@codeaurora.org>
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
msm: camera: Handle locks properly

Update camera drivers to unlock mutex while returning
the function in caseof errors.

Change-Id: Iaac7ae3a0337445ee072c10c69080c24ed6e512c
Signed-off-by: satyavaraprasad yerramsetti <satyav@codeaurora.org>
msm: camera: Enable use of AVTimer, Rotation and Crop for VT

The changes expose parameters for the application to set
the use of AVTimer for TimeStamp information and rotation
angle for video stream along with crop for VT use case.

CRs-fixed: 498762
Change-Id: Icf883f53513ab084f0970e84bbccd8bb9ec64737
Signed-off-by: Alok Kediya <kediya@codeaurora.org>
msm: camera: Recovery through camif stop and overall reset.

Add recovery mechanism in case of bus overflow. As part of the
recovery, stop the CAMIF, reset the VFE and reload the AXI
write masters and then restore the IRQ settings to VFE.

Change-Id: Iba6576777f05135cc13c1ee0c9db764d35c7282a
Signed-off-by: Kevin Chan <ktchan@codeaurora.org>
Signed-off-by: Praveen Ac <praveenac@codeaurora.org>
Signed-off-by: Kiran Kumar H N <hurlisal@codeaurora.org>
msm: camera: Add recovery routine for live snapshot.

During live snapshot, if bus overflow happen, recovery routine will
kick in and reset the hardware. At this point, the live snapshot
might not be completed and application will continue to wait for
the snapshot to complete. This change adds the logic to restart
the snapshot process after recovery is completed.

Change-Id: I9ba0a27ce53eb008a4af8d65a3f37a7cded03559
Signed-off-by: Kevin Chan <ktchan@codeaurora.org>
Signed-off-by: Praveen Ac <praveenac@codeaurora.org>
Signed-off-by: Kiran Kumar H N <hurlisal@codeaurora.org>
msm: camera: Move halt logic in case of overflow to ISR.

Move the halt logic which includes AXI HALT and CAMIF Disable
to ISR to start the recovery mechanism sooner.
Add some protection in case of liveshot.

Change-Id: I28ec462474524c0064cd7ecd4f77801cd494e514
Signed-off-by: Kevin Chan <ktchan@codeaurora.org>
Signed-off-by: Praveen Ac <praveenac@codeaurora.org>
Signed-off-by: Kiran Kumar H N <hurlisal@codeaurora.org>
msm: camera: Add mechanism to stop overflow recovery and handle IOMMU pagefault

CRs-Fixed: 491200

Change-Id: I1e498d87853c4dee8b1821595aad1958cb5341d3
Signed-off-by: Roja Rani Yarubandi <rojay@codeaurora.org>
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
 msm: camera: Handle ioctls issued on vfe subdevice properly

In case vfebase is not set by the time ioctl is issued on the
vfe subdevice, it might lead to kernel panic if the arguments
of the ioctl are not set properly. Now handling these ioctls
before checking for vfebase will remove the possibility of a
kernel panic.

CRs-Fixed: 502383
Change-Id: Ib36db26c58acbaef14f1052aed71b7c3701e93a3
Signed-off-by: Aditya Jonnalagadda <ajonnala@codeaurora.org>
msm: camera: Null check added at iommu_attach_device

In case domain has not been initialized before, added a null
check for it inorder to avoid a potential kernel panic.

CRs-Fixed: 502383
Change-Id: I43a173e96415bdaea0968ce6ca37e6c1ee75d666
Signed-off-by: Aditya Jonnalagadda <ajonnala@codeaurora.org>
msm: camera: Enable frame based AXI WM for RDI0

Frame based AXI WM configuration for RDI0 path
Also populate sensor type in the device info structure.

Change-Id: Ib6d65cd8cb1e4655c4f67903a8f329962512115e
Signed-off-by: Sai Kumar Sanagavarapu <ssanagav@codeaurora.org>
msm: camera: Enable CAMIF SOF in case of non dual camera usecase.

When Dual camera usecase is enabled, the ISPIF PIX SOF is enabled
by default to synchronize with the RDI interfaces.
But in non dual camera usecases, use CAMIF SOF IRQ to increment
the frame IDs being embedded inside the output frames.
Sometimes the SOF IRQs of frame 'n' is clubbed along with the
Output IRQs of the frame 'n-1'. Thus although the output IRQs
are supposed for frame 'n-1' it results in a frame ID of 'n' which
will cause incorrect behaviour downstream. Correct this behaviour
by checking the SOF and Output status bits in the IRQ Mask and
adjust the frame ID accordingly.

CRs-Fixed: 481721
Change-Id: If7a9db2337febf10e89d44c58b9d980d874c69b6
Signed-off-by: Sai Kumar Sanagavarapu <ssanagav@codeaurora.org>
Signed-off-by: Kiran Kumar H N <hurlisal@codeaurora.org>
msm: camera: ABCC feature porting in kernel space

Reference - https://review-android.quicinc.com/#/c/141518/
CRs-fixed: 502029

Change-Id: I40ee7349f26cc9d040a9b36cf8cf30020991c381
Signed-off-by: Alok Kediya <kediya@codeaurora.org>
msm: camera: Return from DQBUF ioctl in case of error.

Incase the vb2_dqbuf call returns error, we are continuing
ahead and trying to access the fields of the vb2 buffer which
may not be initialized yet. Avoid this by checking the
return value of vb2_dqbuf and return immediately in case of
errors.

Change-Id: I33036fe9b3bd7ce2b28e9cd6e4cd5f293425be95
CRs-Fixed: 495635
Signed-off-by: Kiran Kumar H N <hurlisal@codeaurora.org>
msm:camera: Fix signedness issue in hw_exec_cmds

  In hw_exec_cmds()second argument m_cmds should be
  of type unsigned interger

Change-Id: Idad2eb1a59481f3fe9f90221ff2061e8dae57013
CRs-Fixed: 493314
Signed-off-by: Monika Alekhya <malekh@codeaurora.org>
msm: camera: Handle incorrect parameter properly

By this change, when incorrect size is passed, we
return back rather than proceeding forward.

CRs-Fixed: 477936

Change-Id: I8f3ea3c7680a468e36ed0cdb026e95cc29e3f4be
Signed-off-by: Aditya Jonnalagadda <ajonnala@codeaurora.org>
msm: gemini: Reset the core incase of overflow error

Reset the gemini core for the overflow usecases.

Change-Id: I64b4283806d67615b2963e0d6a42f04a40d6a892
Signed-off-by: Sunid Wilson <sunidw@codeaurora.org>
msm: gemini: Fix the size argument of hw_region_dump function.

The size argument for the msm_gemini_hw_region_dump function is
signed which is not correct, since the function operates on
it as if it is unsigned. Change this to unsigned parameter.

Change-Id: Icea70ad20b010651047b911e7b6ae57889e610e7
Signed-off-by: Kiran Kumar H N <hurlisal@codeaurora.org>
msm:camera: Increase the v4l2 event queue length

Observed missing of v4l2 events to userspace media controller,
this can happen if media controller is blocked in post processing
the frames. Hence increasing the queue length gives enough time
to accomodate all the events without being overwritten with
newer events.

Change-Id: Ic3b5fd29df8c6384e83312b9c9ffd788bdf60951
Signed-off-by: Lakshmi Narayana Kalavala <lkalaval@codeaurora.org>
 msm:camera: Fix overflow issue in ioctl_hw_cmds function

    'len' is of type signed int 32bit,but the assigned value
    may exceed maximum unsigned int32 range.Add overflow check
    and graceful exit if 'm'exceeds UINT32_MAX value.

Change-Id: I38f0d10a0cb44d08d0054f91044fc891c246ebd1
CRs-Fixed: 493314
Signed-off-by: Monika Alekhya <malekh@codeaurora.org>
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>