Merge branches 'irq-urgent-for-linus' and 'timers-urgent-for-linus' of git://git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sun, 15 Nov 2015 17:30:48 +0000 (09:30 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 15 Nov 2015 17:30:48 +0000 (09:30 -0800)
Pull irq and timer fixes from Thomas Gleixner:

 - An irq regression fix to restore the wakeup behaviour of chained
   interrupts.

 - A timer fix for a long standing race versus timers scheduled on a
   target cpu which got exposed by recent changes in the workqueue
   implementation.

* 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  genirq/PM: Restore system wake up from chained interrupts

* 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  timers: Use proper base migration in add_timer_on()

kernel/irq/internals.h
kernel/irq/pm.c
kernel/irq/proc.c
kernel/time/timer.c

index 05c2188271b86730323c9bce053adc2d16e8d5a3..fcab63c669059308d3cc27054742587b0627b23f 100644 (file)
@@ -199,6 +199,11 @@ static inline int irq_desc_get_node(struct irq_desc *desc)
        return irq_common_data_get_node(&desc->irq_common_data);
 }
 
+static inline int irq_desc_is_chained(struct irq_desc *desc)
+{
+       return (desc->action && desc->action == &chained_action);
+}
+
 #ifdef CONFIG_PM_SLEEP
 bool irq_pm_check_wakeup(struct irq_desc *desc);
 void irq_pm_install_action(struct irq_desc *desc, struct irqaction *action);
index e80c4400118ae7a8e3f09476964260490fccf01a..cea1de0161f18a164aebb84e275ad67d5899eda8 100644 (file)
@@ -70,7 +70,8 @@ void irq_pm_remove_action(struct irq_desc *desc, struct irqaction *action)
 
 static bool suspend_device_irq(struct irq_desc *desc)
 {
-       if (!desc->action || desc->no_suspend_depth)
+       if (!desc->action || irq_desc_is_chained(desc) ||
+           desc->no_suspend_depth)
                return false;
 
        if (irqd_is_wakeup_set(&desc->irq_data)) {
index a916cf144b6550caf452fc304a1e848d40246b8a..a2c02fd5d6d0f8c1ade72ab2680287f37321aa25 100644 (file)
@@ -475,7 +475,7 @@ int show_interrupts(struct seq_file *p, void *v)
        for_each_online_cpu(j)
                any_count |= kstat_irqs_cpu(i, j);
        action = desc->action;
-       if ((!action || action == &chained_action) && !any_count)
+       if ((!action || irq_desc_is_chained(desc)) && !any_count)
                goto out;
 
        seq_printf(p, "%*d: ", prec, i);
index 74591ba9474f4dff4e0c3d7b7acedbe14b5d57a8..bbc5d1114583b21f1ab489cd40a98f3aa5ebd61d 100644 (file)
@@ -977,13 +977,29 @@ EXPORT_SYMBOL(add_timer);
  */
 void add_timer_on(struct timer_list *timer, int cpu)
 {
-       struct tvec_base *base = per_cpu_ptr(&tvec_bases, cpu);
+       struct tvec_base *new_base = per_cpu_ptr(&tvec_bases, cpu);
+       struct tvec_base *base;
        unsigned long flags;
 
        timer_stats_timer_set_start_info(timer);
        BUG_ON(timer_pending(timer) || !timer->function);
-       spin_lock_irqsave(&base->lock, flags);
-       timer->flags = (timer->flags & ~TIMER_BASEMASK) | cpu;
+
+       /*
+        * If @timer was on a different CPU, it should be migrated with the
+        * old base locked to prevent other operations proceeding with the
+        * wrong base locked.  See lock_timer_base().
+        */
+       base = lock_timer_base(timer, &flags);
+       if (base != new_base) {
+               timer->flags |= TIMER_MIGRATING;
+
+               spin_unlock(&base->lock);
+               base = new_base;
+               spin_lock(&base->lock);
+               WRITE_ONCE(timer->flags,
+                          (timer->flags & ~TIMER_BASEMASK) | cpu);
+       }
+
        debug_activate(timer, timer->expires);
        internal_add_timer(base, timer);
        spin_unlock_irqrestore(&base->lock, flags);