Makefile: No more unsafe math optimizations
crypto: msm: update from CAF kk_3.5_rb2.9

Conflicts:
	drivers/crypto/msm/qcedev.c
qseecom: Remove support for QSEOS_VERSION_TZ13
Remove support for interfacing with TZ version 1.3.
The support for this is deprecated.

Change-Id: Ib02f56d207966879ad4a9d72bf9931889d3bc6ff
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
qseecom: Add support for loading commonlib image

Load the common library image on secure domain during
initialization of the driver.

All secure app loaded on the secure domain (TZ) is currently
refactored to not include all secure libraries. The libraries
are now a part of separate image.  This is used by all secure app.
This common lib image needs to be  loaded before any secure app
can be loaded.

This patch adds support for handling this new change based off
the QSEE version running on secure domain.  The change is to
load the common library image before loading any secure app.

Change-Id: I1c7692b612ea4c7bddbca1af07ddf32a073d70a8
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
qseecom: Add clk management

The CE clock was initialized to run at max of 100 MHz.  This
was done during the probe call. Running the CE clk at 100 MHz
always, is causing a power regression.

Fix is to enable the clk and set it to run at the nominal level
of 50 MHz.  Further more, add clk gating to ensure CE clks are only
bumped up to the max of 100 MHz when client request for high bandwidth.

CRs-Fixed: 416759
Change-Id: I311f6b29e9129a04c3ec7e2a8f893fa08a518bbd
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
qseecom: Tie performance request to client handle
When a user space client application crashes without
disabling clk vote,  there is a possibiltity of crypto
HW being left at its high bandwidth mode.  This results
in power drain.

This patch ties the performance request to the client
handle.  When any client handle is released (done when
the client handle is closed explicitly or when a client
application crashes), appropriate calls are invoked to
disable clk voting as part of closing the handle

Change-Id: I7f801d642ec53e3e5bf18a5d3a6076f973bb5175
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
qseecom: Fix memory leak when __check_if_app_exist() fail

In qseecom_start_app(), when __check_if_app_exist() returns an
error status, the function is exited  with a -EINVAL error.
This result in not de-allocating memory that was allocated for
the handle prior to calling __check_if_app_exists()

Memory that was allocted for the handle, needs to be de-allocated
before exiting with an error status when __check_if_app_exists()
return a failure.

The fix is to re-order the memory allocation of the handle after
__check_if_app_exists() goes through successfully.

Change-Id: I9dde552deb2296ab719ee815314c9da161a5d1da
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
 qseecom: Process incomplete load app command

Add support to process an INCOMPLETE status returned
when a request to load app is issued to QSEE.

Change-Id: If75a5726d3288812ddc6a1e23c5d968e8bc4ee1c
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
qseecom: Release the memory after processing INCOMPLETE_CMD

Release the memory after processing the INCOMPLETE_CMD,
as the same memory location is used for processing
INCOMPLETE_CMD

Change-Id: I9fd305b0e2f272f61b9975d02e222ff543842d7d
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
qseecom: Add clk gating

Curerntly the CE clk is enabled during the probe function and left
enabled, resulting in high power consumption when there is no crypto
operation in progress.

To reduce power, CE clk is only enabled on a need basis. Remove clk
enabling from probe function. Added support to enable/disable clk on
need basis only (on client's request) and when loading images.

Change-Id: I4d56f783903c0875c4ad305a6cebc42e8db8147f
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
qseecom: Return failure if TZ version is incorrect

Remove all QSEOS_VERSION_TZ13 related support and return
error if version is less than TZ 1.4.

Change-Id: If4768c59739186d89650b5ab1160d45218797ba0
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
qseecom: Fix race condition when loading app
When two clients issue a 'qseecom_start_app' request to load and
start the same app, check_if_app_exist() call may return an incorrect
status of the app to have been already loaded.

Fix is to protect/mutex_lock the entire region that checks
if the app is already loaded and loads the app successfully.

Change-Id: I7a23ae8c8935c7c0c2e7c3c6439742d3e8fe7b42
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
arm: Use generic idle thread allocation

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Russell King <linux@arm.linux.org.uk>
Tested-by: Frank Rowand <frank.rowand@am.sony.com>
Link: http://lkml.kernel.org/r/20120420124557.448826362@linutronix.de
ARM: 7587/1: implement optimized percpu variable access

Use the previously unused TPIDRPRW register to store percpu offsets.
TPIDRPRW is only accessible in PL1, so it can only be used in the kernel.

This replaces 2 loads with a mrc instruction for each percpu variable
access. With hackbench, the performance improvement is 1.4% on Cortex-A9
(highbank). Taking an average of 30 runs of "hackbench -l 1000" yields:

Before: 6.2191
After: 6.1348

Will Deacon reported similar delta on v6 with 11MPCore.

The asm "memory clobber" are needed here to ensure the percpu offset
gets reloaded. Testing by Will found that this would not happen in
__schedule() which is a bit of a special case as preemption is disabled
but the execution can move cores.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Acked-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
asm-generic: rwsem: ensure sem->cnt is only accessed via atomic_long_*

The asm-generic rwsem implementation directly acceses sem->cnt when
performing a __down_read_trylock operation. Whilst this is probably safe
on all architectures, we should stick to the atomic_long_* API and use
atomic_long_read instead.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Luis Cruz <ljc2491@gmail.com>
asm-generic: rwsem: de-PPCify rwsem.h

asm-generic/rwsem.h used to live under arch/powerpc. During its
liberation to common code, a few references to its former home where
preserved, in particular the definition of RWSEM_ACTIVE_MASK is
predicated on CONFIG_PPC64.

This patch updates the ifdefs and comments to architecturally neutral
versions.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Luis Cruz <ljc2491@gmail.com>
ARM: rwsem: use asm-generic rwsem implementation
asm-generic offers an atomic-add based rwsem implementation, which
can avoid the need for heavier, spinlock-based synchronisation on the
fast path.

This patch makes use of the optimised implementation for ARM CPUs.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Luis Cruz <ljc2491@gmail.com>
lcd_calibration: iP5 calibration
Signed-off-by: Sooraj <soorajj@me.com>
ARM: 7492/1: add strstr declaration for decompressors

With the generic unaligned.h, more kernel headers get pulled in including
dynamic_debug.h which needs strstr. As it is not really used, we only need
a declaration here.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
ARM: 7592/1: nommu: prevent generation of kernel unaligned memory accesses

Recent ARMv7 toolchains assume that unaligned memory accesses will not
fault and will instead be handled by the processor.

For the nommu case (without an MPU), memory will be treated as
strongly-ordered and therefore unaligned accesses may fault regardless
of the SCTLR.A setting.

This patch passes -mno-unaligned-access to GCC when compiling for nommu
targets, preventing the generation of unaligned memory access in the
kernel.

Acked-by: Nicolas Pitre <nico@linaro.org>
Tested-by: Jonathan Austin <jonathan.austin@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>