Skip to contentSkip to conversation

gic: Unmask private interrupts on all cores during IRQ enable

PATCH Superseded Stephen Caudle 2 participants 2 messages Nov 1, 2010 – Nov 2, 2010

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gic: Unmask private interrupts on all cores during IRQ enable

Requesting/freeing private peripheral interrupts on multi-core chips that use only one IRQ number for all cores currently unmasks/masks the interrupt for only the executing core.

This change prevents the need for a separate call to enable_irq on other cores after request_irq. Also, shutdown is implemented instead of disable to allow for lazy IRQ disabling.

---
 arch/arm/Kconfig      |    5 +++
 arch/arm/common/gic.c |   83 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 88 insertions(+), 0 deletions(-)
arch/arm/Kconfig +5 -0
index a19a526..fbf5236 100644
@@ -1298,6 +1298,11 @@ config LOCAL_TIMERS
 	  accounting to be spread across the timer interval, preventing a
 	  "thundering herd" at every timer tick.
 
+config IRQ_PER_CPU
+	bool
+	depends on SMP
+	default n
+
 source kernel/Kconfig.preempt
 
 config HZ
arch/arm/common/gic.c +83 -0

107 lines not on this page · raw message

Signature · 5 lines
1.7.3.2

--
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum
#1 lore raw
Quoted 9 lines · Stephen Caudle
arch/arm/common/gic.c +9 -0
+#ifdef CONFIG_IRQ_PER_CPU
+static inline void gic_smp_call_function(struct call_single_data *data)
+{
+	int cpu;
+	int this_cpu = smp_processor_id();
+
+	/*
+	 * Since this function is called with interrupts disabled,
+	 * smp_call_function can't be used here because it warns (even

arch/arm/common/gic.c static int gic_set_cpu(unsigned int irq, const struct cpumask *mask_val) · line 192

Quoted 10 lines
arch/arm/common/gic.c +10 -0
+	 * if wait = 0) when interrupts are disabled.
+	 *
+	 * __smp_call_function_single doesn't warn when interrupts are
+	 * disabled and not waiting, so use it instead.
+	 */
+	for_each_online_cpu(cpu)
+		if (cpu != this_cpu)
+			__smp_call_function_single(cpu, data, 0);
+}
+

So you think that calling __smp_call_function_single with irqs disabled with a data that is reused is not deadlock prone ?

If you look, __smp_call_function_single will wait in csd_lock until the previous requested cpu has consumed the request (as it must, because the data contains both the arguments and the list pointers to link the element).

arch/arm/common/gic.c static int gic_set_cpu(unsigned int irq, const struct cpumask *mask_val) · line 211

Quoted 9 lines
arch/arm/common/gic.c +9 -0
+static void gic_enable_irq(unsigned int irq)
+{
+	struct irq_desc *desc = irq_to_desc(irq);
+	struct gic_chip_data *gic_data = get_irq_chip_data(irq);
+
+	if (irq >= GIC_PPI_FIRST && irq <= GIC_PPI_LAST) {
+		gic_data->ppi_data.func = gic_unmask_ppi;
+		gic_data->ppi_data.info = &desc->irq;
+		gic_data->ppi_data.flags = 0;

Oh, now the flags (and therefore the lock) are cleared, and the function is overwritten before it is known that the last cpu has processed this call function request.

So you could have anything from the wrong function executed to the last cpu's ipi function call list is crossed with another cpus, probably leading to other call function data never being processed. In the best case other callers to call_function_single will hang forever waiting for their own (per-cpu by originator) request to be consumed.

If you don't want to wait you must to allocate csd data per cpu, and never clear flags except at the initial allocation. You can not overwrite function or info unless you know its safe if the previous ofunction(odata) is issued and the new nfunction(ndata) is also safe as nfunction(odata) or ofunction(ndata) (or you put in additional barriers so only one has to be safe).

And then someone has to decide delayed mask or unmask is safe.

[note: it may be difficult to impossible to observe these races with nr_cpus <= 2]

btw, the generic code is moving to passing desc not irq numbers around.

milton