From patchwork Mon Nov 25 09:58:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 3228951 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DA6AD9F3B8 for ; Mon, 25 Nov 2013 09:59:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A3E6620221 for ; Mon, 25 Nov 2013 09:59:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB3EE200FF for ; Mon, 25 Nov 2013 09:59:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751588Ab3KYJ6y (ORCPT ); Mon, 25 Nov 2013 04:58:54 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:39641 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751152Ab3KYJ6x (ORCPT ); Mon, 25 Nov 2013 04:58:53 -0500 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MWT003M8D245C40@mailout3.samsung.com> for linux-media@vger.kernel.org; Mon, 25 Nov 2013 18:58:52 +0900 (KST) X-AuditID: cbfee61a-b7f316d000007e34-87-52931f5b2362 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 0C.14.32308.B5F13925; Mon, 25 Nov 2013 18:58:51 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MWT004BMD1ERF40@mmp2.samsung.com>; Mon, 25 Nov 2013 18:58:51 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: sw0312.kim@samsung.com, andrzej.p@samsung.com, s.nawrocki@samsung.com, Jacek Anaszewski , Marek Szyprowski , Kyungmin Park Subject: [PATCH v2 06/16] s5p-jpeg: Fix clock resource management Date: Mon, 25 Nov 2013 10:58:13 +0100 Message-id: <1385373503-1657-7-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1385373503-1657-1-git-send-email-j.anaszewski@samsung.com> References: <1385373503-1657-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpiluLIzCtJLcpLzFFi42I5/e+xoG60/OQgg4YGG4tZL9tZLHqvPme0 ONv0ht2iZ8NWVou1R+6yWxx+085qMWPySzYHdo++LasYPT5vkgtgiuKySUnNySxLLdK3S+DK WDVrClvBDfGKPcu3MDUw/hHuYuTkkBAwkfi66CIjhC0mceHeejYQW0hgOqPEs79hXYxcQHY7 k8ShWd3sIAk2AUOJny9eM4HYIgLyEk96b4A1MAtcYZT4fkEPxBYWcJRoPX8GLM4ioCrRteUD M4jNK+AuserZKpYuRg6gZQoScybZgJicAh4S8yexQqx1l1jyYyP7BEbeBYwMqxhFUwuSC4qT 0nMN9YoTc4tL89L1kvNzNzGCQ+aZ1A7GlQ0WhxgFOBiVeHgtKicFCbEmlhVX5h5ilOBgVhLh PS05OUiINyWxsiq1KD++qDQntfgQozQHi5I474FW60AhgfTEktTs1NSC1CKYLBMHp1QDo4dM V88MSWn/q3FpAZMer5Hm7IqpOLjGaKL7IWMmnbVL2ozzzwf84XiyL1Rzm/ymiw/DW1vuL/AR Z71uJfj33lI/vqSyOWc81+sfUX95V1Un4/0f0dXq3w/P/5f09vQC8bdX7O02X3sc4fTcP7I9 gXlHRtpBTottN38vn9r08AyLXfeO6W53FyixFGckGmoxFxUnAgBfieR1FQIAAA== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Standard suspend/resume path is called after runtime resume of the given device, so suspend/resume callbacks must do all clock management done also by runtime pm to allow for proper power domain shutdown. Moreover, JPEG clock is enabled from probe function but is is not necessary. This patch also moves control of jpeg clock to runtime_pm callbacks. Signed-off-by: Marek Szyprowski Signed-off-by: Seung-Woo Kim Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 35 +++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 32033e7..583fcdd 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1272,7 +1272,6 @@ static int s5p_jpeg_probe(struct platform_device *pdev) return ret; } dev_dbg(&pdev->dev, "clock source %p\n", jpeg->clk); - clk_prepare_enable(jpeg->clk); /* v4l2 device */ ret = v4l2_device_register(&pdev->dev, &jpeg->v4l2_dev); @@ -1380,7 +1379,6 @@ device_register_rollback: v4l2_device_unregister(&jpeg->v4l2_dev); clk_get_rollback: - clk_disable_unprepare(jpeg->clk); clk_put(jpeg->clk); return ret; @@ -1400,7 +1398,9 @@ static int s5p_jpeg_remove(struct platform_device *pdev) v4l2_m2m_release(jpeg->m2m_dev); v4l2_device_unregister(&jpeg->v4l2_dev); - clk_disable_unprepare(jpeg->clk); + if (!pm_runtime_status_suspended(&pdev->dev)) + clk_disable_unprepare(jpeg->clk); + clk_put(jpeg->clk); return 0; @@ -1408,12 +1408,21 @@ static int s5p_jpeg_remove(struct platform_device *pdev) static int s5p_jpeg_runtime_suspend(struct device *dev) { + struct s5p_jpeg *jpeg = dev_get_drvdata(dev); + + clk_disable_unprepare(jpeg->clk); + return 0; } static int s5p_jpeg_runtime_resume(struct device *dev) { struct s5p_jpeg *jpeg = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(jpeg->clk); + if (ret < 0) + return ret; /* * JPEG IP allows storing two Huffman tables for each component @@ -1427,9 +1436,25 @@ static int s5p_jpeg_runtime_resume(struct device *dev) return 0; } +static int s5p_jpeg_suspend(struct device *dev) +{ + if (pm_runtime_suspended(dev)) + return 0; + + return s5p_jpeg_runtime_suspend(dev); +} + +static int s5p_jpeg_resume(struct device *dev) +{ + if (pm_runtime_suspended(dev)) + return 0; + + return s5p_jpeg_runtime_resume(dev); +} + static const struct dev_pm_ops s5p_jpeg_pm_ops = { - .runtime_suspend = s5p_jpeg_runtime_suspend, - .runtime_resume = s5p_jpeg_runtime_resume, + SET_SYSTEM_SLEEP_PM_OPS(s5p_jpeg_suspend, s5p_jpeg_resume) + SET_RUNTIME_PM_OPS(s5p_jpeg_runtime_suspend, s5p_jpeg_runtime_resume, NULL) }; #ifdef CONFIG_OF