The concept of completion
This section will briefly describe completion and the necessary part of its API that the DMA transfer uses. For a complete description, please feel free to have a look at the kernel documentation at Documentation/scheduler/completion.txt
. A common pattern in kernel programming involves initiating some activity outside the current thread, then waiting for that activity to complete.
Completion is a good alternative to sleep()
when waiting for a buffer to be used. It is suitable for sensing data, which is exactly what the DMA callback does.
Working with completion requires this header:
<linux/completion.h>
Like other kernel facility data structures, one can create instances of the struct completion
structure either statically or dynamically:
- Static declaration and initialization look like this:
DECLARE_COMPLETION(my_comp);
- Dynamic allocation looks like this:
struct completion my_comp; init_completion(&my_comp);
When the driver begins some work whose completion...