cpufreq: ondemand: Fix update_sampling_rate race with hotplug

update_sampling_rate has a for loop which goes through each
online cpu and possibly queue up the ondemand work for them.
But while doing this it doesnt take any hotplug lock which
could potentially cause a race condition where ondemand work
is queued after the hotplug code (which sets the policy to NULL)
in the governor has cancelled any pending work. This could cause
a crash while trying to access the NULL policy in dbs_check_cpu.

Protecting the for_each_online_cpu loop with get_online_cpus()
and put_online_cpus().

Change-Id: Ia3f43ca7e4bed542834ab03ca1191d728f13311c
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
sched: Unthrottle rt runqueues in __disable_runtime()

migrate_tasks() uses _pick_next_task_rt() to get tasks from the
real-time runqueues to be migrated. When rt_rq is throttled
_pick_next_task_rt() won't return anything, in which case
migrate_tasks() can't move all threads over and gets stuck in an
infinite loop.

Instead unthrottle rt runqueues before migrating tasks.

Additionally: move unthrottle_offline_cfs_rqs() to rq_offline_fair()

Change-Id: If8a4a399f1a14b7f4789c1b205dcfadbde555214
Signed-off-by: Peter Boonstoppel <pboonstoppel@nvidia.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Turner <pjt@google.com>
Link: http://lkml.kernel.org/r/5FBF8E85CA34454794F0F7ECBA79798F379D3648B7@HQMAIL04.nvidia.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Git-commit: a4c96ae319b8047f62dedbe1eac79e321c185749
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Syed Rameez Mustafa <rameezmustafa@codeaurora.org>
wcnss: Synchronize request_firmware() with suspend

Register for PM notifiers to avoid calling into request_firmware()
when the suspend/resume is in progress. Soon after a subsystem restart,
device can go to suspend mode, and wakeup when WCNSS opens the SMD
port to start NV download. So make sure that userspace is fully thawed
before starting NV download.

Change-Id: Iec0b742fd4c4bc8390ee69ca880ca17ccbb3f124
CRs-Fixed: 529272
Signed-off-by: Sameer Thalappil <sameert@codeaurora.org>
net: sock: validate data_len before allocating skb in sock_alloc_send_pskb()

We need to validate the number of pages consumed by data_len, otherwise frags
array could be overflowed by userspace. So this patch validate data_len and
return -EMSGSIZE when data_len may occupies more frags than MAX_SKB_FRAGS.

Change-Id: I2a7d6bb93e4fa04efc6f576d22277f43b11257d3
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Git-commit: cc9b17ad29ecaa20bfe426a8d4dbfb94b13ff1cc
Git-repo: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
rtnetlink: fix error return code in rtnl_link_fill()

Fix to return a negative error code from the error handling case
instead of 0(possible overwrite to 0 by ops->fill_xstats call),
as returned elsewhere in this function.

Change-Id: Ia985101d5b14755297c8fb62d0133e3da20c66e3
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
Git-commit: fcca143d696092110ae1e361866576804fe887f3
Git-repo: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
rtnetlink: Call nlmsg_parse() with correct header length

Change-Id: I85f2ac4161ed4a6f997be62e80ab96942d8e1894
Signed-off-by: Michael Riesch <michael.riesch@omicron.at>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Benc <jbenc@redhat.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: linux-kernel@vger.kernel.org
Acked-by: Mark Rustad <mark.d.rustad@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Git-commit: 88c5b5ce5cb57af6ca2a7cf4d5715fa320448ff9
Git-repo: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
msm: thermal: Set vdd restriction initialize level to -1

Currently the init level is set to 0(enabled), but at this point of
time, the actual voltage is not being set yet. If the device boots
up in low temp, it will try to set level to 0(enabled) again. Since
it will check the level against with previous level which is also
0(means enabled), it will not set the actual voltage/frequency for
the rails.

Set the init level to -1(disabled), so that when device defaults to
enable vdd restriction, it will actually set the voltage.

Change-Id: I9997245953c9947889a813901032c3df8c737ad3
Signed-off-by: Jennifer Liu <chihning@codeaurora.org>
msm: camera: Release session lock mutex in error case

Unlock the session lock mutex in the ack cmd delete
sequence if fails to find a cmd ack queue.

Change-Id: Ib08c4a259acbea4624fd91f4fb468de37c353b7d
Signed-off-by: Hariram Purushothaman <hpurus@codeaurora.org>
Merge "msm: camera: Release session lock mutex in error case"
power: qpnp-charger: Fix corner cases for soc based resume

Currently SoC based resume only triggers when SoC is queried. This
does not happen when the charger is inserted/removed, so sometimes
when the battery is almost full and the charger is inserted, charging
will not resume even though SoC is below the set resume limit. Fix
this by scheduling work to read the SoC when usb is inserted.

Also, SoC based resume only checks for battery status to be full.
However if charging never finished, there can be a case where battery
status reads discharging but the charger is connected. In this case
SoC based resume should restart charging. Fix this by checking for
battery status to be not charging instead of full.

Change-Id: I74d318ac4a9b45f0de31c885319c38f6e2732060
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
ARM: dts: msm: move led_flash0 device node for msm8974.

The device qcom,camera-led-flash (led_flash0) is only used on
msm8974 boards mtp and fluid.  Therefore, move the specification
of this device to camera files that are specific to msm8974-mtp
and msm8974-fluid.

Change-Id: I8813f58546752ae489f46b8d6533e495a3be8db4
Signed-off-by: David Collins <collinsd@codeaurora.org>
Signed-off-by: Sunil Joseph <jsunil@codeaurora.org>
msm: camera: Implement reading SOC_HW_VER reg

Add implementation to support reading
SOC_HW_VERSION registers for vfe needs.
Add tcsr_soc_hw_version register address
in dts file. Both 8974 and 8x26 family
support that register. 8x10 does not
support it. VFE need this register to
determine difference between 2.1 and 2.2
hardware version. VFE version remain
the same for both hardwares.

Change-Id: I096bcc16f150a2b2f50c5f60ec0ab0ec957d0cdf
Signed-off-by: Slavi Dimitrov <slavid@codeaurora.org>
Signed-off-by: Sunil Joseph <jsunil@codeaurora.org>
msm: camera: add gc0339 driver for msm8x10 qrd board

Add driver for gc0339 camera sensor.
It's a Galaxycore .3 MP Bayer Sensor.
Supports up to 2 mipi lanes.
Preview and snapshot config is 640*480 at 30 fps.
Not support auto focus.

Change-Id: I0af52da0c685e198289acc5ab6c3d21e2f935e7e
Signed-off-by: Li Sun <sunli@codeaurora.org>
Signed-off-by: Sunil Joseph <jsunil@codeaurora.org>
msm: camera: enable gc0339 driver for msm8x12 qrd board

Since gc0339 has no reset pin in msm8x12 qrd board,
before operate on the gpio, a nonzero check is necessary.

Change-Id: Ic87698a1369056b2ce72c0f20fb2dca0ed1ef7a9
Signed-off-by: Li Sun <sunli@codeaurora.org>
Signed-off-by: Sunil Joseph <jsunil@codeaurora.org>
msm: camera: Add input interface in SOF event

For Start of frame event send to userspace,
we need to know whether it is coming from the
pixel interface or the raw interface.
This change add the code to populate the
interface information.

Change-Id: Ie81473d9797e4514394fb89c39f576396e8ff478
Signed-off-by: Peter Liu <pingchie@codeaurora.org>
Signed-off-by: Sunil Joseph <jsunil@codeaurora.org>
msm: camera2: Validate frame during timeout in cpp driver

During long stability stress runs, invalid frames are encountered
in timeout processing. When frame acknowledgement is delayed by
firmware due to various reasons the timeout handler could hit
frame that are already processed. Hence adding NULL condition
check to avoid invalid frame access.

Change-Id: Icaa5e630d5190a7bf0a4e07a95d08e116cb304db
Signed-off-by: Rajakumar Govindaram <rajakuma@codeaurora.org>
Signed-off-by: Sunil Joseph <jsunil@codeaurora.org>
msm: camera: Update CPP driver for new hardware version

Update CPP driver for 0x10010001 version which is used in 8974 v3
pro.

Change-Id: Iefb7d4fa852a3548e866f460994a0c1744578e36
Signed-off-by: Sreesudhan Ramakrish Ramkumar <srramku@codeaurora.org>
Signed-off-by: Sunil Joseph <jsunil@codeaurora.org>
msm: camera: add error check in gc0339 config function

There will be some invalid ioctl arguments passed in from
userspace. Add error check to shield them.

Change-Id: Id24e4f6096a2d600215344e6f3601ef9544ee9b2
Signed-off-by: Li Sun <sunli@codeaurora.org>
Signed-off-by: Sunil Joseph <jsunil@codeaurora.org>
msm: camera: Fix VFE IOMMU page faults

To avoid VFE IOMMU page faults in case of
vfe write masters bus overflows, enable
bus overflow override flag to allow
non overflowing write masters to continue
thier operation.

Change-Id: I9452acac2b70786217b3d65029e1b68cee2fdf3e
Signed-off-by: Suresh Vankadara <svankada@codeaurora.org>
Signed-off-by: Sunil Joseph <jsunil@codeaurora.org>
msm: camera: Use correct type for function return code

Using an unsigned integer to hold the signed return code
is wrong. So fix it by using the correct type to hold the
return code.

CRs-fixed: 512824
Change-Id: I389732a9af740174b26c8c43946e638a1be0d2a2
Signed-off-by: Seemanta Dutta <seemanta@codeaurora.org>
Signed-off-by: Sunil Joseph <jsunil@codeaurora.org>