From patchwork Fri Dec 22 09:46:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10129449 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 522356019C for ; Fri, 22 Dec 2017 09:47:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38F15290F7 for ; Fri, 22 Dec 2017 09:47:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D98129803; Fri, 22 Dec 2017 09:47:24 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9769D290F7 for ; Fri, 22 Dec 2017 09:47:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757929AbdLVJqy (ORCPT ); Fri, 22 Dec 2017 04:46:54 -0500 Received: from mail-bl2nam02on0089.outbound.protection.outlook.com ([104.47.38.89]:36078 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755996AbdLVJqY (ORCPT ); Fri, 22 Dec 2017 04:46:24 -0500 Received: from BLUPR0301CA0021.namprd03.prod.outlook.com (10.162.113.159) by CY4PR03MB2696.namprd03.prod.outlook.com (10.173.43.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.323.15; Fri, 22 Dec 2017 09:46:22 +0000 Received: from BL2FFO11FD027.protection.gbl (2a01:111:f400:7c09::129) by BLUPR0301CA0021.outlook.office365.com (2a01:111:e400:5259::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.345.14 via Frontend Transport; Fri, 22 Dec 2017 09:46:21 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD027.mail.protection.outlook.com (10.173.161.106) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.302.6 via Frontend Transport; Fri, 22 Dec 2017 09:46:06 +0000 Received: from b29396-OptiPlex-7040.ap.freescale.net (b29396-OptiPlex-7040.ap.freescale.net [10.192.242.1]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id vBM9kE4P003622; Fri, 22 Dec 2017 02:46:19 -0700 From: Dong Aisheng To: CC: , , , , Dong Aisheng Subject: [RFC PATCH V1 2/2] clk: add lock for clk_core_is_enabled Date: Fri, 22 Dec 2017 17:46:05 +0800 Message-ID: <1513935965-12909-2-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513935965-12909-1-git-send-email-aisheng.dong@nxp.com> References: <1513935965-12909-1-git-send-email-aisheng.dong@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131584095667484136; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(336005)(7966004)(346002)(39860400002)(396003)(376002)(39380400002)(2980300002)(1110001)(1109001)(339900001)(199004)(189003)(16586007)(106466001)(53936002)(2906002)(316002)(305945005)(47776003)(77096006)(2351001)(5660300001)(104016004)(105606002)(54906003)(356003)(2950100002)(86362001)(6666003)(97736004)(4326008)(85426001)(81166006)(6916009)(8676002)(81156014)(68736007)(498600001)(36756003)(76176011)(51416003)(50226002)(48376002)(8936002)(8656006)(50466002)(59450400001)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR03MB2696; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD027; 1:GKCb3svPulrFRteGhPW7xvt6y5PqJ0O0KFfFXVHnOALbyKRL3ssTUTeBDft3RfqBU/A9idqSJu2yywfi50rKnRMI8MxtdmCtX9ElMv+UjeGrY+n+cYbNT/O+155H4bXM MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9b590644-0812-416d-f5e8-08d54920d2d0 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4628075)(201703131517081)(5600026)(4604075)(2017052603307); SRVR:CY4PR03MB2696; X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2696; 3:u7H3vFuJdjXPX7DZivqycKmkSYnJIRkAieSf/0iyLVJ87nUhmPM6HToWHav3qTNquVVHbmjIE4HcX8pjacMNXhBAcJQOr1fTJrsy9zoaXVEnxU4iMCKOFZC8kJ5Pe20vONVjZySQ7nq9ruFIIl8tvO693zzPlARmp0WKtwc/KmGvOa7iCyY6KPOHmDjSF0oqWjHXHr1Po0N56hysEodUNIZZzhfK6hDcTorBOx5wIR+3z0+Hl/Vg0Gq7MfpzLlUpqTWGB0e26FK5jGSCxr6aResCaO44CT/vS3qrFbw+xPvKqJt+2ud+WQCmOq9B5PBOTDz1a/TNZFhrbcL+e1t26v9+i6S8FZvJ8UZ5yD+tO7c=; 25:158BTIl9dA99sgEJJST/17WEyOVuhg9d3NqkG87SpDqdbqDd4T4hjGs0r2WEAf6ciZ9DvkGf9yAU4vwzbF5c7xog99lMxdmRRzKyW+mz6Kkq0pX0x5QjQE1vPjfUvvXV41nu/tQR4QJL6TyBWALIfgt9t6BQBcu3AL1tpX/i5NzyGABQ7nNunw0+cUoMvu0stHkyEq9kuTzloe4N6DdKCuegUcT5ZNbRSzKveOrkf/dv3voDogGpkMVwR0Ns5JP63DnXwCa1IhpRueVTP9U9NVFBwYG+ZFruz4XSdXpU/mJ7E8QrrbITJcMXX63s8PdyICTP/D8j4lxEsc1CvLpzsw== X-MS-TrafficTypeDiagnostic: CY4PR03MB2696: X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2696; 31:MiHRbAoOuz3cS5L5R0ol48qlWmKriol8SXM8HjMYtTimLuvnPm54CCXkvQRQeqi7k8JWH4KY7Qt6Mmj17lhEof0gsGzbgPM16OA1O5Pf2H9gxueFZnLy6Q4JgqnbdFGiVBSVG4Etw6IVdSgPYilia+FRlKywekd0YLWCk+qgRd/lg0IQTwn9h+8QBgT6hv2a2R16yTPDKv0zP28479PU+xSjDDsf4krfYSUWT8c0Lvg=; 4:efJiq59M5OdGR7vPIfdTxN8IWDCaAxABqHxEYdQD10uz1Vd3KS2y9/Byjdyo4MKV0fRk06avF6lxZwk+25SI81UVl5Ekeh5h3yDUJmx/wyqtUmIzRbBSp5Y2SjLOcoupflPZl2u9qLmQuym2jz8bpFQHDybn2MjZBKoioqmQIZUnmEyQah1X81aIEmIJDGL5LpNs1a3B65LUNIruCbz3HxxGx3IemhsD1cBaiSVr5nlc+WxKmcKPl+F0JvptCAgeJJ5+bubAOcVpScc2DKR86ntE2+wVo8Pbsu7YRIL7fgtv4GXfycGRQbEV8nbBTtwa X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(8121501046)(5005006)(3231023)(3002001)(10201501046)(93006095)(93001095)(6055026)(6096035)(20161123561025)(20161123565025)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(20161123559100)(20161123563025)(20161123556025)(201708071742011); SRVR:CY4PR03MB2696; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:CY4PR03MB2696; X-Forefront-PRVS: 05299D545B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR03MB2696; 23:kDLLp5WgVhdfm8s/Z2YWsK+Y5HTkufK9J7uoH8m10?= =?us-ascii?Q?GO05RSpWjVdoPvfJkjCCrm5d6mle0DqnoBtMvTpuMuCR+yeIerd/s0Cq7/KN?= =?us-ascii?Q?xggOrMEvk1UaU+kuQ0dCN/FTc470y03Ffx9BpYwC4kf8WT3ygZHr8rv8pobI?= =?us-ascii?Q?7dnyYks5GGTleMwB0V/llAqMI5EqA7BLImvqmdckDPj+jrlyRFiKWryQv2+s?= =?us-ascii?Q?jXf40Btur98bLK8mWBHIKy6jxuFnonlLZpiOVGIHWTiFCMY919EtK/Akgqf0?= =?us-ascii?Q?ipzGdzZB6IcqPmxDPPyOEDk7aLaXTfxonRvDbyHdVV78jc98WxTMmhlH4jhg?= =?us-ascii?Q?v+vRUjTIGpJdMZZvoXu52t9tmawFBnyunzT16ohbrRXmL4NKlUEpdONYg/W2?= =?us-ascii?Q?ke+9/fRbAm6xh3vdYIIHGtH9ZAvVdlkN3O5KXbHD7mSun1SwN/Q7lo8japCJ?= =?us-ascii?Q?Bf/uFWk+dITaBi8uBI8EH5tJhsQVsjWjRoO4cP3Z94j/5Z6cuVwJrwAalTZF?= =?us-ascii?Q?otNHmK2ubcCBHZ08DPQdojbaxzUkZDkFBQt35WY8N1i2fjG1ZrMwXD02o4ep?= =?us-ascii?Q?EOgETzD2TN2m7D/3R8cKlABevne1LeGs79Gvyjmqe5Y/D36gRw1lUpg1BQhz?= =?us-ascii?Q?xCoSTzUJW8orxhngbG0dxX/1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JMwbDGrpHPz8uAgPSgALL70qLBruUXFuMrT6QgHh3YU0IlTpec8vUqSrvM3pvvGALFu7is9PHgVwO9RSAOBD2WrpGyxGg+h8g=; 24:BqFBjWht1elqwmbB4qvoFKo/x+3khsmfBYeAjseKppYu+zQNsHLwfrWWMwiQnatN4JXPlI+DhUrRXzPyCBw3NN6KRIzErUgTE7anUNhpWfI=; 7:wvfUUFzzMKavigPSC/qlvV602uxUb/YZYS+RvCKkl1cS3Yu6KMMWW9XD9lQIh/9Skm00X1VMwNYpemdmnCbNmbTHPye7sCAN6S10AhE3n0fz3n7GqaV6EkJCeJNk33n1chkWAJr7fMpR1eOHhiT58+/33Cu6pkmrL5KGWURieOxsAOO/fprGjRuHaSUtJlKkSfie6iBb2f2phx+E2eNUWR/1W3Ey8lvdRCLeT+Qsuqoda+PG4ran5a5xXE+1jFKf SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2017 09:46:06.5768 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9b590644-0812-416d-f5e8-08d54920d2d0 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB2696 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP According to design doc, .is_enabled should be protected by enable lock. Then users don't have to protect it against enable/disable operation in clock drivers. See: Documentation/clk.txt "The enable lock is a spinlock and is held across calls to the .enable, .disable and .is_enabled operations." Cc: Stephen Boyd Cc: Michael Turquette Signed-off-by: Dong Aisheng --- drivers/clk/clk.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index e24968f..d6e2d5c 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -198,14 +198,19 @@ static bool clk_core_is_prepared(struct clk_core *core) static bool clk_core_is_enabled(struct clk_core *core) { + unsigned long flags; bool ret = false; + flags = clk_enable_lock(); + /* * .is_enabled is only mandatory for clocks that gate * fall back to software usage counter if .is_enabled is missing */ - if (!core->ops->is_enabled) + if (!core->ops->is_enabled) { + clk_enable_unlock(flags); return core->enable_count; + } /* * Check if clock controller's device is runtime active before @@ -230,6 +235,8 @@ static bool clk_core_is_enabled(struct clk_core *core) if (core->dev) pm_runtime_put(core->dev); + clk_enable_unlock(flags); + return ret; }