From: Tejun Heo <tj@kernel.org>
To: mingo@elte.hu, tglx@linutronix.de, bphilips@suse.de,
yinghai@kernel.org, akpm@linux-foundation.org,
torvalds@linux-foundation.org, linux-kernel@vger.kernel.org,
jeff@garzik.orglinux
Cc: Tejun Heo <tj@kernel.org>
Subject: [PATCH 10/12] irq: add comment about overall design of lost/spurious IRQ handling
Date: Sun, 13 Jun 2010 17:31:36 +0200 [thread overview]
Message-ID: <1276443098-20653-11-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1276443098-20653-1-git-send-email-tj@kernel.org>
Give a general overview of the facility at the top of file and add
copyright notice.
Signed-off-by: Tejun Heo <tj@kernel.org>
---
kernel/irq/spurious.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 73 insertions(+), 1 deletions(-)
diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c
index 2d92113..329555f 100644
--- a/kernel/irq/spurious.c
+++ b/kernel/irq/spurious.c
@@ -2,8 +2,66 @@
* linux/kernel/irq/spurious.c
*
* Copyright (C) 1992, 1998-2004 Linus Torvalds, Ingo Molnar
+ * Copyright (C) 2010 SUSE Linux Products GmbH
+ * Copyright (C) 2010 Tejun Heo <tj@kernel.org>
*
- * This file contains spurious interrupt handling.
+ * There are two ways interrupt handling can go wrong - too few or too
+ * many. Due to misrouting or other issues, sometimes IRQs don't
+ * reach the driver while at other times an interrupt line gets stuck
+ * and a continuous spurious interrupts are generated.
+ *
+ * This file implements workaround for both cases. Lost interrupts
+ * are handled by IRQ expecting and watching, and spurious interrupts
+ * by spurious polling. All mechanisms need IRQF_SHARED to be set on
+ * the irqaction in question.
+ *
+ * Both lost interrupt workarounds require cooperation from drivers
+ * and can be chosen depending on how much information the driver can
+ * provide.
+ *
+ * - IRQ expecting
+ *
+ * IRQ expecting is useful when the driver can tell when IRQs can be
+ * expected; in other words, when IRQs are used to signal completion
+ * of host initiated operations. This is the surest way to work
+ * around lost interrupts.
+ *
+ * When the controller is expected to raise an IRQ, the driver
+ * should call expect_irq() and, when the expected event happens or
+ * times out, unexpect_irq(). IRQ subsystem polls the interrupt
+ * inbetween.
+ *
+ * As interrupts tend to keep working if it works at the beginning,
+ * IRQ expecting implements "verified state". After certain number
+ * of successful IRQ deliveries, the irqaction becomes verified and
+ * much longer polling interval is used.
+ *
+ * - IRQ watching
+ *
+ * This can be used when the driver doesn't know when to exactly
+ * expect and unexpect IRQs. Once watch_irq() is called, the
+ * irqaction is slowly polled for certain amount of time (1min). If
+ * IRQs are missed during that time, the irqaction is marked and
+ * actively polled; otherwise, the watching is stopped.
+ *
+ * In the most basic case, drivers can call this right after
+ * registering an irqaction to verify IRQ delivery. In many cases,
+ * if IRQ works at the beginning, it keeps working, so just calling
+ * watch_irq() once can provide decent protection against misrouted
+ * IRQs. It would also be a good idea to call watch_irq() when
+ * timeouts are detected.
+ *
+ * - Spurious IRQ handling
+ *
+ * All IRQs are continuously monitored and spurious IRQ handling
+ * kicks in if there are too many spurious IRQs. The IRQ is
+ * disabled and the registered irqactions are polled. The IRQ is
+ * given another shot after certain number IRQs are handled or an
+ * irqaction is added or removed.
+ *
+ * All of the above three mechanisms can be used together. Spurious
+ * IRQ handling is enabled by default and drivers are free to expect
+ * and watch IRQs as they see fit.
*/
#include <linux/jiffies.h>
@@ -17,6 +75,20 @@
#include "internals.h"
+/*
+ * I spent quite some time thinking about each parameter but they
+ * still are just numbers pulled out of my ass. If you think your ass
+ * is prettier than mine, please go ahead and suggest better ones.
+ *
+ * Most parameters are intentionally fixed constants and not
+ * adjustable through API. The nature of IRQ delivery failures isn't
+ * usually dependent on specific drivers and the timing parameters are
+ * more about human perceivable latencies rather than any specific
+ * controller timing details, so figuring out constant values which
+ * can work for most cases shouldn't be too hard. This allows tighter
+ * control over polling behaviors, eases future changes and makes the
+ * interface easy for drivers.
+ */
enum {
/* irqfixup levels */
IRQFIXUP_SPURIOUS = 0, /* spurious storm detection */
--
1.6.4.2
next prev parent reply other threads:[~2010-06-13 15:32 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-13 15:31 [PATCHSET] irq: better lost/spurious irq handling Tejun Heo
2010-06-13 15:31 ` [PATCH 01/12] irq: cleanup irqfixup Tejun Heo
2010-06-13 15:31 ` [PATCH 02/12] irq: make spurious poll timer per desc Tejun Heo
2010-06-15 5:10 ` Konrad Rzeszutek Wilk
2010-06-15 16:34 ` Tejun Heo
2010-06-13 15:31 ` [PATCH 03/12] irq: use desc->poll_timer for irqpoll Tejun Heo
2010-06-13 15:31 ` [PATCH 04/12] irq: kill IRQF_IRQPOLL Tejun Heo
2010-06-13 15:31 ` [PATCH 05/12] irq: misc preparations for further changes Tejun Heo
2010-06-13 15:31 ` [PATCH 06/12] irq: implement irq_schedule_poll() Tejun Heo
2010-06-13 15:31 ` [PATCH 07/12] irq: improve spurious IRQ handling Tejun Heo
2010-06-13 15:31 ` [PATCH 08/12] irq: implement IRQ watching Tejun Heo
2010-06-13 15:31 ` [PATCH 09/12] irq: implement IRQ expecting Tejun Heo
2010-06-14 9:21 ` Jiri Slaby
2010-06-14 9:43 ` Tejun Heo
2010-06-14 9:46 ` Tejun Heo
2010-06-17 3:48 ` Arjan van de Ven
2010-06-17 8:18 ` Tejun Heo
2010-06-17 11:12 ` Thomas Gleixner
2010-06-17 11:23 ` Tejun Heo
2010-06-17 11:43 ` Alan Cox
2010-06-17 15:54 ` Tejun Heo
2010-06-17 16:02 ` Arjan van de Ven
2010-06-17 16:47 ` Tejun Heo
2010-06-18 6:26 ` Arjan van de Ven
2010-06-18 9:23 ` Tejun Heo
2010-06-18 9:45 ` Thomas Gleixner
2010-06-19 8:35 ` Andi Kleen
2010-06-19 8:42 ` Tejun Heo
2010-06-19 9:00 ` Andi Kleen
2010-06-19 9:03 ` Tejun Heo
2010-06-19 14:54 ` Arjan van de Ven
2010-06-19 19:49 ` Andi Kleen
2010-06-19 20:07 ` Arjan van de Ven
2010-06-13 15:31 ` Tejun Heo [this message]
2010-06-13 15:31 ` [PATCH 11/12] libata: use " Tejun Heo
2010-06-13 15:31 ` [PATCH 12/12] usb: use IRQ watching Tejun Heo
2010-06-14 21:41 ` Greg KH
2010-06-14 21:52 ` Tejun Heo
2010-06-14 22:11 ` Greg KH
2010-06-14 22:19 ` Tejun Heo
2010-06-15 10:30 ` Kay Sievers
2010-06-15 11:05 ` Jean Delvare
2010-06-15 13:30 ` Kay Sievers
2010-06-15 11:20 ` Tejun Heo
2010-06-15 13:36 ` Kay Sievers
2010-06-15 17:36 ` Tejun Heo
2010-06-15 17:47 ` Greg KH
2010-06-15 17:52 ` Tejun Heo
2010-06-21 13:51 ` Tejun Heo
2010-06-21 20:27 ` Greg KH
2010-06-22 7:32 ` Tejun Heo
[not found] ` <1276443098-20653-12-git-send-email-tj@kernel.org>
2010-06-21 13:52 ` [PATCH 11/12] libata: use IRQ expecting Tejun Heo
2010-06-25 0:22 ` Jeff Garzik
2010-06-25 7:44 ` Tejun Heo
2010-06-25 9:48 ` Jeff Garzik
2010-06-25 9:51 ` Tejun Heo
2010-06-25 13:02 ` [PATCH 1/2 #upstream] sata_fsl,mv,nv: prepare for NCQ command completion update Tejun Heo
2010-06-25 13:03 ` [PATCH 2/2 #upstream] libata: always use ata_qc_complete_multiple() for NCQ command completions Tejun Heo
2010-08-17 22:03 ` Jeff Garzik
2010-08-01 23:47 ` [PATCH 1/2 #upstream] sata_fsl,mv,nv: prepare for NCQ command completion update Jeff Garzik
2010-08-02 7:18 ` Tejun Heo
2010-08-04 4:22 ` Jeff Garzik
2010-06-26 3:45 ` [PATCH 11/12] libata: use IRQ expecting Jeff Garzik
2010-06-26 3:52 ` Jeff Garzik
2010-06-26 8:31 ` Tejun Heo
2010-06-26 9:16 ` Jeff Garzik
2010-06-26 9:44 ` Tejun Heo
2010-07-02 14:41 ` Tejun Heo
2010-07-02 14:53 ` Tejun Heo
2010-07-10 10:06 ` Tejun Heo
2010-07-14 7:58 ` Jeff Garzik
2010-07-14 9:26 ` Tejun Heo
2010-07-27 17:37 ` Jeff Garzik
2010-07-02 14:59 ` [GIT PULL] irq: better lost/spurious irq handling Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1276443098-20653-11-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=bphilips@suse.de \
--cc=jeff@garzik.orglinux \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=yinghai@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).