From patchwork Mon Nov 14 14:09:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 82112 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1026178qge; Mon, 14 Nov 2016 06:09:53 -0800 (PST) X-Received: by 10.107.175.147 with SMTP id p19mr29435826ioo.80.1479132593461; Mon, 14 Nov 2016 06:09:53 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tl4si6263621pab.239.2016.11.14.06.09.53; Mon, 14 Nov 2016 06:09:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-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-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752250AbcKNOJu (ORCPT + 4 others); Mon, 14 Nov 2016 09:09:50 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:47985 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753481AbcKNOJr (ORCPT ); Mon, 14 Nov 2016 09:09:47 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OGM009TNY07Q380@mailout2.w1.samsung.com>; Mon, 14 Nov 2016 14:09:43 +0000 (GMT) Received: from eusmges3.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20161114140942eucas1p2185e47ca335c434bc1872c292671d36c~G7z8_RvRq2513725137eucas1p25; Mon, 14 Nov 2016 14:09:42 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3.samsung.com (EUCPMTA) with SMTP id 92.EB.11330.6A5C9285; Mon, 14 Nov 2016 14:09:42 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20161114140941eucas1p259a5ef794e4349614f6212cc251b6995~G7z8PqRD11055610556eucas1p2C; Mon, 14 Nov 2016 14:09:41 +0000 (GMT) X-AuditID: cbfec7f2-f79556d000002c42-38-5829c5a6f674 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 3A.1B.07726.9A5C9285; Mon, 14 Nov 2016 14:09:45 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OGM00KD9XZYIX10@eusync3.samsung.com>; Mon, 14 Nov 2016 14:09:41 +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 , Andrzej Hajda , Shuah Khan , Luis de Bethencourt Subject: [PATCH] s5p-mfc: Fix clock management in s5p_mfc_release function Date: Mon, 14 Nov 2016 15:09:26 +0100 Message-id: <1479132566-477-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJIsWRmVeSWpSXmKPExsWy7djP87rLjmpGGDyeJGhxa905VouNM9az Wrx5u4bJ4vz5DewWPRu2slrMOL+PyeLovGmMFmuP3GW3OPymndVi6pcPLBYzJr9kc+D22LSq k81jS/9ddo++LasYPT5vkgtgieKySUnNySxLLdK3S+DK+Hb8KntBF0/FpnbtBsYeri5GTg4J AROJL9c/MUHYYhIX7q1n62Lk4hASWMo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kDrBDb5CROHpvMOoGRewEjwypGkdTS 4tz03GJDveLE3OLSvHS95PzcTYzAwN127OfmHYyXNgYfYhTgYFTi4e3I14gQYk0sK67MPcQo wcGsJMIrDgx7Id6UxMqq1KL8+KLSnNTiQ4ymQLsnMkuJJucDoyqvJN7QxNDc0tDI2MLC3MhI SZy35MOVcCGB9MSS1OzU1ILUIpg+Jg5OqQbGJqPlueUZYRGrUt9ubtT96/Hz6gQnNrETrgyN GUUCCfOM8m2eX789Z+r31w+3Olrvvnr4X/fOUsminy8cNCzWbbvTeGUSf/fKt/lXb9p/UxbZ 8nx5bAu7oPGNm0GhOh+0P8zRXDXp5qTMWCM3ldl3Lnc4K/fLrUubFtqek+e55svqvFOrGHz4 lViKMxINtZiLihMBuKC9hnICAAA= X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20161114140941eucas1p259a5ef794e4349614f6212cc251b6995 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 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: 20161114140941eucas1p259a5ef794e4349614f6212cc251b6995 X-RootMTR: 20161114140941eucas1p259a5ef794e4349614f6212cc251b6995 References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Clock control indirectly requires access to MFC device, so call it only if we are sure that the device exists in s5p_mfc_release function. s5p_mfc_remove() calls s5p_mfc_final_pm(), which releases all PM related resources, including clocks, so any call to clocks related functions is not valid after s5p_mfc_final_pm(). Fixes: d695c12 ("[media] media: s5p-mfc fix invalid memory access from s5p_mfc_release()") Signed-off-by: Marek Szyprowski --- drivers/media/platform/s5p-mfc/s5p_mfc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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 0c8a4616e827..a0a29194ccd1 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -940,10 +940,11 @@ static int s5p_mfc_release(struct file *file) mfc_debug_enter(); if (dev) mutex_lock(&dev->mfc_mutex); - s5p_mfc_clock_on(); vb2_queue_release(&ctx->vq_src); vb2_queue_release(&ctx->vq_dst); if (dev) { + s5p_mfc_clock_on(); + /* Mark context as idle */ clear_work_bit_irqsave(ctx); /* @@ -965,9 +966,9 @@ static int s5p_mfc_release(struct file *file) if (s5p_mfc_power_off() < 0) mfc_err("Power off failed\n"); } + mfc_debug(2, "Shutting down clock\n"); + s5p_mfc_clock_off(); } - mfc_debug(2, "Shutting down clock\n"); - s5p_mfc_clock_off(); if (dev) dev->ctx[ctx->num] = NULL; s5p_mfc_dec_ctrls_delete(ctx);