linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] v4l: vsp1: Fix Suspend-to-RAM
@ 2015-06-30 16:25 Yoshihiro Kaneko
  2015-06-30 16:25 ` [PATCH v2 1/2] v4l: vsp1: Fix ref_count bug Yoshihiro Kaneko
  2015-06-30 16:25 ` [PATCH v2 2/2] v4l: vsp1: Fix Suspend-to-RAM Yoshihiro Kaneko
  0 siblings, 2 replies; 3+ messages in thread
From: Yoshihiro Kaneko @ 2015-06-30 16:25 UTC (permalink / raw)
  To: linux-media
  Cc: Mauro Carvalho Chehab, Laurent Pinchart, Damian Hobson-Garcia,
	Simon Horman, Magnus Damm, linux-sh

This series fixes Suspend-to-RAM to make VSP1 driver continue working
after resuming.
This series includes two patches:
- fix simple ref_count bug
- add stop/restart the video stream

Sei Fumizono (1):
  v4l: vsp1: Fix Suspend-to-RAM

Yoshihiro Kaneko (1):
  v4l: vsp1: Fix ref_count bug

 drivers/media/platform/vsp1/vsp1_drv.c   | 11 +++--
 drivers/media/platform/vsp1/vsp1_video.c | 69 +++++++++++++++++++++++++++++++-
 drivers/media/platform/vsp1/vsp1_video.h |  5 ++-
 3 files changed, 80 insertions(+), 5 deletions(-)

v2 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Laurent Pinchart
  - separate a patch into two patches
  - add stop/restart the video stream code to vsp1_pipelines_suspend() and
    vsp1_pipelines_resume() function in vsp1_video.c.

-- 
1.9.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2 1/2] v4l: vsp1: Fix ref_count bug
  2015-06-30 16:25 [PATCH v2 0/2] v4l: vsp1: Fix Suspend-to-RAM Yoshihiro Kaneko
@ 2015-06-30 16:25 ` Yoshihiro Kaneko
  2015-06-30 16:25 ` [PATCH v2 2/2] v4l: vsp1: Fix Suspend-to-RAM Yoshihiro Kaneko
  1 sibling, 0 replies; 3+ messages in thread
From: Yoshihiro Kaneko @ 2015-06-30 16:25 UTC (permalink / raw)
  To: linux-media
  Cc: Mauro Carvalho Chehab, Laurent Pinchart, Damian Hobson-Garcia,
	Simon Horman, Magnus Damm, linux-sh

This patch fixes the judgement error of ref count in vsp1_pm_resume().

This patch was separated from the patch written by Sei Fumizono.

Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>

---

This patch is based on the master branch of linuxtv.org/media_tree.git.

v2 [Yoshihiro Kaneko]
* compile tested only

 drivers/media/platform/vsp1/vsp1_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c
index 913485a..a7dfbb0 100644
--- a/drivers/media/platform/vsp1/vsp1_drv.c
+++ b/drivers/media/platform/vsp1/vsp1_drv.c
@@ -413,7 +413,7 @@ static int vsp1_pm_resume(struct device *dev)
 
 	WARN_ON(mutex_is_locked(&vsp1->lock));
 
-	if (vsp1->ref_count)
+	if (vsp1->ref_count == 0)
 		return 0;
 
 	return clk_prepare_enable(vsp1->clock);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2 2/2] v4l: vsp1: Fix Suspend-to-RAM
  2015-06-30 16:25 [PATCH v2 0/2] v4l: vsp1: Fix Suspend-to-RAM Yoshihiro Kaneko
  2015-06-30 16:25 ` [PATCH v2 1/2] v4l: vsp1: Fix ref_count bug Yoshihiro Kaneko
@ 2015-06-30 16:25 ` Yoshihiro Kaneko
  1 sibling, 0 replies; 3+ messages in thread
From: Yoshihiro Kaneko @ 2015-06-30 16:25 UTC (permalink / raw)
  To: linux-media
  Cc: Mauro Carvalho Chehab, Laurent Pinchart, Damian Hobson-Garcia,
	Simon Horman, Magnus Damm, linux-sh

From: Sei Fumizono <sei.fumizono.jw@hitachi-solutions.com>

Fix Suspend-to-RAM
so that VSP1 driver continues to work after resuming.

Add stopping VSP1 during suspend.

Signed-off-by: Sei Fumizono <sei.fumizono.jw@hitachi-solutions.com>
Signed-off-by: Yoshifumi Hosoya <yoshifumi.hosoya.wj@renesas.com>
[Kaneko: Moved correction of vsp1_pm_resume() logic to separate patch]
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>

---

This patch is based on the master branch of linuxtv.org/media_tree.git.

v2 [Yoshihiro Kaneko]
* compile tested only
* As suggested by Laurent Pinchart
  - separate a patch into two patches
  - add stop/restart the video stream code to vsp1_pipelines_suspend() and
    vsp1_pipelines_resume() function in vsp1_video.c.

 drivers/media/platform/vsp1/vsp1_drv.c   |  9 ++++-
 drivers/media/platform/vsp1/vsp1_video.c | 69 +++++++++++++++++++++++++++++++-
 drivers/media/platform/vsp1/vsp1_video.h |  5 ++-
 3 files changed, 79 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c
index a7dfbb0..caf55e4 100644
--- a/drivers/media/platform/vsp1/vsp1_drv.c
+++ b/drivers/media/platform/vsp1/vsp1_drv.c
@@ -1,7 +1,7 @@
 /*
  * vsp1_drv.c  --  R-Car VSP1 Driver
  *
- * Copyright (C) 2013-2014 Renesas Electronics Corporation
+ * Copyright (C) 2013-2015 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -403,7 +403,9 @@ static int vsp1_pm_suspend(struct device *dev)
 	if (vsp1->ref_count == 0)
 		return 0;
 
+	vsp1_pipelines_suspend(vsp1);
 	clk_disable_unprepare(vsp1->clock);
+
 	return 0;
 }
 
@@ -416,7 +418,10 @@ static int vsp1_pm_resume(struct device *dev)
 	if (vsp1->ref_count == 0)
 		return 0;
 
-	return clk_prepare_enable(vsp1->clock);
+	clk_prepare_enable(vsp1->clock);
+	vsp1_pipelines_resume(vsp1);
+
+	return 0;
 }
 #endif
 
diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c
index d91f19a..2be96cd 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -1,7 +1,7 @@
 /*
  * vsp1_video.c  --  R-Car VSP1 Video Node
  *
- * Copyright (C) 2013-2014 Renesas Electronics Corporation
+ * Copyright (C) 2013-2015 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -662,6 +662,73 @@ done:
 	spin_unlock_irqrestore(&pipe->irqlock, flags);
 }
 
+void vsp1_pipelines_suspend(struct vsp1_device *vsp1)
+{
+	unsigned int i;
+	unsigned long flags;
+	int ret;
+
+	/* To avoid increasing the system suspend time needlessly, loop over
+	 * the pipelines twice, first to set them all to the stopping state,
+	 * and then to wait for the stop to complete.
+	 */
+	for (i = 0; i < vsp1->pdata.wpf_count; ++i) {
+		struct vsp1_rwpf *wpf = vsp1->wpf[i];
+		struct vsp1_pipeline *pipe;
+
+		if (wpf == NULL)
+			continue;
+
+		pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity);
+		if (pipe == NULL)
+			continue;
+
+		spin_lock_irqsave(&pipe->irqlock, flags);
+		if (pipe->state == VSP1_PIPELINE_RUNNING)
+			pipe->state = VSP1_PIPELINE_STOPPING;
+		spin_unlock_irqrestore(&pipe->irqlock, flags);
+	}
+
+	for (i = 0; i < vsp1->pdata.wpf_count; ++i) {
+		struct vsp1_rwpf *wpf = vsp1->wpf[i];
+		struct vsp1_pipeline *pipe;
+
+		if (wpf == NULL)
+			continue;
+
+		pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity);
+		if (pipe == NULL)
+			continue;
+
+		ret = wait_event_timeout(pipe->wq,
+					 pipe->state == VSP1_PIPELINE_STOPPED,
+					 msecs_to_jiffies(500));
+		if (ret == 0)
+			dev_warn(vsp1->dev, "pipeline stop timeout\n");
+	}
+}
+
+void vsp1_pipelines_resume(struct vsp1_device *vsp1)
+{
+	unsigned int i;
+
+	/* Resume pipeline */
+	for (i = 0; i < vsp1->pdata.wpf_count; ++i) {
+		struct vsp1_rwpf *wpf = vsp1->wpf[i];
+		struct vsp1_pipeline *pipe;
+
+		if (wpf == NULL)
+			continue;
+
+		pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity);
+		if (pipe == NULL)
+			continue;
+
+		if (vsp1_pipeline_ready(pipe))
+			vsp1_pipeline_run(pipe);
+	}
+}
+
 /*
  * Propagate the alpha value through the pipeline.
  *
diff --git a/drivers/media/platform/vsp1/vsp1_video.h b/drivers/media/platform/vsp1/vsp1_video.h
index fd2851a..0887a4d 100644
--- a/drivers/media/platform/vsp1/vsp1_video.h
+++ b/drivers/media/platform/vsp1/vsp1_video.h
@@ -1,7 +1,7 @@
 /*
  * vsp1_video.h  --  R-Car VSP1 Video Node
  *
- * Copyright (C) 2013-2014 Renesas Electronics Corporation
+ * Copyright (C) 2013-2015 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -149,4 +149,7 @@ void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe,
 				   struct vsp1_entity *input,
 				   unsigned int alpha);
 
+void vsp1_pipelines_suspend(struct vsp1_device *vsp1);
+void vsp1_pipelines_resume(struct vsp1_device *vsp1);
+
 #endif /* __VSP1_VIDEO_H__ */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-06-30 16:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-30 16:25 [PATCH v2 0/2] v4l: vsp1: Fix Suspend-to-RAM Yoshihiro Kaneko
2015-06-30 16:25 ` [PATCH v2 1/2] v4l: vsp1: Fix ref_count bug Yoshihiro Kaneko
2015-06-30 16:25 ` [PATCH v2 2/2] v4l: vsp1: Fix Suspend-to-RAM Yoshihiro Kaneko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).