-
Notifications
You must be signed in to change notification settings - Fork 7.3k
interrupt_controller: gic: Support PPIs #19860
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
Gentle ping tagging @bbolen @stephanosio @ioannisg @andrewboie because previously involved with related stuff in the past. |
@stephanosio damn, I was not aware of that. At this point I think the best way forward is just for you to incorporate these changes. Is that ok for you? |
Since we're already here (and #19698 has already become way too big for what it was initially intended for), I think it would be better if these changes get reviewed and merged here. It is very likely that this PR will get merged before #19698, so once that happens, it will cause a merge conflict for #19698 and I will make the necessary adoptions there to incorporate these changes. |
@stephanosio ACK. Pushed a new rev. |
Since you are reworking this can we get the dts for GIC to align with https://git.kernel.org/pub/scm/linux/kernel/git/devicetree/devicetree-rebasing.git/tree/Bindings/interrupt-controller/arm,gic.yaml |
@galak we cannot fully align if I follow the @stephanosio suggestion of using |
Yea, the current Zephyr interrupt API won't be able to accommodate the Linux GIC dts without introducing many hacks (such as specifying dts_fixup for every GIC mapped interrupt, which is a major hassle). The main reason is that Linux IRQ control API accepts |
agree. @galak given that is unlikely that we can align with the Linux kernel soon, I propose to merge the commit as is (with yours and @stephanosio ACK). |
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.
NOTE: Once merged, to be re-integrated into the refactored gic driver in #19698; unit tests for in-depth functional verification is to be implemented in the future.
@galak can you merge this? thanks. |
What the issue w/regards to dts_fixup. I'd prefer if we were more consistent with the the linux binding. I get we'll need to differ for priority, but not sure I understand the other issues. |
For GIC, there are multiple interrupt types with different IRQ bases. If we follow the Linux dts and specify interrupt type in a separate property, for every single IRQ, we have to map/fix-up, the complex (interrupt type)+(type-dependent interrupt index) definition from dts to the actual linear IRQ number used by the Zephyr interrupt API. Refer to the following for what has to be done if we follow the Linux dts: This is simply not practical. If we really wanted to follow the Linux dts, we will have to redesign the Zephyr interrupt API to either accept interrupt type parameter alongside the IRQ number (which is somewhat interrupt controller-specific and should be avoided) or some kind struct representing an IRQ (as Linux is doing, but this is really an overkill for an OS that is intended to run on environments with very limited resources). IMHO, following Linux dts is good while it makes sense; but, if you have to sacrifice tidiness of code and sanity of developers over following Linux dts, that is a very questionable approach. |
Please merge this if there is no further comment. I have a quite few changes that are dependent on this. |
Ping |
@@ -453,7 +467,7 @@ def encode_zephyr_multi_level_irq(irq, irq_num): | |||
while irq_ctrl.interrupts: | |||
irq_num = (irq_num + 1) << 8 | |||
if "irq" not in irq_ctrl.interrupts[0].data: | |||
err("Expected binding for {!r} to have 'irq' in *-cells" | |||
err("Expected binding for {!r} to have 'irq' in interrupt-cells" |
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.
Ah... had missed this one. :)
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.
Looks good, one change I'd like to see is swapping the order of flags
and priority
in the interrupt-cells. This keeps is a bit more compatible with the linux binding, and pretty minor change at this point before we have more dts files that have GICs in them :)
Thanks, I know this was a bit long to get ready. |
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, I'm trying to catch up on all of the cortex changes.
I might suggest squashing this commit on the first one.
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.
Looks good to me
The ARM Generic Interrupt Controller (GIC) supports multiple interrupt types whose linear IRQ numbers are offset by a type-specific base number. This commit adds a function to automatically fix up ARM GIC interrupts in order to output a linear IRQ number that is offset by the interrupt type-specific base number. For more details, refer to the issue zephyrproject-rtos#19860. Signed-off-by: Stephanos Ioannidis <[email protected]>
The GIC-400 driver currently only supports SPIs because the (32) offset for the INTIDs is hard-coded in the driver. At the driver level there is no really difference between PPIs and SPIs so we can easily extend the driver to support PPIs as well. This is useful if we want to add support for the ARM Generic Timers that use INTIDs in the PPI range. SPI interrupts are in the range [0-987]. PPI interrupts are in the range [0-15]. This commit adds interrupt 'type' cell to the GIC device tree binding and changes the 'irq' cell to use interrupt type-specific index, rather than a linear IRQ number. The 'type'+'irq (index)' combo is automatically fixed up into a linear IRQ number by the scripts/dts/gen_defines.py script. Signed-off-by: Stephanos Ioannidis <[email protected]> Signed-off-by: Carlo Caione <[email protected]>
The ARM Generic Interrupt Controller (GIC) supports multiple interrupt types whose linear IRQ numbers are offset by a type-specific base number. This commit adds a function to automatically fix up ARM GIC interrupts in order to output a linear IRQ number that is offset by the interrupt type-specific base number. For more details, refer to the issue zephyrproject-rtos#19860. Signed-off-by: Stephanos Ioannidis <[email protected]>
The GIC-400 driver currently only supports SPIs because the (32) offset
for the INTIDs is hard-coded in the driver. At the driver level there is
no really difference between PPIs and SPIs so we can easily extend the
driver to support PPIs as well.
This is useful if we want to add support for the ARM Generic Timers that
use INTIDs in the PPI range.
SPI interrupts are in the range [0-987]. PPI interrupts are in the
range [0-15].
This patches introduces a new interrupt type (GIC_SPI | GIC_PPI) to be
defined in the DTS to mark the IRQ as SPI or PPI, following what's done
in the Linux kernel. When the IRQ is marked as SPI its INTID is
offsetted by 32, otherwise by 16 when marked as PPI. The fix is done
introducing a new macro to be used in the DTS fixup file.
Signed-off-by: Carlo Caione [email protected]