summaryrefslogtreecommitdiffstats
path: root/kernel/irq/manage.c
diff options
context:
space:
mode:
authorLukas Wunner <lukas@wunner.de>2018-10-18 09:15:05 -0400
committerThomas Gleixner <tglx@linutronix.de>2018-10-19 11:31:00 -0400
commit746a923b863a1065ef77324e1e43f19b1a3eab5c (patch)
tree428e242554fd8e8ded119f6a01b100d7b4c4f9a2 /kernel/irq/manage.c
parente45506ac0af9b56b221863e9649fe122d8bb42ff (diff)
genirq: Fix race on spurious interrupt detection
Commit 1e77d0a1ed74 ("genirq: Sanitize spurious interrupt detection of threaded irqs") made detection of spurious interrupts work for threaded handlers by: a) incrementing a counter every time the thread returns IRQ_HANDLED, and b) checking whether that counter has increased every time the thread is woken. However for oneshot interrupts, the commit unmasks the interrupt before incrementing the counter. If another interrupt occurs right after unmasking but before the counter is incremented, that interrupt is incorrectly considered spurious: time | irq_thread() | irq_thread_fn() | action->thread_fn() | irq_finalize_oneshot() | unmask_threaded_irq() /* interrupt is unmasked */ | | /* interrupt fires, incorrectly deemed spurious */ | | atomic_inc(&desc->threads_handled); /* counter is incremented */ v This is observed with a hi3110 CAN controller receiving data at high volume (from a separate machine sending with "cangen -g 0 -i -x"): The controller signals a huge number of interrupts (hundreds of millions per day) and every second there are about a dozen which are deemed spurious. In theory with high CPU load and the presence of higher priority tasks, the number of incorrectly detected spurious interrupts might increase beyond the 99,900 threshold and cause disablement of the interrupt. In practice it just increments the spurious interrupt count. But that can cause people to waste time investigating it over and over. Fix it by moving the accounting before the invocation of irq_finalize_oneshot(). [ tglx: Folded change log update ] Fixes: 1e77d0a1ed74 ("genirq: Sanitize spurious interrupt detection of threaded irqs") Signed-off-by: Lukas Wunner <lukas@wunner.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Mathias Duckeck <m.duckeck@kunbus.de> Cc: Akshay Bhat <akshay.bhat@timesys.com> Cc: Casey Fitzpatrick <casey.fitzpatrick@timesys.com> Cc: stable@vger.kernel.org # v3.16+ Link: https://lkml.kernel.org/r/1dfd8bbd16163940648045495e3e9698e63b50ad.1539867047.git.lukas@wunner.de
Diffstat (limited to 'kernel/irq/manage.c')
-rw-r--r--kernel/irq/manage.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index fb86146037a7..9dbdccab3b6a 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -927,6 +927,9 @@ irq_forced_thread_fn(struct irq_desc *desc, struct irqaction *action)
927 927
928 local_bh_disable(); 928 local_bh_disable();
929 ret = action->thread_fn(action->irq, action->dev_id); 929 ret = action->thread_fn(action->irq, action->dev_id);
930 if (ret == IRQ_HANDLED)
931 atomic_inc(&desc->threads_handled);
932
930 irq_finalize_oneshot(desc, action); 933 irq_finalize_oneshot(desc, action);
931 local_bh_enable(); 934 local_bh_enable();
932 return ret; 935 return ret;
@@ -943,6 +946,9 @@ static irqreturn_t irq_thread_fn(struct irq_desc *desc,
943 irqreturn_t ret; 946 irqreturn_t ret;
944 947
945 ret = action->thread_fn(action->irq, action->dev_id); 948 ret = action->thread_fn(action->irq, action->dev_id);
949 if (ret == IRQ_HANDLED)
950 atomic_inc(&desc->threads_handled);
951
946 irq_finalize_oneshot(desc, action); 952 irq_finalize_oneshot(desc, action);
947 return ret; 953 return ret;
948} 954}
@@ -1020,8 +1026,6 @@ static int irq_thread(void *data)
1020 irq_thread_check_affinity(desc, action); 1026 irq_thread_check_affinity(desc, action);
1021 1027
1022 action_ret = handler_fn(desc, action); 1028 action_ret = handler_fn(desc, action);
1023 if (action_ret == IRQ_HANDLED)
1024 atomic_inc(&desc->threads_handled);
1025 if (action_ret == IRQ_WAKE_THREAD) 1029 if (action_ret == IRQ_WAKE_THREAD)
1026 irq_wake_secondary(desc, action); 1030 irq_wake_secondary(desc, action);
1027 1031