Skip to content

Commit ba24236

Browse files
ambarusvinodkoul
authored andcommitted
dmaengine: at_hdmac: Fix descriptor handling when issuing it to hardware
As it was before, the descriptor was issued to the hardware without adding it to the active (issued) list. This could result in a completion of other descriptor, or/and in the descriptor never being completed. Fixes: dc78baa ("dmaengine: at_hdmac: new driver for the Atmel AHB DMA Controller") Reported-by: Peter Rosin <peda@axentia.se> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/lkml/13c6c9a2-6db5-c3bf-349b-4c127ad3496a@axentia.se/ Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Link: https://lore.kernel.org/r/20221025090306.297886-1-tudor.ambarus@microchip.com Link: https://lore.kernel.org/r/20221025090306.297886-12-tudor.ambarus@microchip.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 03ed9ba commit ba24236

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

drivers/dma/at_hdmac.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,11 @@ static void atc_advance_work(struct at_dma_chan *atchan)
510510

511511
/* advance work */
512512
spin_lock_irqsave(&atchan->lock, flags);
513-
if (!list_empty(&atchan->active_list))
514-
atc_dostart(atchan, atc_first_active(atchan));
513+
if (!list_empty(&atchan->active_list)) {
514+
desc = atc_first_queued(atchan);
515+
list_move_tail(&desc->desc_node, &atchan->active_list);
516+
atc_dostart(atchan, desc);
517+
}
515518
spin_unlock_irqrestore(&atchan->lock, flags);
516519
}
517520

@@ -523,6 +526,7 @@ static void atc_advance_work(struct at_dma_chan *atchan)
523526
static void atc_handle_error(struct at_dma_chan *atchan)
524527
{
525528
struct at_desc *bad_desc;
529+
struct at_desc *desc;
526530
struct at_desc *child;
527531
unsigned long flags;
528532

@@ -540,8 +544,11 @@ static void atc_handle_error(struct at_dma_chan *atchan)
540544
list_splice_init(&atchan->queue, atchan->active_list.prev);
541545

542546
/* Try to restart the controller */
543-
if (!list_empty(&atchan->active_list))
544-
atc_dostart(atchan, atc_first_active(atchan));
547+
if (!list_empty(&atchan->active_list)) {
548+
desc = atc_first_queued(atchan);
549+
list_move_tail(&desc->desc_node, &atchan->active_list);
550+
atc_dostart(atchan, desc);
551+
}
545552

546553
/*
547554
* KERN_CRITICAL may seem harsh, but since this only happens

0 commit comments

Comments
 (0)