I'm trying to write a linux kernel module which waits for a hardware trigger and then moves some data to an external memory via DMA.
I've got the hardware trigger recognized in my kernel module, now I need to make it perform the DMA. The problem is that the function that performs the DMA involves a point where it sleeps until the DMA is completed. This isn't allowed in interrupts, so I can't call the function directly in my interrupt service routine.
Is there a way I can set some kind of signal so that my kernel module knows to call the DMA function the next chance it gets, but doesn't do so in the interrupt context?
Would suggest you to use bottom halves by registering a callback. Linux works this way, top half/bottom half.
top half services the interrupt and clear interrupt control register, and queuing the registered callback that is your bottom half, it can sleep.
Would suggest you have a read about it in a book by robert love. it is very good place to start.
Check any i2c client driver on linuxkernel org source for reference.
register your callback for DMA post data processing there.
this is just gist on how bottom halves can help you with developing drivers. hope it can be of any help to you.