Skip to content

Commit 3364a35

Browse files
committed
Revert "irq: multilevel: compile 3rd level IRQ APIs only when enabled"
This reverts commit 2152b8e. This commit is breaking CI. Signed-off-by: Anas Nashif <[email protected]>
1 parent c3b2f44 commit 3364a35

File tree

3 files changed

+25
-98
lines changed

3 files changed

+25
-98
lines changed

include/zephyr/irq_multilevel.h

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,15 @@ typedef union _z_irq {
3232
uint32_t l1: CONFIG_1ST_LEVEL_INTERRUPT_BITS;
3333
/* Second level interrupt bits */
3434
uint32_t l2: CONFIG_2ND_LEVEL_INTERRUPT_BITS;
35-
#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
3635
/* Third level interrupt bits */
3736
uint32_t l3: CONFIG_3RD_LEVEL_INTERRUPT_BITS;
38-
#endif /* CONFIG_3RD_LEVEL_INTERRUPTS */
3937
} bits;
4038

41-
#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
4239
/* Third level IRQ's interrupt controller */
4340
struct {
4441
/* IRQ of the third level interrupt aggregator */
4542
uint32_t irq: CONFIG_1ST_LEVEL_INTERRUPT_BITS + CONFIG_2ND_LEVEL_INTERRUPT_BITS;
4643
} l3_intc;
47-
#endif /* CONFIG_3RD_LEVEL_INTERRUPTS */
4844

4945
/* Second level IRQ's interrupt controller */
5046
struct {
@@ -65,20 +61,16 @@ static inline uint32_t _z_l2_irq(_z_irq_t irq)
6561
return irq.bits.l2 - 1;
6662
}
6763

68-
#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
6964
static inline uint32_t _z_l3_irq(_z_irq_t irq)
7065
{
7166
return irq.bits.l3 - 1;
7267
}
73-
#endif /* CONFIG_3RD_LEVEL_INTERRUPTS */
7468

7569
static inline unsigned int _z_irq_get_level(_z_irq_t z_irq)
7670
{
77-
#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
7871
if (z_irq.bits.l3 != 0) {
7972
return 3;
8073
}
81-
#endif /* CONFIG_3RD_LEVEL_INTERRUPTS */
8274

8375
if (z_irq.bits.l2 != 0) {
8476
return 2;
@@ -150,9 +142,7 @@ static inline unsigned int irq_to_level_2(unsigned int irq)
150142
.bits = {
151143
.l1 = 0,
152144
.l2 = irq + 1,
153-
#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
154145
.l3 = 0,
155-
#endif /* CONFIG_3RD_LEVEL_INTERRUPTS */
156146
},
157147
};
158148

@@ -178,7 +168,6 @@ static inline unsigned int irq_parent_level_2(unsigned int irq)
178168
return _z_l1_irq(z_irq);
179169
}
180170

181-
#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
182171
/**
183172
* @brief Return the 3rd level interrupt number
184173
*
@@ -252,7 +241,6 @@ static inline unsigned int irq_parent_level_3(unsigned int irq)
252241

253242
return _z_l2_irq(z_irq);
254243
}
255-
#endif /* CONFIG_3RD_LEVEL_INTERRUPTS */
256244

257245
/**
258246
* @brief Return the interrupt number for a given level
@@ -268,14 +256,11 @@ static inline unsigned int irq_from_level(unsigned int irq, unsigned int level)
268256
return irq;
269257
} else if (level == 2) {
270258
return irq_from_level_2(irq);
271-
}
272-
#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
273-
else if (level == 3) {
259+
} else if (level == 3) {
274260
return irq_from_level_3(irq);
275261
}
276-
#endif /* CONFIG_3RD_LEVEL_INTERRUPTS */
277262

278-
/* level is higher than what's supported */
263+
/* level is higher than 3 */
279264
__ASSERT_NO_MSG(false);
280265
return irq;
281266
}
@@ -294,14 +279,11 @@ static inline unsigned int irq_to_level(unsigned int irq, unsigned int level)
294279
return irq;
295280
} else if (level == 2) {
296281
return irq_to_level_2(irq);
297-
}
298-
#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
299-
else if (level == 3) {
282+
} else if (level == 3) {
300283
return irq_to_level_3(irq);
301284
}
302-
#endif /* CONFIG_3RD_LEVEL_INTERRUPTS */
303285

304-
/* level is higher than what's supported */
286+
/* level is higher than 3 */
305287
__ASSERT_NO_MSG(false);
306288
return irq;
307289
}
@@ -321,14 +303,11 @@ static inline unsigned int irq_parent_level(unsigned int irq, unsigned int level
321303
return irq;
322304
} else if (level == 2) {
323305
return irq_parent_level_2(irq);
324-
}
325-
#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
326-
else if (level == 3) {
306+
} else if (level == 3) {
327307
return irq_parent_level_3(irq);
328308
}
329-
#endif /* CONFIG_3RD_LEVEL_INTERRUPTS */
330309

331-
/* level is higher than what's supported */
310+
/* level is higher than 3 */
332311
__ASSERT_NO_MSG(false);
333312
return irq;
334313
}
@@ -343,24 +322,19 @@ static inline unsigned int irq_parent_level(unsigned int irq, unsigned int level
343322
static inline unsigned int irq_get_intc_irq(unsigned int irq)
344323
{
345324
const unsigned int level = irq_get_level(irq);
325+
326+
__ASSERT_NO_MSG(level <= 3);
346327
_z_irq_t z_irq = {
347328
.irq = irq,
348329
};
349330

350-
#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
351-
__ASSERT_NO_MSG(level <= 3);
352331
if (level == 3) {
353332
return z_irq.l3_intc.irq;
354-
}
355-
#else
356-
__ASSERT_NO_MSG(level <= 2);
357-
#endif /* CONFIG_3RD_LEVEL_INTERRUPTS */
358-
359-
if (level == 2) {
333+
} else if (level == 2) {
360334
return z_irq.l2_intc.irq;
335+
} else {
336+
return irq;
361337
}
362-
363-
return irq;
364338
}
365339

366340
/**
@@ -377,12 +351,8 @@ static inline unsigned int irq_increment(unsigned int irq, unsigned int val)
377351
.irq = irq,
378352
};
379353

380-
if (false) {
381-
/* so that it evaluates the next condition */
382-
#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
383-
} else if (z_irq.bits.l3 != 0) {
354+
if (z_irq.bits.l3 != 0) {
384355
z_irq.bits.l3 += val;
385-
#endif /* CONFIG_3RD_LEVEL_INTERRUPTS */
386356
} else if (z_irq.bits.l2 != 0) {
387357
z_irq.bits.l2 += val;
388358
} else {

tests/kernel/interrupt/src/multilevel_irq.c

Lines changed: 13 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@
1212
ZTEST(interrupt_feature, test_multi_level_api)
1313
{
1414
/* Zephyr multilevel-encoded IRQ */
15+
const uint32_t irqn_l3 = DT_IRQN(DT_NODELABEL(test_l3_irq));
1516
const uint32_t irqn_l2 = DT_IRQN(DT_NODELABEL(test_l2_irq));
1617
const uint32_t irqn_l1 = DT_IRQN(DT_NODELABEL(test_l1_irq));
1718
/* Raw IRQ specified in the devicetree */
19+
const uint32_t raw_l3 = DT_IRQ(DT_NODELABEL(test_l3_irq), irq);
1820
const uint32_t raw_l2 = DT_IRQ(DT_NODELABEL(test_l2_irq), irq);
1921
const uint32_t raw_l1 = DT_IRQ(DT_NODELABEL(test_l1_irq), irq);
2022

2123
/**
2224
* - irq_get_level()
2325
*/
26+
zassert_equal(3, irq_get_level(irqn_l3));
2427
zassert_equal(2, irq_get_level(irqn_l2));
2528
zassert_equal(1, irq_get_level(irqn_l1));
2629

@@ -29,59 +32,13 @@ ZTEST(interrupt_feature, test_multi_level_api)
2932
* - irq_to_level_2()
3033
* - irq_parent_level_2()
3134
*/
35+
zassert_equal(irq_from_level_2(irqn_l3), raw_l2);
3236
zassert_equal(irq_from_level_2(irqn_l2), raw_l2);
3337

3438
zassert_equal(irq_to_level_2(raw_l2) & irqn_l2, irq_to_level_2(raw_l2));
3539

3640
zassert_equal(irq_parent_level_2(irqn_l2), raw_l1);
3741

38-
/**
39-
* - irq_from_level()
40-
* - irq_to_level()
41-
* - irq_parent_level()
42-
*/
43-
zassert_equal(irq_from_level(irqn_l2, 2), raw_l2);
44-
45-
zassert_equal(irq_to_level(raw_l2, 2) & irqn_l2, irq_to_level(raw_l2, 2));
46-
47-
zassert_equal(irq_parent_level(irqn_l2, 2), raw_l1);
48-
49-
/**
50-
* - irq_get_intc_irq()
51-
*/
52-
zassert_equal(irq_get_intc_irq(irqn_l2), irqn_l1);
53-
zassert_equal(irq_get_intc_irq(irqn_l1), irqn_l1);
54-
55-
const uint32_t irqn_l2_inc = DT_IRQN(DT_NODELABEL(test_l2_irq_inc));
56-
const uint32_t irqn_l1_inc = DT_IRQN(DT_NODELABEL(test_l1_irq_inc));
57-
58-
/**
59-
* - irq_increment()
60-
*/
61-
zassert_equal(irq_increment(irqn_l1, 1), irqn_l1_inc);
62-
zassert_equal(irq_increment(irqn_l2, 2), irqn_l2_inc);
63-
}
64-
65-
#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
66-
ZTEST(interrupt_feature, test_multi_level_api_l3)
67-
{
68-
/* Zephyr multilevel-encoded IRQ */
69-
const uint32_t irqn_l2 = DT_IRQN(DT_NODELABEL(test_l2_irq));
70-
const uint32_t irqn_l3 = DT_IRQN(DT_NODELABEL(test_l3_irq));
71-
/* Raw IRQ specified in the devicetree */
72-
const uint32_t raw_l2 = DT_IRQ(DT_NODELABEL(test_l2_irq), irq);
73-
const uint32_t raw_l3 = DT_IRQ(DT_NODELABEL(test_l3_irq), irq);
74-
75-
/**
76-
* - irq_get_level()
77-
*/
78-
zassert_equal(3, irq_get_level(irqn_l3));
79-
80-
/**
81-
* - irq_from_level_2()
82-
*/
83-
zassert_equal(irq_from_level_2(irqn_l3), raw_l2);
84-
8542
/**
8643
* - irq_from_level_3()
8744
* - irq_to_level_3()
@@ -99,24 +56,32 @@ ZTEST(interrupt_feature, test_multi_level_api_l3)
9956
* - irq_parent_level()
10057
*/
10158
zassert_equal(irq_from_level(irqn_l3, 2), raw_l2);
59+
zassert_equal(irq_from_level(irqn_l2, 2), raw_l2);
10260
zassert_equal(irq_from_level(irqn_l3, 3), raw_l3);
10361

62+
zassert_equal(irq_to_level(raw_l2, 2) & irqn_l2, irq_to_level(raw_l2, 2));
10463
zassert_equal(irq_to_level(raw_l3, 3) & irqn_l3, irq_to_level(raw_l3, 3));
10564

65+
zassert_equal(irq_parent_level(irqn_l2, 2), raw_l1);
10666
zassert_equal(irq_parent_level(irqn_l3, 3), raw_l2);
10767

10868
/**
10969
* - irq_get_intc_irq()
11070
*/
11171
zassert_equal(irq_get_intc_irq(irqn_l3), irqn_l2);
72+
zassert_equal(irq_get_intc_irq(irqn_l2), irqn_l1);
73+
zassert_equal(irq_get_intc_irq(irqn_l1), irqn_l1);
11274

11375
const uint32_t irqn_l3_inc = DT_IRQN(DT_NODELABEL(test_l3_irq_inc));
76+
const uint32_t irqn_l2_inc = DT_IRQN(DT_NODELABEL(test_l2_irq_inc));
77+
const uint32_t irqn_l1_inc = DT_IRQN(DT_NODELABEL(test_l1_irq_inc));
11478

11579
/**
11680
* - irq_increment()
11781
*/
82+
zassert_equal(irq_increment(irqn_l1, 1), irqn_l1_inc);
83+
zassert_equal(irq_increment(irqn_l2, 2), irqn_l2_inc);
11884
zassert_equal(irq_increment(irqn_l3, 3), irqn_l3_inc);
11985
}
120-
#endif /* CONFIG_3RD_LEVEL_INTERRUPTS */
12186

12287
ZTEST_SUITE(gen_isr_table_multilevel, NULL, NULL, NULL, NULL, NULL);

tests/kernel/interrupt/testcase.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,3 @@ tests:
8585
- EXTRA_DTC_OVERLAY_FILE="multilevel_irq.overlay"
8686
extra_configs:
8787
- CONFIG_TEST_MULTILEVEL_IRQ=y
88-
arch.interrupt.multilevel_l3:
89-
filter: CONFIG_MULTI_LEVEL_INTERRUPTS
90-
extra_args:
91-
- EXTRA_DTC_OVERLAY_FILE="multilevel_irq.overlay"
92-
extra_configs:
93-
- CONFIG_TEST_MULTILEVEL_IRQ=y
94-
- CONFIG_3RD_LEVEL_INTERRUPTS=y
95-
- CONFIG_3RD_LEVEL_INTERRUPT_BITS=11

0 commit comments

Comments
 (0)