From patchwork Tue Jun 30 16:25:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Kaneko X-Patchwork-Id: 6697341 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B819EC05AC for ; Tue, 30 Jun 2015 16:26:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B319320622 for ; Tue, 30 Jun 2015 16:26:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5E96F20628 for ; Tue, 30 Jun 2015 16:26:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751573AbbF3Q0G (ORCPT ); Tue, 30 Jun 2015 12:26:06 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:33236 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752098AbbF3Q0F (ORCPT ); Tue, 30 Jun 2015 12:26:05 -0400 Received: by pacws9 with SMTP id ws9so8016053pac.0; Tue, 30 Jun 2015 09:26:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RLbfdNwb/KR2v1SYeKgJwHLwk9SgfAEa15zQftWAAH8=; b=Zkgjoi7cOlu3wZnKgajL9uGlkTmueTCi9JjF+5OnG50EcbYSzdK/W3zWX95KrUYWqX qZMSRqoKHZiv9FIyubYQ1OxhYyikQyjfrZPEKPHoTEJPk1dWJjdex7WQkRr7UL0CaRGj j9C35CkdXSSyLtWKXyTadxK2L72VhIoOBE6zSPcMl7F+/MvMaI9wALtDqoOpgHfolO98 g7dfRvQtaNUwz/FrWBSI3GTar4mtdx3Yt7GDzbaxhBsU24SCe/qMY32ks4H6y2fSxDkS Ze2zWOI7qbaO8QU+IO2lM5U5B32Icjf5VFNvCY2+OfPOq368DdFY30ujx6SEbl6+Xa4p wBcg== X-Received: by 10.68.65.74 with SMTP id v10mr29171716pbs.9.1435681563847; Tue, 30 Jun 2015 09:26:03 -0700 (PDT) Received: from localhost.localdomain (KD118152108246.ppp-bb.dion.ne.jp. [118.152.108.246]) by mx.google.com with ESMTPSA id fa15sm13449075pac.25.2015.06.30.09.26.01 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Jun 2015 09:26:03 -0700 (PDT) From: Yoshihiro Kaneko To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , Laurent Pinchart , Damian Hobson-Garcia , Simon Horman , Magnus Damm , linux-sh@vger.kernel.org Subject: [PATCH v2 2/2] v4l: vsp1: Fix Suspend-to-RAM Date: Wed, 1 Jul 2015 01:25:06 +0900 Message-Id: <1435681506-24296-3-git-send-email-ykaneko0929@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1435681506-24296-1-git-send-email-ykaneko0929@gmail.com> References: <1435681506-24296-1-git-send-email-ykaneko0929@gmail.com> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sei Fumizono Fix Suspend-to-RAM so that VSP1 driver continues to work after resuming. Add stopping VSP1 during suspend. Signed-off-by: Sei Fumizono Signed-off-by: Yoshifumi Hosoya [Kaneko: Moved correction of vsp1_pm_resume() logic to separate patch] Signed-off-by: Yoshihiro Kaneko --- 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__ */