Skip to content

Commit d03a19b

Browse files
neosys007miquelraynal
authored andcommitted
mtd: onenand: samsung: report DMA completion timeouts
The S5PC110 OneNAND DMA helpers have bounded waits for transfer completion. The polling helper falls out of its timeout loop and returns success, and the IRQ helper ignores wait_for_completion_timeout(). Return -ETIMEDOUT when the DMA transfer-done bit or completion does not arrive before the timeout so callers can treat the buffer transfer as failed. Fixes: e23abf4 ("mtd: OneNAND: S5PC110: Implement DMA interrupt method") Cc: stable@vger.kernel.org Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
1 parent f9a13e0 commit d03a19b

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

drivers/mtd/nand/onenand/onenand_samsung.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,9 @@ static int s5pc110_dma_poll(dma_addr_t dst, dma_addr_t src, size_t count, int di
554554
} while (!(status & S5PC110_DMA_TRANS_STATUS_TD) &&
555555
time_before(jiffies, timeout));
556556

557+
if (!(status & S5PC110_DMA_TRANS_STATUS_TD))
558+
return -ETIMEDOUT;
559+
557560
writel(S5PC110_DMA_TRANS_CMD_TDC, base + S5PC110_DMA_TRANS_CMD);
558561

559562
return 0;
@@ -608,7 +611,9 @@ static int s5pc110_dma_irq(dma_addr_t dst, dma_addr_t src, size_t count, int dir
608611

609612
writel(S5PC110_DMA_TRANS_CMD_TR, base + S5PC110_DMA_TRANS_CMD);
610613

611-
wait_for_completion_timeout(&onenand->complete, msecs_to_jiffies(20));
614+
if (!wait_for_completion_timeout(&onenand->complete,
615+
msecs_to_jiffies(20)))
616+
return -ETIMEDOUT;
612617

613618
return 0;
614619
}

0 commit comments

Comments
 (0)