msm: kgsl: Fix protected mode for A3XX

Prior merges of the A3XX protected mode code were incorrect. Fix
up the changes to get the branch fully updated with the changes
from msm-3.10.

Change-Id: Ic0dedbad5a0e1aea181141de1527d74b42002e3c
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Protect SMMU registers from being written by the GPU

Put the SMMU register range in protected mode to shield them from
IB1/IB2 writes from userspace.

CRs-Fixed: 599971
Change-Id: Ic0dedbad8c03fc1c54ff73221231e2440d3c34dd
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
qseecom: Validate the pointer returned by ion_import_dma_buf

Do a "IS_ERR_OR_NULL" check for the return value of
ion_import_dma_buf.

Change-Id: Iaac8b59b1f076d002430e0e6aba055bd88c83ed7
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
msm: camera: Fix various small issues in Actuator driver

Bound check and validate userspace parameters direction,
number of steps and direction sign. Also fix possible
memory leak in certain error cases.

CRs-Fixed: 511349
Change-Id: Icaa324468574494fb40f2de78e522090806744cb
Signed-off-by: Yiduo Wang <yiduow@codeaurora.org>
Merge "qseecom: Validate the pointer returned by ion_import_dma_buf"
Merge "msm: camera: Fix various small issues in Actuator driver"
Merge "msm: kgsl: Fix protected mode for A3XX"
Merge "msm: kgsl: Protect SMMU registers from being written by the GPU"
arm: mach-msm: Remove the unused rmt_storage code

The rmt_storage module is no longer used.
Remove the unused module and cleanup the makefile and kconfig.

CRs-Fixed: 549951
Change-Id: Ie9ebaa2209ea9fa0df05dc892504fcb882f00f29
Signed-off-by: Nikhilesh Reddy <reddyn@codeaurora.org>
Merge "arm: mach-msm: Remove the unused rmt_storage code"
qseecom: Add support for bus scaling

Add support for scaling bus to various level:
LOW, MEDIUM, HIGH.  Expose IOCTL to user space
clients to enable selecting a specific bus bandwidth
setting.

Change-Id: I8ef94b84464e86d3ab1e4c78c502e99ef2e0ec9a
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
qseecom: Add basic suspend resume functionality

If ce clock is not disabled in suspend state, memory may be corrupted and
device can not wake up. Thus,if clock is enabled, we disable it in qseecom
suspend function and re-enable it again in resume function.

Change-Id: I70349ad3070c340add1f3fbe392a4bec2b8af9bf
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
(cherry picked from commit 18187de875c8bc6019469562ca843c09421688b8)
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
qseecom: update clock ref count when bus scaling timer is running

when there are multiple enable/dislable clock operations, ce clock
ref count is not updated correctly when the timer to disable clock
is running. Specifically, the ref count is not decreased when the
old operation is finished and then we reset clock for the new enable
clock.Thus, the ce clock is not disabled after all operation are
completed due to incorrect clk ref count. We make a change to
decrease clock reference count before reset timer, when the timer
is running, then clock is disabled when all ce clock operations
finish and the timer expires.

Change-Id: If71fd526acd9a74bf21731841fae0b98e76a89b5
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
(cherry picked from commit 6f31c319f83ebf420e1bf54ced989131f6199614)
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
qseecom: change qseecom bus scaling timer operation

To ensure ce clock is not disabled before tz operation is completed,
we delete the old timer when tz side operation begins,and then add
a new timer after tz operation is completed.

Change-Id: I4bc8fe3d9305cc1ed5db8e6490832fcc791ef3d7
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
qseecom: Ensure CE clk is managed properly

Clk access ref count is not updated correctly when issuing a
request that requires enabling clk. this results in leaving the
clk on during regular operation resulting in failure of the
device to go into low power mode .

Change-Id: I80232433ff09277fe83d78142dcec75e7493d96e
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
ARM: dts: msm: add support for qseecom bus scaling for 8074, 8226 and 8610

To support qseecom bus scaling, ab & ib values are changed to set four
bandwidth levels: "INACTIVE, LOW, MEDIUM and HIGH" with corresponding
bus bandwidth of {0M, 0M, 150M, 492M}; and the flag of support-bus-scaling
is also set for apq8074, msm8226 and 8610.

Change-Id: I15350619143094d280ebc1e3717418285063448d
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
(cherry picked from commit 891cd015033a238fe2d40bab9ce6461820aef889)
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
qseecom: change bus scale up mode in resume function

The maximum bus bandwidth mode supported by bus bandwidth setting
function is 3 (i.e., HIGH),then to scale up bus bandwidth based on
cumulative mode may prevent us from updating the bus bandwidth
correctly when cumulative mode is greater than 3 (which is the case
if there are concurrent applications running). Thus, we made a
change to scale up bus bandwidth mode to at most 3 in qseecom
resume function.

Change-Id: I3ec6eedace2fa2ea7de519df307c3ff9b193c910
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
(cherry picked from commit 2cb7f49a182a40ff4405320a2c31da41a2948c05)
qseecom: Replace kzalloc with ion_alloc

Allocate memory to common lib through kzalloc issues no page errors due to
higher order memory request.So allocate the memory from the heap specially
dedicated to QSEECOM.

Change-Id: Ice4a609d6791ce5adc84b9882231def31674f461
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
(cherry picked from commit 210492cbaf1ac1ec3a1c853be73940f9195884d7)
qseecom: Fix failure to load cmnlib image

Set the physical address field of load_req data struct
correctly using the right ion_phys API.Without this,
secure domain is not able to address/dereference memory
where cmnlib image resides.

Change-Id: I9f75e78227e4eee89fff9ad8b19701ff08e5d90a
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
(cherry picked from commit 7aaf09f5808e13b1707c5b68fadc796a09ccb6c2)
qseecom: Check the return value of "ion_phys"

Check for return value of "ion_phys" and handle
the error case appropriately.

Change-Id: Ib4f24af24de2b2553ed91479f46b2f79e0be0446
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
(cherry picked from commit 514054ce886a8c5550d87e05b1b98da79a1a6ab1)