mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: James Hogan <james.hogan@imgtec.com>
To: <linux-kernel@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	James Hogan <james.hogan@imgtec.com>
Subject: [PATCH 4/5] metag: kick: prevent nested kick handlers
Date: Mon, 1 Jul 2013 17:04:18 +0100	[thread overview]
Message-ID: <1372694659-30176-5-git-send-email-james.hogan@imgtec.com> (raw)
In-Reply-To: <1372694659-30176-1-git-send-email-james.hogan@imgtec.com>

The main kick trigger handler iterates a list of kick handlers and calls
each one. This is done with the kick_handlers_lock spin lock held, but
this causes a problem on SMP where IPIs are implemented with kicks. A
reschedule IPI calls scheduler_ipi() which uses irq_enter() and
irq_exit(). This results in the scheduler being invoked with
kick_handlers_lock held which can result in a nested kick trigger
attempting to acquire the lock, resulting in deadlock.

irq_enter() and irq_exit() can nest, so call them from the main kick
interrupt handler so that softirqs are only handled after
kick_handlers_lock is released.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
---
 arch/metag/kernel/kick.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/metag/kernel/kick.c b/arch/metag/kernel/kick.c
index 50fcbec..beb3776 100644
--- a/arch/metag/kernel/kick.c
+++ b/arch/metag/kernel/kick.c
@@ -26,6 +26,8 @@
  * pass it as an argument.
  */
 #include <linux/export.h>
+#include <linux/hardirq.h>
+#include <linux/irq.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/types.h>
@@ -66,6 +68,7 @@ EXPORT_SYMBOL(kick_unregister_func);
 TBIRES
 kick_handler(TBIRES State, int SigNum, int Triggers, int Inst, PTBI pTBI)
 {
+	struct pt_regs *old_regs;
 	struct kick_irq_handler *kh;
 	struct list_head *lh;
 	int handled = 0;
@@ -79,6 +82,9 @@ kick_handler(TBIRES State, int SigNum, int Triggers, int Inst, PTBI pTBI)
 
 	trace_hardirqs_off();
 
+	old_regs = set_irq_regs((struct pt_regs *)State.Sig.pCtx);
+	irq_enter();
+
 	/*
 	 * There is no need to disable interrupts here because we
 	 * can't nest KICK interrupts in a KICK interrupt handler.
@@ -97,5 +103,8 @@ kick_handler(TBIRES State, int SigNum, int Triggers, int Inst, PTBI pTBI)
 
 	WARN_ON(!handled);
 
+	irq_exit();
+	set_irq_regs(old_regs);
+
 	return tail_end(ret);
 }
-- 
1.8.1.2



  parent reply	other threads:[~2013-07-01 16:05 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-01 16:04 [PATCH 0/5] metag: smp/hotplug fixes James Hogan
2013-07-01 16:04 ` [PATCH 1/5] metag: use clear_tasks_mm_cpumask() James Hogan
2013-07-01 16:04 ` [PATCH 2/5] metag: smp: enable irqs after set_cpu_online James Hogan
2013-07-01 21:42   ` Thomas Gleixner
2013-07-02  5:57   ` Srivatsa S. Bhat
2013-07-01 16:04 ` [PATCH 3/5] metag: smp: don't spin waiting for CPU to start James Hogan
2013-07-01 21:46   ` Thomas Gleixner
2013-07-01 22:02     ` James Hogan
2013-07-02  6:12   ` Srivatsa S. Bhat
2013-07-01 16:04 ` James Hogan [this message]
2013-07-01 21:51   ` [PATCH 4/5] metag: kick: prevent nested kick handlers Thomas Gleixner
2013-07-01 22:17     ` James Hogan
2013-07-01 22:56       ` Thomas Gleixner
2013-07-02  0:00         ` James Hogan
2013-07-01 16:04 ` [PATCH 5/5] metag: cpu hotplug: route_irq: preserve irq mask James Hogan
2013-07-01 21:51   ` Thomas Gleixner
2013-07-02  6:16   ` Srivatsa S. Bhat
2013-07-02  9:59     ` James Hogan

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=1372694659-30176-5-git-send-email-james.hogan@imgtec.com \
    --to=james.hogan@imgtec.com \
    --cc=linux-kernel@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®