Skip to content

Commit

Permalink
irq: multilevel: fix irq_parent_level_3()
Browse files Browse the repository at this point in the history
The IRQ for level 1 and above is incremented by 1 when encoded
with Zephyr's multilevel IRQ scheme, so it should be
decremented by 1.

Signed-off-by: Yong Cong Sin <[email protected]>
Signed-off-by: Yong Cong Sin <[email protected]>
  • Loading branch information
ycsin authored and aescolar committed Oct 2, 2024
1 parent 08ceb14 commit cb6417c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions include/zephyr/irq_multilevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ static inline unsigned int irq_to_level_3(unsigned int irq)
*/
static inline unsigned int irq_parent_level_3(unsigned int irq)
{
return (irq >> CONFIG_1ST_LEVEL_INTERRUPT_BITS) &
BIT_MASK(CONFIG_2ND_LEVEL_INTERRUPT_BITS);
return ((irq >> CONFIG_1ST_LEVEL_INTERRUPT_BITS) &
BIT_MASK(CONFIG_2ND_LEVEL_INTERRUPT_BITS)) -
1;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/kernel/gen_isr_table/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,8 @@ static void test_multi_level_bit_masks_fn(uint32_t irq1, uint32_t irq2, uint32_t
zassert_equal(hwirq3, irq_from_level(irqn, 3));
zassert_equal((hwirq3 + 1) << l3_shift, irq_to_level_3(hwirq3));
zassert_equal((hwirq3 + 1) << l3_shift, irq_to_level(hwirq3, 3));
zassert_equal(hwirq2 + 1, irq_parent_level_3(irqn));
zassert_equal(hwirq2 + 1, irq_parent_level(irqn, 3));
zassert_equal(hwirq2, irq_parent_level_3(irqn));
zassert_equal(hwirq2, irq_parent_level(irqn, 3));
}

if (has_l3) {
Expand Down

0 comments on commit cb6417c

Please sign in to comment.