]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: stm32: dcmi: stop the dma transfer on overrun
authorAlain Volmat <alain.volmat@foss.st.com>
Tue, 6 Jan 2026 11:34:32 +0000 (12:34 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 11 Mar 2026 00:05:32 +0000 (01:05 +0100)
Ensure to stop the dma transfer whenever receiving a overrun
to avoid having a buffer partially filled with a frame and
partially with the next frame.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/platform/st/stm32/stm32-dcmi.c

index 0874974bbad4c57212de5f6e206165ce3e192efd..20f5b9ab6a1c664710912f5a9f27032e0aef2c65 100644 (file)
@@ -402,9 +402,21 @@ static irqreturn_t dcmi_irq_thread(int irq, void *arg)
        spin_lock_irq(&dcmi->irqlock);
 
        if (dcmi->misr & IT_OVR) {
+               /* Disable capture */
+               reg_clear(dcmi->regs, DCMI_CR, CR_CAPTURE);
+
                dcmi->overrun_count++;
+
                if (dcmi->overrun_count > OVERRUN_ERROR_THRESHOLD)
                        dcmi->errors_count++;
+
+               spin_unlock_irq(&dcmi->irqlock);
+               dmaengine_terminate_sync(dcmi->dma_chan);
+
+               if (dcmi_restart_capture(dcmi))
+                       dev_err(dcmi->dev, "%s: Cannot restart capture\n", __func__);
+
+               return IRQ_HANDLED;
        }
        if (dcmi->misr & IT_ERR)
                dcmi->errors_count++;