Commit e815ffc7 authored by Thomas Gleixner's avatar Thomas Gleixner
Browse files

genirq/spurious: Cleanup code

parent 659ff9c9
Loading
Loading
Loading
Loading
+28 −46
Original line number Diff line number Diff line
@@ -34,8 +34,9 @@ static atomic_t irq_poll_active;
 * true and let the handler run.
 */
bool irq_wait_for_poll(struct irq_desc *desc)
	__must_hold(&desc->lock)
{
	lockdep_assert_held(&desc->lock);

	if (WARN_ONCE(irq_poll_cpu == smp_processor_id(),
		      "irq poll in progress on cpu %d for irq %d\n",
		      smp_processor_id(), desc->irq_data.irq))
@@ -157,8 +158,7 @@ static void poll_spurious_irqs(struct timer_list *unused)
			 continue;

		/* Racy but it doesn't matter */
		state = desc->istate;
		barrier();
		state = READ_ONCE(desc->istate);
		if (!(state & IRQS_SPURIOUS_DISABLED))
			continue;

@@ -168,8 +168,7 @@ static void poll_spurious_irqs(struct timer_list *unused)
	}
out:
	atomic_dec(&irq_poll_active);
	mod_timer(&poll_spurious_irq_timer,
		  jiffies + POLL_SPURIOUS_IRQ_INTERVAL);
	mod_timer(&poll_spurious_irq_timer, jiffies + POLL_SPURIOUS_IRQ_INTERVAL);
}

static inline int bad_action_ret(irqreturn_t action_ret)
@@ -195,15 +194,12 @@ static void __report_bad_irq(struct irq_desc *desc, irqreturn_t action_ret)
	struct irqaction *action;
	unsigned long flags;

	if (bad_action_ret(action_ret)) {
		printk(KERN_ERR "irq event %d: bogus return value %x\n",
				irq, action_ret);
	} else {
		printk(KERN_ERR "irq %d: nobody cared (try booting with "
				"the \"irqpoll\" option)\n", irq);
	}
	if (bad_action_ret(action_ret))
		pr_err("irq event %d: bogus return value %x\n", irq, action_ret);
	else
		pr_err("irq %d: nobody cared (try booting with the \"irqpoll\" option)\n", irq);
	dump_stack();
	printk(KERN_ERR "handlers:\n");
	pr_err("handlers:\n");

	/*
	 * We need to take desc->lock here. note_interrupt() is called
@@ -213,11 +209,10 @@ static void __report_bad_irq(struct irq_desc *desc, irqreturn_t action_ret)
	 */
	raw_spin_lock_irqsave(&desc->lock, flags);
	for_each_action_of_desc(desc, action) {
		printk(KERN_ERR "[<%p>] %ps", action->handler, action->handler);
		pr_err("[<%p>] %ps", action->handler, action->handler);
		if (action->thread_fn)
			printk(KERN_CONT " threaded [<%p>] %ps",
					action->thread_fn, action->thread_fn);
		printk(KERN_CONT "\n");
			pr_cont(" threaded [<%p>] %ps", action->thread_fn, action->thread_fn);
		pr_cont("\n");
	}
	raw_spin_unlock_irqrestore(&desc->lock, flags);
}
@@ -232,18 +227,17 @@ static void report_bad_irq(struct irq_desc *desc, irqreturn_t action_ret)
	}
}

static inline int
try_misrouted_irq(unsigned int irq, struct irq_desc *desc,
static inline bool try_misrouted_irq(unsigned int irq, struct irq_desc *desc,
				     irqreturn_t action_ret)
{
	struct irqaction *action;

	if (!irqfixup)
		return 0;
		return false;

	/* We didn't actually handle the IRQ - see if it was misrouted? */
	if (action_ret == IRQ_NONE)
		return 1;
		return true;

	/*
	 * But for 'irqfixup == 2' we also do it for handled interrupts if
@@ -251,19 +245,16 @@ try_misrouted_irq(unsigned int irq, struct irq_desc *desc,
	 * traditional PC timer interrupt.. Legacy)
	 */
	if (irqfixup < 2)
		return 0;
		return false;

	if (!irq)
		return 1;
		return true;

	/*
	 * Since we don't get the descriptor lock, "action" can
	 * change under us.  We don't really care, but we don't
	 * want to follow a NULL pointer. So tell the compiler to
	 * just load it once by using a barrier.
	 * change under us.
	 */
	action = desc->action;
	barrier();
	action = READ_ONCE(desc->action);
	return action && (action->flags & IRQF_IRQPOLL);
}

@@ -273,8 +264,7 @@ void note_interrupt(struct irq_desc *desc, irqreturn_t action_ret)
{
	unsigned int irq;

	if (desc->istate & IRQS_POLL_INPROGRESS ||
	    irq_settings_is_polled(desc))
	if (desc->istate & IRQS_POLL_INPROGRESS || irq_settings_is_polled(desc))
		return;

	if (bad_action_ret(action_ret)) {
@@ -420,13 +410,12 @@ void note_interrupt(struct irq_desc *desc, irqreturn_t action_ret)
		/*
		 * Now kill the IRQ
		 */
		printk(KERN_EMERG "Disabling IRQ #%d\n", irq);
		pr_emerg("Disabling IRQ #%d\n", irq);
		desc->istate |= IRQS_SPURIOUS_DISABLED;
		desc->depth++;
		irq_disable(desc);

		mod_timer(&poll_spurious_irq_timer,
			  jiffies + POLL_SPURIOUS_IRQ_INTERVAL);
		mod_timer(&poll_spurious_irq_timer, jiffies + POLL_SPURIOUS_IRQ_INTERVAL);
	}
	desc->irqs_unhandled = 0;
}
@@ -436,11 +425,9 @@ bool noirqdebug __read_mostly;
int noirqdebug_setup(char *str)
{
	noirqdebug = 1;
	printk(KERN_INFO "IRQ lockup detection disabled\n");

	pr_info("IRQ lockup detection disabled\n");
	return 1;
}

__setup("noirqdebug", noirqdebug_setup);
module_param(noirqdebug, bool, 0644);
MODULE_PARM_DESC(noirqdebug, "Disable irq lockup detection when true");
@@ -452,12 +439,10 @@ static int __init irqfixup_setup(char *str)
		return 1;
	}
	irqfixup = 1;
	printk(KERN_WARNING "Misrouted IRQ fixup support enabled.\n");
	printk(KERN_WARNING "This may impact system performance.\n");

	pr_warn("Misrouted IRQ fixup support enabled.\n");
	pr_warn("This may impact system performance.\n");
	return 1;
}

__setup("irqfixup", irqfixup_setup);
module_param(irqfixup, int, 0644);

@@ -468,11 +453,8 @@ static int __init irqpoll_setup(char *str)
		return 1;
	}
	irqfixup = 2;
	printk(KERN_WARNING "Misrouted IRQ fixup and polling support "
				"enabled\n");
	printk(KERN_WARNING "This may significantly impact system "
				"performance\n");
	pr_warn("Misrouted IRQ fixup and polling support enabled\n");
	pr_warn("This may significantly impact system performance\n");
	return 1;
}

__setup("irqpoll", irqpoll_setup);