I'm guessing it's due to your printk getting printed on the serial console.
printk will probably take quite a time even though it is printing to log. Have you tried to measure the execution time of your ISR itself? There is probably an overhead.
In your case, the ISR is not exiting before it finishes the time measurement, printk everything. If the time taken by ISR itself is more than your pulse width, definitely you are going to miss some interrupts.
Instead of printk, think of some mechanism to pass that data to user space by way of messages, pipes etc. This will help reduce the ISR execution time.
In your user space program, printf is not part of the ISR.
One of the other causes for this kind of delays are mostly due to the Kernel Scheduling latency. But I think it will not be the case in your example.
How did you register the interrupt handler? I’ve been trying to get my quadrature encoder to work but I can’t get the interrupts to fire.
never mind solved it. Turns out in the new device trees, gpio1 is gpio controller 0, gpio2 is gpio controller 1, etc.
Hey, how did you get your quadrature interrupt working. Can you share the details with me it would be very helpful as I am also working on something like that and was having trouble in interrupt handling.