Can a Linux device driver wait for DMA to complete in device_remove ()?

I wrote a Linux device driver for a PCI device. This device performs DMA operations. A problem occurs when a program crashes when a DMA operation is performed.

In fact, when a function fails, the function device_remove()is called by the system (as if it were called close()). This function cleans up the memory areas used by the PCI device and correctly frees the allocated memory. I mean, it works correctly under normal circumstances.

But if DMA is started when it really finishes, it will not be able to perform DMA cleanup because it no longer has access to the device data that has been released. A simple solution would be to wait in the close () function. (This is my understanding, but maybe the last part of the DMA function is never executed?)

Is it good to shout that DMA actually ends in the function device_remove()(aka close()) of the device driver? Are there other means to solve this problem?

+3
source share
1 answer

Yes, the wait should work, but:

PCI, , remove() , DMA, / . , , close() , remove(). (: . ). , , : wait() on close(), fail() remove()

, , , .

+2

Source: https://habr.com/ru/post/1745078/


All Articles