Skip to content

Commit 511601b

Browse files
committed
Merge branches 'irq-urgent-for-linus' and 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
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()
3 parents b84da9f + 4717f13 + 22b886d commit 511601b

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

kernel/irq/internals.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ static inline int irq_desc_get_node(struct irq_desc *desc)
199199
return irq_common_data_get_node(&desc->irq_common_data);
200200
}
201201

202+
static inline int irq_desc_is_chained(struct irq_desc *desc)
203+
{
204+
return (desc->action && desc->action == &chained_action);
205+
}
206+
202207
#ifdef CONFIG_PM_SLEEP
203208
bool irq_pm_check_wakeup(struct irq_desc *desc);
204209
void irq_pm_install_action(struct irq_desc *desc, struct irqaction *action);

kernel/irq/pm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ void irq_pm_remove_action(struct irq_desc *desc, struct irqaction *action)
7070

7171
static bool suspend_device_irq(struct irq_desc *desc)
7272
{
73-
if (!desc->action || desc->no_suspend_depth)
73+
if (!desc->action || irq_desc_is_chained(desc) ||
74+
desc->no_suspend_depth)
7475
return false;
7576

7677
if (irqd_is_wakeup_set(&desc->irq_data)) {

kernel/irq/proc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ int show_interrupts(struct seq_file *p, void *v)
475475
for_each_online_cpu(j)
476476
any_count |= kstat_irqs_cpu(i, j);
477477
action = desc->action;
478-
if ((!action || action == &chained_action) && !any_count)
478+
if ((!action || irq_desc_is_chained(desc)) && !any_count)
479479
goto out;
480480

481481
seq_printf(p, "%*d: ", prec, i);

kernel/time/timer.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -977,13 +977,29 @@ EXPORT_SYMBOL(add_timer);
977977
*/
978978
void add_timer_on(struct timer_list *timer, int cpu)
979979
{
980-
struct tvec_base *base = per_cpu_ptr(&tvec_bases, cpu);
980+
struct tvec_base *new_base = per_cpu_ptr(&tvec_bases, cpu);
981+
struct tvec_base *base;
981982
unsigned long flags;
982983

983984
timer_stats_timer_set_start_info(timer);
984985
BUG_ON(timer_pending(timer) || !timer->function);
985-
spin_lock_irqsave(&base->lock, flags);
986-
timer->flags = (timer->flags & ~TIMER_BASEMASK) | cpu;
986+
987+
/*
988+
* If @timer was on a different CPU, it should be migrated with the
989+
* old base locked to prevent other operations proceeding with the
990+
* wrong base locked. See lock_timer_base().
991+
*/
992+
base = lock_timer_base(timer, &flags);
993+
if (base != new_base) {
994+
timer->flags |= TIMER_MIGRATING;
995+
996+
spin_unlock(&base->lock);
997+
base = new_base;
998+
spin_lock(&base->lock);
999+
WRITE_ONCE(timer->flags,
1000+
(timer->flags & ~TIMER_BASEMASK) | cpu);
1001+
}
1002+
9871003
debug_activate(timer, timer->expires);
9881004
internal_add_timer(base, timer);
9891005
spin_unlock_irqrestore(&base->lock, flags);

0 commit comments

Comments
 (0)