From mboxrd@z Thu Jan 1 00:00:00 1970 From: Saravana Kannan Subject: Re: [PATCH] clk: Fix race condition between clk_set_parent and clk_enable() Date: Wed, 15 May 2013 21:17:03 -0700 Message-ID: <51945DBF.60308@codeaurora.org> References: <1367383328-25700-1-git-send-email-skannan@codeaurora.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Ulf Hansson Cc: linux-arm-kernel@lists.infradead.org, Mike Turquette , Paul Walmsley , Shawn Guo , Sascha Hauer , Rob Herring , Mark Brown , Russell King , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Andrew Lunn , Jeremy Kerr , Thomas Gleixner , Arnd Bergman , Jamie Iles , Richard Zhao , Magnus Damm , Linus Walleij , Stephen Boyd , Amit Kucheria , Deepak Saxena , Grant Likely , Tomasz Figa List-Id: linux-arm-msm@vger.kernel.org On 05/15/2013 12:24 PM, Ulf Hansson wrote: > On 1 May 2013 06:42, Saravana Kannan wrote: >> - /* migrate prepare */ >> - if (clk->prepare_count) >> + /* >> + * Migrate prepare state between parents and prevent race with >> + * clk_enable(). >> + * >> + * If the clock is not prepared, then a race with >> + * clk_enable/disable() is impossible since we already have the >> + * prepare lock (future calls to clk_enable() need to be preceded by >> + * a clk_prepare()). >> + * >> + * If the clock is prepared, migrate the prepared state to the new >> + * parent and also protect against a race with clk_enable() by >> + * forcing the clock and the new parent on. This ensures that all >> + * future calls to clk_enable() are practically NOPs with respect to >> + * hardware and software states. >> + */ > > Maybe an additional note about that since CLK_SET_PARENT_GATE is a > prerequisite for doing migration of "prepare", we also interpreted > this flags as it is acceptable to enable the clock(s) in this context. Done. Sent v2 patch. > > Looks good! Thanks for having another round to fixup this kind of > tricky code. :-) Thanks :-) > Acked-by: Ulf Hansson > Thanks again. -Saravana -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation