> > Hey Markus, > > On 03.12.2021 15:38:38, Markus Mirevik wrote: > > I have a problem I cant figure out underlaying cause to and maybe you > > can help me. > > Let's move the discussion to the linux-can mailing list. > (linux-can@xxxxxxxxxxxxxxx). Sure.. buy replying to that address I hope 😊 > > > I have custom board based on Beaglebone black. > > > > The CPU is a AM3358BZCZ100. > > Connected to this is two mcp2518fd on one SPI line. > > I'm currently running hardknott yocto build with kernel 5.10.79-yocto-tiny. > > > > The initialization of the mcp is fine: > > [ 4.020952] mcp251xfd spi1.0 can0: MCP2518FD rev0.0 (+RX_INT - > MAB_NO_WARN +CRC_REG +CRC_RX +CRC_TX +ECC -HD c:40.00MHz > m:20.00MHz r:17.00MHz e:0.00MHz) successfully initialized. > > [ 4.046274] mcp251xfd spi1.1 can1: MCP2518FD rev0.0 (+RX_INT - > MAB_NO_WARN +CRC_REG +CRC_RX +CRC_TX +ECC -HD c:40.00MHz > m:20.00MHz r:17.00MHz e:0.00MHz) successfully initialized. > > That looks good so far. Do you have connected the INT1 pin of the > mcp2518fd to a GPIO of your board? Yes I have. > > > Right now I have 3 other units talking on the canbus. Sending 3 > > messages every 10ms each. And that works great. > > > > But now to the problem. Every 5 minutes or so. (Not consistent, > > sometimes earlier sometimes later ). I get a spike in CPU usage. > > > > It goes to 50% for sometimes a few seconds sometime a bit longer. In > > between the peaks the CPU is idling around 2,5%. > > - Is this while there is communication on the CAN bus? > - Can you compare the output of: > > | candump any,0:0,#FFFFFFFF -extA > > during this high load against output during normal operation. > Looks the same, but its a lot of messages. I compared 3 different seconds and both receive 594 or 596 messages / second . > - Can you have a look at the IRQs and soft IRQs of your system during > high load and during normal operation: > | watch -n1 cat /proc/interrupts /proc/softirqs Looks sort of the same to me the same to me, With 53% load Stop Start Sum /s Time: 18:17:25 18:16:36 49 1 HI: 2 2 0,00 0,00 TIMER: 79941 79244 697,00 14,22 NET_TX: 1085 1075 10,00 0,20 NET_RX: 3131831 3103252 28579,00 583,24 BLOCK: 1224 1224 0,00 0,00 IRQ_POLL: 0 0 0,00 0,00 TASKLET: 1276 1276 0,00 0,00 SCHED: 0 0 0,00 0,00 HRTIMER: 0 0 0,00 0,00 RCU 173305 171765 1540,00 31,43 Normal 3% load Stop Start Diff /s Time: 18:21:24 18:20:35 49 1 HI: 2 2 0,00 0,00 TIMER: 83236 82552 684,00 13,96 NET_TX: 1133 1123 10,00 0,20 NET_RX: 3244121 3221392 22729,00 463,86 BLOCK: 1224 1224 0,00 0,00 IRQ_POLL: 0 0 0,00 0,00 TASKLET: 1276 1276 0,00 0,00 SCHED: 0 0 0,00 0,00 HRTIMER: 0 0 0,00 0,00 RCU 180684 179154 1530,00 31,22 A bit more NET_RX.. might that be an indicator? > > > Neither top or htop shows what process is using the CPU. > > (irq/64-spi1.1 is stable around 14%) > > Please use htop, make sure you don't hide the kernel threads (Setup -> > Display options -> Hide kernel threads), display detailed CPU usage (Setup -> > Meters -> CPU [Text]). What kind of CPU usage ("sy", "ni", "hi", "si",...) do > you have during high load? Kernel threads is showing but I don’t seem to have the CPU[Text] option.. > > > This only happens when I'm receiving on the can bus. If I bring can1 > > down it disappears right away. If I don't have anything connected it > > doesn't happened. > > OK, that answers my first question. :) > > > The communication works great, no errors, no dropped, nothing that looks > weird to me.. > > # ip -details -statistics link show can1 > > 6: can1: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP > mode DEFAULT group default qlen 10 > > link/can promiscuity 0 minmtu 0 maxmtu 0 > > can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0 > > bitrate 1000000 sample-point 0.750 > > tq 25 prop-seg 14 phase-seg1 15 phase-seg2 10 sjw 1 > > mcp251xfd: tseg1 2..256 tseg2 1..128 sjw 1..128 brp 1..256 brp-inc 1 > > mcp251xfd: dtseg1 1..32 dtseg2 1..16 dsjw 1..16 dbrp 1..256 dbrp-inc 1 > > clock 40000000 > > re-started bus-errors arbit-lost error-warn error-pass bus-off > > 0 0 0 0 0 0 numtxqueues 1 numrxqueues 1 > gso_max_size 65536 gso_max_segs 65535 > > RX: bytes packets errors dropped missed mcast > > 4298124 537270 0 0 0 0 > > TX: bytes packets errors dropped carrier collsns > > 3 3 0 0 0 0 > > > > > > I have tested everything I can think of but I am not closer to a > > answer to why this happens. Maybe you have some ideas? Or at least can > > point me in the right direction? > > - Can you check if removing "microchip,rx-int-gpios" from you DT brings > any difference? Yes, it does not effect the 50% burst episodes. But it seems to use a bit more CPU when idle without the RX-int. > - Can you send the complete mcp251xfd DT config snippet. > Yes, I can. #include <dt-bindings/gpio/gpio.h> #include <dt-bindings/interrupt-controller/irq.h> &am33xx_pinmux{ pinctrl_spi1_pins: pinctrl_spi1_pins { pinctrl-single,pins = < AM33XX_IOPAD(0x990, PIN_INPUT | MUX_MODE3) /* (A13) mcasp0_aclkx.spi1_sclk */ AM33XX_IOPAD(0x994, PIN_INPUT | MUX_MODE3) /* (B13) mcasp0_fsx.spi1_d0 */ AM33XX_IOPAD(0x998, PIN_INPUT | MUX_MODE3) /* (D12) mcasp0_axr0.spi1_d1 */ AM33XX_IOPAD(0x96c, PIN_OUTPUT_PULLUP | MUX_MODE5) /* (E17) uart0_rtsn.spi1_cs0 CleANopen LEFT*/ AM33XX_IOPAD(0x9b0, PIN_OUTPUT_PULLUP | MUX_MODE4) /* (A15) xdma_event_intr0.spi1_cs1 SAWM CAN RIGHT*/ >; }; can0_int_pins: can0_int_pins { pinctrl-single,pins = < /*CleANopen*/ AM33XX_IOPAD(0x89c, PIN_INPUT | MUX_MODE7) /* (T6) gpmc_be0n_cle.gpio2[5] nINT */ AM33XX_IOPAD(0x968, PIN_INPUT | MUX_MODE7) /* (E18) uart0_ctsn.gpio1[8] nINT1 */ >; }; can1_int_pins: can1_int_pins { pinctrl-single,pins = < /*SAWM CAN*/ AM33XX_IOPAD(0x820, PIN_INPUT | MUX_MODE7) /* (U10) gpmc_ad8.gpio0[22] nINT */ AM33XX_IOPAD(0x8c8, PIN_INPUT | MUX_MODE7) /* (U3) lcd_data10.gpio2[16] nINT1 */ AM33XX_IOPAD(0x8cc, PIN_INPUT | MUX_MODE7) /* (U4) lcd_data11.gpio2[17] nINT0 NOT USED */ >; }; }; /{ /* external 40M oscillator of mcp2518fd on SPI1.0 */ mcp2518fd_can0_osc: mcp2518fd_can0_osc { compatible = "fixed-clock"; #clock-cells = <0>; clock-frequency = <40000000>; }; }; /{ /* external 40M oscillator of mcp2518fd on SPI1.1 */ mcp2518fd_can1_osc: mcp2518fd_can1_osc { compatible = "fixed-clock"; #clock-cells = <0>; clock-frequency = <40000000>; }; }; /* the spi config of the can-controller itself binding everything together */ &spi1{ #address-cells = <1>; #size-cells = <0>; status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_spi1_pins>; /*CleANopen*/ can@0 { compatible = "microchip,mcp2518fd"; reg = <0>; clocks = <&mcp2518fd_can0_osc>; pinctrl-names = "default"; pinctrl-0 = <&can0_int_pins>; spi-max-frequency = <20000000>; interrupts-extended = <&gpio2 5 IRQ_TYPE_LEVEL_LOW>; microchip,rx-int-gpios = <&gpio1 8 GPIO_ACTIVE_LOW>; }; can@1 { compatible = "microchip,mcp2518fd"; reg = <1>; clocks = <&mcp2518fd_can1_osc>; pinctrl-names = "default"; pinctrl-0 = <&can1_int_pins>; spi-max-frequency = <20000000>; interrupts-extended = <&gpio0 22 IRQ_TYPE_LEVEL_LOW>; microchip,rx-int-gpios = <&gpio2 16 GPIO_ACTIVE_LOW>; }; }; Thank you for your time! Markus > regards, > Marc > > -- > Pengutronix e.K. | Marc Kleine-Budde | > Embedded Linux | https://www.pengutronix.de | > Vertretung West/Dortmund | Phone: +49-231-2826-924 | > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |