crypto: msm: add suspend/resume callback for qcedev driver

Make chanegs to add suspend/resume callback for qcedev driver, and
disable ce clocks when entering suspend and re-enable clocks in resume.

Change-Id: Ibeab1e7cb531af79ae973d7ff0d0ed2d776f6d6f
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: William Clark <wclark@codeaurora.org>
seq_file: introduce seq_setwidth() and seq_pad()

There are several users who want to know bytes written by seq_*() for
alignment purpose.  Currently they are using %n format for knowing it
because seq_*() returns 0 on success.

This patch introduces seq_setwidth() and seq_pad() for allowing them to
align without using %n format.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Joe Perches <joe@perches.com>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Git-commit: 839cc2a94cc3665bafe32203c2f095f4dd470a80)
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
CRs-fixed: 665291
Change-Id: I727d9af5ed320d717295c9d0f82c88623fb181c1
Signed-off-by: David Brown <davidb@codeaurora.org>
vsprintf: ignore %n again

This ignores %n in printf again, as was originally documented.
Implementing %n poses a greater security risk than utility, so it should
stay ignored.  To help anyone attempting to use %n, a warning will be
emitted if it is encountered.

Based on an earlier patch by Joe Perches.

Because %n was designed to write to pointers on the stack, it has been
frequently used as an attack vector when bugs are found that leak
user-controlled strings into functions that ultimately process format
strings.  While this class of bug can still be turned into an
information leak, removing %n eliminates the common method of elevating
such a bug into an arbitrary kernel memory writing primitive,
significantly reducing the danger of this class of bug.

For seq_file users that need to know the length of a written string for
padding, please see seq_setwidth() and seq_pad() instead.

Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Joe Perches <joe@perches.com>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Git-commit: 9196436ab2f713b823a2ba2024cb69f40b2f54a5
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
CRs-fixed: 665291
Change-Id: Id191acaf66e3c395df92b0a77331269b525e3cad
Signed-off-by: David Brown <davidb@codeaurora.org>
msm: kgsl: Fix memory entry leak when calling adreno_convertaddr

When adreno_convertaddr is called the memory searched in this function
may have a memory entry associated with it if this allocation belongs
to user space. A reference to this memory entry is taken when
this function is called which should be returned when the caller is
done using the memory. Made changes to return a reference to the
entry when calling this function which is returned when caller is
done using the memory.

Change-Id: I610553fd4b119d3c47cbfcec970d50046dbb2863
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
msm: kgsl: Keep track of kernel space mappings to memory

Add a counter to count number of times a memory descriptor is
mapped in the kernel and unmap the kernel mapping only when the
count reaches 0. There can be multiple threads using the kernel
mapping at the same time hence a counter is used to make sure
that we do not unmap the mapping before the last thread has
finished using it.

Change-Id: I9c53deb6af12fb1f6ed30e46b386e1cd60dafdda
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
shutup to logs. added lg exfat load hack.
qseecom: Change pr_warning message to pr_debug

Change warning message to debug message to reduce the excessive logging.
These changes are applicable only if any process is trying to interrupt
the blocking listener services.

Change-Id: Ie1c9af0daf16ef2c39e198f30b0151e2246d79e3
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
msm: camera: Fix CCI error timeout issue

CCI error timeout happens in stability testing where more than one
camera is used concurrently for different CCI masters. In that case,
2 threads configures different queues. In rare case, interrupts for
both queues can come at same time. So, the status register should be
checked independently for all bits. Otherwise the function returns
without serivicing if any of the condition check in irq handler
evaluates to TRUE.

Change-Id: Id21615521df7df0c6a7364bd3c73d3d2c1c5ad9a
Signed-off-by: Sreesudhan Ramakrish Ramkumar <srramku@codeaurora.org>
camera_v2: Don't touch CCI if daemon crashed.

If daemon crashes, refrain from writing to the CCI. This is needed
because these writes will not wait in a process crash scenario and can
potentially leave the CCI in a bad state.

Change-Id: I530cf1d0b507a9b9d2bc5889a0c81609d770a14d
Signed-off-by: Ankit Premrajka <ankitp@codeaurora.org>
arm/dt: msm8974: Change I2C clock for main and sub camera separately

Change I2C clock for main and sub camera separately

Change-Id: Ifdd8d2458f1d47d13bed978e29ffbb23757bf860
Signed-off-by: Vasko Kalanoski <vaskok@codeaurora.org>

Conflicts:

	arch/arm/boot/dts/msm8974-camera.dtsi
msm: camera: Use correct type for function return code

Using an unsigned integer to hold the signed return code
is wrong. So fix it by using the correct type to hold the
return code.

CRs-fixed: 512824
Change-Id: I389732a9af740174b26c8c43946e638a1be0d2a2
Signed-off-by: Seemanta Dutta <seemanta@codeaurora.org>
msm: camera: Implements ISPIF HW reset.

1. Add version and ISPs number properties in DT ISPIF node
  ISPIF driver needs to know HW version of ISPIF module and number of
  ISPs to which it is connected in order to execute proper reset of
  ISPIF module. For this purpose, two optional properties for these
  are added to ISPIF node. Both properties are optional - if not
  present, ISPIF driver will use default values.

2. Resets ISPIF HW
  Force hardware reset during hardware start to ensure
  all the line buffers are cleared. Reset is done once after first
  open of the module. In order to reset module clocks of CSID and ISPs
  connected to it should be enabled.

Change-Id: I6570ea45d1211c66fe5d6e80d1d2faa019415b68
Signed-off-by: Petar Sivenov <psiven@codeaurora.org>

Conflicts:

	drivers/media/platform/msm/camera_v2/ispif/msm_ispif.h
msm: camera: Non-busy polling and timeout when stopping ISPIF.

Previously a busy loop used to wait for ISPIF stop on frame
boundary. This was bad not only for busy polling, but
because if sensor has stopped streaming for some reason, the ISPIF
will never stop thus making the loop endless.
The new solution uses readl_poll_timeout macro, polling once in
millisecond for maximum of 500 milliseconds (which corresponds to
2FPS - minimum supported frame rate). If polling times out, driver
reports the error to the user space for appropriate recovery.

Change-Id: I14e9825e2c8b67bab7a2e13fa0b0ef4710456805
Signed-off-by: Petar Sivenov <psiven@codeaurora.org>
msm: camera: Fix Possible Integer overflow in ispif driver

Fix Possible Integer overflow in ispif driver in multiple places.

CRs-Fixed: 510051
Change-Id: I738c11b2d8e2ef7433bb01ba416590f7952acc2e
Signed-off-by: Lakshmi Narayana Kalavala <lkalaval@codeaurora.org>
msm: camera: ISPIF HW reset is incorrecty invoked

Currently ISPIF HW reset is implemented for msm8974 ISPIF HW module only.
However, the check for module is not correct and reset sequence is executed
for 8226 also, putting HW in bad state. The patch uses correct check
against HW version to prevent that.

Change-Id: Iff9ab2deb7c6c207d9493ce2abe56bad4d9d7f6f
Signed-off-by: Petar Sivenov <psiven@codeaurora.org>
msm: camera: Fix ispif stop frame boundary timeout issue

Previously a 500ms timeout set for stop frame boundary.
But sometimes when doing snapshot with large linecount may make
the frame rate drop to 1fps. Set the timeout to 1s to avoid camera
crash.

Change-Id: Id51fb3eb58300df20e792bdab9702af7c4e18943
Signed-off-by: Ju He <juhe@codeaurora.org>
msm: camera: Enabling all CSI clocks for ISPIF hw reset.

To perform complete ISPIF HW reset need to enable all CSI
clocks. Earlier only csi0 clock was enabled, causing problems
in reseting RDI interface. Also added change to disable clocks
before returning from hw reset if there is a timeout.

Change-Id: Ia0befc058f06596688b9310ee6c8bf4b017a13ce
Signed-off-by: Sagar Gore <csgore@codeaurora.org>
msm: camera: Fix unterminated of_device_id table

Add a NULL table entry at end for msm, ispif and
msm_generic_buf_mgr device tree match tables.

Change-Id: I05f08c77a8a25112cd17955e98018ac88b7a834c
CRs-Fixed: 582110
Signed-off-by: Hariram Purushothaman <hpurus@codeaurora.org>
msm: camera: Add defensive check in ISPIF driver

In case of error handling, call ispif release only if ispif handle
is valid. In case of mm-qcamara-daemon crash when camera is not open,
these handles are not valid. Hence it leads to kernel crash in ispif
release handler.

Change-Id: Ifb402b6907052594d12fcf9495694e6c5184af1b
Signed-off-by: Sreesudhan Ramakrish Ramkumar <srramku@codeaurora.org>
msm: camera: Add in-sensor mode support for eeprom

Add in-sensor mode calibration support for eeprom.
User are able to write back calibration settings
via ioctrl interface of the sensor.

Change-Id: I5fbfa8967885b683e498fe670a0c36d58d4b44e7
Signed-off-by: Ju He <juhe@codeaurora.org>