]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fbdev: viafb: return an error when DMA copy times out
authorPengpeng Hou <pengpeng@iscas.ac.cn>
Wed, 24 Jun 2026 14:43:13 +0000 (22:43 +0800)
committerHelge Deller <deller@gmx.de>
Thu, 25 Jun 2026 16:36:53 +0000 (18:36 +0200)
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>
Signed-off-by: Helge Deller <deller@gmx.de>
drivers/video/fbdev/via/via-core.c

index a8d4a3e2c65ede20781284cd4b24f2dfa344737f..1632a669941ab1a3aa81fb5b1d24aadf2f69e6be 100644 (file)
@@ -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 */