USB: diag_bridge: Fix a possible freed memory access

The platform device is freed in disconnect.  Don't access pdev
in diag_bridge_delete() which gets called after disconnect. Store
pdev->id in the corresponding driver's private structure.

CRs-Fixed: 470151
Change-Id: I2d97b508f227d6ccc3a87e03481293fa1054bbbc
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
USB: gadget: Cleanup boot-up message with default usb composition

The print message with rmnet bind and adb_bind is enabled by default.
It appears for each default composition switch. Watchdog timeout is
seen if there is stability issue on device bootup with serial console
enable. Hence move message loglevel from pr_info to pr_debug to
resolve this issue.

CRs-Fixed: 499244
Change-Id: Ife129604a1d877a4c8c6b7cd7a75a6af2ff03578
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
usb: xhci: Add support for SINGLE_STEP_SET_FEATURE test of EHSET

The Embedded High-speed Host Electrical Test (EHSET) procedure defines
the SINGLE_STEP_SET_FEATURE test for an embedded USB Host port. Upon
activating this test mode, the SETUP stage of a GetDescriptor request
is sent and followed by a delay of 15 seconds before finishing with
the DATA and STATUS stages. The idea is that this delay will give the
test operator sufficient time to configure the oscilloscope to perform
a measurement of the response time delay between the latter two stages.

This test is not implemented by the EHCI/xHCI host controller itself but
can be implemented in software. Similar to commit 75e845f64 ("usb: ehci:
Add support for SINGLE_STEP_SET_FEATURE test of EHSET"), this patch adds
such support to the xHCI driver.

CRs-fixed: 461710
Change-Id: I69aad8b068e40c13a58a66be917c185492615bfb
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Revert "USB: dwc3: ep0.c: Disable U1 and U2 low power modes"

Commit 4f1de530f4d5989022d9594413132ea175c2845e disabled U1 and
U2 low power modes to avoid USB reenumeration issue seen during
data transfers in superspeed mode. This USB reenumeration is
resolved by commit Ibd5d8180202b2f877304be3da9d976fe54df3eed
"USB: dwc3: core: Set elastic buffer mode to zero". Hence revert
the commit to reenable U1 and U2 low power modes, otherwise USB3
complaince tests fail.

CRs-Fixed: 483202
Change-Id: I87443c9dc4cac443137f64998ced9fda1e583a44
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
usb: misc: diag_bridge: use platform_device_register_simple

Simplify platform_device allocation in probe() function by
calling platform_device_register_simple(). This does the job
of both allocation as well as calling platform_device_add(),
which will reduce the number of error checks needed by one.

CRs-fixed: 534397
Change-Id: I02815b67a36dd7da0bf872ca5bd7464e290267c8
Signed-off-by: Jack Pham <jackp@codeaurora.org>
USB: gadget: f_mtp: Fix bug in receive_file work

If cable is disconnected while receive_file work is in progress,
there is a case where mtp driver returns -ECANCELLED instead of
-EIO. This results in mtp server thread not getting disconnect
notification and mtp release will not be called. Due to this, mtp
server will not start mtp connection after next USB connection.

CRs-Fixed: 590055
Change-Id: I909bebe0d22c19329cebb0a4a76424e08c82328c
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
iommu: msm: Add standalone support for secure SMMU

Add a configuration option that allows for testing of systems without
a secure environment. When turning on this option all the IOMMUs will
be programmed by the kernel regardless of whether the IOMMU is secure
or not. This allows for early testing during bringup.

Change-Id: I34fde3ba74a69a1d3fb3e5efba3e02cbcc9272d4
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
iommu: msm: Add cache maintenance for calls into TZ

The scm_call API is no longer providing implicit cache maintenance for
shared buffers. Add cache flushing for buffers heading towards TZ and
cache invalidation for buffers coming from TZ.

Change-Id: I21a60f912bf73daeaa9ade99c3af755db9665e25
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
iommu: msm: don't rely on structure format coming from TZ

The format of the secure fault register dump structure in TZ could
change over time. However, it should always adhere to the following
format (each row is 4 bytes wide):

    |-----------|
    | dump_size |
    | reg1_addr |
    | reg1_val  |
    | ...       |
    | regn_addr |
    | regn_val  |
    |-----------|

Rather than relying on the format of the structure, iterate over
the (addr, value) pairs.

Change-Id: I811c7781d6db11ef1eb07c0c1608b8db6978a758
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
iommu: msm: Only flush the exact list size

Before giving a list of memory chunks to trustzone, the list needs
to be flushed. The list is simply an array of physical addresses.
The current flush routine takes into account the size of the memory
chunk which is incorrect. The memory chunk size is not used in
calculating the list length since the list is a list of pointers.
Adjust the cache flushing routine to flush the actual size of the
list: size of each entry times the number of entries.

Change-Id: I3fbc7cb7e6c823823481b5fb205a1414e76150c9
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
iommu: msm: Refactor printing of page fault

Refactor the code that reads the registers during an IOMMU
page fault to make the code more maintainable and make it
easier to add support for new registers.

Change-Id: I6437754ee372a03344b307554e1e3a51dc810ddb
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
iommu: msm: Add printing of 64 bits of TTBR0/1

When we get a page fault we print the value of TTBR0 and
TTBR1. However, we are only printing 32 bits of this 64
bit register.

Print the full 64 bits of this register which will be
helpful when debugging page fault issues.

Change-Id: I47963ff74daab98022250c54f80b87f130885e52
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
iommu: msm: Add support for selecting remote spinlock in device tree

Certain SoCs need to aquire a remote spinlock before accessing SMMU
registers. This adds support for specifying in the device tree which
SMMUs must take the remote spinlock.

CRs-fixed: 517873
Change-Id: I28582c137d2ff4f98c982b5a12aa6fd3c9e295bc
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
msm: cpp: Attach/detach iommu device on open/close node

Change the iommu device attachement to happen on
cpp_open_node and detachment in cpp_close_node.
It decrease the power consumption when Camera is not
working.

Change-Id: I7f8d65e14af2949d9512191459d313ac4d3fff9c
Signed-off-by: Iliya Varadzhakov <ivarad@codeaurora.org>
msm: camera: Handling get buf properly when buffer queue is empty

There can be a possibility that the buffer queue is empty and
we ask for a buffer. In that case the address holding the buffer queue
structure data is not NULL but the entries of the structure are
NULL.

In such a case in addition to checking if bufq address is NULL,
when we request for a buffer, we also make sure that handle is
not NULL.

CRs-Fixed: 533384

Change-Id: I78acdc0455cd187e709722a36d9943af0444eaee
Signed-off-by: Aditya Jonnalagadda <ajonnala@codeaurora.org>
msm: camera: Exit gracefully while camera daemon crashes

Add camera daemon shutdown handling in all camera
sub devices to exit camera gracefully and it helps
to restart camera.

Change-Id: I39643a16f100b873275efe3a0c6184fe54e52830
Signed-off-by: Suresh Vankadara <svankada@codeaurora.org>
msm: camera: increase the length of property array

Increase the length of property array as the pageen property may
be longer than 12.

Change-Id: I1b85e9b9eb01af991dd628a08ca5e334c0fdbc82
Signed-off-by: Wang Wenbin <wenbinw@codeaurora.org>
msm: camera: solve twice request MCLK GPIO for camera

In 8x26 MTP/QRD design, main/front camera sensor shares
the same MCLK GPIO, the poweron may fails in some cases
Change the process to output a error message for driver
bringup state to make sure other gpio are handled properly.

Change-Id: I48ee01f32ae5d7e02d3efe8578a747f23a6d8a71
Signed-off-by: Su Liu <suliu@codeaurora.org>
msm:cpp: Fix for spurious interrupts from CPP hardware

When power up the CPP, it generates spurious interrupts
that can confuse microntroller and halt it. This fix
clears the interrupt requests from CPP before enable
Microcontroller at "Open Camera" event.

Change-Id: I3b75f2513efc30fb0f35dd086464f0b6c3a6ff9b
Signed-off-by: Iliya Varadzhakov <ivarad@codeaurora.org>
msm: camera: Fix various small issues in sensor driver

Add size check for zero the userspace arguments
before passing to kzalloc. Upper bound will be
max to uint16_t as these changes between different
sensors.

CRs-fixed: 507874
Change-Id: I13fb5740ab83c5719244d012a27d50abb26083d0
Signed-off-by: Hariram Purushothaman <hpurus@codeaurora.org>