msm: kgsl: Add TSE performance counter to software hang detection

Our current hang detection logic covers rendering pass by checking for
shader performance counters but it does not cover the case where there
is long binning or resolve pass. For long binning pass shader is inactive
making our current hang detection logic faulty. Checking for TSE number of
input primitives covers binning and resolve passes and makes our hang
detection logic robust.

CRs-fixed: 521284
Change-Id: Ifdec4b53685903456feb367f64380119b1485408
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
qdsp6v2: Add support for suspend command for WMA decoder

WMA DSP decoder consumes more power in pause state. This is because
WMA decoder expects suspend command after it is paused. Add support
for suspend command.

Change-Id: Ifdfccb6cf6270db5b131a65f17edac40ef1a85db
CRs-Fixed: 553828
Signed-off-by: Alexy Joseph <alexyj@codeaurora.org>
power: qpnp-bms: do not change OCV to reach 0% at boot

Previously, the BMS driver changed OCV if SoC is negative at boot
time. The reasoning was that since SoC cannot be negative, the
OCV must be bad. However, this is incorrect. Sometimes it is possible
to boot below the cutoff voltage, and sometimes other factors such
as UUC can bring the SoC below 0%. For example, during temperature
testing, even with a good OCV, the UUC can bring the SoC down to below
0 by the time the high boot current pulls down the battery voltage.

Having an OCV that is erroneously high can cause many issues. For
example, if the battery charges after the erroneous OCV is set, the BMS
driver may see 100% way before charging actually stops. Also, if the
temperature changes, the BMS can easily UVLO because it thinks the
battery has more charge than it actually does.

However, still correct the OCV if SoC is only slightly negative because
that can result from a bad OCV. Otherwise, change the BMS algorithm to
just report 0 if the SoC is very negative but do not do anything permanent
to the state of charge parameters.

Change-Id: I78d4f5965d4b895c2d00c0060737359fabd4d84d
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
power: qpnp-bms: use minimum iavg upon boot if nothing is stored

Previously, the BMS driver takes fresh average curernt samples upon boot
if there is no shutdown SoC stored. However, this creates a lot of
problems when booting up at low SoCs because the IAVG is huge upon boot.
This creates an issue where UUC is pulled very high and SoC is pulled
very low.

Fix this by always using the minimal iavg if nothing is stored at
shutdown.

Change-Id: Ib7747e3b4ee2a07a952a73e613146d8766be47cd
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
msm: qdsp6v2: Buffer address for Record and playback is 32-byte aligned.

Use 32-byte aligned buffer address to ADSP for playback
and record usecases. ADSP expects 32-byte aligned buffers,
and if they are not received, ADSP will return them.
This causes failure in record and playback.

Change-Id: I220e987b94f656bab8ad28f4db8c3da176db2dfd
CRs-Fixed: 549103
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>
msm: vidc: Handle SYS_IDLE interrupt concurrency

It is possible to receive SYS_IDLE message before
Venus core sends the interrupt for that message.
This results in clocks not being disabled at all
and device will continue to drain power.

This change checks when the interrupt is received
if the venus core is still in IDLE state. If it is
then disable the clocks.

Change-Id: If2b8d778054a702eada40ac3588e2ec3a3fbd80a
CRs-fixed: 548745
Signed-off-by: Sachin Shah <sachins@codeaurora.org>
cfg80211: export regulatory_hint_user() API

This is to help the hardware configured in world
roaming mode to save power when not connected to
any AP.

CRs-Fixed: 542802
Change-Id: Ia643d0e9848dcd486832973bd6dd186edd7bd4ea
Signed-off-by: Mihir Shete <smihir@codeaurora.org>
msm_serial_hs: Fix race condition with BAM rx pipe

Crash observed due to the race condition with bam
rx pipe during sps_disconnect and sps_transfer_one
operations executed at the same time on two CPUs.

Because of this race condition rx bam descriptor
pointer becomes NULL and accessing of this pointer
leads to crash.

This patch waits for sps_transfer_one function to
complete, if it is in progress, before calling
sps_disconnect function from the set_termios.

CRs-Fixed: 534029
Change-Id: I7581062a17a3dc7ede8eb58e4d25e3b517812ab2
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
msm_serial_hs: Disable RFR line and auto RFR in set_termios

This change disables the RFR line during set_termios call so that
the remote side does not send data during this call and thus prevents
data omission and corruption.

CRs-Fixed: 557659
Change-Id: I0708168b858a42d102ad3e5ebcbd6ca33943c8b1
Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
msm_serial_hs: fix compilation warning

Add proper typecasting for the physical address type

Change-Id: Ibf46360c31f3475123e2fe35b4ae89d8afe82abf
Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
Signed-off-by: Dilip Kota <c_dkota@codeaurora.org>
cfg80211: add flags to define country IE processing rules

802.11 cards may have different country IE parsing behavioural
preferences and vendors may want to support these. These preferences
were managed by the WIPHY_FLAG_CUSTOM_REGULATORY and the
WIPHY_FLAG_STRICT_REGULATORY flags and their combination.
Instead of using this existing notation, split out the country IE
behavioural preferences to a new flag. This will allow us to add more
customizations easily and make the code more maintainable. Also add
a new flag to disable country IE hints issued by the CORE as the
first customization.

Change-Id: I66ba4a92ac0f029a115eea0a274b02db11279787
CRs-Fixed: 542802
Signed-off-by: Mihir Shete <smihir@codeaurora.org>
crypto: msm: check potential integer overflow on AEAD req length

According to the specification of AEAD, AEAD request cryptlen is
not a Fixed maximum and assoclen is also same. This could lead to
potential integer overflow, thus allocating less memory. So we
need to check potential integer overflow on AEAD request length.

Change-Id: I58a0c5e1a6e890bad30f7865e96b7db46337158c
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
power: qpnp-charger: change the kzalloc to devm_kzalloc in driver

Change the kzalloc allocations in the driver to devm_kzalloc
so that memory allocated with in probe function is automatically
freed on driver detach.

CRs-Fixed: 564898
Change-Id: I1edd08a0d08a6acbd0c1427ecc9f93c705d55f2f
Signed-off-by: Prasad Sodagudi <psodagud@codeaurora.org>
ASoC: jack: Push locking for jacks down to the jack

Currently operations on jack reporting take the CODEC mutex both to protect
the current jack status and also to protect the DAPM run which is triggered
on status updates. Since the addition of a DAPM-specific lock we no longer
need to worry about locking DAPM as it has its own finer grained lock so
create a per jack lock to take care of the jack status.

This is both cleaner where the jack isn't specifically associated with a
CODEC and clearer as it's much more obvious what the lock is protecting.

Change-Id: Ieb4b48ef9a59db812f79c093ef6e1e7068922694
CRs-Fixed: 567030
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Gopikrishnaiah Anandan <agopik@codeaurora.org>
ASoC: dapm: Change mutex lock subclass in dapm

Address the compilation issue by changing the subclass
enum in mixer/mux power update dapm functions

Change-Id: I3946cf2a5c6a0b469378d5c0583fd9c8567d4b70
CRs-Fixed: 567030
Signed-off-by: Gopikrishnaiah Anandan <agopik@codeaurora.org>
USB: msm_otg: Add support for AHB2AHB Bypass Mode in device mode

With AHB2AHB Bypass Mode, USB 2.0 Core is running using PNOC clock
and runs synchronous to PNOC which provides better throughput.
AHB2AHB Bypass mode can be enable with USB controller using
USB_AHBMODE register. It has below requirement :
- It should be enable before setting kicking USB controller
(i.e. setting R/S bit).
- PNOC should be running at MAX speed to get better throughput.
- While doing asynchronous clock reset with USB core, it is required
to disable this functionality as PNOC clock can't be disable and
re-enable as it is performed with other USB core clock.

CRs-Fixed: 550553
Change-Id: I9feac91b8885a393a13a039e9c89d63d0af2aed6
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
USB: gadget: Add support to enable streaming mode with required function

Supported different usb functions' has different throughput requirement.
USB controller supports streaming mode feature which enables double
buffering scheme on both IN and OUT endpoint, and reduces number of
NAKs for IN transfer. Hence noticeble throughput is increased with it.
Currently streaming mode is disable with USB controller. As supported
usb functions'like mtp, rndis are required to have higher throughput.
Add support which allows to enable streaming mode with usb controller
in device mode when particular function based composition is being enabled.

CRs-Fixed: 550553
Change-Id: Ibf6f3dc3f3b821647ba9beb15ed735a85c8ed586
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
ARM: dts: msm: Enable AHB2AHB By pass and streaming mode with rndis

AHB2AHB By pass and streaming mode are USB controller feature. Enable
AHB2AHB By Pass feature device mode functionality. Enable streaming
mode only when rndis function is present as part of USB composition.

CRs-Fixed: 550553
Change-Id: I978c25b9f455e267ed54a9ace8832cacb9d739e2
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
ARM: dts: msm: update LPM parameters for 8x10v1 and v2

Platform PM driver takes LPM parameters as one of the input
and decide the best idle system low power mode. Current LPM
parameters are not optimal and this can lead to more power
consumption for APPS proc active usecases. This change tunes
the low power mode parameters such as "latency",
"time overhead", "steady state power" and "energy overhead"
for 8x10v1 and 8x10v2.

CRs-fixed: 506262
Change-Id: I448863d2a77742599682b98b22171c7caf4c03d7
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
msm: rpm-regulator-smd: correct use-after-free in rpm_vreg_device_remove

Modify the rpm_vreg_device_remove() function so that the reg
pointer is not dereferenced after being freed.

Change-Id: I0bc2c38a00c5d6b783f52c0ae0f1faa31d3a1e4d
CRs-Fixed: 564463
Signed-off-by: David Collins <collinsd@codeaurora.org>