-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Enable Zephyr to handle shared interrupts #49379
Comments
Would really like to have this feature, STM32/GD32 now need to rely on hacks to use shared IRQs. What is the reason for |
I was thinking that calling too many functions in an ISR would bog down the system and I haven't seen very many MCUs that have more than three peripherals sharing one interrupt line but the short answer is, the number was chosen arbitrarily. |
I like that approach of calling all the registered handlers from the isr in the shared_isr section, without requiring a separate driver. Do you plan to open a PR implementing this proposal or would you rather gather more feedback before. |
I think the only issue is the number of shared interrupts allowed. I'll bump it up to 4 and open a PR. I thought about using a Kconfig but I didn't know how to pass the option to the python script. |
How does this differ from what is done in drivers/interrupt_controller/Kconfig.shared_irq & drivers/interrupt_controller/intc_shared_irq.c? |
To be honest, I was unaware of this implementation and it seems that no projects are using it, other than drivers/ethernet/eth_smsc911x.c including the header. The shared_irq implementation doesn't seem very compatible with the current drivers and would require some code changes. This pull request is more efficient when calling the shared ISR handlers. |
I have tried this approach in the past. The int_shared_irq controller is based on multilevel interrupts, which are not supported on aarch32. |
I've received some useful comments on the PR but I think the discussion should move back to the issue. In the PR, I've implemented two different versions that each have pros and cons. I'd like to list them here so we can pick one. 1) Only ISRs created with IRQ_DIRECT_CONNECT can be shared. /* Shared Prototypes */ /* IRQ_DIRECT_CONNECT table */ /* IRQ_CONNECT table */ void attribute((section(".shared_isr")))shared_isr_20(void){ 2) Allow ISRs created with IRQ_CONNECT to share IRQ lines. /* IRQ_DIRECT_CONNECT table */ /* IRQ_CONNECT table */ Each entry in the __sw_isr_table is a NULL terminated list of shared interrupts with corresponding arguments. The Or there is another way that I've yet to consider. |
I haven't gone into much detail on how ISR tables are generated, so please ignore the following if it doesn't make sense. In case of shared IRQs, would it be possible to autogenerate a function stub that calls the N attached routines with the right parameter? Then the table would just point to such function stub. Non-shared IRQs would just call the original function. |
@gmarull |
@gmarull |
Zephyr now supports shared interrupts on the architecture level: #61422 |
Introduction
Allow up to three Interrupt Service Routines (ISRs) to share one interrupt line.
Problem description
Many MCUs have peripherals that share interrupt lines. For example, the USB, UCPD1, and UCPD2 peripherals on the STM32G0B0x1 share interrupt 8. Currently no practical application can use those peripherals together without circumventing the Zephyr interrupt system or writing a custom device driver.
Proposed change
Interrupts are registered with a macro similar to
IRQ_DIRECT_CONNECT
that’s namedIRQ_SHARE_CONNECT
.Allow up to three ISRs to share one interrupt line.
Only one of the user ISRs should service the interrupt, unless the interrupt is pending due to more than one source.
Detailed RFC
Create a new flag,
ISR_FLAG_SHARE
, that’s passed toZ_ISR_DECLARE
.Add a new section to the linker script:
When the
gen_isr_tables.py
script executes and detects that theISR_FLAG_SHARE
flag is set, it generates a shared ISR that calls the user ISRs in sequence. The generated ISR is placed in the.shared_isr
section.For example:
Resulting
build/zephyr/isr_tables.c
generated bygen_isr_tables.py
:I have only tested this on the Cortex M architecture.
The text was updated successfully, but these errors were encountered: