mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Eliav Farber" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Eliav Farber <farbere@amazon.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org
Subject: [tip: irq/core] genirq/kexec: Prevent redundant IRQ masking by checking state before shutdown
Date: Wed, 11 Dec 2024 19:42:34 -0000	[thread overview]
Message-ID: <173394615478.412.4916928149680637989.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20241204142003.32859-3-farbere@amazon.com>

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     b4706d814921cc2df7bb59ad8f9ee84855a4f0c4
Gitweb:        https://git.kernel.org/tip/b4706d814921cc2df7bb59ad8f9ee84855a4f0c4
Author:        Eliav Farber <farbere@amazon.com>
AuthorDate:    Wed, 04 Dec 2024 14:20:03 
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 11 Dec 2024 20:32:34 +01:00

genirq/kexec: Prevent redundant IRQ masking by checking state before shutdown

During machine kexec, machine_kexec_mask_interrupts() is responsible for
disabling or masking all interrupts. While the irq_disable() is only
invoked when the interrupt is not yet disabled, it unconditionally invokes
the irq_mask() callback for every interrupt descriptor, even when the
interrupt is already masked or not even started up yet.

A specific issue was observed in the crash kernel flow after unbinding a
device (prior to kexec) that used a GPIO as an IRQ source. The warning was
triggered by the gpiochip_disable_irq() function, which attempts to clear
the FLAG_IRQ_IS_ENABLED flag when FLAG_USED_AS_IRQ was not set.

This issue surfaced after commit a8173820f441 ("gpio: gpiolib: Allow GPIO
IRQs to lazy disable") introduced lazy disablement for GPIO IRQs. It
replaced disable/enable hooks with mask/unmask hooks. Unlike the disable
hook, the mask hook doesn't handle already-masked IRQs.

When a GPIO-IRQ driver is unbound, the IRQ is released, triggering
__irq_disable() and irq_state_set_masked(). A subsequent call to
machine_kexec_mask_interrupts() re-invokes chip->irq_mask(). This results
in a call chain, including gpiochip_irq_mask() and gpiochip_disable_irq().
Since FLAG_USED_AS_IRQ was cleared earlier, the warning is triggered.

Replace the direct invocation of the irq_mask() and irq_disable() callbacks
invoking to irq_shutdown(), which handles the cases correct and avoid it
all together when the interrupt has never been started up.

Signed-off-by: Eliav Farber <farbere@amazon.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241204142003.32859-3-farbere@amazon.com

---
 kernel/irq/kexec.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/kernel/irq/kexec.c b/kernel/irq/kexec.c
index 0f9548c..1a3deff 100644
--- a/kernel/irq/kexec.c
+++ b/kernel/irq/kexec.c
@@ -17,7 +17,7 @@ void machine_kexec_mask_interrupts(void)
 		int check_eoi = 1;
 
 		chip = irq_desc_get_chip(desc);
-		if (!chip)
+		if (!chip || !irqd_is_started(&desc->irq_data))
 			continue;
 
 		if (IS_ENABLED(CONFIG_GENERIC_IRQ_KEXEC_CLEAR_VM_FORWARD)) {
@@ -31,10 +31,6 @@ void machine_kexec_mask_interrupts(void)
 		if (check_eoi && chip->irq_eoi && irqd_irq_inprogress(&desc->irq_data))
 			chip->irq_eoi(&desc->irq_data);
 
-		if (chip->irq_mask)
-			chip->irq_mask(&desc->irq_data);
-
-		if (chip->irq_disable && !irqd_irq_disabled(&desc->irq_data))
-			chip->irq_disable(&desc->irq_data);
+		irq_shutdown(desc);
 	}
 }

  reply	other threads:[~2024-12-11 19:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-04 14:20 [PATCH v6 0/2] Improve interrupt handling during machine kexec Eliav Farber
2024-12-04 14:20 ` [PATCH v6 1/2] kexec: Consolidate machine_kexec_mask_interrupts() implementation Eliav Farber
2024-12-11 19:42   ` [tip: irq/core] " tip-bot2 for Eliav Farber
2025-01-27 16:39   ` [PATCH v6 1/2] " Will Deacon
2024-12-04 14:20 ` [PATCH v6 2/2] kexec: Prevent redundant IRQ masking by checking state before shutdown Eliav Farber
2024-12-11 19:42   ` tip-bot2 for Eliav Farber [this message]
2025-02-03 19:15 ` [PATCH v6 0/2] Improve interrupt handling during machine kexec patchwork-bot+linux-riscv

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=173394615478.412.4916928149680637989.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=farbere@amazon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@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

all inboxes | Powered by JetHome®