Received: by 10.223.185.116 with SMTP id b49csp5841027wrg; Wed, 7 Mar 2018 19:55:18 -0800 (PST) X-Google-Smtp-Source: AG47ELvSc7RXYWkKnLUyWwJr1ZHYf/8rHmFTZYoCS1LyPQutZupQdyjS9M+Se9xb5aP/lEMHvte2 X-Received: by 10.98.69.196 with SMTP id n65mr24989040pfi.29.1520481318456; Wed, 07 Mar 2018 19:55:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520481318; cv=none; d=google.com; s=arc-20160816; b=ufjyhXSf6a1k94IPSx/MmouqvZaeY+YlUcGYp47Hm6ZisoVLSUBUwz0Oc4GEN1JeO2 elIUUfhRWwZgqdmnUJmgp2e0Z2+ePdjE7KFaAJ6SGDJhPk21o1B/xDcY00yFImilRvbE PErl+3fENsTIRAvibjnqTyr89rHFTIRb/CDhDYGB06iOpIW5RO2HOnyPGIMvMpPsYieI LLXkjyRJAEa20RZe1kcSPMT1p65BQ9mc7wUvjafLlxM7VHU8rK5+SSZ7Jp46ovMeuqcH CH2Gz7xqWI587mx8p8NEJSRIaN7HsVz5Uj56PvSj4qXcQl26/DBfujp1iqeNbEbRt1yE HorA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=wSYYu/BEjTPPfwMsLVfpBiN1vfMGfjhziltirunTOSg=; b=TPrIBuX2DbKRyHdsXmI84Eb2Pytlpqu4YOHwnMrsZYuy6ievoslDVZOdqTrWslWnbk HrfsYmcu5QiguFYfRYyIhcokpc85y+jfT+zOXAOms9u5g+/7r69wYlnweEAfmzKLX8S0 ndz/En1vc9U1lFC1Xs+NOn1FdhOTF6Iily29h9xyhni/3ec5SFqd4VMVJmhL/i+qpSom XQ8TqxU6KXAemWccOlp9TpEu4b4ee9KhafRuYE8cY+hyTApS0zaJE2j5LxhiBI6z3XtW hbN7lYbfIKHtuWCWRTcFvCB1rKSZGCRNC+/pGyY05tmARq7GG6UIJ7Kvvb0uwsfbJPRD sp+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=QI1pLiU8; dkim=fail header.i=@jms.id.au header.s=google header.b=GdTwsfyR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bf5-v6si2577030plb.780.2018.03.07.19.55.02; Wed, 07 Mar 2018 19:55:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=QI1pLiU8; dkim=fail header.i=@jms.id.au header.s=google header.b=GdTwsfyR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754836AbeCHDyH (ORCPT + 99 others); Wed, 7 Mar 2018 22:54:07 -0500 Received: from mail-qk0-f194.google.com ([209.85.220.194]:40494 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754279AbeCHDyG (ORCPT ); Wed, 7 Mar 2018 22:54:06 -0500 Received: by mail-qk0-f194.google.com with SMTP id o25so5345216qkl.7; Wed, 07 Mar 2018 19:54:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=wSYYu/BEjTPPfwMsLVfpBiN1vfMGfjhziltirunTOSg=; b=QI1pLiU8IMBcbf+EpHqib0EwOsJ88rAetSem8wT6pO/5yytjIaHSznaTXCMOievX6M 1au1TqpyFYde0VGKsWRNDcTNT6/L/Emlcg2Qi0qghvoKrhDowR0C8uf1lE+xe2R0ZrMl D4xSkjrWSm1dX/OiEToe4EH9q9sXEkK0how2lRdoa3itP7ag615I9tNHEqK+GY13Zlzs dJOElhjihsv8MoBdGtpwHLYBneTNbYEmTif9mJAX7kTO8J+CQkrGKcb0QRBJvphRp9Hc 8r1KkWmyjKoW4gBXgX2y47kJJyPnraWk5G/16n7Y6zX3sMJTvz5uZdn9xhHE9p+fjw4L pTtA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jms.id.au; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=wSYYu/BEjTPPfwMsLVfpBiN1vfMGfjhziltirunTOSg=; b=GdTwsfyRMTYBpJY1aBaD5S52yglIZWeJySuITHhBqz2mVcYr6ezepwk2QYKnUplaTI ssxgeaVO7j2ch8gZHJ90v7Ze0Ikt3Y3mw1FqQ6hGGTxvocYXppVnDCD3lRIBCZ9PRPaa tWzJ6/n60hD4tYEbhjqGPbJaCSrPjQgrN8srw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=wSYYu/BEjTPPfwMsLVfpBiN1vfMGfjhziltirunTOSg=; b=RN19fX63D+1/7RnaDqTwr5hj05ZhUdhchcdGZ/AyugZ/K8sjpOxUYt/SRHWNKep3OU n2SU9X3AzaKufGeL4cJZ4G/Y8rGR2bgAeA/YmJLXwxEYezt2PoUQeJp6XeVph/f/hEEd CwPRvyp2cXBufu1IARtNMlj7n03Xj8eaoMhJXxBjuoQOT2Lur/7a7S2eC5cN9Bt3N9kD PIhggXmbgxm3rwDYSskyUBIUmUmIBe/d4QoVygBPbQwYe+BpyXPinn+0R1hoG3XkLIdy Ym2Y78iMbuWBmoZLofjKerdXIGGqDDFYzR0eziJpf0zg/cCjFbMa98AyKREuhTvXZvtO u19Q== X-Gm-Message-State: AElRT7ES6S6+MqYjqF58/VWGT+73zF9YfQJnrBtevsZZ6FLOIr1QpWhM OAow7oOgF80D7yxohoev+t5ZfPvMfTKyns+Dq6o= X-Received: by 10.55.187.199 with SMTP id l190mr37767237qkf.336.1520481245192; Wed, 07 Mar 2018 19:54:05 -0800 (PST) MIME-Version: 1.0 Received: by 10.200.50.69 with HTTP; Wed, 7 Mar 2018 19:53:44 -0800 (PST) In-Reply-To: References: <1520440570-25280-1-git-send-email-eajames@linux.vnet.ibm.com> From: Joel Stanley Date: Thu, 8 Mar 2018 14:23:44 +1030 X-Google-Sender-Auth: h4IrKkGldaAE_kftDo0eW8MAXwI Message-ID: Subject: Re: [PATCH] clk: aspeed: Prevent reset if clock is enabled To: Eddie James Cc: Linux Kernel Mailing List , linux-clk@vger.kernel.org, Michael Turquette , sboyd@kernel.org, Lei YU , Ryan Chen Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 8, 2018 at 2:12 PM, Joel Stanley wrote: > Hi Eddie, > > On Thu, Mar 8, 2018 at 3:06 AM, Eddie James wrote: >> According to the Aspeed specification, the reset and enable sequence >> should be done when the clock is stopped. The specification doesn't >> define behavior if the reset is done while the clock is enabled. >> >> From testing on the AST2500, the LPC Controller has problems if the >> clock is reset while enabled. >> >> Therefore, check whether the clock is enabled or not before performing >> the reset and enable sequence in the Aspeed clock driver. >> >> Signed-off-by: Eddie James >> --- >> drivers/clk/clk-aspeed.c | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/drivers/clk/clk-aspeed.c b/drivers/clk/clk-aspeed.c >> index 9f7f931..a13054d 100644 >> --- a/drivers/clk/clk-aspeed.c >> +++ b/drivers/clk/clk-aspeed.c >> @@ -212,6 +212,12 @@ static int aspeed_clk_enable(struct clk_hw *hw) >> u32 clk = BIT(gate->clock_idx); >> u32 rst = BIT(gate->reset_idx); >> u32 enval; >> + u32 reg; >> + >> + /* Only reset/enable/unreset if clock is stopped */ >> + regmap_read(gate->map, ASPEED_CLK_STOP_CTRL, ®); >> + if (!(reg & clk)) >> + return 0; > > This doesn't generalise to all of the clocks, as some clocks use set > to disable. Perhaps we could do something like this: > > /* Only reset/enable/unreset if clock is stopped. The LPC clock > on ast2500 has issues otherwise */ We've seen this on both the ast2400 and ast2500, so if you do take my suggestion perhaps just say "The LPC clock has issues otherwise". > enval = (gate->flags & CLK_GATE_SET_TO_DISABLE) ? 0 : clk; > regmap_read(gate->map, ASPEED_CLK_STOP_CTRL, ®); > if ((reg & clk) == enval) { > spin_unlock_irqrestore(gate->lock, flags); > return 0; > } > > I think we should also do this operation under the lock. > > Please cc Ryan Chen so he can confirm that > this workaround is valid, and credit Lei who spent a lot of time > investigating this issue. Perhaps "Root-caused-by". > > Cheers, > > Joel