From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751696AbbEDIsP (ORCPT ); Mon, 4 May 2015 04:48:15 -0400 Received: from mail-by2on0119.outbound.protection.outlook.com ([207.46.100.119]:21813 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751084AbbEDIsF (ORCPT ); Mon, 4 May 2015 04:48:05 -0400 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; Date: Mon, 4 May 2015 16:35:51 +0800 From: Dong Aisheng To: Stephen Boyd CC: Dong Aisheng , , , , , , , , , Subject: Re: [PATCH RFC v1 2/5] clk: add missing lock when call clk_core_enable in clk_set_parent Message-ID: <20150504083549.GC4082@shlinux1.ap.freescale.net> References: <1429107999-24413-1-git-send-email-aisheng.dong@freescale.com> <1429107999-24413-3-git-send-email-aisheng.dong@freescale.com> <55427D83.3060900@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <55427D83.3060900@codeaurora.org> User-Agent: Mutt/1.5.20 (2009-06-14) X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(339900001)(199003)(51704005)(479174004)(24454002)(189002)(92566002)(6806004)(2950100001)(87936001)(47776003)(106466001)(77096005)(5001960100002)(46102003)(85426001)(19580405001)(107886002)(46406003)(104016003)(5001920100001)(62966003)(105606002)(50466002)(54356999)(23726002)(76176999)(110136002)(19580395003)(33656002)(77156002)(50986999)(97756001)(217873001)(4001430100001)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR03MB1346;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:sfv;A:1;MX:1;LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1346; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BLUPR03MB1346;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1346; X-Forefront-PRVS: 05669A7924 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2015 08:48:00.6587 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB1346 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 30, 2015 at 12:07:47PM -0700, Stephen Boyd wrote: > On 04/15/15 07:26, Dong Aisheng wrote: > > clk_core_enable is executed without &enable_clock in clk_set_parent function. > > Adding it to avoid potential race condition issue. > > > > Fixes: 035a61c314eb ("clk: Make clk API return per-user struct clk instances") > > Cc: Mike Turquette > > Cc: Stephen Boyd > > Signed-off-by: Dong Aisheng > > --- > > Can you please describe the race condition? From what I can tell there > is not a race condition here and we've gone around on this part of the > code before to fix any race conditions. > Do you mean we do not need to acquire enable lock when execute clk_core_enable in set_parent function? Can you help explain a bit more why? The clk doc looks to me says the enable lock should be held across calls to the .enable, .disable and .is_enabled operations. And before the commit 035a61c314eb ("clk: Make clk API return per-user struct clk instances"), all the clk_enable/disable in set_parent() is executed with lock. A rough thinking of race condition is assuming Thread A calls clk_set_parent(x, y) while Thread B calls clk_enable(x), clock x is disabled but prepared initially, due to clk_core_enable in set_parent() is not executed with enable clock, the clk_core_enable may be reentrant during the locking time executed by B. Won't this be a race condition? Regards Dong Aisheng > -- > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, > a Linux Foundation Collaborative Project >