Repository navigation
arch/tricore: support interrupt nesting - #21308
zhangyu981027 wants to merge 6 commits into
Conversation
|
|
@zhangyu-duck please fix the conflict. |
51161b9 to
d35556f
Compare
|
@zhangyu-duck please fix the conflict. |
casaroli
left a comment
There was a problem hiding this comment.
The body says "Depends on #21307", which is closed without merge, and "only the last 4 commits belong to this PR", but the PR carries 20 commits. Three of them are also in #21355.
Fix: rebase on master, keep only the commits of this PR, and update the body.
The logs in the Testing section do not say that CONFIG_ARCH_IRQPRIO is on, and no defconfig sets it, so they may run only the non-nesting path.
Fix: add an ostest log with CONFIG_ARCH_IRQPRIO=y.
d35556f to
d043c35
Compare
Decouple interrupt priority (SRPN) from the IRQ index used by up_irq_to_ndx. Add a per-CPU SRPN-to-IRQ mapping table so that SRPN can be independently allocated and reassigned without affecting the IRQ numbering scheme. Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
Reason for revert: the mapping from IRQ to NDX should only be a logical relationship; Tricore directly treated Prio as NDX, which led to the existence of this interface. Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
Read the irq number from the ICU LASR register of the current core instead of translating the SRPN through g_srpn_to_irq. LASR must be read before interrupts are re-enabled. Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
Split the single interrupt entry (tricore_doirq) into two paths: tricore_irq_direct: fast dispatch with re-enable for nesting, triggers a low-priority GPSR if context switch is needed. tricore_irq_sched: deferred context switch and signal delivery at the lowest SRPN, runs only after all nested interrupts complete. Defer signal delivery for the running task to the scheduling GPSR so up_schedule_sigaction() always has a saved context. Save and restore PPRS around this path to preserve the protection register set. Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
When CONFIG_ARCH_IRQPRIO is disabled, all IRQs go through tricore_irq_sched, which does ack, dispatch and context switch. No interrupt nesting and no scheduling GPSR are used. When CONFIG_ARCH_IRQPRIO is enabled, keep the two paths: SRPN 1 for the scheduling GPSR and SRPN 2~255 for the nestable direct path. Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
The fast irq path (like CONFIG_ARCH_HIPRI_INTERRUPT) does not save regs in irq, similar to arm's pendsv, so xcp.regs may be NULL. TriCore cannot access the NULL address, so check regs before use. Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
d043c35 to
d76960f
Compare
The PR info gives detailed test results |
|
@casaroli please review again |
Summary
Add priority-based interrupt nesting support for TriCore while preserving
the existing non-nesting configuration:
tricore_irq_direct: fast, nestable dispatch. It triggers alow-priority GPSR when a context switch is required.
tricore_irq_sched: deferred context-switch and signal-deliveryhandling at the lowest SRPN, running after nested interrupts complete.
up_schedule_sigaction()always has a saved context. Save and restorePPRS around this path to preserve the protection register set.
CONFIG_ARCH_IRQPRIO=y, SRPN 1 is used for scheduling andSRPNs 2-255 use the nestable direct-interrupt path.
CONFIG_ARCH_IRQPRIO=n, all interrupts use the software-managedsingle-entry
tricore_irq_schedpath without nesting.__INTTAB_CPU0as the final BIV value. The full vector-tableconfiguration keeps BIV 8 KB-aligned, while the single-entry
configuration places the entry at offset
0x1fe0.orderedto the absolute-address TASKING text groups so that bothTC3 and TC4 LSL files link correctly.
up_getusrsp()whenregsis NULL because the fastinterrupt path does not save a register frame.
instead of translating the SRPN through
g_srpn_to_irq.Commits
This PR is based directly on Apache NuttX master and contains six commits:
Impact
TriCore architecture only. Interrupt nesting remains controlled by
CONFIG_ARCH_IRQPRIO; the non-nesting configuration retains itssingle-entry dispatch behavior.
The TASKING LSL change only declares the required ordering for an
absolute-address group. It does not change the resulting section
addresses. No other architecture is affected.
Testing
Validation was performed after rebasing onto Apache NuttX master
e0a754b0bee56bd8803122f963ca4ebebed438df.Build: All eight TC397/TC4x9 GCC and TASKING configurations passed build
and static layout verification. After the signal-delivery review fix, the
TC397 GCC
CONFIG_ARCH_IRQPRIO=yconfiguration was rebuilt successfully.Test: The updated TC397 GCC
CONFIG_ARCH_IRQPRIO=yimage passed completeostest, and the instrumented SRPN 2-to-3 test reached nesting depth 2.
The final source tree is byte-identical to the snapshots used for the
20261124 on-target tests below.
Board configurations:
a2g-tc397-5v-tft:nshtriboard_tc4x9_com:nshBuild and static layout verification
ELF symbols, section sizes, and startup disassembly were checked for every
configuration in this table.
CONFIG_ARCH_IRQPRIOnynynynyCommon static-verification results:
CONFIG_ARCH_IRQPRIO=n:__INTTAB_CPU0 = tricore_inttab = 0x80001fe0,.intvecsize is0x20.CONFIG_ARCH_IRQPRIO=y:__INTTAB_CPU0 = 0x80000000,tricore_inttab = 0x80000020,.intvecsize is0x1fe0.0x80002000,text starts at
0x80002100, and startup disassembly confirms thatthe expected
__INTTAB_CPU0value is written to BIV.The TC397 TASKING images and all TC4x9 images were built and checked
statically only; they were not flashed or run in this validation round.
TC397 on-target verification
Target: Infineon Application Kit TC397 V2.0, serial number
AK8MNLZR.Each image contained a unique hello marker to confirm that the intended
image was running.
CONFIG_ARCH_IRQPRIO=nIRQNEST_20261123_OFF_E0A754hello,uname -a, complete ostest, including vforkCONFIG_ARCH_IRQPRIO=yIRQNEST_20261124_DEV_SIG_PS6hello,uname -a, complete ostest, including vforkIRQNEST_20261124_DEV_SIG_PS6_NESTmax=2 low=1 high=2 nested=1The
CONFIG_ARCH_IRQPRIO=nrun was the regression test before the latestsignal-delivery update. Both
CONFIG_ARCH_IRQPRIO=yruns used the finalsignal-delivery implementation. Complete ostest finished without
assertions, TriCore traps, or panics, and vfork reported that the child
ran and exited before the parent resumed.
For the nesting test, a high-priority SRPN 3 GPSR interrupt was
triggered from the low-priority SRPN 2 GPSR ISR. The high-priority ISR
ran before the low-priority ISR returned, proving an actual nesting
depth greater than one.
The nesting instrumentation was temporary and is not included in this
PR.