mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 01:49:46 +00:00
PCI: rcar-host: Convert struct rcar_msi mask_lock into raw spinlock
commit5ed35b4d49upstream. The rcar_msi_irq_unmask() function may be called from a PCI driver request_threaded_irq() function. This triggers kernel/irq/manage.c __setup_irq() which locks raw spinlock &desc->lock descriptor lock and with that descriptor lock held, calls rcar_msi_irq_unmask(). Since the &desc->lock descriptor lock is a raw spinlock, and the rcar_msi .mask_lock is not a raw spinlock, this setup triggers 'BUG: Invalid wait context' with CONFIG_PROVE_RAW_LOCK_NESTING=y. Use scoped_guard() to simplify the locking. Fixes:83ed8d4fa6("PCI: rcar: Convert to MSI domains") Reported-by: Duy Nguyen <duy.nguyen.rh@renesas.com> Reported-by: Thuan Nguyen <thuan.nguyen-hong@banvien.com.vn> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org> Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Marc Zyngier <maz@kernel.org> Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20250909162707.13927-2-marek.vasut+renesas@mailbox.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
8f79f82ea5
commit
7503861b83
@@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/clk-provider.h>
|
||||
#include <linux/delay.h>
|
||||
@@ -37,7 +38,7 @@ struct rcar_msi {
|
||||
DECLARE_BITMAP(used, INT_PCI_MSI_NR);
|
||||
struct irq_domain *domain;
|
||||
struct mutex map_lock;
|
||||
spinlock_t mask_lock;
|
||||
raw_spinlock_t mask_lock;
|
||||
int irq1;
|
||||
int irq2;
|
||||
};
|
||||
@@ -625,28 +626,26 @@ static void rcar_msi_irq_mask(struct irq_data *d)
|
||||
{
|
||||
struct rcar_msi *msi = irq_data_get_irq_chip_data(d);
|
||||
struct rcar_pcie *pcie = &msi_to_host(msi)->pcie;
|
||||
unsigned long flags;
|
||||
u32 value;
|
||||
|
||||
spin_lock_irqsave(&msi->mask_lock, flags);
|
||||
value = rcar_pci_read_reg(pcie, PCIEMSIIER);
|
||||
value &= ~BIT(d->hwirq);
|
||||
rcar_pci_write_reg(pcie, value, PCIEMSIIER);
|
||||
spin_unlock_irqrestore(&msi->mask_lock, flags);
|
||||
scoped_guard(raw_spinlock_irqsave, &msi->mask_lock) {
|
||||
value = rcar_pci_read_reg(pcie, PCIEMSIIER);
|
||||
value &= ~BIT(d->hwirq);
|
||||
rcar_pci_write_reg(pcie, value, PCIEMSIIER);
|
||||
}
|
||||
}
|
||||
|
||||
static void rcar_msi_irq_unmask(struct irq_data *d)
|
||||
{
|
||||
struct rcar_msi *msi = irq_data_get_irq_chip_data(d);
|
||||
struct rcar_pcie *pcie = &msi_to_host(msi)->pcie;
|
||||
unsigned long flags;
|
||||
u32 value;
|
||||
|
||||
spin_lock_irqsave(&msi->mask_lock, flags);
|
||||
value = rcar_pci_read_reg(pcie, PCIEMSIIER);
|
||||
value |= BIT(d->hwirq);
|
||||
rcar_pci_write_reg(pcie, value, PCIEMSIIER);
|
||||
spin_unlock_irqrestore(&msi->mask_lock, flags);
|
||||
scoped_guard(raw_spinlock_irqsave, &msi->mask_lock) {
|
||||
value = rcar_pci_read_reg(pcie, PCIEMSIIER);
|
||||
value |= BIT(d->hwirq);
|
||||
rcar_pci_write_reg(pcie, value, PCIEMSIIER);
|
||||
}
|
||||
}
|
||||
|
||||
static void rcar_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
|
||||
@@ -756,7 +755,7 @@ static int rcar_pcie_enable_msi(struct rcar_pcie_host *host)
|
||||
int err;
|
||||
|
||||
mutex_init(&msi->map_lock);
|
||||
spin_lock_init(&msi->mask_lock);
|
||||
raw_spin_lock_init(&msi->mask_lock);
|
||||
|
||||
err = of_address_to_resource(dev->of_node, 0, &res);
|
||||
if (err)
|
||||
|
||||
Reference in New Issue
Block a user