Skip to content

Commit e79b2fe

Browse files
Marek Vasutopsiff
authored andcommitted
PCI: tegra: Convert struct tegra_msi mask_lock into raw spinlock
commit 26fda92d3b56bf44a02bcb4001c5a5548e0ae8ee upstream. The tegra_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 tegra_msi_irq_unmask(). Since the &desc->lock descriptor lock is a raw spinlock, and the tegra_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: 2c99e55 ("PCI: tegra: Convert to MSI domains") Reported-by: Geert Uytterhoeven <geert+renesas@glider.be> Closes: https://patchwork.kernel.org/project/linux-pci/patch/20250909162707.13927-2-marek.vasut+renesas@mailbox.org/#26574451 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> Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20250922150811.88450-1-marek.vasut+renesas@mailbox.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit d4f9b44e81fcd2b5e8c0516dfce47cb4c8a64e57)
1 parent c5d856a commit e79b2fe

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

drivers/pci/controller/pci-tegra.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515

1616
#include <linux/clk.h>
17+
#include <linux/cleanup.h>
1718
#include <linux/debugfs.h>
1819
#include <linux/delay.h>
1920
#include <linux/export.h>
@@ -269,7 +270,7 @@ struct tegra_msi {
269270
DECLARE_BITMAP(used, INT_PCI_MSI_NR);
270271
struct irq_domain *domain;
271272
struct mutex map_lock;
272-
spinlock_t mask_lock;
273+
raw_spinlock_t mask_lock;
273274
void *virt;
274275
dma_addr_t phys;
275276
int irq;
@@ -1604,29 +1605,27 @@ static void tegra_msi_irq_mask(struct irq_data *d)
16041605
struct tegra_msi *msi = irq_data_get_irq_chip_data(d);
16051606
struct tegra_pcie *pcie = msi_to_pcie(msi);
16061607
unsigned int index = d->hwirq / 32;
1607-
unsigned long flags;
16081608
u32 value;
16091609

1610-
spin_lock_irqsave(&msi->mask_lock, flags);
1611-
value = afi_readl(pcie, AFI_MSI_EN_VEC(index));
1612-
value &= ~BIT(d->hwirq % 32);
1613-
afi_writel(pcie, value, AFI_MSI_EN_VEC(index));
1614-
spin_unlock_irqrestore(&msi->mask_lock, flags);
1610+
scoped_guard(raw_spinlock_irqsave, &msi->mask_lock) {
1611+
value = afi_readl(pcie, AFI_MSI_EN_VEC(index));
1612+
value &= ~BIT(d->hwirq % 32);
1613+
afi_writel(pcie, value, AFI_MSI_EN_VEC(index));
1614+
}
16151615
}
16161616

16171617
static void tegra_msi_irq_unmask(struct irq_data *d)
16181618
{
16191619
struct tegra_msi *msi = irq_data_get_irq_chip_data(d);
16201620
struct tegra_pcie *pcie = msi_to_pcie(msi);
16211621
unsigned int index = d->hwirq / 32;
1622-
unsigned long flags;
16231622
u32 value;
16241623

1625-
spin_lock_irqsave(&msi->mask_lock, flags);
1626-
value = afi_readl(pcie, AFI_MSI_EN_VEC(index));
1627-
value |= BIT(d->hwirq % 32);
1628-
afi_writel(pcie, value, AFI_MSI_EN_VEC(index));
1629-
spin_unlock_irqrestore(&msi->mask_lock, flags);
1624+
scoped_guard(raw_spinlock_irqsave, &msi->mask_lock) {
1625+
value = afi_readl(pcie, AFI_MSI_EN_VEC(index));
1626+
value |= BIT(d->hwirq % 32);
1627+
afi_writel(pcie, value, AFI_MSI_EN_VEC(index));
1628+
}
16301629
}
16311630

16321631
static void tegra_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
@@ -1736,7 +1735,7 @@ static int tegra_pcie_msi_setup(struct tegra_pcie *pcie)
17361735
int err;
17371736

17381737
mutex_init(&msi->map_lock);
1739-
spin_lock_init(&msi->mask_lock);
1738+
raw_spin_lock_init(&msi->mask_lock);
17401739

17411740
if (IS_ENABLED(CONFIG_PCI_MSI)) {
17421741
err = tegra_allocate_domains(msi);

0 commit comments

Comments
 (0)