Skip to content

Commit

Permalink
microblaze: Fix intc_enable_or_unmask function
Browse files Browse the repository at this point in the history
Intc_enable_or_unmask() is called at the last stage of handle_level_irq().

This function enables the irq first (Write INTC.SIE) and clear ISR next (Write INTC.IAR).
This would create problems that processor will get into a new interrupt as soon as SIE
is written because the previous level interrupt has been captured by INTC.

If the description bring some puzzles, here is the details of how interrupt is handled
for MicroBlaze after Interrupt signal is detected:
1. disable INTC (INTC.CIE = 1)
2. Acknowledge INTC (INTC.IAR = 1)
3. gets into interrupt source's handler, for example, timer's handler
4. Timer is interrupt handler acknowledge Timer Interrupt Status (Timer.TCSR0[23] = 1), and return
5. Enable INTC (INTC.SIE = 1)
6. Acknowledge INTC (INTC.IAR = 1)

INTC continue to capture source inputs even if INTC is disabled (INTC.IER == 1).
So between the gap of step 2 and step 3, the level interrupt from source makes INTC captures
a new interrupt and thus the INTC.ISR = 1 during step 3, 4, and 5.
When INTC is enabled in step 5, INTC's interrupt output will go high immediately.

In summary, the driver should issue step 6 before step 5.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
  • Loading branch information
Michal Simek committed Dec 13, 2012
1 parent b881e99 commit 7958a68
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion arch/microblaze/kernel/intc.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ static void intc_enable_or_unmask(struct irq_data *d)
unsigned long mask = 1 << d->hwirq;

pr_debug("enable_or_unmask: %ld\n", d->hwirq);
out_be32(INTC_BASE + SIE, mask);

/* ack level irqs because they can't be acked during
* ack function since the handle_level_irq function
* acks the irq before calling the interrupt handler
*/
if (irqd_is_level_type(d))
out_be32(INTC_BASE + IAR, mask);

out_be32(INTC_BASE + SIE, mask);
}

static void intc_disable_or_mask(struct irq_data *d)
Expand Down

0 comments on commit 7958a68

Please sign in to comment.