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
Zephyr Shared ISRs #49427
Zephyr Shared ISRs #49427
Conversation
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.
Minor nitpick-ish comments are based on a quick browse through the PR .. I'll do a more thorough review and test when I'm back in the office next week.
This feature will also need some sort of test. For example: arm_irq_advanced_features |
would be nice to detect shared IRQs from devicetree :). |
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.
My biggest concern here is that this shared IRQ support is done leveraging the direct IRQs instead of regular IRQs (and the IRQ vector table instead of the ISR table). Now, direct IRQs are tricky, serviced in a special way and definitely harder to get them right.
So, why exactly not using the regular ISR table instead of the vector table?
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.
Some notes. I like the feature, no so much the API. What users want is almost certainly "shared interrupts just work" and not "use these special rules to register shared interrupts".
That's the use case, because if the drivers for those shared ISRs are tightly coupled and willing to write special code, they'd be able to just share an ISR between them anyway.
When app authors want "shared IRQs" it's because hardware designers messed up and the software is having to make things work by sharing an interrupt across multiple drivers/modules that are not related and don't want to have to do anything special.
How about CONFIG_KERNEL_SHARED_IRQ instead (and maybe an ARCH_SUPPORT_SHARED_IRQ flag), and when you have that set the kernel automatically knows that sw_isr_table[] entries are linked list records and that it needs to traverse them instead of just running the one it finds?
The regular ISR table pass an argument to the ISR, which can't be used with the shared ISRs because they would need different arguments passed to them. |
7235525
to
7b0ba60
Compare
@microbuilder I'm getting error while running the arm_irq_advanced_features tests. I'll upload my test for this PR when I can get the other tests to pass. |
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 <sbh1187@gmail.com>
@tejlmand could you take another look? Thanks |
@tejlmand @carlocaione Could you take another look? Thanks |
@sambhurst and this is zephyr.elf struct device address has been changed, shared interrupt point to zephyr.pre1.elf address. this is isr_tables.c
I have tested this patch in newest zephyr, the struct device does have offset. update: here is my solution:
in file zephyr/cmake/linker_script/common/common-rom.cmake Line: 26 Add
and in file zephyr/include/zephyr/linker/common-rom/common-rom-kernel-devices.ld Line: 47 Add
then I got same struct device address. and do not forget remove put them in text section code. |
@@ -83,6 +83,8 @@ zephyr_linker_section_configure(SECTION .text INPUT ".glue_7t") | |||
zephyr_linker_section_configure(SECTION .text INPUT ".glue_7") | |||
zephyr_linker_section_configure(SECTION .text INPUT ".vfp11_veneer") | |||
zephyr_linker_section_configure(SECTION .text INPUT ".v4_bx") | |||
zephyr_linker_section_configure(SECTION .text INPUT ".shared_irq") |
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.
.text section is before .device, in final link, it will change .device section address.
@@ -141,6 +141,8 @@ SECTIONS | |||
|
|||
*(.text) | |||
*(".text.*") | |||
*(.shared_irq) |
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.
Move .shared_irq and shared_irq_arg to .sw_isr_table will not influence the .device address
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.
this is not possible. The code dealing with the shared interrupt must be somewhere in the .text
section, see #49427 (review). If not, must be in a section with the correct settings for eXecution for MMU / MPU.
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.
this is not possible. The code dealing with the shared interrupt must be somewhere in the
.text
section, see #49427 (review). If not, must be in a section with the correct settings for eXecution for MMU / MPU.
Put text section blew device is it possible?
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.
Not quite sure I understood the question. If you are asking whether the current placement of the shared_irq
code in the text
section is correct then it is not. The shifting of the addresses was a problem already seen in the past, see #49427 (review)
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.
We need to have:
- The
shared_irq
code in a section that is mapped as eXecutable (.text
is a natural choice, but I'm open to anything really) because the script is generating code at build time that (of course) needs to be eXecuted. - As pointed out by @tejlmand the shifting addresses are allowed only between stage 0 and 1. Having shifting addresses between other linking stages could be problematic.
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.
We need to have:
- The
shared_irq
code in a section that is mapped as eXecutable (.text
is a natural choice, but I'm open to anything really) because the script is generating code at build time that (of course) needs to be eXecuted.- As pointed out by @tejlmand the shifting addresses are allowed only between stage 0 and 1. Having shifting addresses between other linking stages could be problematic.
Here's my opinion:
- The code does not have to be in the text section.
- sw_isr_table link stage is below text and device, so that function in text section address and device in device section address will not be change.
so put shared_irq and shared_irq_arg to sw_isr_table will not effect.
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. |
@sambhurst For my information, do you plan to complete this PR ? |
@erwango I'd like to finish this PR but there doesn't seem to be a general agreement on how this feature should be implemented. To simplify the effort, I proposed to just implement and test it for Arm Cortex devices and later roll it out to other devices, but this proposal wasn't well received. So, unless we can arrive at a consensus, we can close this PR. |
Did this issue come up in your test? and my solution is right? |
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. |
I would like to get shared IRQ working, it's important for some MCU. For what I understood the remaining issues are:
Both issues seems to contradict themselves, therefore I have just tried an alternative way with a common shared irq handler getting passed the data, i.e. both argument and function. For that I reused the existing Before continuing in that direction, and then getting things working on at least a second architecture, I would like to know if that strategy is acceptable? Things like naming, comments and so on, can probably be improved, but before investing time on that I would like to get some feedback about the big picture. |
I agree with your patch, |
Please, open a (different) PR with your code so people can have a chance to take a look and we can check if CI is happy with this solution as well. |
@carlocaione @aurel32
I have tried on qemu_cortex_m3 board, hello_world runs well.
@aurel32 use KEEP in link script make text size not change is the best way, not my thought. |
Thanks for testing ! On my side I forgot to mention here that I opened a PR as requested, with the test passing on all tested platforms, that is: qemu_cortex_m0 qemu_cortex_m3 qemu_cortex_a9 qemu_cortex_a53 qemu_cortex_a53_smp |
@aurel32 |
@aurel32 Thanks for picking this up. |
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 PR implements a feature that allows for the use of shared interrupts in Zephyr. I've only tested it on the arm aarch32. Please see #49379 for more context. Also, I'm not a python programmer, so I'm sure my changes to gen_isr_tables.py can be improved upon.