mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeffy Chen <jeffy.chen@rock-chips.com>
To: linux-kernel@vger.kernel.org
Cc: briannorris@chromium.org, dianders@chromium.org,
	tfiga@chromium.org, Jeffy Chen <jeffy.chen@rock-chips.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH] genirq: Check irq disabled & masked states in irq_shutdown
Date: Fri, 26 May 2017 21:17:38 +0800	[thread overview]
Message-ID: <1495804658-12410-1-git-send-email-jeffy.chen@rock-chips.com> (raw)

If irq is already disabled and masked, we would hit a unbalanced irq
shutdown/disable/mask when freeing it.

Add a state check in irq_shutdown to prevent this.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---

 kernel/irq/chip.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 686be4b..816da03 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -206,14 +206,20 @@ int irq_startup(struct irq_desc *desc, bool resend)
 
 void irq_shutdown(struct irq_desc *desc)
 {
-	irq_state_set_disabled(desc);
 	desc->depth = 1;
+
+	if (unlikely(irqd_irq_disabled(&desc->irq_data) &&
+		irqd_irq_masked(&desc->irq_data)))
+		goto out;
+
+	irq_state_set_disabled(desc);
 	if (desc->irq_data.chip->irq_shutdown)
 		desc->irq_data.chip->irq_shutdown(&desc->irq_data);
 	else if (desc->irq_data.chip->irq_disable)
 		desc->irq_data.chip->irq_disable(&desc->irq_data);
 	else
 		desc->irq_data.chip->irq_mask(&desc->irq_data);
+out:
 	irq_domain_deactivate_irq(&desc->irq_data);
 	irq_state_set_masked(desc);
 }
-- 
2.1.4

             reply	other threads:[~2017-05-26 13:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-26 13:17 Jeffy Chen [this message]
2017-05-26 13:20 ` Thomas Gleixner
2017-05-27  4:52   ` jeffy
2017-05-27  8:16     ` Thomas Gleixner
2017-05-30 23:20       ` Brian Norris
2017-05-30 23:32         ` Brian Norris
2017-05-31  8:38           ` Thomas Gleixner
2017-05-31  9:22         ` Thomas Gleixner

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=1495804658-12410-1-git-send-email-jeffy.chen@rock-chips.com \
    --to=jeffy.chen@rock-chips.com \
    --cc=briannorris@chromium.org \
    --cc=dianders@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tfiga@chromium.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®