omap3: ISP: Fix the failure of CCDC capture during suspend/resume
PATCH 1/2 omap3: ISP: Fix the failure of CCDC capture during suspend/resume
From: Abhilash K V <[email protected]>
While resuming from the "suspended to memory" state, occasionally CCDC fails to get enabled and thus fails to capture frames any more till the next suspend/resume is issued.
This is a race condition which happens only when a CCDC frame-completion ISR is pending even as ISP device's isp_pm_prepare() is getting called and only one buffer is left on the DMA queue.
The DMA queue buffers are thus depleted which results in its underrun.So when ISP resumes there are no buffers on the queue (as the application which can issue buffers is yet to resume) to start video capture.
This fix addresses this issue by dequeuing and enqueing the last buffer in isp_pm_prepare() after its DMA gets completed. Thus,when ISP resumes it always finds atleast one buffer on the DMA queue - this is true if application uses only 3 buffers.
--- drivers/media/video/omap3isp/isp.c | 20 +++++++++++ drivers/media/video/omap3isp/isp.h | 4 ++ drivers/media/video/omap3isp/ispvideo.c | 56 ++++++++++++++++++++++++++++++- drivers/media/video/omap3isp/ispvideo.h | 2 + 4 files changed, 81 insertions(+), 1 deletions(-)
drivers/media/video/omap3isp/isp.c +20 -0
@@ -1566,8 +1566,20 @@ static int isp_pm_prepare(struct device *dev) {struct isp_device *isp =dev_get_drvdata (dev);int reset; +int err =0 ; +struct isp_ccdc_device *ccdc = &isp->isp_ccdc; +struct isp_video *video = &ccdc->video_out; +struct isp_pipeline *pipe =to_isp_pipeline (&video->video.entity); +unsigned long flags;WARN_ON (mutex_is_locked (&isp->isp_mutex)); +spin_lock_irqsave (&pipe->lock, flags); + pipe->state |=ISP_PIPELINE_PREPARE_SUSPEND ; +spin_unlock_irqrestore (&pipe->lock, flags); + + err =isp_video_handle_buffer_starvation (video); +if (err <0 ) +return err;if (isp->ref_count ==0 )return 0 ;
@@ -1596,6 +1608,14 @@ static int isp_pm_suspend(struct device *dev)static int isp_pm_resume (struct device *dev) {struct isp_device *isp =dev_get_drvdata (dev); +struct isp_ccdc_device *ccdc = &isp->isp_ccdc; +struct isp_video *video = &ccdc->video_out; +struct isp_pipeline *pipe =to_isp_pipeline (&video->video.entity); +unsigned long flags; + +spin_lock_irqsave (&pipe->lock, flags); + pipe->state &= ~ISP_PIPELINE_PREPARE_SUSPEND ; +spin_unlock_irqrestore (&pipe->lock, flags);if (isp->ref_count ==0 )return 0 ;
drivers/media/video/omap3isp/isp.h +4 -0
@@ -349,6 +349,10 @@ int omap3isp_register_entities(struct platform_device *pdev, struct v4l2_device *v4l2_dev);void omap3isp_unregister_entities (struct platform_device *pdev); +#ifdef CONFIG_PM +int isp_video_handle_buffer_starvation (struct isp_video *video); +#endif +/* * isp_reg_readl - Read value of an OMAP3 ISP register * @dev: Device pointer specific to the OMAP3 ISP.
drivers/media/video/omap3isp/ispvideo.c +55 -1
74 lines not on this page · raw message
drivers/media/video/omap3isp/ispvideo.h +2 -0
@@ -84,6 +84,8 @@ enum isp_pipeline_state {ISP_PIPELINE_IDLE_OUTPUT =32 ,/* The pipeline is currently streaming. */ ISP_PIPELINE_STREAM =64 , +/* The pipeline is currently preparing to suspend. */ + ISP_PIPELINE_PREPARE_SUSPEND = 128, }; struct isp_pipeline {
Signature · 1 line
1.7.0.4
Hi,
Quoted 11 lines · On Wednesday 10 August 2011 16:03:12 Deepthy Ravi wrote:
From: Abhilash K V <[email protected]>
While resuming from the "suspended to memory" state, occasionally CCDC fails to get enabled and thus fails to capture frames any more till the next suspend/resume is issued.
This is a race condition which happens only when a CCDC frame-completion ISR is pending even as ISP device'sisp_pm_prepare()is getting called and only one buffer is left on the DMA queue.
The DMA queue buffers are thus depleted which results in
Quoted 8 lines
its underrun.So when ISP resumes there are no buffers on the queue (as the application which can issue buffers is yet to resume) to start video capture.
This fix addresses this issue by dequeuing and enqueing the last buffer inisp_pm_prepare()after its DMA gets completed. Thus,when ISP resumes it always finds atleast one buffer on the DMA queue - this is true if application uses only 3 buffers.
How is that problem specific to the CCDC ? Can't it be reproduce at the preview engine or resizer output as well ?
Signature · 3 lines
Regards, Laurent Pinchart
Quoted 23 lines · On Tue, Aug 30, 2011 Laurent Pinchart wrote:
Hi,
Quoted 11 lines · On Wednesday 10 August 2011 16:03:12 Deepthy Ravi wrote:
From: Abhilash K V <[email protected]>
While resuming from the "suspended to memory" state, occasionally CCDC fails to get enabled and thus fails to capture frames any more till the next suspend/resume is issued.
This is a race condition which happens only when a CCDC frame-completion ISR is pending even as ISP device'sisp_pm_prepare()is getting called and only one buffer is left on the DMA queue.
The DMA queue buffers are thus depleted which results inQuoted 8 lines
its underrun.So when ISP resumes there are no buffers on the queue (as the application which can issue buffers is yet to resume) to start video capture.
This fix addresses this issue by dequeuing and enqueing the last buffer inisp_pm_prepare()after its DMA gets completed. Thus,when ISP resumes it always finds atleast one buffer on the DMA queue - this is true if application uses only 3 buffers.
Quoted 2 lines
How is that problem specific to the CCDC ? Can't it be reproduce at the preview engine or resizer output as well ?
[Abhilash K V]Yes, I believe this issue would crop with preview and resizer too though I have not been able to try these out.
Quoted 6 lines
--
Regards,Laurent Pinchart
Hi,
Quoted 22 lines · Abhilash
Quoted 21 lines · On Tue, Aug 30, 2011 Laurent Pinchart wrote:
Quoted 19 lines · On Wednesday 10 August 2011 16:03:12 Deepthy Ravi wrote:
From: Abhilash K V <[email protected]>
While resuming from the "suspended to memory" state, occasionally CCDC fails to get enabled and thus fails to capture frames any more till the next suspend/resume is issued.
This is a race condition which happens only when a CCDC frame-completion ISR is pending even as ISP device'sisp_pm_prepare()is getting called and only one buffer is left on the DMA queue.
The DMA queue buffers are thus depleted which results in its underrun.So when ISP resumes there are no buffers on the queue (as the application which can issue buffers is yet to resume) to start video capture.
This fix addresses this issue by dequeuing and enqueing the last buffer inisp_pm_prepare()after its DMA gets completed. Thus,when ISP resumes it always finds atleast one buffer on the DMA queue - this is true if application uses only 3 buffers.
Quoted 5 lines
Quoted 2 lines
How is that problem specific to the CCDC ? Can't it be reproduce at the preview engine or resizer output as well ?
Yes, I believe this issue would crop with preview and resizer too though I have not been able to try these out.
That's my belief as well. In that case the fix should be generic, not CCDC- specific.
Signature · 3 lines
Regards, Laurent Pinchart