add CYPRESS CYTTSP4 Touchscreen driver

used in Xperia M2, E3, T2 Ultra

includes
commit 665e45b0147358a3dc413344d17b096342fdf9e0
Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
Date:   Tue Dec 9 10:10:15 2014 +0000

    drivers: TS: cyttsp4: Add config option for Yukon

    This is to make sure that noone sends a wrong firmware
    to the TS IC.

commit 8393813f5283f40a631474793fcb0ec72ee31cea
Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
Date:   Tue Dec 9 10:34:33 2014 +0000

    drivers: TS: Do not panic if vreg_l27 is not specified

    This is required for Seagull as it hasn't got that vreg
    and it's not specified in DT.

commit f48b78e456c9768308ce9796159a8fad7cb228e9
Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
Date:   Wed Dec 10 10:53:49 2014 +0000

    drivers: TS: cyttsp4: Stop spamming

Signed-off-by: Alin Jerpelea <alin.jerpelea@sonymobile.com>
add sensors to IIO framework

add:
Yamaha YAS532 3-Axis Magnetometer
Bosch BMA250E 3-Axis Accelerometer
Kionix KXTJ2 3-Axis Accelerometer

used in Xperia M2

Signed-off-by: Alin Jerpelea <alin.jerpelea@sonymobile.com>
add BMA255/BMA250E/BMA222E/BMA280 acceleration sensor

driver is used in Xperia T3

Signed-off-by: Alin Jerpelea <alin.jerpelea@sonymobile.com>
add BMG160 Gyroscope sensor

driver is used in Xperia T3

Signed-off-by: Alin Jerpelea <alin.jerpelea@sonymobile.com>
add BMM050 Magnetic Sensor

driver is used in Xperia T3

Signed-off-by: Alin Jerpelea <alin.jerpelea@sonymobile.com>
update STK3X1X driver

used in Xperia M2 and T3

Signed-off-by: Alin Jerpelea <alin.jerpelea@sonymobile.com>
video: backlight: add lm3630 driver
shinano: update touchpad wake code

reconcile with aosp usage
fix d2w on aosp

Change-Id: I19731226c8558069da4ca8da2feff240034b1a53
Display driver changes

Add changes to support M2,T3,E3 devices

includes
commit a9c352bc0ce39bc8b5155ff5a197c4788e70593d
Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
Date:   Mon Dec 1 22:50:54 2014 +0000

    Port Flamingo display to Sony's unified display driver

commit acc25abf8933fa40ffa1798ad3a37dc09aefeeaa
Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
Date:   Tue Dec 2 10:45:04 2014 +0000

    video: msm: mdss: mdss_dsi_panel_driver: Add somc,no-vsp-gpio property

    Some devices don't need/have this GPIO, so the driver
    can continue to go through its code even if we
    haven't specified the somc,vsp-gpio property.

commit 7cf303074cf6ec93b230656c8d0334a0684f26d9
Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
Date:   Tue Dec 2 14:46:16 2014 +0000

    arm: Seagull: Welcome to the Sony Unified display driver

commit edf230222fde4e12dc18867521dd99bdf3520d6b
Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
Date:   Tue Dec 2 15:11:36 2014 +0000

    video: msm: mdss: mdss_dsi_panel_driver: Fix mistake

commit 017ab0ca4a77ae2e2e353140d30c86084238ba61
Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
Date:   Wed Dec 3 11:19:40 2014 +0000

    video: msm: mdss: Add upside down panel support

commit 8000d028700d2853be252dda53980304c8485999
Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
Date:   Mon Dec 8 12:34:36 2014 +0000

    drivers: video: msm: Make Seagull's display to work (see comment)

    The panel enable/disable/reset logic is now okay, but we still
    have to fix the panel detection because actually there's some
    problem that makes us unable to read the panel ID.
    At this stage, the only working panels on Seagull
    are the two JDI and it's only because of a coincidence in
    the bad id detection that now reads 0x00 (same ID as JDI panel).

commit 19ac1fdfb3ee9c3ef8bde75b12fe8a59c1ec2084
Author: erikcas <erikcas1972@gmail.com>
Date:   Sun Dec 7 10:42:51 2014 +0100

    silence compilation warnings on use of void + return

    Change-Id: Ia7dae48d00970dfe3e8d033349ffd39435a69383
    Signed-off-by: erikcas <erikcas1972@gmail.com>

Signed-off-by: Alin Jerpelea <alin.jerpelea@sonymobile.com>
drivers: power: qpnp-charger: Fix USB for Yukon boards
yukon: add platform

FLAMINGO DEVICE (Xperia E3)

commit b9a936293c4c85ddaaa5aa0585f1d3721395b531
Author: Adam Farden <adam@farden.cz>
Date:   Sat Nov 15 11:10:16 2014 +0100

Flamingo: add platform

includes
commit db1bbf6b8d6ff974a29f27dadb87e25d2045d656
Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
Date:   Fri Nov 28 02:43:12 2014 +0000

    arm: dts: flamingo: Specify i2c-src-freq and master-id for i2c nodes

    Let's make the kernel happy.

commit 5e0d84b0c208888fa5d78173166d88a1f5cb4180
Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
Date:   Mon Dec 1 09:35:52 2014 +0000

    arm: dts: Flamingo: Remove the qcom,mode property from pm8226_s2

    ....for CPR to work correctly and the device to go to sleep
    without any problem.

commit ff2280813faaf6f19e9c8d502c57eb99fa5e3e3e
Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
Date:   Mon Dec 1 22:31:58 2014 +0000

    arm: configs: Flamingo is ready to migrate to the new display driver.

commit b981c240f3cb8c7efa3d0324a723bb5239cc09b3
Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
Date:   Mon Dec 1 22:50:54 2014 +0000

    Port Flamingo display to Sony's unified display driver

commit bb955fa38c5998185b615e859158828130b358b4
Author: Adam Farden <adam@farden.cz>
Date:   Tue Dec 2 21:38:49 2014 +0100

    Flamingo: consolidate and tidy dtsi

    * Remove unused qhd panels
    * Combine 3 dtsi files into one
    * Rename to remove v3

    Signed-off-by: Adam Farden <adam@farden.cz>

commit 2f02c23390a0c28b7004af2cec521557ca0685eb
Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
Date:   Wed Dec 3 09:43:20 2014 +0000

    arm: Flamingo: Remove unused panel

commit d3f736f02d9af3a02efcf3058646f53966e1b50f
Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
Date:   Tue Dec 9 12:07:23 2014 +0000

    arm: Flamingo: Migrate to *.c batterydata

EAGLE DEVICE (Xperia M2)

commit 61bdd9339d3a558a4a7650980d05851382bd3aac
Author: Alin Jerpelea <alin.jerpelea@sonymobile.com>
Date:   Tue Nov 18 17:30:29 2014 +0100

    Eagle: add platform

    includes
    commit ceda5c1348bdf1519460cbc4e707101cbb82b053
    Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
    Date:   Mon Nov 24 11:03:13 2014 +0000

        arm: dts: Eagle: Fix camera regulators

    commit 1bfca7bdb995967a139d24251d638e9a3f3db1d2
    Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
    Date:   Tue Dec 2 11:18:31 2014 +0000

        arm: configs: Eagle: Use upstream FB_MSM_LOGO

    git cherry-pick ccb555cbe003406b4684f403c6518bbf796f2440
    Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
    Date:   Tue Dec 2 11:45:16 2014 +0000

        arm: boot: dts: Eagle: Fix primary panel property

    commit a2ea9c3c9d0d82a39fe4cc8b7c578f12d1b6700a
    Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
    Date:   Tue Dec 2 10:51:42 2014 +0000

        arm: Eagle: Welcome to the Sony Unified display driver

    commit 371f0da8f511a8cc19b323656a3c44c8cb2f2fab
    Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
    Date:   Wed Dec 3 11:20:07 2014 +0000

        arm: Eagle: Specify upside-down panel property

    commit f1730c27b03bbb7a609c475e3647f0c8c11e2f4e
    Author: erikcas <erikcas1972@gmail.com>
    Date:   Sun Nov 30 01:54:25 2014 +0100

        Eagle: fix regulator msm8226_l27

    Signed-off-by: Alin Jerpelea <alin.jerpelea@sonymobile.com>

TIANCHI DEVICE (Xperia T2 Ultra)

commit 0352d27fe9c87a6fa36ca83e69cdb2b3df2399b9
Author: Adam Farden <adam@farden.cz>
Date:   Thu Nov 20 19:39:55 2014 +0100

    Tianchi: Platform

    includes
    commit 5d1b1f19310f3dabedd90a95b4df521d552eb298
    Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
    Date:   Mon Nov 24 10:30:37 2014 +0000

        arm: dts: Tianchi: 8226_l28 shall be always-on

    commit 0f8788430e5462adbf0514b0b0fca72dc52cb44f
    Author: Adam Farden <adam@farden.cz>
    Date:   Tue Dec 2 19:36:15 2014 +0100

        Tianchi: fix dt.img generation

        Now we can use v2 dt.img like other devices
        msm8926-yukon_tianchi.dtsi is simply an out-of-date msm8926.dtsi, it
        was forked due to Sony's backporting of kernel features.

        Signed-off-by: Adam Farden <adam@farden.cz>

    commit 96d74bf5c429ca9e80ce64b1f08d8adad21f3370
    Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
    Date:   Tue Dec 9 09:46:30 2014 +0000

        arm: dts: Tianchi: Specify new reset sequences for panels

        The new driver isn't using the classic reset sequence.
        Instead, it uses different sequences for poweron and off
        and that's good for us because we would anyway do the same.

SEAGULL DEVICE (Xperia T3)
commit a17b0d3da5399cf1580e57dc15b7a10705286334
Author: Alin Jerpelea <alin.jerpelea@sonymobile.com>
Date:   Sat Nov 22 13:08:46 2014 +0100

    seagull: platform import

    includes
    commit d5bf5ee2b4e5d4ac73dd689646be6cb5aea0b1ff
    Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
    Date:   Mon Nov 24 10:18:42 2014 +0000

        arm: dts: Seagull: 8226_l19 shall be always-on

    git cherry-pick 16a392d15d4b67cd3993164ac4b61b401ed54e50
    Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
    Date:   Tue Dec 2 15:07:18 2014 +0000

        arm: configs: Update Seagull config for new display driver

    commit 569b2622c67df69b9c07d9199664994badae0426
    Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
    Date:   Tue Dec 2 14:46:16 2014 +0000

        arm: Seagull: Welcome to the Sony Unified display driver

    commit fa87f98040967eaadae2a27dbb68baddc0d1ed02
    Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
    Date:   Sun Dec 7 10:02:53 2014 +0000

        arm: dts: Seagull: Configure I2C QUP2 properly and add regulator changes

    commit 38dd4656532de7d4963ea0fb752d43bd866de632
    Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
    Date:   Mon Dec 8 12:39:37 2014 +0000

        arm: dts: Seagull: Rename, fix and unify panel

        Also remove the spi0 property and alias, because of GPIO conflicts.

    commit 3a0c87b2d1f7492e6378e881d979f6bc7daea344
    Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
    Date:   Mon Dec 8 12:45:26 2014 +0000

        arm: dts: Seagull: Declare address-cells and size-cells for i2c QUP2

        ....So that we'll stop getting warnings while generating the DTB.

    commit 1c7f38e40d4d1194993587d7424b68cc393e92bc
    Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
    Date:   Tue Dec 9 10:12:27 2014 +0000

        arm: configs: Seagull: New config for touchscreen

    commit 16814e9f6dc522cc7988a111f54f5308dd6779ab
    Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
    Date:   Tue Dec 9 12:07:23 2014 +0000

        arm: Seagull: Fix volume up button

    commit 0bd24fcc29a32bf2c1959fbe6b66a252d60bf4b3
    Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
    Date:   Wed Dec 10 10:47:30 2014 +0000

    arm: Seagull: Fix battery charging

    Signed-off-by: Alin Jerpelea <alin.jerpelea@sonymobile.com>

COMMON
commit 1bc18c7213d89d73617097b758a97ed1e864f69d
Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
Date:   Thu Dec 4 21:49:37 2014 +0000

    arm: msm: Add SOMC Yukon board to Kconfig

commit bbe9643bd5cfd6d79a98eccf1075cbc4dd1cb36a
Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
Date:   Tue Dec 9 10:02:20 2014 +0000

    arm: dts: Introduce common properties for SOMC Yukon

    commit a42765af76cdbbe18c3d5a674252a8e49b694988
    Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
    Date:   Tue Dec 9 01:27:44 2014 +0000

        arm: dts: Yukon: add qcom,clamp-soc-max-count property for battery

commit aa812f39642505c04a153bff635b3c270b9c0bae
Author: Angelo G. Del Regno -- EternityProject Team Manager <kholk11@gmail.com>
Date:   Tue Dec 9 15:21:58 2014 +0000

    arm: dts: Flamingo: Cleanup and unify

commit 5bfa3243f3e3e362687c6c1c84d2bdb713ad69f5
Author: Alin Jerpelea <alin.jerpelea@sonymobile.com>
Date:   Wed Dec 10 11:00:35 2014 +0100

    yukon: gpio key cleanup

    this commit also fixes gpio keys bug for eagle

    Signed-off-by: Alin Jerpelea <alin.jerpelea@sonymobile.com>
tianchi: use standard wled:backlight naming

Signed-off-by: Alin Jerpelea <alin.jerpelea@sonymobile.com>
Eagle: port camera from stock 18.3.1.C.0.21

Change-Id: Id8d991f830b8bf000d2cb0d67350b7da1271d855
Fix sizeof-pointer-memaccess warning with gcc 4.8

This patch fixes wrong memcpy size when copying ltk value to
HCI_OP_LE_LTK_REPLY command.

Change-Id: I44e5e3da15369d4b424581720ccd3bac820ef2e0
Copy audio_effects.h to userspace

Change-Id: Idce1c1e51b80ae58cfd663376a41cb37a0649f5b
Hotplug thread infrastructure

smp: Add generic smpboot facility

Start a new file, which will hold SMP and CPU hotplug related generic
infrastructure.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Richard Kuo <rkuo@codeaurora.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Hirokazu Takata <takata@linux-m32r.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: David Howells <dhowells@redhat.com>
Cc: James E.J. Bottomley <jejb@parisc-linux.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: x86@kernel.org
Link: http://lkml.kernel.org/r/20120420124557.035417523@linutronix.de

Change-Id: Ia1ad435435aa12c47ac0d381ae031ebf6edcff1f

smp: Provide generic idle thread allocation

All SMP architectures have magic to fork the idle task and to store it
for reusage when cpu hotplug is enabled. Provide a generic
infrastructure for it.

Create/reinit the idle thread for the cpu which is brought up in the
generic code and hand the thread pointer to the architecture code via
__cpu_up().

Note, that fork_idle() is called via a workqueue, because this
guarantees that the idle thread does not get a reference to a user
space VM. This can happen when the boot process did not bring up all
possible cpus and a later cpu_up() is initiated via the sysfs
interface. In that case fork_idle() would be called in the context of
the user space task and take a reference on the user space VM.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Richard Kuo <rkuo@codeaurora.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Hirokazu Takata <takata@linux-m32r.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: David Howells <dhowells@redhat.com>
Cc: James E.J. Bottomley <jejb@parisc-linux.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: x86@kernel.org
Acked-by: Venkatesh Pallipadi <venki@google.com>
Link: http://lkml.kernel.org/r/20120420124557.102478630@linutronix.de

Change-Id: Ie2d32789f3a69ee15f38ba704aaa84d6be85bcd4

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

percpu areas are already allocated during boot for each possible cpu.
percpu idle threads can be considered as an extension of the percpu areas,
and allocate them for each possible cpu during boot.

This will eliminate the need for workqueue based idle thread allocation.
In future we can move the idle thread area into the percpu area too.

[ tglx: Moved the loop into smpboot.c and added an error check when
  the init code failed to allocate an idle thread for a cpu which
  should be onlined ]

Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: venki@google.com
Link: http://lkml.kernel.org/r/1334966930.28674.245.camel@sbsiddha-desk.sc.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Change-Id: I36828165fc08b7c0a8a0fe6a2aa24d358e623dd2

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

While trying to initialize idle threads for all cpus, idle_threads_init()
calls smp_processor_id() in a loop, which is unnecessary. The intent
is to initialize idle threads for all non-boot cpus. So just use a variable
to note the boot cpu and use it in the loop.

Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: suresh.b.siddha@intel.com
Cc: venki@google.com
Cc: nikunj@linux.vnet.ibm.com
Link: http://lkml.kernel.org/r/20120524151055.2549.64309.stgit@srivatsabhat.in.ibm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Change-Id: Ib65df4c31e93e1622c26f2c2a4946ffd28c1839d

smpboot, idle: Fix comment mismatch over idle_threads_init()

The comment over idle_threads_init() really talks about the functionality
of idle_init(). Move that comment to idle_init(), and add a suitable
comment over idle_threads_init().

Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: suresh.b.siddha@intel.com
Cc: venki@google.com
Cc: nikunj@linux.vnet.ibm.com
Link: http://lkml.kernel.org/r/20120524151100.2549.66501.stgit@srivatsabhat.in.ibm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Change-Id: Ib0cd6d6e19e0c64868a42a77101b080a5f3b04f8

kthread_worker: reorganize to prepare for flush_kthread_work() reimplementation

Make the following two non-functional changes.

* Separate out insert_kthread_work() from queue_kthread_work().

* Relocate struct kthread_flush_work and kthread_flush_work_fn()
  definitions above flush_kthread_work().

v2: Added lockdep_assert_held() in insert_kthread_work() as suggested
    by Andy Walls.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Andy Walls <awalls@md.metrocast.net>

Change-Id: Ie1eef2c000c328ec16f32db011377415237da93d

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

kthread_worker provides minimalistic workqueue-like interface for
users which need a dedicated worker thread (e.g. for realtime
priority).  It has basic queue, flush_work, flush_worker operations
which mostly match the workqueue counterparts; however, due to the way
flush_work() is implemented, it has a noticeable difference of not
allowing work items to be freed while being executed.

While the current users of kthread_worker are okay with the current
behavior, the restriction does impede some valid use cases.  Also,
removing this difference isn't difficult and actually makes the code
easier to understand.

This patch reimplements flush_kthread_work() such that it uses a
flush_work item instead of queue/done sequence numbers.

Signed-off-by: Tejun Heo <tj@kernel.org>

Change-Id: I06e2ab5ef8ea3caa8e40257da0a636ab9eb5ae55

kthread: Implement park/unpark facility

To avoid the full teardown/setup of per cpu kthreads in the case of
cpu hot(un)plug, provide a facility which allows to put the kthread
into a park position and unpark it when the cpu comes online again.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/20120716103948.236618824@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Change-Id: I05d28788540b666349bafecf6cb3fdc873b6cdde

smpboot: Provide infrastructure for percpu hotplug threads

Provide a generic interface for setting up and tearing down percpu
threads.

On registration the threads for already online cpus are created and
started. On deregistration (modules) the threads are stoppped.

During hotplug operations the threads are created, started, parked and
unparked. The datastructure for registration provides a pointer to
percpu storage space and optional setup, cleanup, park, unpark
functions. These functions are called when the thread state changes.

Each implementation has to provide a function which is queried and
returns whether the thread should run and the thread function itself.

The core code handles all state transitions and avoids duplicated code
in the call sites.

[ paulmck: Preemption leak fix ]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20120716103948.352501068@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Change-Id: Ib2ac667cd13cf26a042d65c1b3f20fe7e4b02423

hotplug: Fix UP bug in smpboot hotplug code

Because kernel subsystems need their per-CPU kthreads on UP systems as
well as on SMP systems, the smpboot hotplug kthread functions must be
provided in UP builds as well as in SMP builds.  This commit therefore
adds smpboot.c to UP builds and excludes irrelevant code via #ifdef.

Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Change-Id: I7b570d6c241c513227c3fdc1d843bf369bed036c

smpboot: Allow selfparking per cpu threads

The stop machine threads are still killed when a cpu goes offline. The
reason is that the thread is used to bring the cpu down, so it can't
be parked along with the other per cpu threads.

Allow a per cpu thread to be excluded from automatic parking, so it
can park itself once it's done

Add a create callback function as well.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Arjan van de Veen <arjan@infradead.org>
Cc: Paul Turner <pjt@google.com>
Cc: Richard Weinberger <rw@linutronix.de>
Cc: Magnus Damm <magnus.damm@gmail.com>
Link: http://lkml.kernel.org/r/20130131120741.553993267@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Change-Id: I864f39336a2cb648c518526459929c081f831216

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

The smpboot threads rely on the park/unpark mechanism which binds per
cpu threads on a particular core. Though the functionality is racy:

CPU0	       	 	CPU1  	     	    CPU2
unpark(T)				    wake_up_process(T)
  clear(SHOULD_PARK)	T runs
			leave parkme() due to !SHOULD_PARK
  bind_to(CPU2)		BUG_ON(wrong CPU)

We cannot let the tasks move themself to the target CPU as one of
those tasks is actually the migration thread itself, which requires
that it starts running on the target cpu right away.

The solution to this problem is to prevent wakeups in park mode which
are not from unpark(). That way we can guarantee that the association
of the task to the target cpu is working correctly.

Add a new task state (TASK_PARKED) which prevents other wakeups and
use this state explicitly for the unpark wakeup.

Peter noticed: Also, since the task state is visible to userspace and
all the parked tasks are still in the PID space, its a good hint in ps
and friends that these tasks aren't really there for the moment.

The migration thread has another related issue.

CPU0	      	     	 CPU1
Bring up CPU2
create_thread(T)
park(T)
 wait_for_completion()
			 parkme()
			 complete()
sched_set_stop_task()
			 schedule(TASK_PARKED)

The sched_set_stop_task() call is issued while the task is on the
runqueue of CPU1 and that confuses the hell out of the stop_task class
on that cpu. So we need the same synchronizaion before
sched_set_stop_task().

Reported-by: Dave Jones <davej@redhat.com>
Reported-and-tested-by: Dave Hansen <dave@sr71.net>
Reported-and-tested-by: Borislav Petkov <bp@alien8.de>
Acked-by: Peter Ziljstra <peterz@infradead.org>
Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: dhillf@gmail.com
Cc: Ingo Molnar <mingo@kernel.org>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/alpine.LFD.2.02.1304091635430.21884@ionos
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Change-Id: If1e9993951c4ad1f6f35ad0698f6ccd05a67e81f

stop_machine: Store task reference in a separate per cpu variable

To allow the stopper thread being managed by the smpboot thread
infrastructure separate out the task storage from the stopper data
structure.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Arjan van de Veen <arjan@infradead.org>
Cc: Paul Turner <pjt@google.com>
Cc: Richard Weinberger <rw@linutronix.de>
Cc: Magnus Damm <magnus.damm@gmail.com>
Link: http://lkml.kernel.org/r/20130131120741.626690384@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Change-Id: Ibfe2389e42fcf2e236940bbc223a36da571ed6e9

stop_machine: Use smpboot threads

Use the smpboot thread infrastructure. Mark the stopper thread
selfparking and park it after it has finished the take_cpu_down()
work.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Arjan van de Veen <arjan@infradead.org>
Cc: Paul Turner <pjt@google.com>
Cc: Richard Weinberger <rw@linutronix.de>
Cc: Magnus Damm <magnus.damm@gmail.com>
Link: http://lkml.kernel.org/r/20130131120741.686315164@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Change-Id: I30771810f2cbb2a64ca090864156edc79d338dfd

stop_machine: Mark per cpu stopper enabled early

commit 14e568e78 (stop_machine: Use smpboot threads) introduced the
following regression:

Before this commit the stopper enabled bit was set in the online
notifier.

CPU0				CPU1
cpu_up
				cpu online
hotplug_notifier(ONLINE)
  stopper(CPU1)->enabled = true;
...
stop_machine()

The conversion to smpboot threads moved the enablement to the wakeup
path of the parked thread. The majority of users seem to have the
following working order:

CPU0				CPU1
cpu_up
				cpu online
unpark_threads()
  wakeup(stopper[CPU1])
....
				stopper thread runs
				  stopper(CPU1)->enabled = true;
stop_machine()

But Konrad and Sander have observed:

CPU0				CPU1
cpu_up
				cpu online
unpark_threads()
  wakeup(stopper[CPU1])
....
stop_machine()
				stopper thread runs
				  stopper(CPU1)->enabled = true;

Now the stop machinery kicks CPU0 into the stop loop, where it gets
stuck forever because the queue code saw stopper(CPU1)->enabled ==
false, so CPU0 waits for CPU1 to enter stomp_machine, but the CPU1
stopper work got discarded due to enabled == false.

Add a pre_unpark function to the smpboot thread descriptor and call it
before waking the thread.

This fixes the problem at hand, but the stop_machine code should be
more robust. The stopper->enabled flag smells fishy at best.

Thanks to Konrad for going through a loop of debug patches and
providing the information to decode this issue.

Reported-and-tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reported-and-tested-by: Sander Eikelenboom <linux@eikelenboom.it>
Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Link: http://lkml.kernel.org/r/alpine.LFD.2.02.1302261843240.22263@ionos
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Change-Id: Iaff8824879eb21552fc9e46e259b604dfce113bc
cpufreq: cpu-boost: Use hotplug thread infrastructure

Before this patch, thread migration ran in uninterruptible threads.
Use the relatively new hotplug thread infrastructure with parked
threads to reduce cpu load (x4).

Change-Id: I4fa1f3a6d6b2b68ecb6e751678584f24abd85992
cpufreq: ondemand: Use hotplug thread infrastructure

The dbs_sync threads caused considerable load, even when ondemand
wasn't even active. Use the hotplug thread infrastructure to park
the threads.

Change-Id: I8e2c780e3f00b73edc0337e01c226386146e0fd4
random: make 'add_interrupt_randomness()' do something sane

commit 775f4b297b780601e61787b766f306ed3e1d23eb upstream.

We've been moving away from add_interrupt_randomness() for various
reasons: it's too expensive to do on every interrupt, and flooding the
CPU with interrupts could theoretically cause bogus floods of entropy
from a somewhat externally controllable source.

This solves both problems by limiting the actual randomness addition
to just once a second or after 64 interrupts, whicever comes first.
During that time, the interrupt cycle data is buffered up in a per-cpu
pool.  Also, we make sure the the nonblocking pool used by urandom is
initialized before we start feeding the normal input pool.  This
assures that /dev/urandom is returning unpredictable data as soon as
possible.

(Based on an original patch by Linus, but significantly modified by
tytso.)

Tested-by: Eric Wustrow <ewust@umich.edu>
Reported-by: Eric Wustrow <ewust@umich.edu>
Reported-by: Nadia Heninger <nadiah@cs.ucsd.edu>
Reported-by: Zakir Durumeric <zakir@umich.edu>
Reported-by: J. Alex Halderman <jhalderm@umich.edu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Patrick Tjin <pattjin.google.com>

random: use lockless techniques in the interrupt path

commit 902c098a3663de3fa18639efbb71b6080f0bcd3c upstream.

The real-time Linux folks don't like add_interrupt_randomness() taking
a spinlock since it is called in the low-level interrupt routine.
This also allows us to reduce the overhead in the fast path, for the
random driver, which is the interrupt collection path.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Patrick Tjin <pattjin@google.com>

random: create add_device_randomness() interface

commit a2080a67abe9e314f9e9c2cc3a4a176e8a8f8793 upstream.

Add a new interface, add_device_randomness() for adding data to the
random pool that is likely to differ between two devices (or possibly
even per boot).  This would be things like MAC addresses or serial
numbers, or the read-out of the RTC. This does *not* add any actual
entropy to the pool, but it initializes the pool to different values
for devices that might otherwise be identical and have very little
entropy available to them (particularly common in the embedded world).

[ Modified by tytso to mix in a timestamp, since there may be some
  variability caused by the time needed to detect/configure the hardware
  in question. ]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Patrick Tjin <pattjin@google.com>

usb: feed USB device information to the /dev/random driver

commit b04b3156a20d395a7faa8eed98698d1e17a36000 upstream.

Send the USB device's serial, product, and manufacturer strings to the
/dev/random driver to help seed its pools.

Cc: Linus Torvalds <torvalds@linux-foundation.org>
Acked-by: Greg KH <greg@kroah.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Conflicts:
	drivers/usb/core/hub.c

Signed-off-by: Patrick Tjin <pattjin@google.com>

net: feed /dev/random with the MAC address when registering a device

commit 7bf2357524408b97fec58344caf7397f8140c3fd upstream.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: David Miller <davem@davemloft.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Patrick Tjin <pattjin@google.com>

random: use the arch-specific rng in xfer_secondary_pool

commit e6d4947b12e8ad947add1032dd754803c6004824 upstream.

If the CPU supports a hardware random number generator, use it in
xfer_secondary_pool(), where it will significantly improve things and
where we can afford it.

Also, remove the use of the arch-specific rng in
add_timer_randomness(), since the call is significantly slower than
get_cycles(), and we're much better off using it in
xfer_secondary_pool() anyway.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Patrick Tjin <pattjin@google.com>

random: add new get_random_bytes_arch() function

commit c2557a303ab6712bb6e09447df828c557c710ac9 upstream.

Create a new function, get_random_bytes_arch() which will use the
architecture-specific hardware random number generator if it is
present.  Change get_random_bytes() to not use the HW RNG, even if it
is avaiable.

The reason for this is that the hw random number generator is fast (if
it is present), but it requires that we trust the hardware
manufacturer to have not put in a back door.  (For example, an
increasing counter encrypted by an AES key known to the NSA.)

It's unlikely that Intel (for example) was paid off by the US
Government to do this, but it's impossible for them to prove otherwise
  --- especially since Bull Mountain is documented to use AES as a
whitener.  Hence, the output of an evil, trojan-horse version of
RDRAND is statistically indistinguishable from an RDRAND implemented
to the specifications claimed by Intel.  Short of using a tunnelling
electronic microscope to reverse engineer an Ivy Bridge chip and
disassembling and analyzing the CPU microcode, there's no way for us
to tell for sure.

Since users of get_random_bytes() in the Linux kernel need to be able
to support hardware systems where the HW RNG is not present, most
time-sensitive users of this interface have already created their own
cryptographic RNG interface which uses get_random_bytes() as a seed.
So it's much better to use the HW RNG to improve the existing random
number generator, by mixing in any entropy returned by the HW RNG into
/dev/random's entropy pool, but to always _use_ /dev/random's entropy
pool.

This way we get almost of the benefits of the HW RNG without any
potential liabilities.  The only benefits we forgo is the
speed/performance enhancements --- and generic kernel code can't
depend on depend on get_random_bytes() having the speed of a HW RNG
anyway.

For those places that really want access to the arch-specific HW RNG,
if it is available, we provide get_random_bytes_arch().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Patrick Tjin <pattjin@google.com>

random: remove rand_initialize_irq()

commit c5857ccf293968348e5eb4ebedc68074de3dcda6 upstream.

With the new interrupt sampling system, we are no longer using the
timer_rand_state structure in the irq descriptor, so we can stop
initializing it now.

[ Merged in fixes from Sedat to find some last missing references to
  rand_initialize_irq() ]

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Patrick Tjin <pattjin@google.com>
softirq: Use hotplug thread infrastructure

[ paulmck: Call rcu_note_context_switch() with interrupts enabled. ]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20120716103948.456416747@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>