From patchwork Thu Nov 30 12:14:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 10084729 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3675660234 for ; Thu, 30 Nov 2017 12:15:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A17629F44 for ; Thu, 30 Nov 2017 12:15:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1EDB429F74; Thu, 30 Nov 2017 12:15:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B3CDE29F44 for ; Thu, 30 Nov 2017 12:15:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: Message-id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:List-Owner; bh=VkFsYdTGmDgZEXYWt8DrAIcyW86CGgXjb8ER/53l41M=; b=jr U/1ISZF1yy3t9U/pTiDd73SxoHv+CYEZJ5rPbJTLx/RR31ddMekELJDz/z1RWln8981XKOXXDMZx1 cdwVTAvvFdA89JeeaFxU8oIBRxoPND3HVyYsR4wBXLU+JkSZDAx2tyOn1XaLVzbBjvTTOOztMuY3e rVQRi5Qxv1q2XUoB9cckT8FsV62YFD32jTkR0DfClZjfnVkmRHnEn29JPbwctqStQCOS9UZQfOk1D 6PDU7lrVFt0v8e0c6EwQZhLLhuNz3OGM79g/+gEF2i1DJ6pz+E5IgaK8s4Z2W947wYhT5CjOkFoqp ewDbv0YDQtNVWgnjPpUtez0C7oXdRjLg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eKNkn-0001vq-8e; Thu, 30 Nov 2017 12:15:45 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eKNkh-0000y6-N0 for linux-arm-kernel@lists.infradead.org; Thu, 30 Nov 2017 12:15:43 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20171130121513euoutp0182826104e9c08ebe91ffb80782b401ca~73Bwounei0774307743euoutp01D; Thu, 30 Nov 2017 12:15:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20171130121513euoutp0182826104e9c08ebe91ffb80782b401ca~73Bwounei0774307743euoutp01D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1512044113; bh=4WbKMDWZrIZPj6qtBoItcwYihVI274D1bIDm00RyMRc=; h=From:To:Cc:Subject:Date:References:From; b=aQ5dSpZvTEaOGyE88GRuU+qhqxp0QBuBlWqMPclpodhzG1B4sHVkhONJISpFUAEGI REsZDgqsq7CEUtU7W3NLLUAQP+HDWNCbRJTVW3DtxwuPLdYcPj4d1DfobUkosFNELN n7fOGjUCMeoghUBT5Ii/KtfeXIEXGOkFLBMJVAJw= Received: from eusmges3.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171130121512eucas1p18c32237bcb74cc7a611a976c1661b96b~73BwDCwM92873728737eucas1p1m; Thu, 30 Nov 2017 12:15:12 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3.samsung.com (EUCPMTA) with SMTP id 96.23.12867.056FF1A5; Thu, 30 Nov 2017 12:15:12 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171130121511eucas1p1832c1f6e5bc9e263860e40478efca132~73BvPtAYc2798227982eucas1p1K; Thu, 30 Nov 2017 12:15:11 +0000 (GMT) X-AuditID: cbfec7f2-f793b6d000003243-46-5a1ff650523b Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 51.E6.18832.F46FF1A5; Thu, 30 Nov 2017 12:15:11 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P08001RRCP62Z90@eusync4.samsung.com>; Thu, 30 Nov 2017 12:15:11 +0000 (GMT) From: Marek Szyprowski To: linux-clk@vger.kernel.org, linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] clk: Manage proper runtime PM state in clk_change_rate() Date: Thu, 30 Nov 2017 13:14:51 +0100 Message-id: <20171130121451.6710-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.15.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGIsWRmVeSWpSXmKPExsWy7djPc7oB3+SjDE60yVtsnLGe1eL6l+es FpseX2O1+Nhzj9Xic+8RRosZ5/cxWaw9cpfd4uIpV4vDb9pZLX6c6WaxOL423IHb4/2NVnaP y329TB53ru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e5gkPq9+y9zFyMEhLOApsfGiH0gDi4CqxJv7DSwgNq+AjcTUzfdZ IdbJSyz+vpNtAiP3AkaGVYwiqaXFuem5xYZ6xYm5xaV56XrJ+bmbGIEBte3Yz807GC9tDD7E KMDBqMTDe0NNPkqINbGsuDL3EKMEB7OSCK/yCaAQb0piZVVqUX58UWlOavEhRmkOFiVx3t49 qyOFBNITS1KzU1MLUotgskwcnFINjBJdPq9jzgb8F1P5U71m0vbKGb/Xmj6oFvC04uCYrdnW J2VbxHPtkrr8tNilLR0zNqqrRJ5/Zl9r3a4upTMj7fL/9rDe5ZHv9m5LyN4ULKtpuz5t14vm r7PapHlfNMjdUdBUXn+n7Gvxa4X9jA0SYtP+c2cFbHVarTjruItFoGyi9brtW4NSlFiKMxIN tZiLihMBFSKctiQCAAA= X-CMS-MailID: 20171130121511eucas1p1832c1f6e5bc9e263860e40478efca132 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20171130121511eucas1p1832c1f6e5bc9e263860e40478efca132 X-RootMTR: 20171130121511eucas1p1832c1f6e5bc9e263860e40478efca132 References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171130_041539_909802_3900B4C6 X-CRM114-Status: GOOD ( 15.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Bartlomiej Zolnierkiewicz , Michael Turquette , Stephen Boyd , Chanwoo Choi , Sylwester Nawrocki , Marek Szyprowski MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP clk_change_rate() propagates rate change down to all its children. Such operation requires managing proper runtime PM state of each child, what was missing. Add needed calls to clk_pm_runtime*() to ensure that set_rate() clock callback is called on runtime active clock. This fixes following issue found on Exynos5433 TM2 board with devfreq enabled: Synchronous External Abort: synchronous external abort (0x96000210) at 0xffffff80093f5600 Internal error: : 96000210 [#1] PREEMPT SMP Modules linked in: CPU: 0 PID: 5 Comm: kworker/u16:0 Not tainted 4.15.0-rc1-next-20171129+ #4 Hardware name: Samsung TM2 board (DT) Workqueue: devfreq_wq devfreq_monitor task: ffffffc0ca96b600 task.stack: ffffff80093a8000 pstate: a0000085 (NzCv daIf -PAN -UAO) pc : clk_divider_set_rate+0x54/0x118 lr : clk_divider_set_rate+0x44/0x118 ... Process kworker/u16:0 (pid: 5, stack limit = 0xffffff80093a8000) Call trace: clk_divider_set_rate+0x54/0x118 clk_change_rate+0xfc/0x4e0 clk_change_rate+0x1f0/0x4e0 clk_change_rate+0x1f0/0x4e0 clk_change_rate+0x1f0/0x4e0 clk_core_set_rate_nolock+0x138/0x148 clk_set_rate+0x28/0x50 exynos_bus_passive_target+0x6c/0x11c update_devfreq_passive+0x58/0xb4 devfreq_passive_notifier_call+0x50/0x5c notifier_call_chain+0x4c/0x88 __srcu_notifier_call_chain+0x54/0x80 srcu_notifier_call_chain+0x14/0x1c update_devfreq+0x100/0x1b4 devfreq_monitor+0x2c/0x88 process_one_work+0x148/0x3d8 worker_thread+0x13c/0x3f8 kthread+0x100/0x12c ret_from_fork+0x10/0x18 Reported-by: Chanwoo Choi Fixes: 9a34b45397e5 ("clk: Add support for runtime PM") Signed-off-by: Marek Szyprowski Reviewed-by: Ulf Hansson Tested-by: Chanwoo Choi Reviewed-by: Chanwoo Choi --- For some unknown reason handling of this case was missing in the initial patch, which added runtime PM support for clock core. Even tests in linux-next did not revealed this issue. This patch finaly fixes it, as it is now easy to trigger it with v4.15-rc1. Best regards Marek Szyprowski Samsung R&D Institute Poland --- drivers/clk/clk.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 647d056df88c..8a1860a36c77 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1564,6 +1564,9 @@ static void clk_change_rate(struct clk_core *core) best_parent_rate = core->parent->rate; } + if (clk_pm_runtime_get(core)) + return; + if (core->flags & CLK_SET_RATE_UNGATE) { unsigned long flags; @@ -1634,6 +1637,8 @@ static void clk_change_rate(struct clk_core *core) /* handle the new child who might not be in core->children yet */ if (core->new_child) clk_change_rate(core->new_child); + + clk_pm_runtime_put(core); } static int clk_core_set_rate_nolock(struct clk_core *core,