Skip to contentSkip to conversation

irqchip/exynos-combiner: switch to raw_spinlock

PATCH In review Marek Szyprowski 3 participants 5 messages May 20 – May 21 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20260520220432eucas1p10502ca0f9368bd6de5ce027ad8170109@eucas1p1.samsung.com

#1 lore raw

PATCH 1/1 irqchip/exynos-combiner: switch to raw_spinlock

The exynos-combiner driver uses a regular spinlock to protect access to the combiner interrupt status register in combiner_handle_cascade_irq(), which is invoked in hard IRQ context as a chained interrupt handler.

When PREEMPT_RT is enabled on ARM, regular spinlock is converted to a sleeping lock (mutex-based), which must not be used in atomic context such as hard interrupt handlers. Switch the irq_controller_lock to raw_spinlock, which remains a true non-sleeping spinlock even under PREEMPT_RT.

Fixes a900e5d99718 ("ARM: exynos: move exynos4210-combiner to drivers/irqchip")
---
 drivers/irqchip/exynos-combiner.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/irqchip/exynos-combiner.c +3 -3
index 11d105457798..03cafcc5c835 100644
@@ -24,7 +24,7 @@
 
 #define IRQ_IN_COMBINER		8
 
-static DEFINE_SPINLOCK(irq_controller_lock);
+static DEFINE_RAW_SPINLOCK(irq_controller_lock);
 
 struct combiner_chip_data {
 	unsigned int hwirq_offset;
@@ -72,9 +72,9 @@ static void combiner_handle_cascade_irq(struct irq_desc *desc)
 
 	chained_irq_enter(chip, desc);
 
-	spin_lock(&irq_controller_lock);
+	raw_spin_lock(&irq_controller_lock);
 	status = readl_relaxed(chip_data->base + COMBINER_INT_STATUS);
-	spin_unlock(&irq_controller_lock);
+	raw_spin_unlock(&irq_controller_lock);
 	status &= chip_data->irq_mask;
 
 	if (status == 0)
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#2 lore raw
Quoted 4 lines · Marek Szyprowski

The exynos-combiner driver uses a regular spinlock to protect access to the combiner interrupt status register in combiner_handle_cascade_irq(), which is invoked in hard IRQ context as a chained interrupt handler.

Quoted 8 lines

When PREEMPT_RT is enabled on ARM, regular spinlock is converted to a sleeping lock (mutex-based), which must not be used in atomic context such as hard interrupt handlers. Switch the irq_controller_lock to raw_spinlock, which remains a true non-sleeping spinlock even under PREEMPT_RT.

Fixes a900e5d99718 ("ARM: exynos: move exynos4210-combiner to drivers/irqchip")

For the change based on the reasoning

but why do you need a lock around a single read of a register? As far as I can tell, it was introduced in commit
84bbc16c1f621 ("ARM: S5PV310: Add IRQ support")

and then dragged through the kernel, merged, renamed, unmerged until it got where it is today.

This

	https://lore.kernel.org/all/[email protected]/

is v1, as you see the lock is used in multiple places. Then someone asked "why locking"

	https://lore.kernel.org/all/20100628144743.GB3287@debian/

and in v2

	https://lore.kernel.org/all/[email protected]/

it went down to a single user.

It looks like a leftover from initial development. So it would make sense to einer remove it or add a comment why it is still there after all these years since it is not obvious.

Sebastian

maintainer
#3 lore raw
In reply to Marek Szyprowski
Quoted 9 lines · Marek Szyprowski

The exynos-combiner driver uses a regular spinlock to protect access to the combiner interrupt status register in combiner_handle_cascade_irq(), which is invoked in hard IRQ context as a chained interrupt handler.

When PREEMPT_RT is enabled on ARM, regular spinlock is converted to a sleeping lock (mutex-based), which must not be used in atomic context such as hard interrupt handlers. Switch the irq_controller_lock to raw_spinlock, which remains a true non-sleeping spinlock even under PREEMPT_RT.

Mechanically this makes sense, but out of curiosity I have to ask:

Quoted 6 lines
drivers/irqchip/exynos-combiner.c +1 -1
-static DEFINE_SPINLOCK(irq_controller_lock);
+static DEFINE_RAW_SPINLOCK(irq_controller_lock);
 
 struct combiner_chip_data {
 	unsigned int hwirq_offset;

drivers/irqchip/exynos-combiner.c static void combiner_handle_cascade_irq(struct irq_desc *desc) · line 77

Quoted 8 lines
drivers/irqchip/exynos-combiner.c +2 -2
@@ -72,9 +72,9 @@ static void combiner_handle_cascade_irq(struct irq_desc *desc)
 
 	chained_irq_enter(chip, desc);
 
-	spin_lock(&irq_controller_lock);
+	raw_spin_lock(&irq_controller_lock);
 	status = readl_relaxed(chip_data->base + COMBINER_INT_STATUS);
-	spin_unlock(&irq_controller_lock);
+	raw_spin_unlock(&irq_controller_lock);

What is this lock actually protecting?

Each combiner has it's own @base address, so there is no concurrency problem between two cascade interrupts being handled at the same time.

That means the only possible problem would be that the same cascade interrupt is handled on two CPUs concurrently. Is that even possible?

Thanks,

tglx

#4 lore raw
Quoted 28 lines · Thomas Gleixner
Quoted 9 lines · Marek Szyprowski

The exynos-combiner driver uses a regular spinlock to protect access to the combiner interrupt status register in combiner_handle_cascade_irq(), which is invoked in hard IRQ context as a chained interrupt handler.

When PREEMPT_RT is enabled on ARM, regular spinlock is converted to a sleeping lock (mutex-based), which must not be used in atomic context such as hard interrupt handlers. Switch the irq_controller_lock to raw_spinlock, which remains a true non-sleeping spinlock even under PREEMPT_RT.

Mechanically this makes sense, but out of curiosity I have to ask:

Quoted 6 lines
drivers/irqchip/exynos-combiner.c +1 -1
-static DEFINE_SPINLOCK(irq_controller_lock);
+static DEFINE_RAW_SPINLOCK(irq_controller_lock);
 
 struct combiner_chip_data {
 	unsigned int hwirq_offset;

drivers/irqchip/exynos-combiner.c static void combiner_handle_cascade_irq(struct irq_desc *desc) · line 77

Quoted 8 lines
drivers/irqchip/exynos-combiner.c +2 -2
@@ -72,9 +72,9 @@ static void combiner_handle_cascade_irq(struct irq_desc *desc)
 
 	chained_irq_enter(chip, desc);
 
-	spin_lock(&irq_controller_lock);
+	raw_spin_lock(&irq_controller_lock);
 	status = readl_relaxed(chip_data->base + COMBINER_INT_STATUS);
-	spin_unlock(&irq_controller_lock);
+	raw_spin_unlock(&irq_controller_lock);

What is this lock actually protecting?

Quoted 5 lines

Each combiner has it's own @base address, so there is no concurrency problem between two cascade interrupts being handled at the same time.

That means the only possible problem would be that the same cascade interrupt is handled on two CPUs concurrently. Is that even possible?

Frankly speaking I did this conversion mechanically, late in the evening to fix the bug warning I've spotted. Indeed this spinlock looks like a copy&paste or development leftover. The only side-effect of it I see is a memory barrier, which might affect how the register access happens, but this should not affect cascade operation imho. Do You want me to send a patch removing it completely?

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland
maintainer
#5 lore raw
Quoted 6 lines · Marek Szyprowski
Quoted 5 lines · Thomas Gleixner

What is this lock actually protecting?

Each combiner has it's own @base address, so there is no concurrency problem between two cascade interrupts being handled at the same time.

Quoted 7 lines
Quoted 2 lines

That means the only possible problem would be that the same cascade interrupt is handled on two CPUs concurrently. Is that even possible?

Frankly speaking I did this conversion mechanically, late in the evening to fix the bug warning I've spotted. Indeed this spinlock looks like a copy&paste or development leftover. The only side-effect of it I see is a memory barrier, which might affect how the register access happens, but this should not affect cascade operation imho. Do You want me to send a patch removing it completely?

I've applied the fixup for now. But, yes please send a removal against

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/urgent

Thanks,

tglx