cpufreq : Fix crash input event handler on governor switch

When an input event and CPU1 hotplug occurs at the same
time, a race condition can happen between cpufreq and
cpu hotplug resulting in a kernel panic.
When a hotplug operation is underway on CPU1,
__cpufreq_remove_dev is called. __cpufreq_remove_dev gets
the lock, proceeds to free the policy info of the current
governor and calls the ondemand governor with a STOP event.
If an input event occurs around the same time, it waits
for __cpufreq_remove_dev to release the lock. Meanwhile,
the ondemand governor clears some of its settings, but
fails to clear its local current policy. As soon as the
input event handler acquires the lock, it now uses the
invalid ondemand current policy handle to make frequency
changes. This results in a kernel panic.

Skip making frequency changes if this condition happens.

CRs-fixed: 327622,319348
Signed-off-by: Anitha Anand <anithas@codeaurora.org>
(cherry picked from commit 3dd6509401d44d16231002fbe8674f4e5f29a1a2)

Change-Id: I37a3d97bc74c828669e71af52d8f4012f108e917
Signed-off-by: Swetha Basineni <sbasin@codeaurora.org>
msm: dsps: read from sleep clock in DSPS_IOCTL_READ_SLOW_TIMER

The DSPS timestamps are synchronized to the MPM clock, so change the
READ_SLOW_TIMER ioctl to return the MSM sleep clock ticks rather than
read the DSPS timer directly.

(cherry picked from commit 341446bea2e4c9c82bdc5e7f6e9d92f8d4c817cf)

Change-Id: Ib09e5c8d421e7c1df6dc952e783b3c14b6d722ca
Acked-By: John Larkin <jlarkin@qualcomm.com>
Signed-off-by: Jeff Ohlstein <johlstei@codeaurora.org>
msm: timer: add api to read sleep counter

The DSPS driver uses the sleep counter to synchronize itself to the MPM
time. The sensors processor synchronizes itself to this as well.

(cherry picked from commit ecefdc0a38448ffe37342ebf6b3ee453ce1ee416)

Change-Id: If12b55bbf5f50c007d319cfb3796191b3e9a2a4a
Signed-off-by: Jeff Ohlstein <johlstei@codeaurora.org>
fix build
msm: msm_bus: Fix aggregation of clocks in active-only context

Clock rates in active-only context are being compared with
clocks in active and sleep (dual) context. This prevents the
reduction in clock rates even though the requests have been
withdrawn. The issue is observed when graphics 3D core
requests for maximum bandwidth on EBI right before apps processor
requests for turbo frequencies for EBI.

Fix this by avoiding the aggregation between active-only and
dual context clock rates.

(cherry picked from commit 2235a405d803fd372c7c343cac10de6105462e03)

Change-Id: Ifb452ff67014b4cd2e7d0d5762e0906e931ba4e4
Signed-off-by: Gagan Mac<gmac@codeaurora.org>
clk: add helper functions clk_prepare_enable and clk_disable_unprepare

It's for migrating to generic clk framework API.

The helper functions  help cases clk_enable/clk_disable is used
in non-atomic context.
For example, Call clk_enable in probe and clk_disable in remove.

Change-Id: If4023d1856ecc07f332f072c1b4831ad3cba82de
Signed-off-by: Richard Zhao <richard.zhao@linaro.org>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Russell King <linux@arm.linux.org.uk>
Acked-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
arm: irq: Remove check for hardirq mask size

SPARSE_IRQ gives the freedom to use high, discontiguous IRQ
numbers at very low memory costs. But even with SPARSE_IRQ, the
highest interrupt number of the system is limited by NR_IRQS,
since NR_IRQS defines the number of IRQ_BITMAP_BITS.

NR_IRQS is currently limited to 1024 on ARM, as of the following
commit:

commit 5a5fb7dbe88dd57dc2bef0f3be9da991e789612d
Author: Steven Rostedt <srostedt@redhat.com>
Date:   Thu Feb 12 10:53:37 2009 -0500

    preempt-count: force hardirq-count to max of 10

This implies that architectures having more than 1024 interrupts
cannot manage. Let's remove the constraint on nesting level,
since as the commit above mentions, we're probably bound by stack
size at that point, anyways.

Change-Id: Ic4af331874a8fda66e2c94ef80ad73314badd74d
Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
msm: IDLE_TIMER wakes up waiting processes

The msm_idle_stats_update_event() function is now a public function.
In case of IDLE_TIMER expiry, kgsl calls this function to immediately
wake up waiting processes.

Change-Id: Ia259d10e08deea71db047d8091cc97066fba3c1c
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
msm_serial_hs_lite: set uart clock rate to zero after disabling clock

Change-Id: Ib6413cae2ee32cd5e6c049f4a22ee24b808cb2fa
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
msm: smd: Clear Apps SMSM_RESET for Subsytem Restart

The restart code expects the Apps to clear the SMSM_RESET
bit in AFTER_SHUTDOWN to prevent duplicate restart
notifications for forced restarts.

CRs-Fixed: 329757
Change-Id: Ifd3de0746253947b078c8d9627f075be312c0def
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
v4l: add control definitions for codec devices

Add control definitions and documentation for controls
specific to codec devices.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Change-Id: I94e1be196120988cfee2420ba6bd342eece1f481
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
tick-sched: change the cpu that updates rq_stats

It can happen that the scheduler tick stops on cpu 0 but keeps
running on some other cpu. Make the cpu in-charge of updating
the jiffies also update the rq_stats.

Change-Id: Idb1a8132bd96500c68c516b4a99663965cec28e1
Signed-off-by: Amar Singhal <asinghal@codeaurora.org>
arm: irq: Correct set_irq_flags check for invalid irq

The current check compares against nr_irqs, which is assigned as
machine_desc->nr_irqs if defined. Per the usage in
arch_probe_nr_irqs(), nr_irqs is interpreted to mean the
preallocated irqs when used in a SPARSE_IRQ configuration. So
it's entirely possible that a chip driver will set its IRQ flags
for a IRQ number greater than nr_irqs.

NR_IRQS is still the largest IRQ any system can have, so let's
check for that instead.

Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
msm: pil-dsps: Assert peripheral reset in addition to proc reset

Failure to assert the peripheral reset in addition to the
processor reset causes state to be maintained across reboots.
Assert the peripheral reset to fully reset the dsps.

Change-Id: I737271a9ffa42253894f83dfd856fb3419ef8275
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
msm: dsps: add proper delay for DSPS to be ready

Change-Id: I3fe2ce13c899c5e602c474c069f5beee1587394f
Signed-off-by: Vidyakumar Athota <vathot@codeaurora.org>
Signed-off-by: Praveena Pachipulusu <pveena@codeaurora.org>
msm_fb: Fixing Aspect Ratio

Non-standard resolution, like 531*398, is treated as 720*480 instead of
640*480 , as it has non 4:3 aspect ratio.Chanding aspect ration calculation
to be in a range , rather than absolute.

CRs-Fixed: 320022
Change-Id: Ie3b1ebefe48ef648720f06336239af907c3468d2
Signed-off-by: Abhishek Kharbanda <akharban@codeaurora.org>
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
msm: scm-pas: Request bandwidth for auth_and_reset()

The secure processor doesn't have the capability to request
bandwidth itself. Add bandwidth requests for it so that
performance doesn't suffer.

The bus driver is lacking a couple features:

 (1) No control of daytona fabric

 (2) No endpoints for the crypto engine on the daytona fabric

Solve (1) with a clock voter on daytona fabric and (2) with a
bandwidth request for SPS which lives on the daytona fabric.

Change-Id: Ib6ca67043bc3b97dbbecb1b571c4d33721fae11c
CRs-Fixed: 319454
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
cfg80211/nl80211: Send AssocReq IEs to user space in AP mode

When user space SME/MLME (e.g., hostapd) is not used in AP mode, the
IEs from the (Re)Association Request frame that was processed in
firmware need to be made available for user space (e.g., RSN IE for
hostapd). Allow this to be done with cfg80211_new_sta().

Add a comment pointing out the use of enum station_info_flags for
all new struct station_info fields. In addition, memset the sinfo
buffer to zero before use on all paths in the current tree to avoid
leaving uninitialized pointers in the data.

Change-Id: Ia2220d58ee81c1b7ca905cfc8eb55b6a84779d38
Signed-off-by: Deepthi Gowri <deepthi@codeaurora.org>
arm: Init SPARSEMEM section for removed memory

If a memblock has been removed with memblock_remove, it will
be skipped in 'for_each_memblock'. If a SPARSEMEM section
is completely enclosed within this removed memblock,
memory_present will never be called and the section will
never be initialized. This will cause garbage dereferences
later on.

This change loops on the memory banks, instead of the memblocks.
Memory banks always exist, regardless of memblock_remove and
ensure that all SPARSEMEM sections will be initialized, even
if they are removed later.

Change-Id: I1b7b0418a7e752f5bf69c3ec2ea8ea17e8ecfec5
Signed-off-by: Jack Cheung <jackc@codeaurora.org>