Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linux kernel module dies after 100000 interrupts

I'm working on a kernel module for the 2.6.39 kernel. (I know this is out of date, but it's what came with my evaluation board and I wanted to get this working before moving to the 3.x series.)

My module is very simple at the moment. It listens for a 200us pulse on a GPIO pin, then increments a counter which resets it every 25089 iterations. (25089 is the size of a buffer to be used later.) Strangely enough though, my module dies after exactly 100000 interrupts every time I use it, and I'm really at a loss. I looked at changing the kernel jiffy frequency, but that seems like it's unrelated. I also tried using a tickless kernel, and that doesn't seem to have an effect either. I can't find much of anything on google about this problem either. Has anyone else seen this issue?

I'm building for an Atmel AT91 processor if that is important. I'll list my crash message below.

root@at91:~# irq 56: nobody cared (try booting with the "irqpoll" option)
[<c0036804>] (unwind_backtrace+0x0/0xec) from [<c006eca4>] (__report_bad_irq+0x34/0xa0)
[<c006eca4>] (__report_bad_irq+0x34/0xa0) from [<c006eed0>] (note_interrupt+0x1c0/0x22c)
[<c006eed0>] (note_interrupt+0x1c0/0x22c) from [<c006d904>] (handle_irq_event_percpu+0x168/0x19c)
[<c006d904>] (handle_irq_event_percpu+0x168/0x19c) from [<c006d960>] (handle_irq_event+0x28/0x38)
[<c006d960>] (handle_irq_event+0x28/0x38) from [<c003ace0>] (gpio_irq_handler+0x74/0x98)
[<c003ace0>] (gpio_irq_handler+0x74/0x98) from [<c002b078>] (asm_do_IRQ+0x78/0xac)
[<c002b078>] (asm_do_IRQ+0x78/0xac) from [<c00313d4>] (__irq_svc+0x34/0x60)
Exception stack(0xc04b1f70 to 0xc04b1fb8)
1f60: 00000000 0005317f 0005217f 60000013
1f80: c04b0000 c04b61cc c04b5ffc c04e1224 20000000 41069265 20025cbc 00000000
1fa0: 600000d3 c04b1fb8 c0032cc8 c0032cd4 60000013 ffffffff
[<c00313d4>] (__irq_svc+0x34/0x60) from [<c0032cd4>] (default_idle+0x38/0x40)
[<c0032cd4>] (default_idle+0x38/0x40) from [<c0032af8>] (cpu_idle+0x70/0xc8)
[<c0032af8>] (cpu_idle+0x70/0xc8) from [<c00089c0>] (start_kernel+0x284/0x2e4)
[<c00089c0>] (start_kernel+0x284/0x2e4) from [<20008038>] (0x20008038)
handlers:
[<c01eb660>] (grab_spi_data+0x0/0x6c)
Disabling IRQ #56


root@at91:~# cat /proc/interrupts 
       CPU0       
1:       1387       AIC  at91_tick, at91_rtc, ttyS0
12:         39       AIC  atmel_mci.0
13:          0       AIC  atmel_spi.0
14:          0       AIC  atmel_spi.1
17:       1804       AIC  tc_clkevt
20:       7520       AIC  at_hdmac
21:          0       AIC  at_hdmac
22:          1       AIC  ehci_hcd:usb1, ohci_hcd:usb2
23:          0       AIC  atmel_usba_udc
24:        136       AIC  eth0
26:          0       AIC  atmel_mci.1
56:     100000      GPIO  quicklogic_ready
80:          0      GPIO  atmel_usba_udc
142:          0      GPIO  mmc-detect
143:          1      GPIO  mmc-detect
Err:          0

My interrupt handler is called grab_spi_data, which you can see is that the bottom of the backtrace, and I'm watching IRQ 56. I am really stumped.

like image 808
Maxwell Bottiger Avatar asked Sep 30 '13 18:09

Maxwell Bottiger


1 Answers

Looks like you're not handling the IRQs.
Linux gets upset after 100,000 times - See the comment above __report_bad_irq and find this magic number.

Your interrupt handler probably never returns IRQ_HANDLED, which is what it should do after handling the interrupt.

like image 167
ugoren Avatar answered Nov 07 '22 23:11

ugoren