How to trigger a function in kernel module interru

2019-06-10 19:51发布

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?

1条回答
Evening l夕情丶
2楼-- · 2019-06-10 20:39

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.

https://doc.lagout.org/operating%20system%20/linux/Linux%20Kernel%20Development%2C%203rd%20Edition.pdf

Check any i2c client driver on linuxkernel org source for reference.

https://elixir.bootlin.com/linux/latest/source/drivers/misc/fsa9480.c#L394

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.

查看更多
登录 后发表回答