irq: multilevel: fix irq_parent_level_3()

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 <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
This commit is contained in:
Yong Cong Sin 2024-09-23 13:42:10 +08:00 committed by Alberto Escolar
commit cb6417cff4
2 changed files with 5 additions and 4 deletions

View file

@ -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;
}
/**

View file

@ -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) {