From patchwork Thu Nov 10 10:31:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 81618 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp650282qge; Thu, 10 Nov 2016 02:31:51 -0800 (PST) X-Received: by 10.98.150.88 with SMTP id c85mr8802103pfe.68.1478773911168; Thu, 10 Nov 2016 02:31:51 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id po7si3438989pab.181.2016.11.10.02.31.51; Thu, 10 Nov 2016 02:31:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932354AbcKJKbq (ORCPT + 4 others); Thu, 10 Nov 2016 05:31:46 -0500 Received: from mailout3.w1.samsung.com ([210.118.77.13]:35062 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932267AbcKJKbl (ORCPT ); Thu, 10 Nov 2016 05:31:41 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OGF00KAU98P3I80@mailout3.w1.samsung.com>; Thu, 10 Nov 2016 10:31:37 +0000 (GMT) Received: from eusmges1.samsung.com (unknown [203.254.199.239]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20161110103137eucas1p2c941daa2af7286edaa74038b0d372f9d~FqQZeGkM71578915789eucas1p2q; Thu, 10 Nov 2016 10:31:37 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1.samsung.com (EUCPMTA) with SMTP id AC.B0.23383.A8C44285; Thu, 10 Nov 2016 10:31:38 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20161110103136eucas1p2c55d1177fcc97c5dbf1bc650e88d72ce~FqQY3NlLS2301223012eucas1p2L; Thu, 10 Nov 2016 10:31:36 +0000 (GMT) X-AuditID: cbfec7ef-f79e76d000005b57-c2-58244c8a5b11 Received: from eusync2.samsung.com ( [203.254.199.212]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 9D.1D.10494.C6C44285; Thu, 10 Nov 2016 10:31:08 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OGF00DAR98IFU80@eusync2.samsung.com>; Thu, 10 Nov 2016 10:31:36 +0000 (GMT) From: Marek Szyprowski To: linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Sylwester Nawrocki , Krzysztof Kozlowski , Seung-Woo Kim , Bartlomiej Zolnierkiewicz , Javier Martinez Canillas Subject: [PATCH 4/4] s5p-mfc: Use clock gating only on MFC v5 hardware Date: Thu, 10 Nov 2016 11:31:23 +0100 Message-id: <1478773883-12083-5-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1478773883-12083-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrBIsWRmVeSWpSXmKPExsWy7djPc7pdPioRBt+O81rcWneO1WLjjPWs FtfP21nsuPmFzeLN2zVMFufPb2C36NmwldVixvl9TBZrj9xltzj8ph3InfySzYHbY9OqTjaP Lf132T36tqxi9Pi8SS6AJYrLJiU1J7MstUjfLoEr49jFi2wFP6QqOnefYmxgfCjWxcjJISFg IjF923M2CFtM4sK99UA2F4eQwDJG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Ftxw8WiG1yEiePTWYFsTkFPCVaNs9khNjs IfFhVz/LBEbeBYwMqxhFUkuLc9Nzi430ihNzi0vz0vWS83M3MQIDfduxn1t2MHa9Cz7EKMDB qMTD26GpHCHEmlhWXJl7iFGCg1lJhLffSyVCiDclsbIqtSg/vqg0J7X4EKMp0FETmaVEk/OB UZhXEm9oYmhuaWhkbGFhbmSkJM479cOVcCGB9MSS1OzU1ILUIpg+Jg5OqQbGan+mIEcXkzgX rozjex9terd0j3Skg7+eMO/tgjmVD5xfpucenmywxa/GcvHi7/0fUlddDLgTYPFdUF/7S/nK Tx/1H8m6R+7Sevc0UXuW58LVsj1r+L/+mCe2konxptbbdzKKOlEqF4tjg3Pc3+2cwjDJYdls 5xc7+E6sv1/hsk3WJ5up/aG9EktxRqKhFnNRcSIAdYE0iYoCAAA= X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20161110103136eucas1p2c55d1177fcc97c5dbf1bc650e88d72ce X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 X-Local-Sender: =?UTF-8?B?TWFyZWsgU3p5cHJvd3NraRtTUlBPTC1LZXJuZWwgKFRQKRs=?= =?UTF-8?B?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?UTF-8?B?TWFyZWsgU3p5cHJvd3NraRtTUlBPTC1LZXJuZWwgKFRQKRtT?= =?UTF-8?B?YW1zdW5nIEVsZWN0cm9uaWNzG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjczOTI=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20161110103136eucas1p2c55d1177fcc97c5dbf1bc650e88d72ce X-RootMTR: 20161110103136eucas1p2c55d1177fcc97c5dbf1bc650e88d72ce References: <1478773883-12083-1-git-send-email-m.szyprowski@samsung.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Newer MFC hardware have internal clock gating feature, so additional software-triggered clock gating sometimes causes misbehavior of the MFC firmware and results in freeze or crash. This patch changes the driver to use software-triggered clock gating only when working with v5 MFC hardware, where it has been proven to work properly. Signed-off-by: Marek Szyprowski --- drivers/media/platform/s5p-mfc/s5p_mfc.c | 1 + drivers/media/platform/s5p-mfc/s5p_mfc_common.h | 2 ++ drivers/media/platform/s5p-mfc/s5p_mfc_pm.c | 17 +++++++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index 994a27b..7d39359 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -1441,6 +1441,7 @@ static int s5p_mfc_runtime_resume(struct device *dev) .buf_size = &buf_size_v5, .buf_align = &mfc_buf_align_v5, .fw_name[0] = "s5p-mfc.fw", + .use_clock_gating = true, }; static struct s5p_mfc_buf_size_v6 mfc_buf_size_v6 = { diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h index 46b99f2..c068ee3 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h @@ -199,6 +199,7 @@ struct s5p_mfc_buf { struct s5p_mfc_pm { struct clk *clock; struct clk *clock_gate; + bool use_clock_gating; atomic_t power; struct device *device; }; @@ -235,6 +236,7 @@ struct s5p_mfc_variant { struct s5p_mfc_buf_size *buf_size; struct s5p_mfc_buf_align *buf_align; char *fw_name[MFC_FW_MAX_VERSIONS]; + bool use_clock_gating; }; /** diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c index 930dc2d..b5806ab 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c @@ -37,6 +37,7 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev) pm = &dev->pm; p_dev = dev; + pm->use_clock_gating = dev->variant->use_clock_gating; pm->clock_gate = clk_get(&dev->plat_dev->dev, MFC_GATE_CLK_NAME); if (IS_ERR(pm->clock_gate)) { mfc_err("Failed to get clock-gating control\n"); @@ -108,6 +109,8 @@ int s5p_mfc_clock_on(void) atomic_inc(&clk_ref); mfc_debug(3, "+ %d\n", atomic_read(&clk_ref)); #endif + if (!pm->use_clock_gating) + return 0; if (!IS_ERR_OR_NULL(pm->clock_gate)) ret = clk_enable(pm->clock_gate); return ret; @@ -119,22 +122,32 @@ void s5p_mfc_clock_off(void) atomic_dec(&clk_ref); mfc_debug(3, "- %d\n", atomic_read(&clk_ref)); #endif + if (!pm->use_clock_gating) + return; if (!IS_ERR_OR_NULL(pm->clock_gate)) clk_disable(pm->clock_gate); } int s5p_mfc_power_on(void) { + int ret = 0; + #ifdef CONFIG_PM - return pm_runtime_get_sync(pm->device); + ret = pm_runtime_get_sync(pm->device); + if (ret) + return ret; #else atomic_set(&pm->power, 1); - return 0; #endif + if (!pm->use_clock_gating && !IS_ERR_OR_NULL(pm->clock_gate)) + ret = clk_enable(pm->clock_gate); + return ret; } int s5p_mfc_power_off(void) { + if (!pm->use_clock_gating && !IS_ERR_OR_NULL(pm->clock_gate)) + clk_disable(pm->clock_gate); #ifdef CONFIG_PM return pm_runtime_put_sync(pm->device); #else