Skip to contentSkip to conversation

irqchip/armada-370-xp: Use atomic_io_modify() instead of another spinlock

PATCH In review Marek Behún 2 participants 2 messages Jun 20, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 irqchip/armada-370-xp: Use atomic_io_modify() instead of another spinlock

Use the dedicated atomic_io_modify() instead of hardcoded spin_lock() + readl() + writel() + spin_unlock() sequence.

This allows us to drop the irq_controller_lock spinlock from the driver.

---
Note: the atomic_io_modify() function is defined only for arm platform, and it is currently used only in 3 drivers:

drivers/clocksource/timer-armada-370-xp.c
drivers/clocksource/timer-orion.c
drivers/watchdog/orion_wdt.c

Do we want to use this? Is there some other standardized alternative that can be used across all platforms?

---
 drivers/irqchip/irq-armada-370-xp.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/irqchip/irq-armada-370-xp.c +3 -9
index 924a574f28ea..8d76e70f8dfd 100644
@@ -512,24 +512,18 @@ static __init void armada_xp_ipi_init(struct device_node *node)
 	set_smp_ipi_range(base_ipi, IPI_DOORBELL_END);
 }
 
-static DEFINE_RAW_SPINLOCK(irq_controller_lock);
-
 static int armada_xp_set_affinity(struct irq_data *d,
 				  const struct cpumask *mask_val, bool force)
 {
 	irq_hw_number_t hwirq = irqd_to_hwirq(d);
-	unsigned long reg, mask;
 	int cpu;
 
 	/* Select a single core from the affinity mask which is online */
 	cpu = cpumask_any_and(mask_val, cpu_online_mask);
-	mask = 1UL << cpu_logical_map(cpu);
 
-	raw_spin_lock(&irq_controller_lock);
-	reg = readl(main_int_base + ARMADA_370_XP_INT_SOURCE_CTL(hwirq));
-	reg = (reg & (~ARMADA_370_XP_INT_SOURCE_CPU_MASK)) | mask;
-	writel(reg, main_int_base + ARMADA_370_XP_INT_SOURCE_CTL(hwirq));
-	raw_spin_unlock(&irq_controller_lock);
+	atomic_io_modify(main_int_base + ARMADA_370_XP_INT_SOURCE_CTL(hwirq),
+			 ARMADA_370_XP_INT_SOURCE_CPU_MASK,
+			 BIT(cpu_logical_map(cpu)));
 
 	irq_data_update_effective_affinity(d, cpumask_of(cpu));
 
Signature · 1 line
2.44.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Marek Behún

Use the dedicated atomic_io_modify() instead of hardcoded spin_lock() + readl() + writel() + spin_unlock() sequence.

This allows us to drop the irq_controller_lock spinlock from the driver.

---
Note: the atomic_io_modify() function is defined only for arm platform, and it is currently used only in 3 drivers:

Quoted 6 lines

drivers/clocksource/timer-armada-370-xp.c
drivers/clocksource/timer-orion.c
drivers/watchdog/orion_wdt.c

Do we want to use this? Is there some other standardized alternative that can be used across all platforms?

I took a quick look at the code. I don't see anything architecture specific in there. It could be moved somewhere more general.

Maybe ask Arnd, he tends to have a good overview for this sort of thing.

The patch itself looks fine.

Andrew