cpufreq: interactive: Remove unnecessary cpu_online() check

Cpufreq no longer calls governor callback for offlined cpus. i.e. All
policy->cpus are guaranteed to be online. Hence we don't need explicit check to
see if cpu is online or not.

Change-Id: I9ad85ea4addd5b4a40952e59ed730dd15e328690
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
qcom-cpufreq: Move the enabling of the CPU/L2 clocks to CPU_STARTING

It is a requirement of PLLs in MSM SoCs that the PLL power
supplies be enabled while the PLL is running. If the PLL is
locked and outputs enabled, turning off the regulator(s)
supplying the PLL will cause the PLL to enter an unpredictable
state.

Now in the CPU_UP_PREPARE notifier, the CPU clocks are prepared
and enabled, causing the source HFPLLs to also turn on. Note
that the CPU isn't clocked yet. It is possible that execution is
pre-empted and the CPU running the notifier enters power
collapse. If all other CPUs also enter power collapse, then it
is possible for an RPM notification to go out, allowing the RPM
to transition the Apps processor to its sleep set. This can
result in the HFPLL supplies being turned off while the HFPLL is
running, violating the requirement mentioned above. Once the CPU
is unclamped, the CPU is effectively unclocked, due to the HFPLL
being in an unknown state.

There is a check that is enabled in the PM code's CPU_UP_PREPARE
notifier callback. This check ensures that the problematic RPM
notification cannot occur until the core that is being brought
online also enters power collapse. However, there is no ordering
guarantee between that PM's hotplug notifier callback's execution
and the cpufreq hotplug notifier callback's execution. This
ordering depends on program link order, which is unreliable.

It is necessary to ensure that once the HFPLL is enabled, the
RPM cannot transition apps to its sleep set. Move the enabling
of the CPU clocks to the CPU_STARTING notifier, which runs on
the CPU bring brought online. The CPU_STARTING notifier is
guaranteed to run after the CPU_UP_PREPARE notifier, which
implies that the aforementioned do-not-notify-rpm check is
executed *before* the HFPLL is enabled. Therefore even if all
cores enter power collapse after the HFPLL is enabled, the
HFPLL supplies are guaranteed to stay on, or the CPU clock
is switched to the safe source and the HFPLL is turned off.

CRs-Fixed: 622738
Change-Id: I136841405806c07e755919859e649ded0c719abb
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
Revert dubious scheduler changes.

 * Rolled this series back on other devices as well. It's causing bad
   jank all over the system under a lot of use cases.

Revert "sched: reinitialize rq->next_balance when a CPU is hot-added"

This reverts commit 7c588520b259bf0a342058aa4a9e5ea677522a0d.

Revert "nohz: stat: Fix CPU idle time accounting"

This reverts commit 9446ae3986469a19a603344862e856d54f6df15b.

Revert "sched: remove redundant update_runtime notifier"

This reverts commit 1eb858976a30964ee1812f34f8a05056814ea8e9.

Revert "sched,rt: disable rt_runtime borrowing by default"

This reverts commit a731e214fe6606896de2b50a629bedbdbd95ced7.

Revert "sched/rt: Remove redundant nr_cpus_allowed test"

This reverts commit e169d922cc1fa6026225f9abc71ea28facafd43a.

Revert "sched: Micro-optimize the smart wake-affine logic"

This reverts commit 3bd0f8f8c045c77ca1d46a95ae09ab08c5d52c5d.

Revert "sched: Implement smarter wake-affine logic"

This reverts commit 8ea57b5895029c0694e8cb53295ce2cf735e9505.

Revert "sched: Reduce overestimating rq->avg_idle"

This reverts commit b49d8687515095bdf5089014c2c023d0e61de0cc.

Revert "sched: scale the busy and this queue's per-task load before compare"

This reverts commit a4d496cb8d418891f12cca0e5a3bd64dc2b83ea9.

Revert "sched: reduce calculation effort in fix_small_imbalance"

This reverts commit 65d048b5ef51f2104d3a26fb3e1fddfa8d401090.

Revert "mutex: back out architecture specific check for negative mutex count"

This reverts commit 2f983cc28c06648cc6a50b28a85b3008b51ec850.

Revert "mutex: Queue mutex spinners with MCS lock to reduce cacheline contention"

This reverts commit f6ab92b597a5d1cc6e4ffe82a787cd868140bc09.

Revert "mutex: Make more scalable by doing less atomic operations"

This reverts commit f425908d01a43e0e63e42d51b50c7b9b028e9702.

Change-Id: I7fcb7b2a7bb5657bf70a2189b2d04a5289987106
Signed-off-by: Dan Trifan <jimsth@gmail.com>
iommu: msm: Add base physical address to drvdata structure

Add the physical address value to the iommu drvdata structure. This
address is needed for debugging purposes when we get iommu page
faults and during iommu halt and tlb sync issues.

Change-Id: I2d4f36cdfe8a3da772839cb07cd186820f2e1f52
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
Revert "iommu: msm: Add timeouts for some operations"

This reverts commit e77f861a361431d540284f044142ef452dc45ad9.

Signed-off-by: Dan Trifan <jimsth@gmail.com>
iommu: msm: Do not sleep for 10 ms when TLB sync does not complete

TLB sync might take longer than expected to complete and we wait for 10 ms
to recheck. This is causing jitter in some applications. Instead of waiting
too long to check whether TLB sync has completed we use function
readl_tight_poll_timeout to quickly poll the status without incurring sleep
delay.

We also ensure that if we do eventually time out on the TLB sync or iommu
halt we cause a crash to indicate that something has gone wrong.

CRs-fixed: 608971
Change-Id: I6b3e5155ab7aafa80432f95554d25cf0e2b753f9
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
iommu: msm: Check VBIF state during IOMMU access timeout

Check whether halting the VBIF XIN when the TLB sync or IOMMU halt
times out clears the issue indicating an issue with the master not clearing
the VBIF FIFO.

Change-Id: I552f72db17e31a174ab2725bbecbf4ad98a9d378
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
defconfig: enable MSM_IOMMU_VBIF_CHECK

Signed-off-by: Dan Trifan <jimsth@gmail.com>
arm: arch_timer: set memory mapped timer interrupt as IRQF_TIMER

The memory mapped timer is used as a broadcast timer to wake the core for
timer interrupts when the arch timer might not be functional. When interrupt
is not marked as IRQF_NO_SUSPEND, the interrupt gets disabled during the
suspend_device_irqs() callback in the suspend path. If a core were to enter a
idle low power mode which relies on broadcast timer to process the interrupt,
the core is never woken up for timer interrupts.

Mark the interrupt with IRQF_TIMER which marks this interrupt as a timer
interrupt and also marks it as IRQF_NO_SUSPEND

CRs-fixed: 636712
Change-Id: I0484e92a9d05f66a0c5b3c00c584a3dd3fe6ae85
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
cma: Make locking finer grained

CMA locking is currently very coarse. The cma_mutex protects both
the bitmap and avoids concurrency with alloc_contig_range. There
are several situations which may result in a deadlock on the CMA
mutex currently, mostly involving AB/BA situations with alloc and
free. Fix this issue by protecting the bitmap with a mutex per CMA
region and use the existing mutex for protecting against concurrency
with alloc_contig_range.

Change-Id: I6863ba7ab7fae07c68fee23b0aa4c869244fe2a1
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
ion: retry during race with shrinking/allocating

There exists a race between shrinking/allocating

Thread 1:                           Thread:2
mutex_lock(&sheap->alloc_lock)
ion_secure_cma_add_to_pool()
mutex_lock(&sheap->chunk_lock)
chunk->cnt = 0
mutex_unlock(&sheap->chunk_lock)
                                    ion_secure_cma_shrinker
                                    mutex_lock(&sheap->chunk_lock)
                                    __ion_secure_cma_shrink_pool
                                    chunk->cnt == 0 for the
                                       just allocated chunk
                                    ion_secure_cma-free_chunk
ion_secure_cma_alloc_from_pool
no memory to allocate!

If this race happens, just retry adding memory to the pool instead
of BUGing out the system.

Change-Id: Ic95782db6d88a33f01dcc5248fc957ca0f378078
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm: lpm_levels: Fix incorrect computation of next wakeup time

The next event timer wakeup was incorrectly computed when the hard timer
event doesn't exist. Fix by ensuring the next wakeup is computed only
when a timer event is valid

Change-Id: I40c1f372f84d8f43b2101e37dcfb592193d4b2e0
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>