Any suggestions for troubleshooting missed interrupts?

Hey guys, a friend of mine is currently working on AT91SAM9M10-EKES. The Code registers IRQ for 2 GPIO pins (PA20 & PA21) but only receives 22/26 expected interrupts (random). Could there be an issue in this IRQ handling code?
static irqreturn_t wiegand_interrupt(int irq, void *dev_id){
atomic_inc(&counter);
printk(KERN_WARNING "IRQ received, counting... %d\n", atomic_read(&counter));
return 0;
}

irq1 = gpio_to_irq(AT91_PIN_PA21);
if (irq1 < 0) {
err = irq1;
printk("Unable to get irq number for GPIO %d, error %d\n", AT91_PIN_PA21, err);
goto fail;
}

err = request_irq(irq1, wiegand_interrupt, 0, "wiegand", NULL);

irq2 = gpio_to_irq(AT91_PIN_PA20);
if (irq2 < 0) {
err = irq2;
printk("Unable to get irq number for GPIO %d, error %d\n", AT91_PIN_PA21, err);
goto fail;
}

err = request_irq(irq2, wiegand_interrupt, 0, "wiegand", NULL);
static irqreturn_t wiegand_interrupt(int irq, void *dev_id){
atomic_inc(&counter);
printk(KERN_WARNING "IRQ received, counting... %d\n", atomic_read(&counter));
return 0;
}

irq1 = gpio_to_irq(AT91_PIN_PA21);
if (irq1 < 0) {
err = irq1;
printk("Unable to get irq number for GPIO %d, error %d\n", AT91_PIN_PA21, err);
goto fail;
}

err = request_irq(irq1, wiegand_interrupt, 0, "wiegand", NULL);

irq2 = gpio_to_irq(AT91_PIN_PA20);
if (irq2 < 0) {
err = irq2;
printk("Unable to get irq number for GPIO %d, error %d\n", AT91_PIN_PA21, err);
goto fail;
}

err = request_irq(irq2, wiegand_interrupt, 0, "wiegand", NULL);
Any suggestions for troubleshooting missed interrupts? @Middleware & OS
Solution:
Yup, I had to define separate interrupt handler functions for each IRQ line. I also found this stuff helpful too https://linux-kernel-labs.github.io/refs/heads/master/labs/interrupts.html...
Jump to solution
4 Replies
Dtynin
Dtynin•6mo ago
@Sterling From what I see so far 🫠.. I don't think you should be requesting the same interrupt handler wiegand_interrupt for both IRQ lines PA20 and PA21. Interrupt handlers are to be unique for each IRQ line
Sterling
Sterling•6mo ago
So could this be the reason for the missing interrupts ? 🤔 @Dtynin
Marvee Amasi
Marvee Amasi•6mo ago
Yh , @Sterling , where you able to fix it?
Solution
Sterling
Sterling•6mo ago
Yup, I had to define separate interrupt handler functions for each IRQ line. I also found this stuff helpful too https://linux-kernel-labs.github.io/refs/heads/master/labs/interrupts.html
Want results from more Discord servers?
Add your server