From patchwork Wed Mar 22 09:22:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 95705 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp143992qgd; Wed, 22 Mar 2017 02:35:54 -0700 (PDT) X-Received: by 10.84.129.67 with SMTP id 61mr54254540plb.16.1490175354515; Wed, 22 Mar 2017 02:35:54 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o20si1109584pgn.150.2017.03.22.02.35.54; Wed, 22 Mar 2017 02:35:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933918AbdCVJfx (ORCPT + 13 others); Wed, 22 Mar 2017 05:35:53 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:55661 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933703AbdCVJfw (ORCPT ); Wed, 22 Mar 2017 05:35:52 -0400 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 <0ON700MB1M2JCW80@mailout3.w1.samsung.com>; Wed, 22 Mar 2017 09:23:07 +0000 (GMT) Received: from eusmges3.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170322092306eucas1p1a33ae1d858b409d236195dd09c908ff2~uKeQicRs_1069010690eucas1p1T; Wed, 22 Mar 2017 09:23:06 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3.samsung.com (EUCPMTA) with SMTP id 64.83.09557.A7242D85; Wed, 22 Mar 2017 09:23:06 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170322092305eucas1p20d2a6dfede483210febea5b5e0ff68db~uKePgflC_1035510355eucas1p2k; Wed, 22 Mar 2017 09:23:05 +0000 (GMT) X-AuditID: cbfec7f2-f790f6d000002555-2e-58d2427a7353 Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id DD.EF.10233.88242D85; Wed, 22 Mar 2017 09:23:20 +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 <0ON70016EM2CDR70@eusync4.samsung.com>; Wed, 22 Mar 2017 09:23:05 +0000 (GMT) From: Marek Szyprowski To: linux-clk@vger.kernel.org, linux-pm@vger.kernel.org Cc: Marek Szyprowski , "Rafael J. Wysocki" , Ulf Hansson , Bartlomiej Zolnierkiewicz Subject: [PATCH] PM / runtime: Use synchronous runtime PM call in rpm_put_suppliers() Date: Wed, 22 Mar 2017 10:22:50 +0100 Message-id: <1490174570-18345-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsWy7djPc7pVTpciDCbN4LfYOGM9q8XHnnus Fp97jzBarD1yl93izOlLrBbH14Y7sHncubaHzWPL1XYWj74tqxg9Pm+SC2CJ4rJJSc3JLEst 0rdL4Mr4t3c6Y8EH3orJd/4xNTAe4u5i5OSQEDCRaP2/hxXCFpO4cG89WxcjF4eQwFJGieae 0ywQzmdGiYkTuxhhOibfPApVtYxR4vvDI4wQTgOTxKvJi9lBqtgEDCW63naxgdgiAuYSbSdO s4IUMQvsYJTo+7KSG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Z/ILCWanA+MkrySeEMTQ3NLQyNjCwtzIyMlcd6pH66ECwmkJ5akZqemFqQWwfQxcXBKNTD6 eoc6W9pOS8o+vPbJou8XTtYFcv3csfZvTZ4Cv0+t22ev6LhrGn+eT971zPpRUNojXrZpJpZv nx3smLB3nq74jpZbvUyXQpWWHTdbEfzuJoet1cLtB8uzU/+3XFvpceGBRmod3x8xPyazU38C Lj08cSllP4Oei7/mRJkFIWXboo8pMW270+WmxFKckWioxVxUnAgALtGu4VoCAAA= X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170322092305eucas1p20d2a6dfede483210febea5b5e0ff68db X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 X-Local-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1B?= =?utf-8?b?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1BSam?= =?utf-8?q?sung_Electronics=1BSenior_Software_Engineer?= X-Sender-Code: =?utf-8?q?C10=1BEHQ=1BC10CD02CD027392?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170322092305eucas1p20d2a6dfede483210febea5b5e0ff68db X-RootMTR: 20170322092305eucas1p20d2a6dfede483210febea5b5e0ff68db References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org rpm_put_suppliers() might be called as a result of pm_runtime_put_sync() call, where the called explicitly wants to perform the operation in synchronous way to avoid some deadlocks related to concurrent code execution in the PM workers. However the current code for handling device links always use asynchronous calls. This patch changes it to always use the synchronous calls. This patch fixes the potential deadlock, which appears during adding runtime PM support to clock framework, which uses global mutex, which is reentrant only for the current process, so trying to execute runtime PM callback from the worker results in deadlock (the mentioned mutex is already taken by the current process, which waits for execution of PM worker). Signed-off-by: Marek Szyprowski --- Hi Rafael & Ulf, This was the simplest way of fixing this issue. Other way would be to propagate rpmflags to rpm_get/put_suppliers() to ensure that synchronous calls will be also done on the linked devices. Which way is better in your opinion? Best regards Marek Szyprowski Samsung R&D Institute Poland --- drivers/base/power/runtime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 7bcf80fa9ada..b7df589ae579 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -292,7 +292,7 @@ static void rpm_put_suppliers(struct device *dev) list_for_each_entry_rcu(link, &dev->links.suppliers, c_node) if (link->rpm_active && READ_ONCE(link->status) != DL_STATE_SUPPLIER_UNBIND) { - pm_runtime_put(link->supplier); + pm_runtime_put_sync(link->supplier); link->rpm_active = false; } }