From: Zhang Xiao <xiao.zhang@windriver.com>
To: <linux-kernel@vger.kernel.org>
Cc: <linux-rt-users@vger.kernel.org>, <mingo@elte.hu>,
<tglx@linutronix.de>, <xiao.zhang@windriver.com>
Subject: [PATCH] genirq: use simple work queue for polling spurious irq
Date: Fri, 23 Dec 2016 12:37:58 +0800 [thread overview]
Message-ID: <1482467878-17158-1-git-send-email-xiao.zhang@windriver.com> (raw)
Spurious irq will be disabled and then polled through mod_timer in
interrupt context. While mod_timer has a common spin_lock operation
thus will cause an error: BUG: sleeping function called from invalid
context.
Move the mod_timer into simple work queue to fix it.
Signed-off-by: Zhang Xiao <xiao.zhang@windriver.com>
---
kernel/irq/spurious.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c
index 903a69c..0ce2a38 100644
--- a/kernel/irq/spurious.c
+++ b/kernel/irq/spurious.c
@@ -24,6 +24,36 @@ static DEFINE_TIMER(poll_spurious_irq_timer, poll_spurious_irqs, 0, 0);
static int irq_poll_cpu;
static atomic_t irq_poll_active;
+#ifdef CONFIG_PREEMPT_RT_FULL
+#include <linux/work-simple.h>
+
+static bool mod_timer_work_ready __read_mostly;
+static struct swork_event mod_timer_work;
+
+static void __mod_timer_work(struct swork_event *event)
+{
+ mod_timer(&poll_spurious_irq_timer,
+ jiffies + POLL_SPURIOUS_IRQ_INTERVAL);
+}
+
+static int __init mod_timer_work_init(void)
+{
+ int err;
+
+ err = swork_get();
+ if(err) {
+ printk(KERN_ERR "mod_timer work init failed.\n");
+ return err;
+ }
+
+ INIT_SWORK(&mod_timer_work, __mod_timer_work);
+ mod_timer_work_ready = true;
+ return 0;
+}
+
+early_initcall(mod_timer_work_init);
+#endif /* CONFIG_PREEMPT_RT_FULL */
+
/*
* We wait here for a poller to finish.
*
@@ -422,8 +452,17 @@ void note_interrupt(unsigned int irq, struct irq_desc *desc,
desc->depth++;
irq_disable(desc);
+#ifdef CONFIG_PREEMPT_RT_FULL
+ /*
+ * Avoid calling mod_timer directly in interrupt
+ * contex here. Let simple workqueue do it.
+ */
+ if(mod_timer_work_ready)
+ swork_queue(&mod_timer_work);
+#else
mod_timer(&poll_spurious_irq_timer,
jiffies + POLL_SPURIOUS_IRQ_INTERVAL);
+#endif /* CONFIG_PREEMPT_RT_FULL */
}
desc->irqs_unhandled = 0;
}
--
1.9.1
reply other threads:[~2016-12-23 4:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1482467878-17158-1-git-send-email-xiao.zhang@windriver.com \
--to=xiao.zhang@windriver.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
/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).