RE: pcm|dmaengine|imx-sdma race condition on i.MX6

From: Benjamin Bara - SKIDATA
Date: Wed Aug 19 2020 - 10:25:49 EST


> -----Original Message-----
> From: Lars-Peter Clausen <lars@xxxxxxxxxx>
> Sent: Mittwoch, 19. August 2020 13:08
> I think this might be an sdma specific problem after all.
> dmaengine_terminate_async() will issue a request to stop the DMA. But it
> is still safe to issue the next transfer, even without calling
> dmaengine_synchronize(). The DMA should start the new transfer at its
> earliest convenience in that case.
>
> dmaegine_synchronize() is so that the consumer has a guarantee that the
> DMA is finished using the resources (e.g. the memory buffers) associated
> with the DMA transfer so it can safely free them.

Thank you for the clarifications!

> I don't know how feasible this is to implement in the SDMA dmaengine
> driver. But I think what is should do is to have some flag to indicate
> if a terminate is in progress. If a new transfer is issued while
> terminate is in progress the transfer should go on a list. Once
> terminate finishes it should check the list and start the transfer if
> there are any on the list.

IMHO that's nearly what Robin's patches does, so this should be sufficient:
Putting the descriptors to free in an extra termination list and ensuring
that a new transfer is handled after the last termination is done.


@Robin:
Is it possible to tag the commits for the stable-tree
Cc: stable@xxxxxxxxxxxxxxx?

Best regards and thank you all!
Benjamin
Richard