Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interrupt nesting #10057

Merged
merged 9 commits into from
Aug 7, 2023
Merged

Conversation

wming-github
Copy link

Summary

Provides interrupt nesting and zero-latency interrupt support for the ARM M core architecture, including: ARMV6-M ARMV7-M ARMV8-M

Impact

Interrupt exception for arm m core architecture

Testing

Validation enables different priority interrupts to be nested

wangming9 added 9 commits August 3, 2023 17:43
To simplify the interrupt handling in protected mode.

Signed-off-by: wangming9 <[email protected]>
1、The process stack supports interrupt nesting, Execute in MSP;
2、The interrupt stack supports interrupt nesting;
   The thread mode use PSP, and the handle mode use MSP;
3、Adjust arm_doirq、exception_common implementation to meet interrupt nesting
4、Adjust the conditions for returning MSP and PSP;
5、remove setintstack,add arm_initialize_stack;

Signed-off-by: wangming9 <[email protected]>
To simplify the interrupt handling in protected mode.

Signed-off-by: wangming9 <[email protected]>
Solve the dependency on ARMV6M when compiling tlsr8278adk80d:nsh.

Signed-off-by: wangming9 <[email protected]>
1、The process stack supports interrupt nesting, Execute in MSP;
2、The interrupt stack supports interrupt nesting;
   The thread mode use PSP, and the handle mode use MSP;
3、Adjust arm_doirq、exception_common implementation to meet interrupt nesting
4、Adjust the conditions for returning MSP and PSP;
5、remove setintstack;

Signed-off-by: wangming9 <[email protected]>
To simplify the interrupt handling in protected mode.

Signed-off-by: wangming9 <[email protected]>
1、The process stack supports interrupt nesting, Execute in MSP;
2、The interrupt stack supports interrupt nesting;
   The thread mode use PSP, and the handle mode use MSP;
3、Adjust arm_doirq、exception_common implementation to meet interrupt nesting
4、Adjust the conditions for returning MSP and PSP;
5、remove setintstack;

Signed-off-by: wangming9 <[email protected]>
The first time interrupt nesting occurs between REE and TEE,
CURRENT_REGS needs to be set.

If TEE nesting REE breaks, then EXC_RETURN.S=0,EXC_RETURN.ES=1;
Conversely, EXC_RETURN.S=1,EXC_RETURN.ES=0;
Interrupt nesting between TEE and REE can be determined based
on the S and ES bits of EXC_RETURN.
Only once nesting between TEE and REE is supported, and cyclic
nesting between TEE and REE is not supported.

Signed-off-by: wangming9 <[email protected]>
@patacongo
Copy link
Contributor

patacongo commented Aug 3, 2023

See Issue #1134 and Wiki https://cwiki.apache.org/confluence/display/NUTTX/Nested+Interrupts

@xiaoxiang781216 xiaoxiang781216 linked an issue Aug 3, 2023 that may be closed by this pull request
Copy link
Contributor

@davids5 davids5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be configurable. The majority of the system assumes code executable under interrupt is not interruptible. If this code comes in without the option to disable it, it will wreak havoc with existing systems.

@xiaoxiang781216
Copy link
Contributor

xiaoxiang781216 commented Aug 4, 2023

This needs to be configurable. The majority of the system assumes code executable under interrupt is not interruptible. If this code comes in without the option to disable it, it will wreak havoc with existing systems.

@davids5 , before this patch, if user want to use zero latency interrupt, they have to:

  1. Modify some entries in _vector from exception_common to a reenterable function
  2. Save and restore the context in the new function
  3. Dispatch the real work to a callback function

as describe in https://cwiki.apache.org/confluence/display/NUTTX/High+Performance%2C+Zero+Latency+Interrupts

This patch just make exception_common reenterable, so you don't write a new one. But the interruption doesn't happen util you configure some IRQs have higher priority than NVIC_SYSH_PRIORITY_DEFAULT, enable ARMV7M_USEBASEPRI and ARCH_HIPRI_INTERRUPT:
https://github.com/apache/nuttx/blob/master/arch/Kconfig#L1153C8-L1153C28
https://github.com/apache/nuttx/blob/master/arch/arm/src/armv7-m/Kconfig#L16

@xiaoxiang781216
Copy link
Contributor

ping @davids5, could you give the feedback about my explanation?

@davids5
Copy link
Contributor

davids5 commented Aug 7, 2023

@xiaoxiang781216 Thank you for the explanation. I should have realized that if any driver already had priorities not set properly, it would already cause crashes (IIRC @patacongo removed some of these inconsistent priorities years ago in the Kinetis arch)

@xiaoxiang781216
Copy link
Contributor

xiaoxiang781216 commented Aug 7, 2023

@xiaoxiang781216 Thank you for the explanation. I should have realized that if any driver already had priorities not set properly, it would already cause crashes (IIRC @patacongo removed some of these inconsistent priorities years ago in the Kinetis arch)

Yes, it crashes before, but it mayn't crash now if the driver doesn't call any OS API directly since exception_common is reenterable safe now.

@xiaoxiang781216 xiaoxiang781216 merged commit 8d21bbf into apache:master Aug 7, 2023
26 checks passed
@jerpelea jerpelea added this to To-Add in Release Notes - 12.3.0 Sep 26, 2023
@jerpelea jerpelea moved this from To-Add to done in Release Notes - 12.3.0 Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Nested Interrupt Support
4 participants