msm_serial_hs: Fix the logic for numbering the serial device

This patch fixes the way the UART nodes are enumerated when
aliases are used to identify the nodes. The atomic variable that
used to hold the next available node number was incorrectly being
incremented and if that number were to hold a number that was also
used in an alias, the probe would fail. This patch corrects it.
It also removes the atomic variable and introduces two apis to set
and get the next device number and this logic is protected by a mutex.

Change-Id: Iaee655603b527f3283e1f12d90b1220e9315b529
Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
security: selinux: Add Per-File-Encryption hooks

Add hooks for tagging/detecting Per-File-Encryption files.

Change-Id: I9d1f791b68d3552b1a508c21ff8336182e8527fa
Signed-off-by: Amir Samuelov <amirs@codeaurora.org>
defconfig: msm8974: Enable Per-File-Tagger driver

Add Per-File-Tagger (PFT) to allow Per-File-Encryption (PFE)
for msm8974 target.

Change-Id: I9c68313f86cc0e6cae040f4e60e052480115447c
Signed-off-by: Amir Samuelov <amirs@codeaurora.org>
platform: msm: add Per-File-Tagger (PFT) driver

This driver is part of the Per-File-Encryption (PFE) feature.
It allows to tag enterprise files and encrypt them
while keeping the user private files untagged and plain text.

Change-Id: I2ba8bffb2a8815991dc3994a1f94a0c52b937a25
Signed-off-by: Nir Ofry <nofry@codeaurora.org>
Signed-off-by: Amir Samuelov <amirs@codeaurora.org>
msm: kgsl: Add a timer to detect possible syncpoint deadlocks

Use timers to detect when a syncpoint stays active for too long. This
won't avoid deadlocks but it sure will make it easier to debug them.

Conflicts:
        drivers/gpu/msm/kgsl_device.h

Change-Id: Ic0dedbadde07abcc1d39563c3b141591cbf2f634
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Avoid a deadlock with the cmdbatch timer

Don't take the cmdbatch lock while deleting the cmdbatch timer.
This avoids a deadlock where del_timer_sync() waits for the timer
function which needs to take the lock.

CRs-Fixed: 644944
Change-Id: Iaeb5a26b67e96e8e748fb9ff8c26fa8b0f2c3827
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
platform: msm: pft: fix close all encrypted files

filp_close() eventually calls pft_file_close().
Simplify pft_close_opened_enc_files() and remove having mutex
in both places that cause a deadlock.

Change-Id: I0afa2d2f0806f18d430c027601fb9974855ef185
Signed-off-by: Amir Samuelov <amirs@codeaurora.org>
msm: kgsl: Clear the memstore while destroying the context

When creating a context, we add the event group much before
initializing the memstore for that context. Between these events,
its possible that events are registered and retired and the
timestamp read in retire_events() gets us the last timestamp of
the last destroyed context. This results in the processed
timestamp to be greater than the actual retired timestamp in the
memstore which is very problematic for us.

CRs-Fixed: 640550
Change-Id: I2ace6d99e2ce417ba38f6bbbeeb787478eb4e372
Signed-off-by: Shrenuj Bansal <shrenujb@codeaurora.org>
msm: kgsl: Cleanup the memory free list

Tighten up the memory free list code and remove the memory unused
debugfs file.  Outside of the cleanup the functional changes are
a) move the mutex to a spinlock for speed, and b) only return the
last entry in the list for given pid/gpu address combination.

Conflicts:
	drivers/gpu/msm/kgsl.c
	drivers/gpu/msm/kgsl.h
	drivers/gpu/msm/kgsl_debugfs.c

Change-Id: Ic0dedbad9595302e2b42de2807fa82c425d1717f
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
platform: msm: fix PFT char device major number

Dynamically allocate the major number
of the PFT character device.

Change-Id: I7877579781353203753f86a3993bc5731307db2a
Signed-off-by: Amir Samuelov <amirs@codeaurora.org>
msm-camera: Use waiteventinterruptibletimeout during sensor init.

If sensor probe fails VIDIOC_MSM_SENSOR_INIT_CFG ioctl is
blocking, so modifying wait_event_interruptible call to
wait_event_interruptible_timeout.

Change-Id: Icf6522d01e97c7a154177b88f7161cdf65c7d9eb
CRs-Fixed: 666077
Signed-off-by: Katta Santhisindhu <kattas@codeaurora.org>
msm-camera:isp: Handle interrupts with zero values

Do not process VFE interrupts if they are genernated with
zero values. Also rate limit a couple of error messages. This
will avoid unnecessary watchdog timeouts.

Change-Id: I14a433d86f207be7e00992a75e317b24ba31a84b
CRs-fixed: 675181
Signed-off-by: Venu Yeshala <vyeshala@codeaurora.org>
power: qpnp-charger: if OTG is on and DC_IN removed resume charging

In the case DC_IN is charging and an OTG device is connected
subsequently and the DC_IN charger removed, battery would be still
reported as full despite the fact that no charger is connected.

Fix this by checking if OTG is enabled in
qpnp_chg_dc_dcin_valid_irq_handler.

Change-Id: Id0f7588fdcfb86261e129ab5b73e7da587889713
CRs-Fixed: 654771
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
ASoC: DPCM: Remove redundant code introduced during framework update

There is redundant code introduced during ALSA DPCM update to add
support for compressed audio, which calls the soc_pcm_prepare()
twice. Update to remove the reduandant code.

Change-Id: I5b3b7bc005816141537434be47ec743c7c02b274
CRs-fixed: 672001
Signed-off-by: Kuirong Wang <kuirongw@codeaurora.org>
msm: thermal: Update debug/error logs to be more informative

Update/Add debug and error logs to KTM to give more informative
logs for debugging. Updated the log signature for KTM to
print the module name and function name by default.
The new log signature looks like,
msm_thermal: <FUNCTION_NAME>: <LOG_MESSAGE>

Change-Id: Ie2e03cfaf8d4df5ea8ee51334d55a9de9ca4f75e
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
Merge "msm-camera: Use waiteventinterruptibletimeout during sensor init."
Merge "msm_serial_hs: Fix the logic for numbering the serial device"
USB: ehci-msm2: Correct USB PHY RESET sequence

Existing code assumes that USB PHY is reset as part of block
reset using GCC, but that is not the case. This results in
PHY access failures later when ulpi accesses are performed,
or device enumeration fails as CORE can't access PHY.
Correct PHY reset sequence by using USB_PHY_PON bit with
USB_OTG_HS_PHY_CTRL register as per hardware programming
guidelines. Since, driver supports selection of primary or
secondary PHY with CI controller, choose PHY_CTRL_REG
accordingly. Also, debug out important USB register when
ulpi read/write timeout is seen with USB PHY.

CRs-fixed: 676343
Change-Id: Ie69e44a1134c1f4458619ae93520e722aad9e0c8
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
usb: dwc3: otg: Don't set psy type to BATTERY if no charger connected

USB driver incorrectly sets USB power supply type to BATTERY on
charger disconnect. Some userspace client may fail to work properly
by assuming that usb_psy i.e. '/sys/class/power_supply/usb' is
of type battery and subsequent reading of battery status from this
USB supply will fail. Hence, set this to POWER_SUPPLY_TYPE_UNKNOWN.

CRs-fixed: 676051
Change-Id: I0a93b607f8cb328486397fa7bc96ff2177db5a77
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
msm: mdss: enable MRPS command for short read commands

Currently, we specify the size of payload that the panel needs
to send back via the MRPS command only for DCS/Generic long
read commands. Enable the MRPS command to be sent for short
commands also based on the return length of the payload expected.

Change-Id: I634a8e5d12a8ea8d0a8118f360aef27610b21c9c
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>