cgroup: fix exit() vs rmdir() race

commit 71b5707e119653039e6e95213f00479668c79b75 upstream.

In cgroup_exit() put_css_set_taskexit() is called without any lock,
which might lead to accessing a freed cgroup:

thread1                           thread2
---------------------------------------------
exit()
  cgroup_exit()
    put_css_set_taskexit()
      atomic_dec(cgrp->count);
                                   rmdir();
      /* not safe !! */
      check_for_release(cgrp);

rcu_read_lock() can be used to make sure the cgroup is alive.

Signed-off-by: Li Zefan <lizefan@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

[moddingg33k: backported for MSM-3.4 kernel]
Signed-off-by: moddingg33k <moddingg33k@t-online.de>
kernel/resource.c: upstream to k-org 3.4.y mainline
lib/genalloc.c: revert Huawei KGSL 'fix'

Signed-off-by: moddingg33k <moddingg33k@t-online.de>
sched: Notify hrtimer users of switches to NOHZ mode

When NOHZ=y and high res timers are disabled (via cmdline or
Kconfig) tick_nohz_switch_to_nohz() will notify the user about
switching into NOHZ mode. Nothing is printed for the case where
HIGH_RES_TIMERS=y. Fix this for the HIGH_RES_TIMERS=y case by
duplicating the printk from the low res NOHZ path in the high res
NOHZ path.

Signed-off-by: Stephen Boyd <sb...@codeaurora.org>
arm/smp.c: convert printk to pr_info

Signed-off-by: moddingg33k <moddingg33k@t-online.de>
kernel/exit.c: remove Huawei kernel log spam

Signed-off-by: moddingg33k <moddingg33k@t-online.de>
Revert "Optimized ARM RWSEM algorithm"
ARM: 7693/1: mm: clean-up in order to reduce to call kmap_high_get()

In kmap_atomic(), kmap_high_get() is invoked for checking already
mapped area. In __flush_dcache_page() and dma_cache_maint_page(),
we explicitly call kmap_high_get() before kmap_atomic()
when cache_is_vipt(), so kmap_high_get() can be invoked twice.
This is useless operation, so remove one.

v2: change cache_is_vipt() to cache_is_vipt_nonaliasing() in order to
be self-documented

Change-Id: I36e5a63fdae158d9e7562f564f7e593b351f6960
Acked-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Git-commit: dd0f67f4747797f36f0c6bab7fed6a1f2448476d
Git-repo: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/
[Few merge conflict resolved]
Signed-off-by: Chintan Pandya <cpandya@codeaurora.org>

Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
msm: kgsl: use kgsl_mmu_device_setstate() if the GPU is already idle

Use the default setstate function, which directly reprograms the IOMMU,
to change IOMMU pagetables or flush the TLB if the GPU is already idle.
This condition often occurs when the GPU is being powered down. In this
case it is desirable to avoid the overhead of issuing commands, waiting
for idle and firing events that results from using the GPU
command stream to reprogram the IOMMU.

Change-Id: I633002ac49c8fe58df3f1f6a1fd1ddf705fc1733
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Revert "sched: cpu_power: enable ARCH_POWER"

This reverts commit 420c9d564089022f484ee4479427c1004cbeadfb.
PM / tracing: remove deprecated power trace API

The text in Documentation said it would be removed in 2.6.41;
the text in the Kconfig said removal in the 3.1 release.  Either
way you look at it, we are well past both, so push it off a cliff.

Note that the POWER_CSTATE and the POWER_PSTATE are part of the
legacy tracing API.  Remove all tracepoints which use these flags.
As can be seen from context, most already have a trace entry via
trace_cpu_idle anyways.

Also, the cpufreq/cpufreq.c PSTATE one is actually unpaired, as
compared to the CSTATE ones which all have a clear start/stop.
As part of this, the trace_power_frequency also becomes orphaned,
so it too is deleted.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
config: *update*
msm: Remove old unused sdio related code

Cleanup mach-msm by removing unused sdio related code.

Change-Id: I485deb7d6499771294b494f5542ba510c10255cb
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
msm: Remove ANDROID_PMEM from the Kconfig dependencies

The PMEM driver is completely deprecated. Remove any Kconfig
that is still depending on it.

Change-Id: I3386a7eedf34213f2c644372a719ae00c65b0d6d
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
msm: avs: Remove vestigial software based AVS

Older targets like 8x50 had the first version of Apdaptive Voltage
Scaling done in software. This feature was never enabled and supported.
Remove the code and the associated config items.

Change-Id: If3bdab7d0bdb5d51e099f7c37f56592826edc102
Signed-off-by: Praveen Chidambaram <pchidamb@codeaurora.org>
msm: event_timer: Support to add event timers.

Add support to allow drivers to specify future events
that need to be treated as hard deadlines. Upon event timer
expiry the driver will be notified by callback function
that the driver provides.
The pm code can query the earliest event and modify
the event timer accounting for the back off based on the
latency of the low power mode being entered.

Change-Id: Iec26f77de3b826bff456b12f3230268d9bdc2255
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
msm: Rename pmem variables and macros

Since MSM no longer uses PMEM, the variables, macros, and kernel
config (CONFIG_KERNEL_PMEM_EBI_REGION) relating to PMEM should be
renamed to something more generic.

Change-Id: I4ca909098c96317853d4f040850b63f37db4811e
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
Revert: genirq: explicitly mask a freed irq

This reverts:

      When an interrupt is freed, the shutdown or the disable callback
      is called for that interrupt. These calls might not be implemented
      or even if they were, might not mask the interrupt.

      Explicitly mask the interrupt when it is freed. If not masked, the
      interrupt could trigger, set the pending bit in the irq controller
      and cause unnecessary wakeup or exits from idle power collapse.

      Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Revert: genirq: chip: set pending only for edge interrupts

This reverts:

      The IRQS_PENDING flag is meant to record an edge interrupt trigger event
      when that interrupt is disabled.

      When an edge triggered interrupt is enabled, check_irq_resend() retriggers
      that irq and resets the flag to zero if set. Note that check_irq_resend()
      only does this for edge triggered interrupts.

      For level triggered interrupts it is expected that the interrupt remains
      active and doesn't need this PENDING flag assistance from software for
      re-triggering it.

      However, handle_fasteoi_irq flow handler sets the PENDING flag even for
      a disabled level interrupt. This causes an adverse effect if that level
      interrupt is marked wakeup. The suspend code sees the pending flag on a
      wakeup interrupt and aborts suspend whereas check_irq_resend does not reset
      it to 0 (as it is a level interrupt). The end result is that the PENDING
      flag on this level triggered wakeup interrupt never clears and the system
      keeps aborting suspend.

      Fix this by setting IRQS_PENDING flag only for edge interrupts in the
      handle_fasteoi_irq.

      CRs-Fixed: 314344
      Change-Id: I775d40f434f9309fd9672bae372b0f0fb5b91627
      Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Revert: genirq: fix handle_nested_irq for lazy disable

This reverts:

      When lazy disabling is implemented and an interrupt is disabled the
      genirq code ends up marking it as IRQ_DISABLED in the descriptor.
      The interrupt stays enabled in the controller.  If the interrupt
      fires after disabling, the flow handlers namely handle_level_irq and
      handle_edge_irq mask the interrupt in the controller.

      This is not the case with handle_nested_irq. The interrupt stays enabled in
      the controller and if it were a level interrupt it keeps firing only to be
      ignored by handle_nested_irq.

      Update handle_nested_irq to mask such an interrupt.

      CRs-Fixed: 300931
      Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>