config: *update*
ARM: add SCHED_HRTICK config option

As we don't include kernel/Kconfig.hz as this defines HZ values
unsuitable for ARM platforms, add the SCHED_HRTICK to properly configure
the scheduler for hrtimer operation.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
mm: remove compressed copy from zram in-memory

Swap subsystem does lazy swap slot free with expecting the page would be
swapped out again so we can avoid unnecessary write.

But the problem in in-memory swap(ex, zram) is that it consumes memory
space until vm_swap_full(ie, used half of all of swap device) condition
meet.  It could be bad if we use multiple swap device, small in-memory
swap and big storage swap or in-memory swap alone.

This patch makes swap subsystem free swap slot as soon as swap-read is
completed and make the swapcache page dirty so the page should be
written out the swap device to reclaim it.  It means we never lose it.

I tested this patch with kernel compile workload.

1. before

   compile time : 9882.42
   zram max wasted space by fragmentation: 13471881 byte
   memory space consumed by zram: 174227456 byte
   the number of slot free notify: 206684

2. after

   compile time : 9653.90
   zram max wasted space by fragmentation: 11805932 byte
   memory space consumed by zram: 154001408 byte
   the number of slot free notify: 426972

[akpm@linux-foundation.org: tweak comment text]
[artem.savkov@gmail.com: fix BUG due to non-swapcache pages in end_swap_bio_read()]
[akpm@linux-foundation.org: invert unlikely() test, augment comment, 80-col cleanup]
Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
Signed-off-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Artem Savkov <artem.savkov@gmail.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Seth Jennings <sjenning@linux.vnet.ibm.com>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Konrad Rzeszutek Wilk <konrad@darnok.org>
Cc: Shaohua Li <shli@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Conflicts:
	mm/page_io.c

Change-Id: I8f11fb7f0391954435002e7f290352f311c907d4
mmc: msm_sdcc: check for pending_resume in SDCC system suspend

If system comes out of suspend, msmsdcc_pm_resume() sets the
host->pending_resume flag if the SDCC wasn't runtime suspended.
Now if the system again goes to suspend without any SDCC activity
then host->pending_resume flag will remain set which may cause the SDCC
resume to happen first and then suspend.

To avoid this unnecessary resume/suspend, make sure that pending_resume
flag is cleared before calling the msmsdcc_runtime_suspend().

CRs-Fixed: 438081
Change-Id: I2b667bec704f938a532d4780dd9b7937e2eb12c7
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
mm: pass readahead info down to the i/o scheduler

Some i/o schedulers (i.e. row-iosched, cfq-iosched) deploy an idling
algorithm in order to be better synced with the readahead algorithm.
Idling is a prediction algorithm for incoming read requests.

In this patch we mark pages which are part of a readahead window, by
setting a newly introduced flag. With this flag, the i/o scheduler can
identify a request which is associated with a readahead page. This
enables the i/o scheduler's idling mechanism to be en-sync with the
readahead mechanism and, in turn, can increase read throughput.

Change-Id: I0654f23315b6d19d71bcc9cc029c6b281a44b196
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
usb: gadget: composite: Fix a bug in delayed status handling

The SET_CONFIGURATION control request's status phase is delayed
till the new config change is handled by the file-storage thread.
If the cable is disconnected or the bus is reset before the
previous config is handled, then composite driver is not notified
about the delayed status.  As a result of which, the delayed_status
field of composite device structure remains non-zero.  The status
phase of next SET_CONFIGURATION control request is not sent.
This makes the gadget unusable.

Calling usb_composite_setup_continue() after the disconnect or reset
does not make any sense.  If the host sends another control request
before the status phase of the previous control request is sent, the
delayed_status must be reset to zero.  This is not straight forward
as the UDC handles some control requests without delegating them to
the composite driver.  A simple fix would be resetting the delayed
status value after the disconnect/reset.

CRs-Fixed: 501527
Change-Id: I67c832afc88c9e7d025247e539b7223fd83644d7
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
msm: pm2: Update SPC LPM stats correctly

Currently StandalonePC stats are updating incorrectly even
for successful cases. After debug found that compiler has
optimized some of the instructions where the return value
from "msm_pm_power_collapse_standalone()" being compared
incorrectly and always log the stats as failed even for
success cases. Change the "exit_stat" variable to "volatile"
to avoid any optimization.

CRs-Fixed: 433578
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
(cherry picked from commit f59048d29fd75a30cac8c294e068178d9d489af3)

Change-Id: If1f9313f7968e93f5dcd9fb33426496f5091d14a
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
acpuclock-7627.c: fixing table selection in select_freq_plan()

In the function 'select_freq_plan()' there's a check to select
the correct table for 1008Mhz CPU's, because there's a conflict
between 7627AA and 8625 chips.

However this check is wrong:
	if (pll_mhz[ACPU_PLL_2] == 245)

It should be:
	if (pll_mhz[ACPU_PLL_1] == 245)

We don't want to check PLL_2 but PLL_1 being '245' or not.

Due of this bug the wrong frequency table is getting selected
for 1GHz 8625 chips with PLL_2=245.

Previously-detected-by: Peter Jung <peter.jung@lge.com>
Signed-off-by: moddingg33k <moddingg33k@t-online.de>
base: genlock: Zero a structure before sending it to user space

In the handler for GENLOCK_IOC_EXPORT zero the entire genlock_lock
structure before passing it to the user.

CRs-fixed: 552303
Change-Id: Ic0dedbad257bf0a448d0bf67a14a3932b7925bfc
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
kernel: Prevent unnecessary rfkill event generation.

Prevent unnecessary rfkill event generation when the state has
not actually changed. These events have to be delivered to
relevant userspace processes, causing these processes to wake
up and do something while they could as well have slept. This
obviously results in more CPU usage, longer time-to-sleep-again
and therefore higher power consumption.

Change-Id: I3ac4e141fbdf1315b74d3bad6aa96f34b00c3f92
CRs-fixed: 398283
Signed-off-by: Vitaly Wool <vitalywool@gmail.com>
Signed-off-by: Mykyta Iziumtsev <nikita.izyumtsev@gmail.com>
Signed-off-by: Deepthi Gowri <deepthi@codeaurora.org>
Patch-mainline: v3.7
Git-commit: eab48345c2b2d791159aaac4a77000baa8dbc1ae
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
KBuild: Export msm_rmnet.h to user space

Exposing msm_rmnet.h to user space using standard mechanism such that
user space applications do not have to use relative paths in include
list.

CRs-Fixed: 548664
Change-Id: I807f9854de1d0bf9961607c9ed54dd5ecef782dc
Signed-off-by: Harout Hedeshian <harouth@codeaurora.org>
lib/int_sqrt.c: optimize square root algorithm

Optimize the current version of the shift-and-subtract (hardware)
algorithm, described by John von Newmann[1] and Guy L Steele.

Iterating 1,000,000 times, perf shows for the current version:

 Performance counter stats for './sqrt-curr' (10 runs):

         27.170996 task-clock                #    0.979 CPUs utilized            ( +-  3.19% )
                 3 context-switches          #    0.103 K/sec                    ( +-  4.76% )
                 0 cpu-migrations            #    0.004 K/sec                    ( +-100.00% )
               104 page-faults               #    0.004 M/sec                    ( +-  0.16% )
        64,921,199 cycles                    #    2.389 GHz                      ( +-  0.03% )
        28,967,789 stalled-cycles-frontend   #   44.62% frontend cycles idle     ( +-  0.18% )
   <not supported> stalled-cycles-backend
       104,502,623 instructions              #    1.61  insns per cycle
                                             #    0.28  stalled cycles per insn  ( +-  0.00% )
        34,088,368 branches                  # 1254.587 M/sec                    ( +-  0.00% )
             4,901 branch-misses             #    0.01% of all branches          ( +-  1.32% )

       0.027763015 seconds time elapsed                                          ( +-  3.22% )

And for the new version:

Performance counter stats for './sqrt-new' (10 runs):

          0.496869 task-clock                #    0.519 CPUs utilized            ( +-  2.38% )
                 0 context-switches          #    0.000 K/sec
                 0 cpu-migrations            #    0.403 K/sec                    ( +-100.00% )
               104 page-faults               #    0.209 M/sec                    ( +-  0.15% )
           590,760 cycles                    #    1.189 GHz                      ( +-  2.35% )
           395,053 stalled-cycles-frontend   #   66.87% frontend cycles idle     ( +-  3.67% )
   <not supported> stalled-cycles-backend
           398,963 instructions              #    0.68  insns per cycle
                                             #    0.99  stalled cycles per insn  ( +-  0.39% )
            70,228 branches                  #  141.341 M/sec                    ( +-  0.36% )
             3,364 branch-misses             #    4.79% of all branches          ( +-  5.45% )

       0.000957440 seconds time elapsed                                          ( +-  2.42% )

Furthermore, this saves space in instruction text:

   text    data     bss     dec     hex filename
    111       0       0     111      6f lib/int_sqrt-baseline.o
     89       0       0      89      59 lib/int_sqrt.o

[1] http://en.wikipedia.org/wiki/First_Draft_of_a_Report_on_the_EDVAC

Signed-off-by: Davidlohr Bueso <davidlohr.bueso@hp.com>
Reviewed-by: Jonathan Gonzalez <jgonzlez@linets.cl>
Tested-by: Jonathan Gonzalez <jgonzlez@linets.cl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
PM / Sleep: use resume event when call dpm_resume_early

commit 997a031107ec962967ce36db9bc500f1fad491c1 upstream.

When dpm_suspend_noirq fail, state is PMSG_SUSPEND,
should change to PMSG_RESUME when dpm_resume_early is called

Signed-off-by: Feng Hong <hongfeng@marvell.com>
Signed-off-by: Raul Xiong <xjian@marvell.com>
Signed-off-by: Neil Zhang <zhangwm@marvell.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
base/core.c: remove huawei debug code
FIX: driver core: move the deferred probe pointer into the private area

(moddingg33k): 'INIT_LIST_HEAD(&dev->deferred_probe);' should not exist
		any longer in 'void device_initialize()' after this patch.

		--> So let's remove it.

Nothing outside of the driver core needs to get to the deferred probe
pointer, so move it inside the private area of 'struct device' so no one
tries to mess around with it.

Cc: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
ext4: revert Huawei changes to ialloc

This is causing disasters in 4.3 and especially while SELinux
is enabled. System files are getting deleted and data is getting
remounted as read only. It seems to be the same files getting
deleted every time, common examples are:
- /system/app/Phonesky.apk (!)
- /system/media/bootanimation.zip (uses AOSP animation instead)
- /system/media/video/
- /system/wifi/ (!)

This is also present in the 3.0.8 kernel, but I'm not really
sure why it was changed in the first place - system remounting
seems to be working fine for me...

Not sure if recoveries will need to be rebuilt with this.
genirq: remove deprecated fix for handle_nested_irq

This reverts an old RFC patch: 'genirq: fix handle_nested_irq for lazy disable'

It got merged by CAF along commit: 'AU_LINUX_ANDROID_ICS.04.00.04.00.126'

We shouldn't need this fix anymore on a 3.4.y kernel.

Signed-off-by: moddingg33k <moddingg33k@t-online.de>
genirq: Do not consider disabled wakeup irqs

If an wakeup interrupt has been disabled before the suspend code
disables all interrupts then we have to ignore the pending flag.

Otherwise we would abort suspend over and over as nothing clears the
pending flag because the interrupt is disabled.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: NeilBrown <neilb@suse.de>
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