how to stop losing GPIO interrupts due to bursty processes


Recommended Posts

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

Link to post
Share on other sites
Armbian is a community driven open source project. Do you like to contribute your code?

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

 

Link to post
Share on other sites

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

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...