omap3: ISP: Fix the failure of CCDC capture during suspend/resume
PATCH v2 1/1 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.
---
Changes since v1:
Merged the patch which fixes kernel crash when attempting suspend
drivers/media/video/omap3isp/isp.c | 30 +++++++++++++++- drivers/media/video/omap3isp/isp.h | 4 ++ drivers/media/video/omap3isp/ispvideo.c | 58 ++++++++++++++++++++++++++++++- drivers/media/video/omap3isp/ispvideo.h | 2 + 4 files changed, 92 insertions(+), 2 deletions(-)
drivers/media/video/omap3isp/isp.c +29 -1
@@ -1566,12 +1566,24 @@ 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)); -if (isp->ref_count ==0 )return 0 ; +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; + reset =isp_suspend_modules (isp);isp_disable_interrupts (isp);isp_save_ctx (isp);
@@ -1596,16 +1608,32 @@ 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;if (isp->ref_count ==0 )return 0 ; +spin_lock_irqsave (&pipe->lock, flags); + pipe->state &= ~ISP_PIPELINE_PREPARE_SUSPEND ; +spin_unlock_irqrestore (&pipe->lock, flags); +return isp_enable_clocks (isp); }static void isp_pm_complete (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 ;
drivers/media/video/omap3isp/isp.h +4 -0
@@ -259,6 +259,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 +57 -1
76 lines not on this page · raw message
drivers/media/video/omap3isp/ispvideo.h +2 -0
@@ -83,6 +83,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