Skip to content

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

Merged
merged 2 commits into from
Dec 10, 2019

Conversation

carlocaione
Copy link
Collaborator

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]

@carlocaione
Copy link
Collaborator Author

Gentle ping tagging @bbolen @stephanosio @ioannisg @andrewboie because previously involved with related stuff in the past.

@stephanosio
Copy link
Member

Also it may be worth noting that there was some major refactoring done on GIC driver and Cortex-R interrupt system in general here: 5772e52 82dd67b

@carlocaione
Copy link
Collaborator Author

@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?

@stephanosio
Copy link
Member

@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.

@carlocaione
Copy link
Collaborator Author

@stephanosio ACK. Pushed a new rev.

@galak
Copy link
Collaborator

galak commented Oct 18, 2019

@carlocaione
Copy link
Collaborator Author

@galak we cannot fully align if I follow the @stephanosio suggestion of using GIC_SPI / GIC_PPI as macros instead of flags for the type as done on the Linux kernel. Also on Linux there is no really support for IRQ priority.

@stephanosio
Copy link
Member

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 struct irq_data, whereas Zephyr only accepts single unsigned int irq

@carlocaione
Copy link
Collaborator Author

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).

Copy link
Member

@stephanosio stephanosio left a 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.

@stephanosio
Copy link
Member

@carlocaione
Copy link
Collaborator Author

@galak can you merge this? thanks.

@carlocaione
Copy link
Collaborator Author

@galak please, consider this blocked on #20243. So wait for that before merging this.

@galak
Copy link
Collaborator

galak commented Oct 30, 2019

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 struct irq_data, whereas Zephyr only accepts single unsigned int irq

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.

@stephanosio
Copy link
Member

What the issue w/regards to dts_fixup.

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:
b761bd4#diff-8dec1584212c37fe3f73aa7c195ebde2L9-L16

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.

@stephanosio
Copy link
Member

Please merge this if there is no further comment. I have a quite few changes that are dependent on this.

@stephanosio
Copy link
Member

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"
Copy link
Collaborator

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. :)

Copy link
Collaborator

@galak galak left a 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 :)

@galak
Copy link
Collaborator

galak commented Nov 8, 2019

Thanks, I know this was a bit long to get ready.

Copy link
Collaborator

@bbolen bbolen left a 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.

@carlocaione
Copy link
Collaborator Author

Squashed the commit as suggested by @bbolen and force-pushed again. We should actually squash all the commits together if we care about bisectability.

FWIW #20263 depends on this story.

Copy link
Member

@ioannisg ioannisg left a 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

Mani-Sadhasivam pushed a commit to Mani-Sadhasivam/zephyr that referenced this pull request Dec 6, 2019
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]>
carlocaione and others added 2 commits December 9, 2019 15:56
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Changes to public APIs area: Devicetree
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants