Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dmaengine: altera-msgdma: Correctly handle descriptor callbacks

DMA clients can provide one of two types of callbacks. For this reason
dmaengine drivers should not directly invoke `callback`, but always use
dmaengine_desc_callback_invoke(). This makes sure that both types of
callbacks are handled correctly.

The altera-msgdma driver currently doesn't do this and only handles the
`callback` type callback. If the client used the `callback_result` type
callback it will not be called.

Fix this by switching to `dmaengine_desc_callback_valid()` and
`dmaengine_desc_callback_invoke()`.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20211025075428.2094-1-lars@metafoo.de
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Lars-Peter Clausen and committed by
Vinod Koul
a34da7ef d191a9ab

+4 -6
+4 -6
drivers/dma/altera-msgdma.c
··· 585 585 struct msgdma_sw_desc *desc, *next; 586 586 587 587 list_for_each_entry_safe(desc, next, &mdev->done_list, node) { 588 - dma_async_tx_callback callback; 589 - void *callback_param; 588 + struct dmaengine_desc_callback cb; 590 589 591 590 list_del(&desc->node); 592 591 593 - callback = desc->async_tx.callback; 594 - callback_param = desc->async_tx.callback_param; 595 - if (callback) { 592 + dmaengine_desc_get_callback(&desc->async_tx, &cb); 593 + if (dmaengine_desc_callback_valid(&cb)) { 596 594 spin_unlock(&mdev->lock); 597 - callback(callback_param); 595 + dmaengine_desc_callback_invoke(&cb, NULL); 598 596 spin_lock(&mdev->lock); 599 597 } 600 598