# Adjusting GPIO IRQ affinity in GIC

**URL:** <https://forums.developer.nvidia.com/t/adjusting-gpio-irq-affinity-in-gic/285999>\
**Category:** Jetson Orin NX\
**Tags:** gpio\
**Created:** [March 13, 2024, 11:14pm UTC](https://forums.developer.nvidia.com/t/adjusting-gpio-irq-affinity-in-gic/285999 "2024-03-13T23:14:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhagen55](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@bhagen55](https://forums.developer.nvidia.com/u/bhagen55)\
**Post date:** [March 13, 2024, 11:14pm UTC](https://forums.developer.nvidia.com/t/adjusting-gpio-irq-affinity-in-gic/285999/1 "2024-03-13T23:14:55Z")

</div>

I have a signal coming in on a GPIO pin (specifically pin 118/`GPIO3_PQ.05` on an Orin NX 8GB), and I would like to change the affinity of it’s IRQ to a core other than 0.

Looking at some previous posts:

> [@Changing smp affinity to specific interrupt](https://forums.developer.nvidia.com/t/changing-smp-affinity-to-specific-interrupt/176466/7):
>
> gpio interrupt affinity can not be changed. since gpio interrupt controller is independent. GIC is not handling

> [@Jetson AGX Xavier IRQ over GPIO CPU affinity can’t be changed](https://forums.developer.nvidia.com/t/jetson-agx-xavier-irq-over-gpio-cpu-affinity-can-t-be-changed/161256/14):
>
> Hi Jerry, Thanks for the inputs. Actually I need to handle 4 GPIO Interrupts from external hardware in 4 different cores individually and based on interrupts I need to take some actions. But 2 GPIO handling in two different cores also fine for me. As you suggested I have selected one GPIO from Tegra-Gpio-Aon which is GPIO9\_CAN1\_GPIO0\_DMIC\_CLK (GPIO 257). Pin No 32 on 40 pin header. And I am trying to set the smp\_affinity of the corresponding interrupt. But I am getting write error. Please fi…

> [@Can the cpu affinity of gpio-interrupt be changed](https://forums.developer.nvidia.com/t/can-the-cpu-affinity-of-gpio-interrupt-be-changed/172949/3):
>
> hello 295839633, please check # cat /proc/interrupts, affinity can only be set at the GIC level. affinity can be set separately for these two GPIO controllers (i.e. GPIO and AON-GPIO), which have separate GIC IRQs, please check kernel init messages for the details of GPIO allocations. for example, $ dmesg | grep "registered GPIOs" besides, please also check similar discussion thread as see-also. thanks

It seems ambiguous if this is at all possible, and if so, how to accomplish it. Some posts seem to say it is not possible for GPIO interrupts, and others seem to say it is, with further modification.  
I take it that something related to the generic interrupt controller needs to be modified, likely in a register like [this post suggests](https://forums.developer.nvidia.com/t/irq-balancing/126244/20).

I have read through section 8.2 “Interrupt Controllers” and am struggling to see how it is possible to change the affinity of the GIC.  
I would appreciate some help figuring this out!

---

<div class="post-metadata">

**Author:** ![KevinFFF](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kevinfff/32/15508_2.png) [@KevinFFF](https://forums.developer.nvidia.com/u/KevinFFF)\
**Post date:** [March 14, 2024, 3:16am UTC](https://forums.developer.nvidia.com/t/adjusting-gpio-irq-affinity-in-gic/285999/3 "2024-03-14T03:16:42Z")

</div>

Hi bhagen55,

Some posts you referred are for older release (R32).

Are you using the devkit or custom board for Orin NX?  
What’s your Jetpack version in use?

Please share the result of `cat /proc/interrupts` on your board.

---

<div class="post-metadata">

**Author:** ![bhagen55](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@bhagen55](https://forums.developer.nvidia.com/u/bhagen55)\
**Post date:** [March 14, 2024, 4:52pm UTC](https://forums.developer.nvidia.com/t/adjusting-gpio-irq-affinity-in-gic/285999/4 "2024-03-14T16:52:42Z")

</div>

Hi Kevin,  
We are using a custom board for our Orin NX running Jetpack 5.1.2 / L4T R35.4.1.

I have attached the contents of `/proc/interrupts`  
[interrupts.txt](https://forums.developer.nvidia.com/uploads/short-url/tzrkrSCF6AlQBWOBgeynMWxDZoX.txt) (17.2 KB)

The specific interrupt we are looking to modify is 312 / `pps.-1`  
I have tried changing it’s affinity through `/proc/irq` but am met with read/write errors that I assume mean changing the affinity in that manner is not supported.

```auto
# echo 1 > /proc/irq/312/smp_affinity_list 
sh: echo: write error: Input/output error

```

---

<div class="post-metadata">

**Author:** ![KevinFFF](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kevinfff/32/15508_2.png) [@KevinFFF](https://forums.developer.nvidia.com/u/KevinFFF)\
**Post date:** [March 18, 2024, 2:24pm UTC](https://forums.developer.nvidia.com/t/adjusting-gpio-irq-affinity-in-gic/285999/5 "2024-03-18T14:24:54Z")

</div>

It seems this interrupt is not allowed to be changed as you’ve referred to [Changing smp affinity to specific interrupt - #7 by Bibek](https://forums.developer.nvidia.com/t/changing-smp-affinity-to-specific-interrupt/176466/7)

I think some interrupt can change the smp\_affinity\_list but some interrupt can’t.  
Have you tried to configure other interrupts?

---

<div class="post-metadata">

**Author:** ![linuxdev](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/linuxdev/32/10243_2.png) [@linuxdev](https://forums.developer.nvidia.com/u/linuxdev)\
**Post date:** [March 18, 2024, 3:59pm UTC](https://forums.developer.nvidia.com/t/adjusting-gpio-irq-affinity-in-gic/285999/6 "2024-03-18T15:59:07Z")

</div>

Incidentally, hardware IRQs can only go to cores which have actual wiring to that core. Some PCs will have an asynchronous programmable interrupt controller (APIC) which is used to route to different cores. Jetsons are much more limited because they do not have a general reprogrammable IRQ controller to route to all cores. The first core (CPU0) always has access to all IRQs.

The scheduler can be told to route an IRQ to a core it cannot reach, but at the time the IRQ runs, if things work properly, then the scheduler will still send the IRQ to the first core.

One strategy if you are having performance issues is to take any process on CPU0 that doesn’t have to be there and then to set affinity to any core other than CPU0.

---

<div class="post-metadata">

**Author:** ![bhagen55](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@bhagen55](https://forums.developer.nvidia.com/u/bhagen55)\
**Post date:** [March 18, 2024, 5:43pm UTC](https://forums.developer.nvidia.com/t/adjusting-gpio-irq-affinity-in-gic/285999/7 "2024-03-18T17:43:19Z")

</div>

> Have you tried to configure other interrupts?

I was able to adjust the affinity of other interrupts, like this one:

```auto
151: 186190 0 0 0 0 25 GICv3 208 Level 3c00000.tegra-hsp

```

Can you clarify the wording in the second two forum posts I referenced? The wording of the replies seems to imply it is possible to adjust the affinity of the GPIO interrupts, but it is done in the GIC, and requires editing registers somewhere.

> affinity can only be set at the GIC level.

> if you want to achieve the different affinity for pin level of same GPIO controller then you will need the GPIO routing to one of 8 GPIO controller’s interrupt line and then that interrupt line to the particular CPU via GICs.

---

<div class="post-metadata">

**Author:** ![KevinFFF](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kevinfff/32/15508_2.png) [@KevinFFF](https://forums.developer.nvidia.com/u/KevinFFF)\
**Post date:** [April 25, 2024, 5:41am UTC](https://forums.developer.nvidia.com/t/adjusting-gpio-irq-affinity-in-gic/285999/8 "2024-04-25T05:41:46Z")

</div>

```auto
312: 315 0 0 0 0 0 gpio 105 Edge pps.-1

```

I’ve checked this with internal and confirm that affinity can only be set at the GIC level,  
All GPIOs are a single interrupt as far as the GIC is concerned.  
You can’t configure smp\_affinity for `gpio` since gpio interrupt is independent.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [June 4, 2024, 6:57am UTC](https://forums.developer.nvidia.com/t/adjusting-gpio-irq-affinity-in-gic/285999/10 "2024-06-04T06:57:41Z")

</div>

Closed on June 4, 2024, 6:57am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
