Received: by 10.192.165.148 with SMTP id m20csp3721122imm; Mon, 7 May 2018 18:13:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrKNgIYeFOkLWqy+ShI+s+8RhLyhZ+jUQ3yCSXVvRq1wdnJP9XgUpJ5A2t4akLCZYsTnp5q X-Received: by 2002:a17:902:a512:: with SMTP id s18-v6mr39322182plq.223.1525741993736; Mon, 07 May 2018 18:13:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525741993; cv=none; d=google.com; s=arc-20160816; b=hGIDAMkKOpyUuBrGwcv1EXIxLeNxemjzKsVyyEOlE9JADTlhE0bgtZy1S9x+O/aGPu 0Dvar0cpyIBwY/9EKDQ7PH/MLGP2SpgovaGQHIRmLdo3gk2d3su8wr9Nwx5gAua/2Ftm VbRU5XnD85RsZpfN2LL+CylwjIqZBe2cAYOz/lgzq0h0U5R6BUSsSR1G2w8S13+hiaD9 GbZC1dVhzmFMCj4Enq/W/xZ7D3raV4XuOB76bPtZB8n/sgAQFET22eld0I3lhSr2bZXL vWysmPrw6HfNlguhjb8HKU3auxsie8ANw/3j9PuuOEP26UrN72w+FEW5JohULdbUDN01 WgDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:dkim-signature:arc-authentication-results; bh=qLo7Mvvz0Sx/llOXbxMgNYqm8PEcV5KjFtVhNDakcSw=; b=BBHzUkz+luXxR+62WN6ihrnBfRUO6b8pazxtLEitJq7vDGvqHpttEcVMpVe7rE1A9D P2dWA0cw1cmCScFIXTQH9Jw8qsCwNZYOMCl7NwYDE7NDFN0WgCErWED+Ms6iEgsUlb/0 dHsBkgeDRSaqSQjVNNKiJrg0h10FYofIyFs3QKlwpCw5OfXRAZ/6TvmL0Nh2wlO6h+9c GiKWB2fRRqWMMQsTDQRG/Y6CE7wkhF8BpDdO0GKEEr1SamY/ZcQvGXJvLt5yaRpQ6ry2 uTequbTkUylh9sy/dCmf1bmpAKL7YhsRQsqIgp9sL1V5ahxndnrgxFrh217CJzSnUsqq hfkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yQ4RuQjV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e22-v6si22899265plj.311.2018.05.07.18.12.58; Mon, 07 May 2018 18:13:13 -0700 (PDT) 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=pass header.i=@kernel.org header.s=default header.b=yQ4RuQjV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753588AbeEHBLi (ORCPT + 99 others); Mon, 7 May 2018 21:11:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:42352 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753505AbeEHBLg (ORCPT ); Mon, 7 May 2018 21:11:36 -0400 Received: from localhost (unknown [104.132.1.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D212C20779; Tue, 8 May 2018 01:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1525741895; bh=fYwbpl0BDlRMU4iEzNKGkIqK5ogcVbxcIXqgtiDdTsk=; h=To:From:In-Reply-To:Cc:References:Subject:Date:From; b=yQ4RuQjVFjciRhSmMB7TRJQkyiBTWycwgLgOk4UcTSB9z+J9HtDLPrnqtSjtG6wU3 RWRcbtbEpOULu/FFP0db4mM0gwoxu466hyV8VHpThKJIjdSqVzd6zJ273Og4cPKc5Q spahDEQ+CAUBetevSv8wTFfAaMK8R/HjpIV4bOFw= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: Amit Nischal , Michael Turquette , Stephen Boyd From: Stephen Boyd In-Reply-To: <1525690220-26525-2-git-send-email-anischal@codeaurora.org> Cc: Andy Gross , David Brown , Rajendra Nayak , Odelu Kukatla , Taniya Das , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Amit Nischal References: <1525690220-26525-1-git-send-email-anischal@codeaurora.org> <1525690220-26525-2-git-send-email-anischal@codeaurora.org> Message-ID: <152574189516.138124.5711696582182066656@swboyd.mtv.corp.google.com> User-Agent: alot/0.7 Subject: Re: [PATCH v7 1/3] clk: qcom: Configure the RCGs to a safe source as needed Date: Mon, 07 May 2018 18:11:35 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Amit Nischal (2018-05-07 03:50:18) > For some root clock generators, there could be child branches which are > controlled by an entity other than application processor subsystem. For > such RCGs, as per application processor subsystem clock driver, all of > its downstream clocks are disabled and RCG is in disabled state but in > reality downstream clocks can be left enabled before. > = > So in this scenario, when RCG is disabled as per clock driver's point of > view and when rate scaling request comes before downstream clock enable > request, then RCG fails to update its configuration because in reality > RCG is on and it expects its new source to already be in enable state but > in reality new source is off. In order to avoid having the RCG to go into > an invalid state, add support to update the CFG, M, N and D registers > during set_rate() without configuration update and defer the actual RCG > configuration update to be done during clk_enable() as at this point of > time, both its new parent and safe source will be already enabled and RCG > can safely switch to new parent. > = > During clk_disable() request, configure it to safe source as both its > parents, safe source and current parent will be enabled and RCG can > safely execute a switch. > = > Signed-off-by: Taniya Das > Signed-off-by: Amit Nischal > --- Applied to clk-next. I squashed some style fixups and logic simplifications in too. diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c index 6827ab32c82c..e63911cbfef9 100644 --- a/drivers/clk/qcom/clk-rcg2.c +++ b/drivers/clk/qcom/clk-rcg2.c @@ -797,7 +797,6 @@ static int clk_rcg2_set_force_enable(struct clk_hw *hw) const char *name =3D clk_hw_get_name(hw); int ret, count; = - /* Force enable bit */ ret =3D regmap_update_bits(rcg->clkr.regmap, rcg->cmd_rcgr + CMD_REG, CMD_ROOT_EN, CMD_ROOT_EN); if (ret) @@ -808,12 +807,10 @@ static int clk_rcg2_set_force_enable(struct clk_hw *h= w) if (clk_rcg2_is_enabled(hw)) return 0; = - /* Delay for 1usec and retry polling the status bit */ udelay(1); } - if (!count) - pr_err("%s: RCG did not turn on\n", name); = + pr_err("%s: RCG did not turn on\n", name); return -ETIMEDOUT; } = @@ -821,7 +818,6 @@ static int clk_rcg2_clear_force_enable(struct clk_hw *h= w) { struct clk_rcg2 *rcg =3D to_clk_rcg2(hw); = - /* Clear force enable bit */ return regmap_update_bits(rcg->clkr.regmap, rcg->cmd_rcgr + CMD_REG, CMD_ROOT_EN, 0); } @@ -832,9 +828,6 @@ clk_rcg2_shared_force_enable_clear(struct clk_hw *hw, c= onst struct freq_tbl *f) struct clk_rcg2 *rcg =3D to_clk_rcg2(hw); int ret; = - if (!f) - return -EINVAL; - ret =3D clk_rcg2_set_force_enable(hw); if (ret) return ret; @@ -858,10 +851,9 @@ static int clk_rcg2_shared_set_rate(struct clk_hw *hw,= unsigned long rate, = /* * In case clock is disabled, update the CFG, M, N and D registers - * and do not hit the update bit of CMD register. + * and don't hit the update bit of CMD register. */ if (!__clk_is_enabled(hw->clk)) - /* Skip the configuration update */ return __clk_rcg2_configure(rcg, f); = return clk_rcg2_shared_force_enable_clear(hw, f); @@ -879,8 +871,8 @@ static int clk_rcg2_shared_enable(struct clk_hw *hw) int ret; = /* - * Set the update bit only. - * As required configuration has been already written in set_rate() op. + * Set the update bit because required configuration has already + * been written in set_rate() op. */ ret =3D clk_rcg2_set_force_enable(hw); if (ret) @@ -899,8 +891,8 @@ static void clk_rcg2_shared_disable(struct clk_hw *hw) u32 cfg; = /* - * Store current configuration as switching to safe source - * would clear the SRC and DIV of CFG register. + * Store current configuration as switching to safe source would clear + * the SRC and DIV of CFG register. */ regmap_read(rcg->clkr.regmap, rcg->cmd_rcgr + CFG_REG, &cfg); = @@ -915,7 +907,7 @@ static void clk_rcg2_shared_disable(struct clk_hw *hw) clk_rcg2_set_force_enable(hw); = regmap_write(rcg->clkr.regmap, rcg->cmd_rcgr + CFG_REG, - rcg->safe_src_index << CFG_SRC_SEL_SHIFT); + rcg->safe_src_index << CFG_SRC_SEL_SHIFT); = update_config(rcg); =20