msperl / linux-rpi

Other
22 stars 26 forks source link

Interrupt handling #16

Open urimashi opened 4 years ago

urimashi commented 4 years ago

Hardware: NXP SOC i.MX 8M Min OS: Linux kernel 4.14.98 + mcp25xxfd-V8.2

The following error messages are generated during a trasnsmission attempt: [ 43.425070] BUG: using this_cpu_add() in preemptible [00000000] code: irq/70- mcp25xxf/3073 [ 43.435474] caller is this_cpu_preempt_check+0x18/0x20 [ 43.440821] CPU: 3 PID: 3073 Comm: irq/70-mcp25xxf Not tainted 4.14.98-06024-gefb8424cb055-dirty #19 [ 43.449954] Hardware name: CompuLab SB-UCM-iMX8 board (DT) [ 43.455441] Call trace: [ 43.457897] [] dump_backtrace+0x0/0x3c0 [ 43.463298] [] show_stack+0x14/0x20 [ 43.468354] [] dump_stack+0x8c/0xac [ 43.473407] [] check_preemption_disabled+0xf8/0x100 [ 43.479850] [] this_cpu_preempt_check+0x18/0x20 [ 43.486120] [] __netif_receive_skb_core+0x98/0x9f8 [ 43.492476] [] netif_receive_skb+0x14/0x60 [ 43.498312] [] netif_receive_skb_internal+0x28/0x118 [ 43.504841] [] netif_receive_skb+0x1c/0xe0 [ 43.510523] [] mcp25xxfd_can_int+0x53c/0x9c0 [mcp25xxfd] [ 43.517402] [] irq_thread_fn+0x28/0x88 [ 43.522716] [] irq_thread+0x108/0x180 [ 43.527944] [] kthread+0x130/0x138 [ 43.532910] [] ret_from_fork+0x10/0x18 [ 43.538556] mcp25xxfd spi0.0 can0: CAN Bus error experienced [ 43.544283] BUG: using this_cpu_add() in preemptible [00000000] code: irq/70-mcp25xxf/3073 [ 43.552757] caller is this_cpu_preempt_check+0x18/0x20 [ 43.558097] CPU: 3 PID: 3073 Comm: irq/70-mcp25xxf Not tainted 4.14.98-06024-gefb8424cb055-dirty #19 [ 43.567230] Hardware name: CompuLab SB-UCM-iMX8 board (DT) [ 43.572716] Call trace: [ 43.575172] [] dump_backtrace+0x0/0x3c0 [ 43.580573] [] show_stack+0x14/0x20 [ 43.585628] [] dump_stack+0x8c/0xac [ 43.590682] [] check_preemption_disabled+0xf8/0x100 [ 43.597124] [] this_cpu_preempt_check+0x18/0x20 [ 43.603394] [] __netif_receive_skb_core+0x98/0x9f8 [ 43.609749] [] netif_receive_skb+0x14/0x60 [ 43.615585] [] netif_receive_skb_internal+0x28/0x118 [ 43.622114] [] netif_receive_skb+0x1c/0xe0 [ 43.627796] [] mcp25xxfd_can_int+0x53c/0x9c0 [mcp25xxfd] [ 43.634674] [] irq_thread_fn+0x28/0x88 [ 43.639988] [] irq_thread+0x108/0x180 [ 43.645216] [] kthread+0x130/0x138 [ 43.650183] [] ret_from_fork+0x10/0x18 [ 525.908095] audit: type=1006 audit(1581600601.680:3): pid=3079 uid=0 old-auid=4294967295 auid=0 tty=(none) old-ses=4294967295 ses=2 res=1

Device tree configuration: can0: can@0 { compatible = "microchip,mcp2517fd"; reg = <0>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_can0>; interrupt-parent = <&gpio1>; interrupts = <8 IRQ_TYPE_EDGE_FALLING>; spi-max-frequency = <20000000>; clocks = <&clk40m>;\ };

CAN bus port configuration: ip link set can0 type can bitrate 500000

Please let me know if additional information is needed.

Thanks, Uri

marckleinebudde commented 4 years ago

Hey @urimashi,

feel free to test my rewrite of the mcp25xxfd driver. It's available at:

https://github.com/marckleinebudde/linux/tree/v4.19-rpi/mcp25xxfd-20200211-17

tayear commented 2 years ago

@marckleinebudde Marc, sorry to disturb you, I got the same issue BUG: using __this_cpu_add() in preemptible [00000000] code: irq/70- mcp25xxf/3073.

But when I port your v4.19-rpi/mcp25xxfd-20200429-46 brach, I got some problems such as:

drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c:2462:41: error: 'const struct spi_device' has no member named 'controller' const struct spi_controller *ctlr = spi->controller; ^ drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c:2464:10: error: dereferencing pointer to incomplete type 'const struct spi_controller' if (ctlr->flags & SPI_CONTROLLER_HALF_DUPLEX) ^ drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c:2464:20: error: 'SPI_CONTROLLER_HALF_DUPLEX' undeclared (first use in this function) if (ctlr->flags & SPI_CONTROLLER_HALF_DUPLEX)

My kernel version is 4.9.190.

According to this blog: https://www.spinics.net/lists/linux-can/msg01938.html , you have a patch which can solve this issue. Can you show me that?

Many thanks

marckleinebudde commented 2 years ago

Hey @tayear,

if you are on a raspi, please use the latest Raspi OS, it contains the mcp251xfd driver. Otherwise upgrade to a recent kernel. v5.10 is the oldest one that includes the mcp251xfd driver.

If you want to use any kernel older than v5.10, some, probably a lot of patches need to be back ported, you are missing for example: https://github.com/marckleinebudde/linux/commit/8caab75fd2c2a92667cbb1cd315720bede3feaa9

Note: You have stated porting an old outdated driver, that never got mainline. It obviously has bugs. Please don't use that. Use the latest mainline kernel (v5.16) or a recent raspi OS.

tayear commented 2 years ago

@marckleinebudde Thank you for your reply. My board is not raspi, and the manufacturer only provides this old version (4.9.170) kernel. If I update the kernel by myself, I'm afraid I cannot make it work.

It seems there are only two choices for me: 1, back port spi driver, including patches marckleinebudde/linux@8caab75 you mentioned. 2, modify mcp25xxfd driver by referencing a recent one.

marckleinebudde commented 2 years ago

Hey @tayear,

which SoC are you using? v4.9.170 is really, really old.

The mcp251xfd driver will not work out of the box on such old kernels and the old driver you picked is buggy. So you will have to do both, port SPI changes, a recent mcp251xfd driver and some CAN framework changes to your old kernel.

tayear commented 2 years ago

Hi @marckleinebudde

I'm using AllWinner T507. Well... I will contact the angent to check whether a newer kernel is available. If not, can you give me some hints on how to make it? Each of these three parts seems hard for me...(lol).

marckleinebudde commented 2 years ago

Hello @tayear,

You start with a the mcp251xfd from mainline and back port all needed CAN and SPI patches, or you contact someone doing this professionally.

tayear commented 2 years ago

Hi, @marckleinebudde okay. Thank you very much.