Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* [PATCH] fbdev: via: return an error when DMA copy times out
@ 2026-06-24 14:43 Pengpeng Hou
  2026-06-25 16:36 ` Helge Deller
  0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-06-24 14:43 UTC (permalink / raw)
  To: Florian Tobias Schandinat, Helge Deller
  Cc: Pengpeng Hou, linux-fbdev, dri-devel, linux-kernel

viafb_dma_copy_out_sg() logs a VIA DMA timeout when the DONE bit is not
set after the completion wait and grace delay, but still returns success
to the caller.

Preserve the existing cleanup sequence and return -ETIMEDOUT when the DMA
engine did not report completion.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
 drivers/video/fbdev/via/via-core.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/via/via-core.c b/drivers/video/fbdev/via/via-core.c
index a8d4a3e2c..ff691f83e 100644
--- a/drivers/video/fbdev/via/via-core.c
+++ b/drivers/video/fbdev/via/via-core.c
@@ -234,6 +234,7 @@ int viafb_dma_copy_out_sg(unsigned int offset, struct scatterlist *sg, int nsg)
 	dma_addr_t descr_handle;
 	unsigned long flags;
 	int i;
+	int ret = 0;
 	struct scatterlist *sgentry;
 	dma_addr_t nextdesc;
 
@@ -290,8 +291,10 @@ int viafb_dma_copy_out_sg(unsigned int offset, struct scatterlist *sg, int nsg)
 	 */
 	wait_for_completion_timeout(&viafb_dma_completion, 1);
 	msleep(1);
-	if ((viafb_mmio_read(VDMA_CSR0)&VDMA_C_DONE) == 0)
+	if ((viafb_mmio_read(VDMA_CSR0) & VDMA_C_DONE) == 0) {
 		printk(KERN_ERR "VIA DMA timeout!\n");
+		ret = -ETIMEDOUT;
+	}
 	/*
 	 * Clean up and we're done.
 	 */
@@ -301,7 +304,7 @@ int viafb_dma_copy_out_sg(unsigned int offset, struct scatterlist *sg, int nsg)
 	dma_free_coherent(&global_dev.pdev->dev,
 			nsg*sizeof(struct viafb_vx855_dma_descr), descrpages,
 			descr_handle);
-	return 0;
+	return ret;
 }
 EXPORT_SYMBOL_GPL(viafb_dma_copy_out_sg);
 #endif /* CONFIG_VIDEO_VIA_CAMERA */
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fbdev: via: return an error when DMA copy times out
  2026-06-24 14:43 [PATCH] fbdev: via: return an error when DMA copy times out Pengpeng Hou
@ 2026-06-25 16:36 ` Helge Deller
  0 siblings, 0 replies; 2+ messages in thread
From: Helge Deller @ 2026-06-25 16:36 UTC (permalink / raw)
  To: Pengpeng Hou, Florian Tobias Schandinat
  Cc: linux-fbdev, dri-devel, linux-kernel

On 6/24/26 16:43, Pengpeng Hou wrote:
> viafb_dma_copy_out_sg() logs a VIA DMA timeout when the DONE bit is not
> set after the completion wait and grace delay, but still returns success
> to the caller.
> 
> Preserve the existing cleanup sequence and return -ETIMEDOUT when the DMA
> engine did not report completion.
> 
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
>   drivers/video/fbdev/via/via-core.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)

Note that the return value isn't checked by the caller.
Nevertheless, it's a cleanup, so I applied it.

Thanks!
Helge

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-25 16:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-24 14:43 [PATCH] fbdev: via: return an error when DMA copy times out Pengpeng Hou
2026-06-25 16:36 ` Helge Deller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox