From patchwork Sun Mar 15 14:33:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Kaneko X-Patchwork-Id: 6013111 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 CBCA1BF90F for ; Sun, 15 Mar 2015 14:33:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AB2B12024C for ; Sun, 15 Mar 2015 14:33:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6C74F2022A for ; Sun, 15 Mar 2015 14:33:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752232AbbCOOdX (ORCPT ); Sun, 15 Mar 2015 10:33:23 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:35150 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752455AbbCOOdW (ORCPT ); Sun, 15 Mar 2015 10:33:22 -0400 Received: by pdbop1 with SMTP id op1so32639064pdb.2; Sun, 15 Mar 2015 07:33:21 -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; bh=MowNeifMFHomcKoyjCQMK08bmqDC4TnPvCgvyJzD52g=; b=WOPpw7BC4nfC3WQAwcZnHehZF5AAmrxlwZTc6gJ0c4YNhJoNXme+d0pJomdJCqascI jko40X+rq/6zlfpI+xIklyTCOfJQyJwBGe8HDv0bHkeF7m0+PpoV1ApA4/kfovH0g94s TRdxF6lXVR7YltDsG7tyQbUMeU0IeXEVyzhZkEYFwuRW+iHrrfSI8FuN+z9tWTMG9nQe MudCa8beEuSGDuRt8VOlCTL+GxnuLI2tSBrbFpnTCWHM2YxUsN/gf43yLpzFwYG3r9AA NrzNz33Y5CKXCy5fBBAfzuc7fxmHuJje1JkvZHr0aYPt8kPgYzxcx+3WhRUQOgvF8Q+E ViTg== X-Received: by 10.70.123.131 with SMTP id ma3mr98404428pdb.16.1426430001695; Sun, 15 Mar 2015 07:33:21 -0700 (PDT) Received: from localhost.localdomain (KD118152108246.ppp-bb.dion.ne.jp. [118.152.108.246]) by mx.google.com with ESMTPSA id rf12sm12694528pdb.0.2015.03.15.07.33.19 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 15 Mar 2015 07:33:21 -0700 (PDT) From: Yoshihiro Kaneko To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , Laurent Pinchart , Simon Horman , Magnus Damm , linux-sh@vger.kernel.org Subject: [PATCH/RFC] v4l: vsp1: Fix Suspend-to-RAM Date: Sun, 15 Mar 2015 23:33:07 +0900 Message-Id: <1426429987-3134-1-git-send-email-ykaneko0929@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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. In detail, - Fix the judgment of ref count in resuming. - Add stopping VSP1 during suspend. Signed-off-by: Sei Fumizono Signed-off-by: Yoshifumi Hosoya Signed-off-by: Yoshihiro Kaneko --- This patch is based on the master branch of linuxtv.org/media_tree.git. drivers/media/platform/vsp1/vsp1_drv.c | 39 ++++++++++++++++++++++++++++---- drivers/media/platform/vsp1/vsp1_video.c | 31 ++++++++++++++++++++++++- drivers/media/platform/vsp1/vsp1_video.h | 5 +++- 3 files changed, 69 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c index 913485a..b6e9cbc 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) * @@ -397,26 +397,57 @@ void vsp1_device_put(struct vsp1_device *vsp1) static int vsp1_pm_suspend(struct device *dev) { struct vsp1_device *vsp1 = dev_get_drvdata(dev); + unsigned int i = 0; + int ret = 0; WARN_ON(mutex_is_locked(&vsp1->lock)); if (vsp1->ref_count == 0) return 0; + /* Suspend 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); + ret = vsp1_pipeline_suspend(pipe); + if (ret < 0) + break; + } + clk_disable_unprepare(vsp1->clock); - return 0; + return ret; } static int vsp1_pm_resume(struct device *dev) { struct vsp1_device *vsp1 = dev_get_drvdata(dev); + unsigned int i = 0; WARN_ON(mutex_is_locked(&vsp1->lock)); - if (vsp1->ref_count) + if (vsp1->ref_count == 0) return 0; - return clk_prepare_enable(vsp1->clock); + clk_prepare_enable(vsp1->clock); + + /* 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); + vsp1_pipeline_resume(pipe); + } + + return 0; } #endif diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c index d91f19a..c744608 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,35 @@ done: spin_unlock_irqrestore(&pipe->irqlock, flags); } +int vsp1_pipeline_suspend(struct vsp1_pipeline *pipe) +{ + unsigned long flags; + int ret; + + if (pipe == NULL) + return 0; + + spin_lock_irqsave(&pipe->irqlock, flags); + if (pipe->state == VSP1_PIPELINE_RUNNING) + pipe->state = VSP1_PIPELINE_STOPPING; + spin_unlock_irqrestore(&pipe->irqlock, flags); + + ret = wait_event_timeout(pipe->wq, pipe->state == VSP1_PIPELINE_STOPPED, + msecs_to_jiffies(500)); + ret = ret == 0 ? -ETIMEDOUT : 0; + + return ret; +} + +void vsp1_pipeline_resume(struct vsp1_pipeline *pipe) +{ + if (pipe == NULL) + return; + + 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..958a166 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); +int vsp1_pipeline_suspend(struct vsp1_pipeline *pipe); +void vsp1_pipeline_resume(struct vsp1_pipeline *pipe); + #endif /* __VSP1_VIDEO_H__ */