diff options
author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2015-04-29 16:54:39 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-07-06 08:26:08 -0300 |
commit | 1c991fee30c72ff49bb96558d5f1c14a60230677 (patch) | |
tree | ba676b6b9cae9d99c35379b3e094bef99bd57a23 /drivers/media/platform | |
parent | 139c92866e34bfa4897e644b36147fc86cc7a7a1 (diff) | |
download | linux-1c991fee30c72ff49bb96558d5f1c14a60230677.tar.bz2 |
[media] v4l: vsp1: Fix race condition when stopping pipeline
When stopping the pipeline the driver waits for the pipeline state to be
set to VSP1_PIPELINE_STOPPED but fails to lock the pipe irqlock to read
the state variable protected by the lock. Fix it.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/platform')
-rw-r--r-- | drivers/media/platform/vsp1/vsp1_video.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c index c4b06214b6c1..c1b5a09b8331 100644 --- a/drivers/media/platform/vsp1/vsp1_video.c +++ b/drivers/media/platform/vsp1/vsp1_video.c @@ -514,6 +514,18 @@ static void vsp1_pipeline_run(struct vsp1_pipeline *pipe) pipe->buffers_ready = 0; } +bool vsp1_pipeline_stopped(struct vsp1_pipeline *pipe) +{ + unsigned long flags; + bool stopped; + + spin_lock_irqsave(&pipe->irqlock, flags); + stopped = pipe->state == VSP1_PIPELINE_STOPPED, + spin_unlock_irqrestore(&pipe->irqlock, flags); + + return stopped; +} + static int vsp1_pipeline_stop(struct vsp1_pipeline *pipe) { struct vsp1_entity *entity; @@ -525,7 +537,7 @@ static int vsp1_pipeline_stop(struct vsp1_pipeline *pipe) pipe->state = VSP1_PIPELINE_STOPPING; spin_unlock_irqrestore(&pipe->irqlock, flags); - ret = wait_event_timeout(pipe->wq, pipe->state == VSP1_PIPELINE_STOPPED, + ret = wait_event_timeout(pipe->wq, vsp1_pipeline_stopped(pipe), msecs_to_jiffies(500)); ret = ret == 0 ? -ETIMEDOUT : 0; @@ -741,8 +753,7 @@ void vsp1_pipelines_suspend(struct vsp1_device *vsp1) if (pipe == NULL) continue; - ret = wait_event_timeout(pipe->wq, - pipe->state == VSP1_PIPELINE_STOPPED, + ret = wait_event_timeout(pipe->wq, vsp1_pipeline_stopped(pipe), msecs_to_jiffies(500)); if (ret == 0) dev_warn(vsp1->dev, "pipeline %u stop timeout\n", |