From: Marc Zyngier <maz@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Andy Gross <agross@kernel.org>,
Bjorn Andersson <bjorn.andersson@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
linux-arm-msm@vger.kernel.org
Subject: [PATCH 4/5] irqchip/qcom-pdc: Fix broken locking
Date: Thu, 24 Feb 2022 10:12:25 +0000 [thread overview]
Message-ID: <20220224101226.88373-5-maz@kernel.org> (raw)
In-Reply-To: <20220224101226.88373-1-maz@kernel.org>
pdc_enable_intr() serves as a primitive to qcom_pdc_gic_{en,dis}able,
and has a raw spinlock for mutual exclusion, which is uses with
interruptible primitives.
This means that this critical section can itself be interrupted.
Should the interrupt also be a PDC interrupt, and the endpoint driver
perform an irq_disable() on that interrupt, we end-up in a deadlock.
Fix this by using the irqsave/irqrestore variants of the locking
primitives.
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
drivers/irqchip/qcom-pdc.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c
index 837ca6998f6a..0cd20ddfae2a 100644
--- a/drivers/irqchip/qcom-pdc.c
+++ b/drivers/irqchip/qcom-pdc.c
@@ -55,17 +55,18 @@ static u32 pdc_reg_read(int reg, u32 i)
static void pdc_enable_intr(struct irq_data *d, bool on)
{
int pin_out = d->hwirq;
+ unsigned long flags;
u32 index, mask;
u32 enable;
index = pin_out / 32;
mask = pin_out % 32;
- raw_spin_lock(&pdc_lock);
+ raw_spin_lock_irqsave(&pdc_lock, flags);
enable = pdc_reg_read(IRQ_ENABLE_BANK, index);
enable = on ? ENABLE_INTR(enable, mask) : CLEAR_INTR(enable, mask);
pdc_reg_write(IRQ_ENABLE_BANK, index, enable);
- raw_spin_unlock(&pdc_lock);
+ raw_spin_unlock_irqrestore(&pdc_lock, flags);
}
static void qcom_pdc_gic_disable(struct irq_data *d)
--
2.30.2
next prev parent reply other threads:[~2022-02-24 10:12 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-24 10:12 [PATCH 0/5] irqchip/qcom-pdc: Assorted cleanups and fixes Marc Zyngier
2022-02-24 10:12 ` [PATCH 1/5] irqchip/qcom-pdc: Kill PDC_NO_PARENT_IRQ Marc Zyngier
2022-02-28 17:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-02-28 19:23 ` [PATCH 1/5] " Maulik Shah (mkshah)
2022-03-01 10:11 ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-02-24 10:12 ` [PATCH 2/5] irqchip/qcom-pdc: Kill non-wakeup irqdomain Marc Zyngier
2022-02-28 17:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-02-28 19:29 ` [PATCH 2/5] " Maulik Shah (mkshah)
2022-02-28 20:00 ` Marc Zyngier
2022-03-01 10:11 ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-02-24 10:12 ` [PATCH 3/5] irqchip/qcom-pdc: Kill qcom_pdc_translate helper Marc Zyngier
2022-02-28 17:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-02-28 19:30 ` [PATCH 3/5] " Maulik Shah (mkshah)
2022-03-01 10:11 ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-02-24 10:12 ` Marc Zyngier [this message]
2022-02-28 17:40 ` [irqchip: irq/irqchip-next] irqchip/qcom-pdc: Fix broken locking irqchip-bot for Marc Zyngier
2022-02-28 19:30 ` [PATCH 4/5] " Maulik Shah (mkshah)
2022-03-01 10:11 ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-02-24 10:12 ` [PATCH 5/5] irqchip/qcom-pdc: Drop open coded version of __assign_bit() Marc Zyngier
2022-02-28 17:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-02-28 19:31 ` [PATCH 5/5] " Maulik Shah (mkshah)
2022-03-01 10:11 ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
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=20220224101226.88373-5-maz@kernel.org \
--to=maz@kernel.org \
--cc=agross@kernel.org \
--cc=bjorn.andersson@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--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