Commit c5ae4d40 authored by Helge Deller's avatar Helge Deller Committed by Ben Hutchings

parisc: Filter out spurious interrupts in PA-RISC irq handler

commit b1b4e435 upstream.

When detecting a serial port on newer PA-RISC machines (with iosapic) we have a
long way to go to find the right IRQ line, registering it, then registering the
serial port and the irq handler for the serial port. During this phase spurious
interrupts for the serial port may happen which then crashes the kernel because
the action handler might not have been set up yet.

So, basically it's a race condition between the serial port hardware and the
CPU which sets up the necessary fields in the irq sructs. The main reason for
this race is, that we unmask the serial port irqs too early without having set
up everything properly before (which isn't easily possible because we need the
IRQ number to register the serial ports).

This patch is a work-around for this problem. It adds checks to the CPU irq
handler to verify if the IRQ action field has been initialized already. If not,
we just skip this interrupt (which isn't critical for a serial port at bootup).
The real fix would probably involve rewriting all PA-RISC specific IRQ code
(for CPU, IOSAPIC, GSC and EISA) to use IRQ domains with proper parenting of
the irq chips and proper irq enabling along this line.

This bug has been in the PA-RISC port since the beginning, but the crashes
happened very rarely with currently used hardware.  But on the latest machine
which I bought (a C8000 workstation), which uses the fastest CPUs (4 x PA8900,
1GHz) and which has the largest possible L1 cache size (64MB each), the kernel
crashed at every boot because of this race. So, without this patch the machine
would currently be unuseable.

For the record, here is the flow logic:
1. serial_init_chip() in 8250_gsc.c calls iosapic_serial_irq().
2. iosapic_serial_irq() calls txn_alloc_irq() to find the irq.
3. iosapic_serial_irq() calls cpu_claim_irq() to register the CPU irq
4. cpu_claim_irq() unmasks the CPU irq (which it shouldn't!)
5. serial_init_chip() then registers the 8250 port.
Problems:
- In step 4 the CPU irq shouldn't have been registered yet, but after step 5
- If serial irq happens between 4 and 5 have finished, the kernel will crash

Cc: linux-parisc@vger.kernel.org
Signed-off-by: default avatarHelge Deller <deller@gmx.de>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 24277c76
...@@ -336,8 +336,8 @@ void do_cpu_irq_mask(struct pt_regs *regs) ...@@ -336,8 +336,8 @@ void do_cpu_irq_mask(struct pt_regs *regs)
struct pt_regs *old_regs; struct pt_regs *old_regs;
unsigned long eirr_val; unsigned long eirr_val;
int irq, cpu = smp_processor_id(); int irq, cpu = smp_processor_id();
#ifdef CONFIG_SMP
struct irq_desc *desc; struct irq_desc *desc;
#ifdef CONFIG_SMP
cpumask_t dest; cpumask_t dest;
#endif #endif
...@@ -350,8 +350,12 @@ void do_cpu_irq_mask(struct pt_regs *regs) ...@@ -350,8 +350,12 @@ void do_cpu_irq_mask(struct pt_regs *regs)
goto set_out; goto set_out;
irq = eirr_to_irq(eirr_val); irq = eirr_to_irq(eirr_val);
#ifdef CONFIG_SMP /* Filter out spurious interrupts, mostly from serial port at bootup */
desc = irq_to_desc(irq); desc = irq_to_desc(irq);
if (unlikely(!desc->action))
goto set_out;
#ifdef CONFIG_SMP
cpumask_copy(&dest, desc->irq_data.affinity); cpumask_copy(&dest, desc->irq_data.affinity);
if (irqd_is_per_cpu(&desc->irq_data) && if (irqd_is_per_cpu(&desc->irq_data) &&
!cpu_isset(smp_processor_id(), dest)) { !cpu_isset(smp_processor_id(), dest)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment