[media] marvell-cam: Increase the DMA shutdown timeout
authorJonathan Corbet <corbet@lwn.net>
Fri, 16 Mar 2012 22:14:52 +0000 (19:14 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 20 Mar 2012 01:15:51 +0000 (22:15 -0300)
Experience shows that, on the Armada platform, it can take as much as 120ms
for the DMA engine to actually shut down after it has been told to.  So a
40ms timeout is not adequate; use 150ms instead.  Also make sure we don't
leave the DMA_ACTIVE flag set once things are down.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/marvell-ccic/mcam-core.c

index b261182467636e85baab6b5ce88bce595d4a227b..050724f8d3e68e31efbf4baf2faf9f3234f2fe55 100644 (file)
@@ -742,7 +742,14 @@ static void mcam_ctlr_stop_dma(struct mcam_camera *cam)
        mcam_ctlr_stop(cam);
        cam->state = S_IDLE;
        spin_unlock_irqrestore(&cam->dev_lock, flags);
-       msleep(40);
+       /*
+        * This is a brutally long sleep, but experience shows that
+        * it can take the controller a while to get the message that
+        * it needs to stop grabbing frames.  In particular, we can
+        * sometimes (on mmp) get a frame at the end WITHOUT the
+        * start-of-frame indication.
+        */
+       msleep(150);
        if (test_bit(CF_DMA_ACTIVE, &cam->flags))
                cam_err(cam, "Timeout waiting for DMA to end\n");
                /* This would be bad news - what now? */
@@ -885,6 +892,7 @@ static int mcam_read_setup(struct mcam_camera *cam)
         * Turn it loose.
         */
        spin_lock_irqsave(&cam->dev_lock, flags);
+       clear_bit(CF_DMA_ACTIVE, &cam->flags);
        mcam_reset_buffers(cam);
        mcam_ctlr_irq_enable(cam);
        cam->state = S_STREAMING;