-
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
riscv: privileged: custom Interrupt Controller API #63214
Conversation
This change paves ground for #62606, ping @carlocaione |
43f2e9d
to
ddf13c4
Compare
Hi @carlocaione , @fkokosinski , guys could you please take a look? |
Hi @carlocaione , Could you please clarify the questions above? |
1b07867
to
f4cc7f8
Compare
Hi @carlocaione , could you please take a look? I've addressed your comments. |
f4cc7f8
to
4b2a270
Compare
4b2a270
to
04351ce
Compare
Hi @carlocaione , just a general question (please correct me if I'm wrong): after adding the z_soc_ prefix to the API to be implemented by Custom IC we assume that the IC driver should be placed in soc/ directory and not in drivers/ directory, right? I was expecting that we would use drivers/ directory for the IC driver. So maybe we should have z_ but drop soc part from that API? What do you think? UPD: in case we decide to place the custom IC driver to drivers/ directory, then probably we shouldn't declare custom IC API under soc/ and move it to arch/riscv/irq.h instead? It does look like a generic RISC-V functionality which is not bound to particular SoC, but to be implemented by particular RISC-V IC driver UPD2: @carlocaione , one step further in the direction of mentioned above: if we implement custom IC API within the IC driver code in drivers/interrupt_controller then why do we need to redefine the arch_irq_* functions at all? Why not to implement arch_irq_enable/disable/is_enabled/ z_riscv_irq_priority_set directly in the driver? |
Correct.
But this IC is specific to your SoC (and in this case it can be very well in the
Yes, if the driver can be used by different SoCs / platforms.
I don't think there is a strict rule here but if possible I'd like to keep separate the |
@carlocaione , please find my answers below:
Our custom IC (IPIC) is used with multiple Syntacore SoCs. Also in common case it seems that the same custom IC could be used with different RISC-V SoCs. Ok, so I'll remove the custom IC API declaration from soc/ to arch/ then.
I've just checked and it seems that actually a lot of interrupt controller drivers implement arch_irq_enable/disable/is_enabled functions. I'm also thinking this way: with redefinition of arch_irq_* functions, we show what? That for custom ICs we are skipping some architecture-wide layer, right? Such common layer is possible for standardized RISC-V controllers, like PLIC, but not the custom ones, since there is no common rule for them. Probably the redefinition is indeed better. |
Yup, fine to me.
We are trying to clean-up tree-wide the usage of prefix and interfaces, see #61588 so I would still suggest to avoid using the |
737f7ba
to
ac8094c
Compare
Hi @carlocaione , I've addressed your previous comments, please take a look. |
Hi @carlocaione , just a kind reminder for a review |
@carlocaione , @fkokosinski , guys there is no response from you unfortunately |
please, stop pinging me every single day. Read https://docs.zephyrproject.org/latest/contribute/contributor_expectations.html#pr-review-escalation if you have not done it yet. |
Hi @carlocaione , |
This change introduces the extension for RISC-V IRQ infrastructure API to simplify addition of the custom Interrupt Controllers. The specific RISC-V Inerrupt Controller implementation is getting connected to the Zephyr IRQ infrastructure through this API. The related functions are to be implemented by any custom Interrupt Controller driver. Signed-off-by: Alexander Razinkov <alexander.razinkov@syntacore.com>
ac8094c
to
b1bf19f
Compare
Hi @carlocaione , just a friendly reminder for a review |
* | ||
* @param irq IRQ number to enable | ||
*/ | ||
void z_irq_enable(unsigned int 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.
@nashif I'm out of touch with this topic. What's the latest on the z_*
prefix?
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.
Hi @nashif ,
Is it fine if we use z_* prefix for RISC-V wide API for custom interrupt controllers?
Such API is to be instantiated by the particular RISC-V custom interrupt controller driver in /drivers/interrupt_controller.
Additionally we consider the special case when the interrupt_controller is soc-specific and the driver is placed in /soc/riscv
What do you think?
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.
Hi @nashif ,
There was no response from you unfortunately
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.
Hi @carlocaione , @nashif , @fkokosinski , I came to the Dev Meeting yesterday, but unfortunately you were not participating, so we weren't able to discuss the API. How would we proceed? Would you come to the next Dev Meeting, or maybe let's discuss it on other meeting, like Architecture WG? Or maybe you could suggest your proposal for this API here? This goes terribly slow
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.
sorry for missing all of this dicussion earlier. If you need someone in the devreview meeting, you need to notify them out of github somehow, it is easy to miss notifications. Anyways, the direction we are taking can be seen here: #61547.
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.
Hi @nashif ,
Thanks for your reply! I've checked your proposal and I think I've got your idea.
Please correct me if I'm wrong regarding the next steps here:
- Instead of z_irq_* functions introduced below we should bring the new prefix, platfrom_*, and change the API like this:
void platform_irq_init(void);
void platform_irq_enable(unsigned int irq);
void platform_irq_disable(unsigned int irq);
int platform_irq_is_enabled(unsigned int irq);
-
We still want to define this API on include/zephyr/arch/riscv/ level and not e.g. include/zephyr/arch/ level.
-
We should change RISCV_CUSTOM_INTERRUPT_CONTROLLER to more generic PLATFORM_HAS_CUSTOM_INTERRUPT_CONTROLLER and move this config from arch/riscv/Kconfig to arch/Kconfig
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.
Will push an update version of #61547 but while working on it, I realized that this issue and can be dealt with by providing an interrupt controller driver and should be a much cleaner solution than doing this using overrides and custom hooks, this is what drivers (and especially intc driver are supposed to do). So why can't this be solved using a driver? all of the above calls are basically what intc drivers are supposed to provide anyways. I will push my changes regardless, but we might to rethink the interrupt related part in it.
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.
Hi @nashif ,
all of the above calls are basically what intc drivers are supposed to provide anyways
Absolutely! Please take a look at how all those arch_irq_xxx() functions are implemented for RISC-V, it is just one or some other form of redirection to particular unique intc_ function.
And those functions are indeed should be implemented by any IC, no matter standard or custom one.
So introduction of the clean API mandatory for all the IC implementation may remove this level of indirection entirely.
We still have ARCH-specifics, but it does look, like this specifics could be kept on arch/ level instead of sipping to soc/ level (like we have with RISC-V) just for the sake of calling the unique intc_ function within a particular driver
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.
#66505 could become a generic solution
Hi @carlocaione , @nashif , @fkokosinski , How about to discuss it on Architecture WG meeting? In case you like the idea, could you please add a AWG label? Thanks in advance! |
@carlescufi can you add this to the next arch meeting? |
this week it is @henrikbrixandersen |
@carlocaione I've added it to today's Arch WG meeting agenda. |
Kind of an important to note: it isn't always the case that there is a single interrupt controller to service all interrupts in a system. Whatever API evolves from here must take that into account. |
cc @ycsin @luchnikov |
Just a note, part of the issue with the RISC-V PLIC is that the spec has some ambiguity. |
Architecture WG meeting 2023-12-05:
|
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. |
It looks like the existing path providing IRQ handling functionality for PLIC within the RISC-V Privileged IRQ infrastructure basically fits to any Interrupt Controller which handles 2nd level IRQs, including the custom ones.
This change introduces the extension for RISC-V privileged IRQ infrastructure API to simplify addition of the custom Interrupt Controllers.
The specific Inerrupt Controller implementation is getting connected to the IRQ infrastructure through this API. The related functions are to be implemented by any custom Interrupt Controllers for 2nd level IRQ handling. At the same time no changes for the infrastructure itself is necessary when a new Interrupt Controller is added.