Commit dec2b284 authored by Vineet Gupta's avatar Vineet Gupta

ARCv2: intc: Allow interruption by lowest priority interrupt

ARC HS Cores support configurable multiple interrupt priorities of upto
16 levels.

There is processor "interrupt preemption threshhold" in STATUS32.E[4:1]
And several places need to set this up:
1. seed value as kernel is booting
2. seed value for user space programs
3. Arg to SLEEP instruction in idle task (what interrupt prio can wake)
4. Per-IRQ line prioirty (i.e. what is the priority of interrupt
   raised by a peripheral or timer or perf counter...

Currently above sites use the highest priority 0. This can be potential
problem when multiple priorities are supported. e.g. user space could
only be interrupted by P0 interrupt, not others...
So turn this over and instead make default interruption level to be
the lowest priority possible 15. This should be fine even if there are
fewer priority levels configured (say two: P0 HIGH, P1 LOW)

This feature also effectively disables FIRQ feature if present in
hardware config. With old code, a P0 interrupt would be FIRQ, needing
special handling (ISR or Register Banks) which is NOT supported yet.
Now it not be P0 (P15 or whatever is lowest prio) so FIRQ is not
triggered.
Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
parent 4d0cb15f
...@@ -30,8 +30,11 @@ ...@@ -30,8 +30,11 @@
/* Was Intr taken in User Mode */ /* Was Intr taken in User Mode */
#define AUX_IRQ_ACT_BIT_U 31 #define AUX_IRQ_ACT_BIT_U 31
/* 0 is highest level, but taken by FIRQs, if present in design */ /*
#define ARCV2_IRQ_DEF_PRIO 0 * User space should be interruptable even by lowest prio interrupt
* Safe even if actual interrupt priorities is fewer or even one
*/
#define ARCV2_IRQ_DEF_PRIO 15
/* seed value for status register */ /* seed value for status register */
#define ISA_INIT_STATUS_BITS (STATUS_IE_MASK | STATUS_AD_MASK | \ #define ISA_INIT_STATUS_BITS (STATUS_IE_MASK | STATUS_AD_MASK | \
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include <linux/irqchip.h> #include <linux/irqchip.h>
#include <asm/irq.h> #include <asm/irq.h>
static int irq_prio;
/* /*
* Early Hardware specific Interrupt setup * Early Hardware specific Interrupt setup
* -Called very early (start_kernel -> setup_arch -> setup_processor) * -Called very early (start_kernel -> setup_arch -> setup_processor)
...@@ -24,6 +26,14 @@ void arc_init_IRQ(void) ...@@ -24,6 +26,14 @@ void arc_init_IRQ(void)
{ {
unsigned int tmp; unsigned int tmp;
struct irq_build {
#ifdef CONFIG_CPU_BIG_ENDIAN
unsigned int pad:3, firq:1, prio:4, exts:8, irqs:8, ver:8;
#else
unsigned int ver:8, irqs:8, exts:8, prio:4, firq:1, pad:3;
#endif
} irq_bcr;
struct aux_irq_ctrl { struct aux_irq_ctrl {
#ifdef CONFIG_CPU_BIG_ENDIAN #ifdef CONFIG_CPU_BIG_ENDIAN
unsigned int res3:18, save_idx_regs:1, res2:1, unsigned int res3:18, save_idx_regs:1, res2:1,
...@@ -46,28 +56,25 @@ void arc_init_IRQ(void) ...@@ -46,28 +56,25 @@ void arc_init_IRQ(void)
WRITE_AUX(AUX_IRQ_CTRL, ictrl); WRITE_AUX(AUX_IRQ_CTRL, ictrl);
/* setup status32, don't enable intr yet as kernel doesn't want */
tmp = read_aux_reg(0xa);
tmp |= ISA_INIT_STATUS_BITS;
tmp &= ~STATUS_IE_MASK;
asm volatile("flag %0 \n"::"r"(tmp));
/* /*
* ARCv2 core intc provides multiple interrupt priorities (upto 16). * ARCv2 core intc provides multiple interrupt priorities (upto 16).
* Typical builds though have only two levels (0-high, 1-low) * Typical builds though have only two levels (0-high, 1-low)
* Linux by default uses lower prio 1 for most irqs, reserving 0 for * Linux by default uses lower prio 1 for most irqs, reserving 0 for
* NMI style interrupts in future (say perf) * NMI style interrupts in future (say perf)
*
* Read the intc BCR to confirm that Linux default priority is avail
* in h/w
*
* Note:
* IRQ_BCR[27..24] contains N-1 (for N priority levels) and prio level
* is 0 based.
*/ */
tmp = (read_aux_reg(ARC_REG_IRQ_BCR) >> 24 ) & 0xF;
if (ARCV2_IRQ_DEF_PRIO > tmp) READ_BCR(ARC_REG_IRQ_BCR, irq_bcr);
panic("Linux default irq prio incorrect\n");
irq_prio = irq_bcr.prio; /* Encoded as N-1 for N levels */
pr_info("archs-intc\t: %d priority levels (default %d)%s\n",
irq_prio + 1, irq_prio,
irq_bcr.firq ? " FIRQ (not used)":"");
/* setup status32, don't enable intr yet as kernel doesn't want */
tmp = read_aux_reg(0xa);
tmp |= STATUS_AD_MASK | (irq_prio << 1);
tmp &= ~STATUS_IE_MASK;
asm volatile("flag %0 \n"::"r"(tmp));
} }
static void arcv2_irq_mask(struct irq_data *data) static void arcv2_irq_mask(struct irq_data *data)
...@@ -86,7 +93,7 @@ void arcv2_irq_enable(struct irq_data *data) ...@@ -86,7 +93,7 @@ void arcv2_irq_enable(struct irq_data *data)
{ {
/* set default priority */ /* set default priority */
write_aux_reg(AUX_IRQ_SELECT, data->irq); write_aux_reg(AUX_IRQ_SELECT, data->irq);
write_aux_reg(AUX_IRQ_PRIORITY, ARCV2_IRQ_DEF_PRIO); write_aux_reg(AUX_IRQ_PRIORITY, irq_prio);
/* /*
* hw auto enables (linux unmask) all by default * hw auto enables (linux unmask) all by default
......
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