msm: perf: clean up duplicate constraint events

Events with a duplicate constraint are set to state=OFF when detected,
so that their duplicate counts are not read. However, they were not being
cleaned up because the core code only cleaned up ACTIVE events.
This resulted in counters not being freed and eventually running out
of resources.

Clean up the events with state==OFF that were marked that way because of
constraint duplication.
Ensure counts are not updated for OFF events.

Change-Id: If532801c79e6ad6809869eb0a3063774f00c92c3
Signed-off-by: Neil Leeder <nleeder@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/perf_debug.c
	kernel/events/core.c
msm: perf: initialise krait perf L2 counter enables

Clear the L2 counter enables at initialisation.
They are undefined out of reset.

Change-Id: I957106012625ae09efec47d4f657381963d87a5a
Signed-off-by: Neil Leeder <nleeder@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/perf_debug.c
Perf: Support sw events across hotplug

When CPUs are hotplugged off and on, let the various
sw events continue after the hotplug.

Change-Id: Id1aaf30c459c9cf7c9c38967f9ccad56d4062fd3
Signed-off-by: Neil Leeder <nleeder@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/perf_debug.c
fs: Remove LGE's kfips, ext4 recovery, and readahead profiling

Change-Id: Ib015487d059adfb0dbf12308ba03b575dde5e898

Conflicts:

	fs/ext4/Kconfig
	fs/ext4/super.c
ext4: make sure the journal sb is written in ext4_clear_journal_err()

After we transfer set the EXT4_ERROR_FS bit in the file system
superblock, it's not enough to call jbd2_journal_clear_err() to clear
the error indication from journal superblock --- we need to call
jbd2_journal_update_sb_errno() as well.  Otherwise, when the root file
system is mounted read-only, the journal is replayed, and the error
indicator is transferred to the superblock --- but the s_errno field
in the jbd2 superblock is left set (since although we cleared it in
memory, we never flushed it out to disk).

This can end up confusing e2fsck.  We should make e2fsck more robust
in this case, but the kernel shouldn't be leaving things in this
confused state, either.

Change-Id: I7a7cd58880209fbd54f4ded5f2b62de492cae9e0
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: stable@kernel.org
Git-commit: d796c52ef0b71a988364f6109aeb63d79c5b116b
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Osvaldo Banuelos <osvaldob@codeaurora.org>
mm: compaction: do not accidentally skip pageblocks in the migrate scanner

Compaction uses the ALIGN macro incorrectly with the migrate scanner by
adding pageblock_nr_pages to a PFN.  It happened to work when initially
implemented as the starting PFN was also aligned but with caching
restarts and isolating in smaller chunks this is no longer always true.

The impact is that the migrate scanner scans outside its current
pageblock.  As pfn_valid() is still checked properly it does not cause
any failure and the impact of the bug is that in some cases it will scan
more than necessary when it crosses a page boundary but by no more than
COMPACT_CLUSTER_MAX.  It is highly unlikely this is even measurable but
it's still wrong so this patch addresses the problem.

Signed-off-by: Mel Gorman <mgorman@suse.de>
Reviewed-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
new helper: iterate_fd()

iterates through the opened files in given descriptor table,
calling a supplied function; we stop once non-zero is returned.
Callback gets struct file *, descriptor number and const void *
argument passed to iterator.  It is called with files->file_lock
held, so it is not allowed to block.

tty_io, netprio_cgroup and selinux flush_unauthorized_files()
converted to its use.

Change-Id: I2d89b18c450d64c2e9ec20a0b26977b65afce836
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
ARM: kernel: update cpu_suspend code to use cache LoUIS operations

In processors like A15/A7 L2 cache is unified and integrated within the
processor cache hierarchy, so that it is not considered an outer cache
anymore. For processors like A15/A7 flush_cache_all() ends up cleaning
all cache levels up to Level of Coherency (LoC) that includes
the L2 unified cache.

When a single CPU is suspended (CPU idle) a complete L2 clean is not
required, so generic cpu_suspend code must clean the data cache using the
newly introduced cache LoUIS function.

The context and stack pointer (context pointer) are cleaned to main memory
using cache area functions that operate on MVA and guarantee that the data
is written back to main memory (perform cache cleaning up to the Point of
Coherency - PoC) so that the processor can fetch the context when the MMU
is off in the cpu_resume code path.

outer_cache management remains unchanged.

Change-Id: Id5a6d34d55d1b0a5ef112cafc3ad21c0da4b0b84
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Reviewed-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Tested-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
Revert the new thread parking code

Revert "cpufreq: cpu-boost: Use hotplug thread infrastructure"

This reverts commit 971862830f81d68b0bd55680b66ba05c0019fd36.

Revert "stop_machine: Mark per cpu stopper enabled early"

This reverts commit 9bbae91809e067c02b4b2f4cef72fe3c2caa4292.

Revert "stop_machine: Use smpboot threads"

This reverts commit 1f7de4c015565e6e37e80755d794d9c77a7b1d49.

Revert "stop_machine: Store task reference in a separate per cpu variable"

This reverts commit f10be39fc181939c587c923ebdb8162c4d8d4fac.

Revert "kthread: Prevent unpark race which puts threads on the wrong cpu"

This reverts commit fd63dca05529271e90b349d8e61b68b3d511e033.

Revert "smpboot: Allow selfparking per cpu threads"

This reverts commit 46ee7c24e62b72be30e150608fd7a240426ac824.

Revert "hotplug: Fix UP bug in smpboot hotplug code"

This reverts commit c3e0cb138667d268f255eec82e82aa92de7008eb.

Revert "smpboot: Provide infrastructure for percpu hotplug threads"

This reverts commit 2bb290f1377498c96d5c455ce57f84a0146f9216.

Revert "kthread: Implement park/unpark facility"

This reverts commit 9cd8c2231fbc58517681c71a35801a945d9b6238.

Revert "kthread_worker: reimplement flush_kthread_work() to allow freeing the work item being executed"

This reverts commit f26b4602067b82dda20f0f2a7eaa26ff352200d0.

Revert "kthread_worker: reorganize to prepare for flush_kthread_work() reimplementation"

This reverts commit 4e599e650a043f0ff3f77e13b4902e3ebaa76a11.

Revert "smpboot, idle: Fix comment mismatch over idle_threads_init()"

This reverts commit 7a0bad702f5e53775d5a860d67ea2cd090063661.

Revert "smpboot, idle: Optimize calls to smp_processor_id() in idle_threads_init()"

This reverts commit e9f8737018bf8e0d531082764b55b3ed152a2c29.

Revert "smp, idle: Allocate idle thread for each possible cpu during boot"

This reverts commit e8159c5b0c17b52fb512893c7f1f98fa54c65e65.

Revert "smp: Provide generic idle thread allocation"

This reverts commit 794e6385e1f07d010d83db2eff4d4bad9e9bf19c.

Revert "smp: Add generic smpboot facility"

This reverts commit a21b97ca969e6f778013093200236345722c6a90.

Conflicts:

	arch/arm/Kconfig
	drivers/cpufreq/cpu-boost.c
cpufreq: cpu-boost: Fix queue_delayed_work_on() race with hotplug

Calling queue_delayed_work_on() on a CPU that's in the process of getting
hotplugged out can result in that CPU infinitely looping in
msm_pm_wait_cpu_shutdown(). If queue_delayed_work_on() is called after the
CPU is hotplugged out, it could wake up the CPU without going through the
hotplug path and cause instability. To avoid this, make sure the CPU is and
stays online while queuing a work on it.

Change-Id: I1b4aae3db803e476b1a7676d08f495c1f38bb154
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
ARM: dts: msm: add perf-events support for msm8x10, msm8x12

Add the device definitions for the Cortex-A7
PMU on msm8x10.

Change-Id: I0e45c01cec2c92e437cc11cee88777bca271b839
Signed-off-by: Neil Leeder <nleeder@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/perf_debug.c
Perf: Make per-process counters configurable

Add feature to enable/disable per-process tracecounters at run-time.

Change-Id: Id6a4c7a0ecd1f5add85464c6ed260860e15c4e3b
Signed-off-by: Sheetal Sahasrabudhe <sheetals@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/perf_debug.c
msm: perf: Add L2 support for tracecounters

Add L2 counter output to the tracecounters implementation.
This enables collection of L2 PMU counter values upon context switch.
Set up filtering based on number of L2 counters and number of cores.
Read L2 counter values and display them along with L1 counter values.

Change-Id: I8bbbd251ee52c66505d22ccf037c601013a916f0
Signed-off-by: Sheetal Sahasrabudhe <sheetals@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/perf_debug.c
Perf: keep events across hotplug

Keep event list alive across a CPU hotplug so that perf
can resume when the CPU comes back online. Bring a CPU
online when exiting a perf session so it can be cleaned
up properly.

Change-Id: Ie0e4a43f751beb77afdc84e9d52b21780f279d80
Signed-off-by: Neil Leeder <nleeder@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/perf_debug.c
Perf: bring CPU online if needed when disabling irq

When disabling an irq, check that the CPU is online
before trying to run on that CPU. Bring the CPU
online if necessary.

This fixes a problem where a CPU that was not online
when disabling the irq caused the disable and the
free to fail. A subsequent attempt to request the irq
also failed because it had not been freed.

Change-Id: Ib873b5ded83ab843ea4e609f196a31ef0083a213
Signed-off-by: Neil Leeder <nleeder@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/perf_debug.c
bcmdhd: Adjust default hostwake/reset GPIOs to match the galbis

Change-Id: I84c3d71dde9fdea45652b24a65523d9947cdd25d
bluesleep: Don't wait for uart tx queue to flush before entering standby

There's no need to delay sleep for this. msm_hs_serial will do it on
its own, and this reduces the time to enter lpm

Change-Id: Ia13d44148130aaf133ea888807b5ba114936ce78
Add L-01F(G2 JPN-DCM) defconfig
Add LGL22 au isai (G2 JPN-KDDI) defconfig
futex-prevent-requeue-pi-on-same-futex.patch futex: Forbid uaddr == uaddr2 in futex_requeue(..., requeue_pi=1)

If uaddr == uaddr2, then we have broken the rule of only requeueing
from a non-pi futex to a pi futex with this call. If we attempt this,
then dangling pointers may be left for rt_waiter resulting in an
exploitable condition.

This change brings futex_requeue() into line with
futex_wait_requeue_pi() which performs the same check as per commit
6f7b0a2a5 (futex: Forbid uaddr == uaddr2 in futex_wait_requeue_pi())

[ tglx: Compare the resulting keys as well, as uaddrs might be
  	different depending on the mapping ]

Fixes CVE-2014-3153.

Reported-by: Pinkie Pie
Signed-off-by: Will Drewry <wad@chromium.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: stable@vger.kernel.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Change-Id: I155eafa98f365408450527e34998893dcdd64801