-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Zephyr Shared ISRs (alternative) #57146
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
Conversation
Adds a feature to gen_isr_tables.py that enables it to detect and generate shared IRQs when IRQ_CONNECT is used. Signed-off-by: Sam Hurst <[email protected]>
Add test case of shared interrupts. This tests that IRQs are shared when IRQ_CONNECT is called multiple times on the same IRQ with different ISR handlers. Signed-off-by: Sam Hurst <[email protected]>
It appears that the tests now pass on all the enabled platforms, that is: |
6116977
to
9c0c372
Compare
@carlocaione Thanks for the review. Do you think this PR is acceptable with the issues your reported fixed? I don't plan to spend time on it if it is likely going to be rejected like the original PR. |
Yes, but other reviewers will chime in for sure. So please, rework the commits and push this out of draft state. |
I have just pushed a new version with the comments from @carlocaione fixed. I also simplified a bit the |
The strategy is to not generate code depending on the enabled shared interrupts, but only data. For that a generic shared_irq_handler is added and called with a list of functions and args to be called, ended with 0. Signed-off-by: Aurelien Jarno <[email protected]>
The compliance checks should be fixed by this PR: #57261 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refresh +1 from the last time this came around. This seems very reasonable to me. One nitpick in the test code.
And I'll repeat that I still think it would be simpler to use a linked-list or array representation for the ISRs at build time (even though it adds a few cycles to the case where there is only one ISR registered) instead of doing all the work here to create a special "shared" record.
k_busy_wait(MS_TO_US(DURATION)); | ||
|
||
for (int i = 0; i < MAX_ISR_TESTS; i++) { | ||
zassert_true(test_flag[i] == i + 1, "Test flag not set by ISR%d\n", i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like you want to have the test block after every interrupt, and clear the flags between them. It's important to verify that the right ISRs run, it's equally important to ensure that the wrong ones don't!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The third commit is fixing something introduced by the first one. Squash them.
@@ -416,6 +419,13 @@ config GEN_IRQ_VECTOR_TABLE | |||
indexed by IRQ line. In the latter case, the vector table must be | |||
supplied by the application or architecture code. | |||
|
|||
config ISR_SHARE_IRQ | |||
bool "Allow IRQs to share multiple ISRs" | |||
depends on GEN_ISR_TABLES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also depends on ARCH_HAS_SW_ISR_TABLE_SHARED_IRQ
@aurel32 do you plan to keep working on this? |
@aurel32 |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
This is a continuation from #49427 and should be seen as an alternative proof of concept. The goal is to see if the strategy is working, and check if CI is happy. The details of naming and moving code can be discussed in a second time if this alternative solution is acceptable.
The first two commits are from the original PR, reusing the great of work of @sambhurst. The third commit changes the per shared interrupt handler to a common interrupt handler which is fixed and thus already present in the first linking stage. It is marked as KEEP in the linker file as it is not used before the second stage. It reads both argument and function from a per interrupt table, with a NULL pointer function to mark the end of the list. I reused the existing
_isr_table_entry struct
, but that can be changed later if it proves to be a bad idea.So far I have only tested that on Cortex-M CPU.