Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

how to stop losing GPIO interrupts due to bursty processes

Featured Replies

Dear all,


I'm frequently losing GPIO interrupts on various boards, which seem to be caused by bursty processes.

 

When I shield the cores that have those interrupts according to /proc/interrupts with e..g. "cset shield --cpu=0,1" , way less interrupts are lost (e.g. for 4kHz interrupts one in hours instead of once per minute). Most of these (ADC) interrupts are handled by my own kernel module, but couldn't find how to restrict them to e.g. CPU0, and they are not movable using /proc/irq/*/smp_affinity.


 

HomeCT1:~:% grep ads /proc/interrupts
 66:     166559          0          0          0  sunxi_pio_edge   1 Edge      ads131a04
162:        273  152692648   13858531         17  ads131a04-dev0     Edge      ads131a04_consumer0


HomeCT1:~:% cat /proc/irq/162/smp_affinity
f

 

I noticed that on allwinner (opi0, nanopi neo+2), the ADC interrupts are on different CPU cores. On the neo3 they always seem to go to the 1st CPU core.

 

Is there any way to force the interrupts to 1st core on the allwinner as well (e.g. in kernel module c-code or via devicetree)? This would make it easier to shield the first core and reduce the lost interrupts.

Or is there another way to give more priority to the GPIO interrupts? Making the kernel thread realtime with chrt is apparently not enough.


 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND

 2407 root      rt   0       0      0      0 S   4.6   0.0 116:06.38 [irq/162-ads131a]  

 

Kind regards,

Dennis

  • Author

Hi,

I experimented some further and set /proc/irq/default_smp_affinity to 1 for the first core, and it looks good on paper, but in practice most interrupts still go to the second core.

 

echo 1 > /proc/irq/default_smp_affinity

# dynamically load ADC kernel driver

HomeCT2:~:% cat /proc/irq/162/smp_affinity
1
HomeCT2:~:% cat /proc/irq/162/effective_affinity
0
HomeCT2:~:% grep ads /proc/interrupts 
 66:       1397          0          0          0  sunxi_pio_edge   1 Edge      ads131a04
162:        557    1394461         27          0  ads131a04-dev0     Edge      ads131a04_consumer0

 

  • Author

I tried to override the interrupt affinity using a devicetree overlay, but also this seems to be ignored on sunxi. Anybody knows why?

Is the affinity simply not implemented by sunxi?

 

Below is the overlay to change the interrupt affinity. Devicetree before modification shows interrupt-affinity=<&cpu0>,<&cpu1>,<&cpu2>,<&cpu3>;

 

/dts-v1/;
/plugin/;
/ {
        compatible = "allwinner,sun8i-h3","allwinner,sun50i-h5","friendlyarm,nanopi-neo2";

        fragment@1 {
                target-path = "/pmu";

                __overlay__ {
                        interrupt-affinity = <&cpu0>;
                };
        };
};

 

After boot only using cpu0 is reflected in the runtime devicetree on opi0:
 

$ /lib/modules/5.10.12-sunxi/build/scripts/dtc/dtc -I fs /sys/firmware/devicetree/base|less

        pmu {
                compatible = "arm,cortex-a7-pmu";
                interrupts = <0x00 0x78 0x04 0x00 0x79 0x04 0x00 0x7a 0x04 0x00 0x7b 0x04>;
                interrupt-affinity = <0x30>;
        };
        cpus {
                cpu@0 {
                        compatible = "arm,cortex-a7";
                        phandle = <0x30>;
                        ...
                };
                ...
        };

 

Here is the /proc/interrupt table again:

HomeCT2:~:% grep ads /proc/interrupts 
 66:       1043          0          0          0  sunxi_pio_edge   1 Edge      ads131a04
162:         68        255    1040571          1  ads131a04-dev0     Edge      ads131a04_consumer0

So the affinity has been changed but seems to be ignored.

 

p.s. Sorry for talking to myself;-)

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.