--- /dev/null
+From 4c94cada48f7c660eca582be6032427a5e367117 Mon Sep 17 00:00:00 2001
+From: Frederic Weisbecker <fweisbec@gmail.com>
+Date: Wed, 22 Aug 2012 17:27:34 +0200
+Subject: alpha: Add missing RCU idle APIs on idle loop
+
+From: Frederic Weisbecker <fweisbec@gmail.com>
+
+commit 4c94cada48f7c660eca582be6032427a5e367117 upstream.
+
+In the old times, the whole idle task was considered
+as an RCU quiescent state. But as RCU became more and
+more successful overtime, some RCU read side critical
+section have been added even in the code of some
+architectures idle tasks, for tracing for example.
+
+So nowadays, rcu_idle_enter() and rcu_idle_exit() must
+be called by the architecture to tell RCU about the part
+in the idle loop that doesn't make use of rcu read side
+critical sections, typically the part that puts the CPU
+in low power mode.
+
+This is necessary for RCU to find the quiescent states in
+idle in order to complete grace periods.
+
+Add this missing pair of calls in the Alpha's idle loop.
+
+Reported-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
+Tested-by: Michael Cree <mcree@orcon.net.nz>
+Cc: Richard Henderson <rth@twiddle.net>
+Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
+Cc: Matt Turner <mattst88@gmail.com>
+Cc: alpha <linux-alpha@vger.kernel.org>
+Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Reviewed-by: Josh Triplett <josh@joshtriplett.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/alpha/kernel/process.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/arch/alpha/kernel/process.c
++++ b/arch/alpha/kernel/process.c
+@@ -28,6 +28,7 @@
+ #include <linux/tty.h>
+ #include <linux/console.h>
+ #include <linux/slab.h>
++#include <linux/rcupdate.h>
+
+ #include <asm/reg.h>
+ #include <asm/uaccess.h>
+@@ -54,8 +55,10 @@ cpu_idle(void)
+ /* FIXME -- EV6 and LCA45 know how to power down
+ the CPU. */
+
++ rcu_idle_enter();
+ while (!need_resched())
+ cpu_relax();
++ rcu_idle_exit();
+ schedule();
+ }
+ }
--- /dev/null
+From c633f9e788928e91ad11f44df29b47bbbe9550b0 Mon Sep 17 00:00:00 2001
+From: Frederic Weisbecker <fweisbec@gmail.com>
+Date: Wed, 22 Aug 2012 17:27:34 +0200
+Subject: cris: Add missing RCU idle APIs on idle loop
+
+From: Frederic Weisbecker <fweisbec@gmail.com>
+
+commit c633f9e788928e91ad11f44df29b47bbbe9550b0 upstream.
+
+In the old times, the whole idle task was considered
+as an RCU quiescent state. But as RCU became more and
+more successful overtime, some RCU read side critical
+section have been added even in the code of some
+architectures idle tasks, for tracing for example.
+
+So nowadays, rcu_idle_enter() and rcu_idle_exit() must
+be called by the architecture to tell RCU about the part
+in the idle loop that doesn't make use of rcu read side
+critical sections, typically the part that puts the CPU
+in low power mode.
+
+This is necessary for RCU to find the quiescent states in
+idle in order to complete grace periods.
+
+Add this missing pair of calls in the Cris's idle loop.
+
+Reported-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
+Cc: Mikael Starvik <starvik@axis.com>
+Cc: Jesper Nilsson <jesper.nilsson@axis.com>
+Cc: Cris <linux-cris-kernel@axis.com>
+Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Reviewed-by: Josh Triplett <josh@joshtriplett.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/cris/kernel/process.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/arch/cris/kernel/process.c
++++ b/arch/cris/kernel/process.c
+@@ -25,6 +25,7 @@
+ #include <linux/elfcore.h>
+ #include <linux/mqueue.h>
+ #include <linux/reboot.h>
++#include <linux/rcupdate.h>
+
+ //#define DEBUG
+
+@@ -74,6 +75,7 @@ void cpu_idle (void)
+ {
+ /* endless idle loop with no priority at all */
+ while (1) {
++ rcu_idle_enter();
+ while (!need_resched()) {
+ void (*idle)(void);
+ /*
+@@ -86,6 +88,7 @@ void cpu_idle (void)
+ idle = default_idle;
+ idle();
+ }
++ rcu_idle_exit();
+ schedule_preempt_disabled();
+ }
+ }
--- /dev/null
+From 74d44445afb9f50126eba052adeb89827cee88f3 Mon Sep 17 00:00:00 2001
+From: Daniel Vetter <daniel.vetter@ffwll.ch>
+Date: Tue, 2 Oct 2012 17:54:35 +0200
+Subject: drm/i915: call drm_handle_vblank before finish_page_flip
+
+From: Daniel Vetter <daniel.vetter@ffwll.ch>
+
+commit 74d44445afb9f50126eba052adeb89827cee88f3 upstream.
+
+... since finish_page_flip needs the vblank timestamp generated
+in drm_handle_vblank. Somehow all the gmch platforms get it right,
+but all the pch platform irq handlers get is wrong. Hooray for copy&
+pasting!
+
+Currently this gets papered over by a gross hack in finish_page_flip.
+A second patch will remove that.
+
+Note that without this, the new timestamp sanity checks in flip_test
+occasionally get tripped up, hence the cc: stable tag.
+
+Reviewed-by: mario.kleiner@tuebingen.mpg.de
+Tested-by: Imre Deak <imre.deak@intel.com>
+Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/drm/i915/i915_irq.c | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+--- a/drivers/gpu/drm/i915/i915_irq.c
++++ b/drivers/gpu/drm/i915/i915_irq.c
+@@ -680,12 +680,12 @@ static irqreturn_t ivybridge_irq_handler
+ intel_opregion_gse_intr(dev);
+
+ for (i = 0; i < 3; i++) {
++ if (de_iir & (DE_PIPEA_VBLANK_IVB << (5 * i)))
++ drm_handle_vblank(dev, i);
+ if (de_iir & (DE_PLANEA_FLIP_DONE_IVB << (5 * i))) {
+ intel_prepare_page_flip(dev, i);
+ intel_finish_page_flip_plane(dev, i);
+ }
+- if (de_iir & (DE_PIPEA_VBLANK_IVB << (5 * i)))
+- drm_handle_vblank(dev, i);
+ }
+
+ /* check event from PCH */
+@@ -767,6 +767,12 @@ static irqreturn_t ironlake_irq_handler(
+ if (de_iir & DE_GSE)
+ intel_opregion_gse_intr(dev);
+
++ if (de_iir & DE_PIPEA_VBLANK)
++ drm_handle_vblank(dev, 0);
++
++ if (de_iir & DE_PIPEB_VBLANK)
++ drm_handle_vblank(dev, 1);
++
+ if (de_iir & DE_PLANEA_FLIP_DONE) {
+ intel_prepare_page_flip(dev, 0);
+ intel_finish_page_flip_plane(dev, 0);
+@@ -777,12 +783,6 @@ static irqreturn_t ironlake_irq_handler(
+ intel_finish_page_flip_plane(dev, 1);
+ }
+
+- if (de_iir & DE_PIPEA_VBLANK)
+- drm_handle_vblank(dev, 0);
+-
+- if (de_iir & DE_PIPEB_VBLANK)
+- drm_handle_vblank(dev, 1);
+-
+ /* check event from PCH */
+ if (de_iir & DE_PCH_EVENT) {
+ if (pch_iir & hotplug_mask)
--- /dev/null
+From f8f2ac9a76b0f80a6763ca316116a7bab8486997 Mon Sep 17 00:00:00 2001
+From: Ben Widawsky <ben@bwidawsk.net>
+Date: Wed, 3 Oct 2012 19:34:24 -0700
+Subject: drm/i915: Fix GT_MODE default value
+
+From: Ben Widawsky <ben@bwidawsk.net>
+
+commit f8f2ac9a76b0f80a6763ca316116a7bab8486997 upstream.
+
+I can't even find how I figured this might be needed anymore. But sure
+enough, the value I'm reading back on platforms doesn't match what the
+docs recommends.
+
+It seemed to fix Chris' GT1 in limited testing as well.
+
+Tested-by: Chris Wilson <chris@chris-wilson.co.uk>
+Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
+Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/drm/i915/i915_reg.h | 3 +++
+ drivers/gpu/drm/i915/intel_pm.c | 5 +++++
+ 2 files changed, 8 insertions(+)
+
+--- a/drivers/gpu/drm/i915/i915_reg.h
++++ b/drivers/gpu/drm/i915/i915_reg.h
+@@ -519,6 +519,9 @@
+ # define VS_TIMER_DISPATCH (1 << 6)
+ # define MI_FLUSH_ENABLE (1 << 12)
+
++#define GEN6_GT_MODE 0x20d0
++#define GEN6_GT_MODE_HI (1 << 9)
++
+ #define GFX_MODE 0x02520
+ #define GFX_MODE_GEN7 0x0229c
+ #define RING_MODE_GEN7(ring) ((ring)->mmio_base+0x29c)
+--- a/drivers/gpu/drm/i915/intel_pm.c
++++ b/drivers/gpu/drm/i915/intel_pm.c
+@@ -3387,6 +3387,11 @@ static void gen6_init_clock_gating(struc
+ DISPPLANE_TRICKLE_FEED_DISABLE);
+ intel_flush_display_plane(dev_priv, pipe);
+ }
++
++ /* The default value should be 0x200 according to docs, but the two
++ * platforms I checked have a 0 for this. (Maybe BIOS overrides?) */
++ I915_WRITE(GEN6_GT_MODE, _MASKED_BIT_DISABLE(0xffff));
++ I915_WRITE(GEN6_GT_MODE, _MASKED_BIT_ENABLE(GEN6_GT_MODE_HI));
+ }
+
+ static void gen7_setup_fixed_func_scheduler(struct drm_i915_private *dev_priv)
--- /dev/null
+From 5bb61643f6a70d48de9cfe91ad0fee0d618b6816 Mon Sep 17 00:00:00 2001
+From: Chris Wilson <chris@chris-wilson.co.uk>
+Date: Thu, 27 Sep 2012 21:25:58 +0100
+Subject: drm/i915: Flush the pending flips on the CRTC before modification
+
+From: Chris Wilson <chris@chris-wilson.co.uk>
+
+commit 5bb61643f6a70d48de9cfe91ad0fee0d618b6816 upstream.
+
+This was meant to be the purpose of the
+intel_crtc_wait_for_pending_flips() function which is called whilst
+preparing the CRTC for a modeset or before disabling. However, as Ville
+Syrjala pointed out, we set the pending flip notification on the old
+framebuffer that is no longer attached to the CRTC by the time we come
+to flush the pending operations. Instead, we can simply wait on the
+pending unpin work to be finished on this CRTC, knowning that the
+hardware has therefore finished modifying the registers, before proceeding
+with our direct access.
+
+Fixes i-g-t/flip_test on non-pch platforms. pch platforms simply
+schedule the flip immediately when the pipe is disabled, leading
+to other funny issues.
+
+Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
+[danvet: Added i-g-t note and cc: stable]
+Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/drm/i915/intel_display.c | 24 ++++++++++++++++++++++--
+ 1 file changed, 22 insertions(+), 2 deletions(-)
+
+--- a/drivers/gpu/drm/i915/intel_display.c
++++ b/drivers/gpu/drm/i915/intel_display.c
+@@ -2823,13 +2823,34 @@ static void ironlake_fdi_disable(struct
+ udelay(100);
+ }
+
++static bool intel_crtc_has_pending_flip(struct drm_crtc *crtc)
++{
++ struct drm_device *dev = crtc->dev;
++ struct drm_i915_private *dev_priv = dev->dev_private;
++ unsigned long flags;
++ bool pending;
++
++ if (atomic_read(&dev_priv->mm.wedged))
++ return false;
++
++ spin_lock_irqsave(&dev->event_lock, flags);
++ pending = to_intel_crtc(crtc)->unpin_work != NULL;
++ spin_unlock_irqrestore(&dev->event_lock, flags);
++
++ return pending;
++}
++
+ static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc)
+ {
+ struct drm_device *dev = crtc->dev;
++ struct drm_i915_private *dev_priv = dev->dev_private;
+
+ if (crtc->fb == NULL)
+ return;
+
++ wait_event(dev_priv->pending_flip_queue,
++ !intel_crtc_has_pending_flip(crtc));
++
+ mutex_lock(&dev->struct_mutex);
+ intel_finish_fb(crtc->fb);
+ mutex_unlock(&dev->struct_mutex);
+@@ -6149,9 +6170,8 @@ static void do_intel_finish_page_flip(st
+
+ atomic_clear_mask(1 << intel_crtc->plane,
+ &obj->pending_flip.counter);
+- if (atomic_read(&obj->pending_flip) == 0)
+- wake_up(&dev_priv->pending_flip_queue);
+
++ wake_up(&dev_priv->pending_flip_queue);
+ schedule_work(&work->work);
+
+ trace_i915_flip_complete(intel_crtc->plane, work->pending_flip_obj);
--- /dev/null
+From 41d8fe5bb3cf91ce2716ac8f43e4b40d802a99c8 Mon Sep 17 00:00:00 2001
+From: Frederic Weisbecker <fweisbec@gmail.com>
+Date: Wed, 22 Aug 2012 17:27:34 +0200
+Subject: frv: Add missing RCU idle APIs on idle loop
+
+From: Frederic Weisbecker <fweisbec@gmail.com>
+
+commit 41d8fe5bb3cf91ce2716ac8f43e4b40d802a99c8 upstream.
+
+In the old times, the whole idle task was considered
+as an RCU quiescent state. But as RCU became more and
+more successful overtime, some RCU read side critical
+section have been added even in the code of some
+architectures idle tasks, for tracing for example.
+
+So nowadays, rcu_idle_enter() and rcu_idle_exit() must
+be called by the architecture to tell RCU about the part
+in the idle loop that doesn't make use of rcu read side
+critical sections, typically the part that puts the CPU
+in low power mode.
+
+This is necessary for RCU to find the quiescent states in
+idle in order to complete grace periods.
+
+Add this missing pair of calls in the Frv's idle loop.
+
+Reported-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
+Cc: David Howells <dhowells@redhat.com>
+Acked-by: David Howells <dhowells@redhat.com>
+Reviewed-by: Josh Triplett <josh@joshtriplett.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/frv/kernel/process.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/arch/frv/kernel/process.c
++++ b/arch/frv/kernel/process.c
+@@ -25,6 +25,7 @@
+ #include <linux/reboot.h>
+ #include <linux/interrupt.h>
+ #include <linux/pagemap.h>
++#include <linux/rcupdate.h>
+
+ #include <asm/asm-offsets.h>
+ #include <asm/uaccess.h>
+@@ -69,12 +70,14 @@ void cpu_idle(void)
+ {
+ /* endless idle loop with no priority at all */
+ while (1) {
++ rcu_idle_enter();
+ while (!need_resched()) {
+ check_pgt_cache();
+
+ if (!frv_dma_inprogress && idle)
+ idle();
+ }
++ rcu_idle_exit();
+
+ schedule_preempt_disabled();
+ }
--- /dev/null
+From b2fe1430d4115c74d007c825cb9dc3317f28bb16 Mon Sep 17 00:00:00 2001
+From: Frederic Weisbecker <fweisbec@gmail.com>
+Date: Wed, 22 Aug 2012 17:27:34 +0200
+Subject: h8300: Add missing RCU idle APIs on idle loop
+
+From: Frederic Weisbecker <fweisbec@gmail.com>
+
+commit b2fe1430d4115c74d007c825cb9dc3317f28bb16 upstream.
+
+In the old times, the whole idle task was considered
+as an RCU quiescent state. But as RCU became more and
+more successful overtime, some RCU read side critical
+section have been added even in the code of some
+architectures idle tasks, for tracing for example.
+
+So nowadays, rcu_idle_enter() and rcu_idle_exit() must
+be called by the architecture to tell RCU about the part
+in the idle loop that doesn't make use of rcu read side
+critical sections, typically the part that puts the CPU
+in low power mode.
+
+This is necessary for RCU to find the quiescent states in
+idle in order to complete grace periods.
+
+Add this missing pair of calls in the h8300's idle loop.
+
+Reported-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
+Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
+Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Reviewed-by: Josh Triplett <josh@joshtriplett.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/h8300/kernel/process.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/arch/h8300/kernel/process.c
++++ b/arch/h8300/kernel/process.c
+@@ -36,6 +36,7 @@
+ #include <linux/reboot.h>
+ #include <linux/fs.h>
+ #include <linux/slab.h>
++#include <linux/rcupdate.h>
+
+ #include <asm/uaccess.h>
+ #include <asm/traps.h>
+@@ -78,8 +79,10 @@ void (*idle)(void) = default_idle;
+ void cpu_idle(void)
+ {
+ while (1) {
++ rcu_idle_enter();
+ while (!need_resched())
+ idle();
++ rcu_idle_exit();
+ schedule_preempt_disabled();
+ }
+ }
--- /dev/null
+From 93482f4ef1093f5961a63359a34612183d6beea0 Mon Sep 17 00:00:00 2001
+From: "Paul E. McKenney" <paul.mckenney@linaro.org>
+Date: Fri, 24 Aug 2012 13:22:13 -0700
+Subject: ia64: Add missing RCU idle APIs on idle loop
+
+From: "Paul E. McKenney" <paul.mckenney@linaro.org>
+
+commit 93482f4ef1093f5961a63359a34612183d6beea0 upstream.
+
+Traditionally, the entire idle task served as an RCU quiescent state.
+But when RCU read side critical sections started appearing within the
+idle loop, this traditional strategy became untenable. The fix was to
+create new RCU APIs named rcu_idle_enter() and rcu_idle_exit(), which
+must be called by each architecture's idle loop so that RCU can tell
+when it is safe to ignore a given idle CPU.
+
+Unfortunately, this fix was never applied to ia64, a shortcoming remedied
+by this commit.
+
+Reported by: Tony Luck <tony.luck@intel.com>
+Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org>
+Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Tested by: Tony Luck <tony.luck@intel.com>
+Reviewed-by: Josh Triplett <josh@joshtriplett.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/ia64/kernel/process.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/arch/ia64/kernel/process.c
++++ b/arch/ia64/kernel/process.c
+@@ -29,6 +29,7 @@
+ #include <linux/kdebug.h>
+ #include <linux/utsname.h>
+ #include <linux/tracehook.h>
++#include <linux/rcupdate.h>
+
+ #include <asm/cpu.h>
+ #include <asm/delay.h>
+@@ -279,6 +280,7 @@ cpu_idle (void)
+
+ /* endless idle loop with no priority at all */
+ while (1) {
++ rcu_idle_enter();
+ if (can_do_pal_halt) {
+ current_thread_info()->status &= ~TS_POLLING;
+ /*
+@@ -309,6 +311,7 @@ cpu_idle (void)
+ normal_xtp();
+ #endif
+ }
++ rcu_idle_exit();
+ schedule_preempt_disabled();
+ check_pgt_cache();
+ if (cpu_is_offline(cpu))
--- /dev/null
+From 48ae077cfce72591b8fc80e1dcc87806f86fed7f Mon Sep 17 00:00:00 2001
+From: Frederic Weisbecker <fweisbec@gmail.com>
+Date: Wed, 22 Aug 2012 17:27:34 +0200
+Subject: m32r: Add missing RCU idle APIs on idle loop
+
+From: Frederic Weisbecker <fweisbec@gmail.com>
+
+commit 48ae077cfce72591b8fc80e1dcc87806f86fed7f upstream.
+
+In the old times, the whole idle task was considered
+as an RCU quiescent state. But as RCU became more and
+more successful overtime, some RCU read side critical
+section have been added even in the code of some
+architectures idle tasks, for tracing for example.
+
+So nowadays, rcu_idle_enter() and rcu_idle_exit() must
+be called by the architecture to tell RCU about the part
+in the idle loop that doesn't make use of rcu read side
+critical sections, typically the part that puts the CPU
+in low power mode.
+
+This is necessary for RCU to find the quiescent states in
+idle in order to complete grace periods.
+
+Add this missing pair of calls in the m32r's idle loop.
+
+Reported-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
+Cc: Hirokazu Takata <takata@linux-m32r.org>
+Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Reviewed-by: Josh Triplett <josh@joshtriplett.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/m32r/kernel/process.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/arch/m32r/kernel/process.c
++++ b/arch/m32r/kernel/process.c
+@@ -26,6 +26,7 @@
+ #include <linux/ptrace.h>
+ #include <linux/unistd.h>
+ #include <linux/hardirq.h>
++#include <linux/rcupdate.h>
+
+ #include <asm/io.h>
+ #include <asm/uaccess.h>
+@@ -82,6 +83,7 @@ void cpu_idle (void)
+ {
+ /* endless idle loop with no priority at all */
+ while (1) {
++ rcu_idle_enter();
+ while (!need_resched()) {
+ void (*idle)(void) = pm_idle;
+
+@@ -90,6 +92,7 @@ void cpu_idle (void)
+
+ idle();
+ }
++ rcu_idle_exit();
+ schedule_preempt_disabled();
+ }
+ }
--- /dev/null
+From 5b57ba37e82a15f345a6a2eb8c01a2b2d94c5eeb Mon Sep 17 00:00:00 2001
+From: Frederic Weisbecker <fweisbec@gmail.com>
+Date: Wed, 22 Aug 2012 17:27:34 +0200
+Subject: m68k: Add missing RCU idle APIs on idle loop
+
+From: Frederic Weisbecker <fweisbec@gmail.com>
+
+commit 5b57ba37e82a15f345a6a2eb8c01a2b2d94c5eeb upstream.
+
+In the old times, the whole idle task was considered
+as an RCU quiescent state. But as RCU became more and
+more successful overtime, some RCU read side critical
+section have been added even in the code of some
+architectures idle tasks, for tracing for example.
+
+So nowadays, rcu_idle_enter() and rcu_idle_exit() must
+be called by the architecture to tell RCU about the part
+in the idle loop that doesn't make use of rcu read side
+critical sections, typically the part that puts the CPU
+in low power mode.
+
+This is necessary for RCU to find the quiescent states in
+idle in order to complete grace periods.
+
+Add this missing pair of calls in the m68k's idle loop.
+
+Reported-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
+Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
+Cc: m68k <linux-m68k@lists.linux-m68k.org>
+Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Reviewed-by: Josh Triplett <josh@joshtriplett.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/m68k/kernel/process.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/arch/m68k/kernel/process.c
++++ b/arch/m68k/kernel/process.c
+@@ -25,6 +25,7 @@
+ #include <linux/reboot.h>
+ #include <linux/init_task.h>
+ #include <linux/mqueue.h>
++#include <linux/rcupdate.h>
+
+ #include <asm/uaccess.h>
+ #include <asm/traps.h>
+@@ -75,8 +76,10 @@ void cpu_idle(void)
+ {
+ /* endless idle loop with no priority at all */
+ while (1) {
++ rcu_idle_enter();
+ while (!need_resched())
+ idle();
++ rcu_idle_exit();
+ schedule_preempt_disabled();
+ }
+ }
--- /dev/null
+From 5b0753a90b7a98bc613c3767e9263a1a76d4f900 Mon Sep 17 00:00:00 2001
+From: Frederic Weisbecker <fweisbec@gmail.com>
+Date: Wed, 22 Aug 2012 17:27:34 +0200
+Subject: mn10300: Add missing RCU idle APIs on idle loop
+
+From: Frederic Weisbecker <fweisbec@gmail.com>
+
+commit 5b0753a90b7a98bc613c3767e9263a1a76d4f900 upstream.
+
+In the old times, the whole idle task was considered
+as an RCU quiescent state. But as RCU became more and
+more successful overtime, some RCU read side critical
+section have been added even in the code of some
+architectures idle tasks, for tracing for example.
+
+So nowadays, rcu_idle_enter() and rcu_idle_exit() must
+be called by the architecture to tell RCU about the part
+in the idle loop that doesn't make use of rcu read side
+critical sections, typically the part that puts the CPU
+in low power mode.
+
+This is necessary for RCU to find the quiescent states in
+idle in order to complete grace periods.
+
+Add this missing pair of calls in the mn10300's idle loop.
+
+Reported-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
+Cc: David Howells <dhowells@redhat.com>
+Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
+Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Acked-by: David Howells <dhowells@redhat.com>
+Reviewed-by: Josh Triplett <josh@joshtriplett.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/mn10300/kernel/process.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/arch/mn10300/kernel/process.c
++++ b/arch/mn10300/kernel/process.c
+@@ -25,6 +25,7 @@
+ #include <linux/err.h>
+ #include <linux/fs.h>
+ #include <linux/slab.h>
++#include <linux/rcupdate.h>
+ #include <asm/uaccess.h>
+ #include <asm/pgtable.h>
+ #include <asm/io.h>
+@@ -107,6 +108,7 @@ void cpu_idle(void)
+ {
+ /* endless idle loop with no priority at all */
+ for (;;) {
++ rcu_idle_enter();
+ while (!need_resched()) {
+ void (*idle)(void);
+
+@@ -121,6 +123,7 @@ void cpu_idle(void)
+ }
+ idle();
+ }
++ rcu_idle_exit();
+
+ schedule_preempt_disabled();
+ }
--- /dev/null
+From fbe752188d5589e7fcbb8e79824e560f77dccc92 Mon Sep 17 00:00:00 2001
+From: Frederic Weisbecker <fweisbec@gmail.com>
+Date: Wed, 22 Aug 2012 17:27:34 +0200
+Subject: parisc: Add missing RCU idle APIs on idle loop
+
+From: Frederic Weisbecker <fweisbec@gmail.com>
+
+commit fbe752188d5589e7fcbb8e79824e560f77dccc92 upstream.
+
+In the old times, the whole idle task was considered
+as an RCU quiescent state. But as RCU became more and
+more successful overtime, some RCU read side critical
+section have been added even in the code of some
+architectures idle tasks, for tracing for example.
+
+So nowadays, rcu_idle_enter() and rcu_idle_exit() must
+be called by the architecture to tell RCU about the part
+in the idle loop that doesn't make use of rcu read side
+critical sections, typically the part that puts the CPU
+in low power mode.
+
+This is necessary for RCU to find the quiescent states in
+idle in order to complete grace periods.
+
+Add this missing pair of calls in the parisc's idle loop.
+
+Reported-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
+Cc: James E.J. Bottomley <jejb@parisc-linux.org>
+Cc: Helge Deller <deller@gmx.de>
+Cc: Parisc <linux-parisc@vger.kernel.org>
+Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Reviewed-by: Josh Triplett <josh@joshtriplett.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/parisc/kernel/process.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/arch/parisc/kernel/process.c
++++ b/arch/parisc/kernel/process.c
+@@ -48,6 +48,7 @@
+ #include <linux/unistd.h>
+ #include <linux/kallsyms.h>
+ #include <linux/uaccess.h>
++#include <linux/rcupdate.h>
+
+ #include <asm/io.h>
+ #include <asm/asm-offsets.h>
+@@ -69,8 +70,10 @@ void cpu_idle(void)
+
+ /* endless idle loop with no priority at all */
+ while (1) {
++ rcu_idle_enter();
+ while (!need_resched())
+ barrier();
++ rcu_idle_exit();
+ schedule_preempt_disabled();
+ check_pgt_cache();
+ }
--- /dev/null
+From a10d206ef1a83121ab7430cb196e0376a7145b22 Mon Sep 17 00:00:00 2001
+From: "Paul E. McKenney" <paul.mckenney@linaro.org>
+Date: Sat, 22 Sep 2012 13:55:30 -0700
+Subject: rcu: Fix day-one dyntick-idle stall-warning bug
+
+From: "Paul E. McKenney" <paul.mckenney@linaro.org>
+
+commit a10d206ef1a83121ab7430cb196e0376a7145b22 upstream.
+
+Each grace period is supposed to have at least one callback waiting
+for that grace period to complete. However, if CONFIG_NO_HZ=n, an
+extra callback-free grace period is no big problem -- it will chew up
+a tiny bit of CPU time, but it will complete normally. In contrast,
+CONFIG_NO_HZ=y kernels have the potential for all the CPUs to go to
+sleep indefinitely, in turn indefinitely delaying completion of the
+callback-free grace period. Given that nothing is waiting on this grace
+period, this is also not a problem.
+
+That is, unless RCU CPU stall warnings are also enabled, as they are
+in recent kernels. In this case, if a CPU wakes up after at least one
+minute of inactivity, an RCU CPU stall warning will result. The reason
+that no one noticed until quite recently is that most systems have enough
+OS noise that they will never remain absolutely idle for a full minute.
+But there are some embedded systems with cut-down userspace configurations
+that consistently get into this situation.
+
+All this begs the question of exactly how a callback-free grace period
+gets started in the first place. This can happen due to the fact that
+CPUs do not necessarily agree on which grace period is in progress.
+If a CPU still believes that the grace period that just completed is
+still ongoing, it will believe that it has callbacks that need to wait for
+another grace period, never mind the fact that the grace period that they
+were waiting for just completed. This CPU can therefore erroneously
+decide to start a new grace period. Note that this can happen in
+TREE_RCU and TREE_PREEMPT_RCU even on a single-CPU system: Deadlock
+considerations mean that the CPU that detected the end of the grace
+period is not necessarily officially informed of this fact for some time.
+
+Once this CPU notices that the earlier grace period completed, it will
+invoke its callbacks. It then won't have any callbacks left. If no
+other CPU has any callbacks, we now have a callback-free grace period.
+
+This commit therefore makes CPUs check more carefully before starting a
+new grace period. This new check relies on an array of tail pointers
+into each CPU's list of callbacks. If the CPU is up to date on which
+grace periods have completed, it checks to see if any callbacks follow
+the RCU_DONE_TAIL segment, otherwise it checks to see if any callbacks
+follow the RCU_WAIT_TAIL segment. The reason that this works is that
+the RCU_WAIT_TAIL segment will be promoted to the RCU_DONE_TAIL segment
+as soon as the CPU is officially notified that the old grace period
+has ended.
+
+This change is to cpu_needs_another_gp(), which is called in a number
+of places. The only one that really matters is in rcu_start_gp(), where
+the root rcu_node structure's ->lock is held, which prevents any
+other CPU from starting or completing a grace period, so that the
+comparison that determines whether the CPU is missing the completion
+of a grace period is stable.
+
+Reported-by: Becky Bruce <bgillbruce@gmail.com>
+Reported-by: Subodh Nijsure <snijsure@grid-net.com>
+Reported-by: Paul Walmsley <paul@pwsan.com>
+Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org>
+Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Tested-by: Paul Walmsley <paul@pwsan.com> # OMAP3730, OMAP4430
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/rcutree.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+--- a/kernel/rcutree.c
++++ b/kernel/rcutree.c
+@@ -305,7 +305,9 @@ cpu_has_callbacks_ready_to_invoke(struct
+ static int
+ cpu_needs_another_gp(struct rcu_state *rsp, struct rcu_data *rdp)
+ {
+- return *rdp->nxttail[RCU_DONE_TAIL] && !rcu_gp_in_progress(rsp);
++ return *rdp->nxttail[RCU_DONE_TAIL +
++ ACCESS_ONCE(rsp->completed) != rdp->completed] &&
++ !rcu_gp_in_progress(rsp);
+ }
+
+ /*
--- /dev/null
+From 0ee23fda59740767324b4340247ca41a2f498ca6 Mon Sep 17 00:00:00 2001
+From: Frederic Weisbecker <fweisbec@gmail.com>
+Date: Wed, 22 Aug 2012 17:27:34 +0200
+Subject: score: Add missing RCU idle APIs on idle loop
+
+From: Frederic Weisbecker <fweisbec@gmail.com>
+
+commit 0ee23fda59740767324b4340247ca41a2f498ca6 upstream.
+
+In the old times, the whole idle task was considered
+as an RCU quiescent state. But as RCU became more and
+more successful overtime, some RCU read side critical
+section have been added even in the code of some
+architectures idle tasks, for tracing for example.
+
+So nowadays, rcu_idle_enter() and rcu_idle_exit() must
+be called by the architecture to tell RCU about the part
+in the idle loop that doesn't make use of rcu read side
+critical sections, typically the part that puts the CPU
+in low power mode.
+
+This is necessary for RCU to find the quiescent states in
+idle in order to complete grace periods.
+
+Add this missing pair of calls in scores's idle loop.
+
+Reported-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
+Cc: Chen Liqin <liqin.chen@sunplusct.com>
+Cc: Lennox Wu <lennox.wu@gmail.com>
+Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Reviewed-by: Josh Triplett <josh@joshtriplett.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/score/kernel/process.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+--- a/arch/score/kernel/process.c
++++ b/arch/score/kernel/process.c
+@@ -27,6 +27,7 @@
+ #include <linux/reboot.h>
+ #include <linux/elfcore.h>
+ #include <linux/pm.h>
++#include <linux/rcupdate.h>
+
+ void (*pm_power_off)(void);
+ EXPORT_SYMBOL(pm_power_off);
+@@ -50,9 +51,10 @@ void __noreturn cpu_idle(void)
+ {
+ /* endless idle loop with no priority at all */
+ while (1) {
++ rcu_idle_enter();
+ while (!need_resched())
+ barrier();
+-
++ rcu_idle_exit();
+ schedule_preempt_disabled();
+ }
+ }
drm-radeon-add-msi-quirk-for-gateway-rs690.patch
drm-radeon-force-msis-on-rs690-asics.patch
hid-hidraw-don-t-deallocate-memory-when-it-is-in-use.patch
+drm-i915-flush-the-pending-flips-on-the-crtc-before-modification.patch
+drm-i915-call-drm_handle_vblank-before-finish_page_flip.patch
+drm-i915-fix-gt_mode-default-value.patch
+ia64-add-missing-rcu-idle-apis-on-idle-loop.patch
+h8300-add-missing-rcu-idle-apis-on-idle-loop.patch
+parisc-add-missing-rcu-idle-apis-on-idle-loop.patch
+xtensa-add-missing-rcu-idle-apis-on-idle-loop.patch
+frv-add-missing-rcu-idle-apis-on-idle-loop.patch
+mn10300-add-missing-rcu-idle-apis-on-idle-loop.patch
+m68k-add-missing-rcu-idle-apis-on-idle-loop.patch
+alpha-add-missing-rcu-idle-apis-on-idle-loop.patch
+cris-add-missing-rcu-idle-apis-on-idle-loop.patch
+m32r-add-missing-rcu-idle-apis-on-idle-loop.patch
+score-add-missing-rcu-idle-apis-on-idle-loop.patch
+rcu-fix-day-one-dyntick-idle-stall-warning-bug.patch
--- /dev/null
+From 11ad47a0edbd62bfc0547cfcdf227a911433f207 Mon Sep 17 00:00:00 2001
+From: Frederic Weisbecker <fweisbec@gmail.com>
+Date: Wed, 22 Aug 2012 17:27:34 +0200
+Subject: xtensa: Add missing RCU idle APIs on idle loop
+
+From: Frederic Weisbecker <fweisbec@gmail.com>
+
+commit 11ad47a0edbd62bfc0547cfcdf227a911433f207 upstream.
+
+In the old times, the whole idle task was considered
+as an RCU quiescent state. But as RCU became more and
+more successful overtime, some RCU read side critical
+section have been added even in the code of some
+architectures idle tasks, for tracing for example.
+
+So nowadays, rcu_idle_enter() and rcu_idle_exit() must
+be called by the architecture to tell RCU about the part
+in the idle loop that doesn't make use of rcu read side
+critical sections, typically the part that puts the CPU
+in low power mode.
+
+This is necessary for RCU to find the quiescent states in
+idle in order to complete grace periods.
+
+Add this missing pair of calls in the xtensa's idle loop.
+
+Reported-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
+Cc: Chris Zankel <chris@zankel.net>
+Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+Reviewed-by: Josh Triplett <josh@joshtriplett.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/xtensa/kernel/process.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/arch/xtensa/kernel/process.c
++++ b/arch/xtensa/kernel/process.c
+@@ -31,6 +31,7 @@
+ #include <linux/mqueue.h>
+ #include <linux/fs.h>
+ #include <linux/slab.h>
++#include <linux/rcupdate.h>
+
+ #include <asm/pgtable.h>
+ #include <asm/uaccess.h>
+@@ -110,8 +111,10 @@ void cpu_idle(void)
+
+ /* endless idle loop with no priority at all */
+ while (1) {
++ rcu_idle_enter();
+ while (!need_resched())
+ platform_idle();
++ rcu_idle_exit();
+ schedule_preempt_disabled();
+ }
+ }