diff options
author | Jonathan Wright <jonathan.wright@arm.com> | 2018-04-10 11:45:31 +0100 |
---|---|---|
committer | Jonathan Wright <jonathan.wright@arm.com> | 2018-04-10 14:49:07 +0100 |
commit | edbdbc17fcf638f01af1089b812989ec3aebc346 (patch) | |
tree | b8cab1f2de51bb0cdca775f8cbaf8a02d76a4dbc | |
parent | 699fa90de5b7fe963d4aee73f84f79f9a0b0cfc8 (diff) |
lib/irq: fix size of ppi_desc_table and spi_desc_table arrays
Reduces the size of the ppi_desc_table from 32 to 16 (since the
MIN_PPI_ID is 16, entries [0-15] were unused.) Accesses to the table
have been modified to take into account the MIN_PPI_ID offset.
In the same way, reduces the size of the spi_desc_table by 32 since the
MIN_SPI_ID is 32, entries [0-31] were unused. Accesses to the table
have been modified to take into account the MIN_SPI_ID offset.
Change-Id: I7f7f3c413cafcdc9b7efea42ca361151b8f40982
-rw-r--r-- | lib/irq/irq.c | 79 |
1 files changed, 34 insertions, 45 deletions
diff --git a/lib/irq/irq.c b/lib/irq/irq.c index 8b6860a..7fa6837 100644 --- a/lib/irq/irq.c +++ b/lib/irq/irq.c @@ -47,8 +47,9 @@ (((irq_num) >= MIN_SPI_ID) && \ ((irq_num) <= MIN_SPI_ID + PLAT_MAX_SPI_OFFSET_ID)) -static spi_desc spi_desc_table[PLAT_MAX_SPI_OFFSET_ID]; -static ppi_desc ppi_desc_table[PLATFORM_CORE_COUNT][MAX_PPI_ID + 1]; +static spi_desc spi_desc_table[PLAT_MAX_SPI_OFFSET_ID - MIN_SPI_ID]; +static ppi_desc ppi_desc_table[PLATFORM_CORE_COUNT][ + (MAX_PPI_ID + 1) - MIN_PPI_ID]; static sgi_desc sgi_desc_table[PLATFORM_CORE_COUNT][MAX_SGI_ID + 1]; static spurious_desc spurious_desc_handler; @@ -63,6 +64,28 @@ static spurious_desc spurious_desc_handler; */ static spinlock_t spi_lock; +static irq_handler_t *get_irq_handler(unsigned int irq_num) +{ + if (IS_PLAT_SPI(irq_num)) + return &spi_desc_table[irq_num - MIN_SPI_ID].handler; + + unsigned int mpid = read_mpidr_el1(); + unsigned int linear_id = platform_get_core_pos(mpid); + + if (IS_PPI(irq_num)) + return &ppi_desc_table[linear_id][irq_num - MIN_PPI_ID].handler; + + if (IS_SGI(irq_num)) + return &sgi_desc_table[linear_id][irq_num - MIN_SGI_ID].handler; + + /* + * The only possibility is for it to be a spurious + * interrupt. + */ + assert(irq_num == GIC_SPURIOUS_INTERRUPT); + return &spurious_desc_handler; +} + void tftf_send_sgi(unsigned int sgi_id, unsigned int core_pos) { assert(IS_SGI(sgi_id)); @@ -121,27 +144,9 @@ static int tftf_irq_update_handler(unsigned int irq_num, int ret = -1; unsigned int spi_num; - if (IS_PLAT_SPI(irq_num)) { - spi_num = irq_num - MIN_SPI_ID; - cur_handler = &spi_desc_table[spi_num].handler; - spin_lock(&spi_lock); - } else { - unsigned int mpid = read_mpidr_el1(); - unsigned int linear_id = platform_get_core_pos(mpid); - - if (IS_PPI(irq_num)) { - cur_handler = &ppi_desc_table[linear_id][irq_num].handler; - } else if (IS_SGI(irq_num)) { - cur_handler = &sgi_desc_table[linear_id][irq_num].handler; - } else { - /* - * The only possibility is for it to be a spurious - * interrupt. - */ - assert(irq_num == GIC_SPURIOUS_INTERRUPT); - cur_handler = &spurious_desc_handler; - } - } + cur_handler = get_irq_handler(irq_num); + if (IS_PLAT_SPI(irq_num)) + spin_lock(&spin_lock); /* * Update the IRQ handler, if the current handler is in the expected @@ -195,30 +200,14 @@ int tftf_irq_handler_dispatcher(void) /* Acknowledge the interrupt */ irq_num = arm_gic_intr_ack(&raw_iar); - /* Call the user-defined handler, if any */ + cur_handler = get_irq_handler(irq_num); if (IS_PLAT_SPI(irq_num)) { - spi_num = irq_num - MIN_SPI_ID; - handler = &spi_desc_table[spi_num].handler; irq_data = &irq_num; - } else { - unsigned int mpid = read_mpidr_el1(); - unsigned int linear_id = platform_get_core_pos(mpid); - - if (IS_PPI(irq_num)) { - handler = &ppi_desc_table[linear_id][irq_num].handler; - irq_data = &irq_num; - } else if (IS_SGI(irq_num)) { - handler = &sgi_desc_table[linear_id][irq_num].handler; - sgi_data.irq_id = irq_num; - irq_data = &sgi_data; - } else { - /* - * The only possibility is for it to be a spurious - * interrupt. - */ - assert(irq_num == GIC_SPURIOUS_INTERRUPT); - handler = &spurious_desc_handler; - } + } else if (IS_PPI(irq_num)) { + irq_data = &irq_num; + } else if (IS_SGI(irq_num)) { + sgi_data.irq_id = irq_num; + irq_data = &sgi_data; } if (*handler != NULL) |