Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2274969imm; Mon, 24 Sep 2018 01:08:58 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbhmcy9CS3Knsm1Y2P8PCVP7csDanODQ0a5+Aiy+w/47f4DRgOuPfAyFxWYmm+6oPfDr/4i X-Received: by 2002:a62:1a8f:: with SMTP id a137-v6mr9274389pfa.190.1537776538848; Mon, 24 Sep 2018 01:08:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537776538; cv=none; d=google.com; s=arc-20160816; b=OF5LEpHKijrHQpix5WlhTZJVpNoFpTFZet/QwIgjL33Nd+Bc/KFtMzVgWyrSXr8Pkw 4MVJkGiT/ie0U8vvg4dp3y7UYlW/u1culCa4skv5lcIuzUW/1hh5cWX48eJPQc72HBMT /taZY3m+3Ujr3yOABHlld1p3KP1Vws8fD5LmdFDSVTJBreWK1dNy1HRsxWMqVOck8xxC ZoPdWF5W/sGjLb+klb9eNKBgK7okhidYciF6gWSQFutsxJNrayxceeazD1oAXKpnfUTZ iNPEJZZRAOAcPgW/GF+QZQN9tKPOcxBXY57OcUmVIZWdeT+U7a+YH55blfsfz7Uvh5+a 4w4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Zsg2wOD81o6UeTs6JodahP3dvNM/mHBaVxxM8dSftac=; b=SuNrPhOnuwyoVjChBgO8FHBDQXry2OqGAHp0bFsjZ0sP8wwrPOCbMXaKBiaaOHlzt7 gZLnzQLKo9xcGMv0zLyrmcaUQWCAFzrLQ+Plwm15ViKZTOeCNt0rZeHvJeNQ+IPtxGtt 3nweS1lKvUh7ecKPml8SpSgEjJoP2wivYxQVZ+26Q8iIegpbuRK8lEV8Za5lWz60nqAv Q6i1Kg5h2cLU6vx0mh55q/SVR3KWeoLC2FsqM98zrj2oBczO2es8xeNtNfnga/ffsdoO rxq17gtDE1vJKC868nku0hF7DMvxkiFKU8j53L6qvACKZ27RUeFK6uQgiCJ6Qf1btqVA XXDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b="M1e/HulU"; 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=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w20-v6si4829359pga.610.2018.09.24.01.08.43; Mon, 24 Sep 2018 01:08:58 -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=@nvidia.com header.s=n1 header.b="M1e/HulU"; 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=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727136AbeIXOJB (ORCPT + 99 others); Mon, 24 Sep 2018 10:09:01 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:4287 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725956AbeIXOJB (ORCPT ); Mon, 24 Sep 2018 10:09:01 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 24 Sep 2018 01:07:46 -0700 Received: from HQMAIL101.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Mon, 24 Sep 2018 01:08:09 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Mon, 24 Sep 2018 01:08:09 -0700 Received: from tbergstrom-lnx.Nvidia.com (10.124.1.5) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 24 Sep 2018 08:08:09 +0000 Received: by tbergstrom-lnx.Nvidia.com (Postfix, from userid 1002) id 8EBFEF8076D; Mon, 24 Sep 2018 11:08:03 +0300 (EEST) Date: Mon, 24 Sep 2018 11:08:03 +0300 From: Peter De Schrijver To: ryang CC: Prashant Gaikwad , Michael Turquette , Stephen Boyd , Thierry Reding , Jonathan Hunter , , , Subject: Re: [PATCH] clk: tegra: Return the exact clock rate from clk_round_rate Message-ID: <20180924080803.GF7636@tbergstrom-lnx.Nvidia.com> References: <20180921220149.17136-1-decatf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20180921220149.17136-1-decatf@gmail.com> X-NVConfidentiality: public User-Agent: Mutt/1.5.21 (2010-09-15) X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL101.nvidia.com (172.20.187.10) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1537776466; bh=Zsg2wOD81o6UeTs6JodahP3dvNM/mHBaVxxM8dSftac=; h=X-PGP-Universal:Date:From:To:CC:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To: X-NVConfidentiality:User-Agent:X-Originating-IP:X-ClientProxiedBy; b=M1e/HulU8zD52wBzJ0hImlRCFBWVKno1erNAOwHo1bF0IGqJuEih3EMuSjPBkj/EY qc2gL54oEwGHyyH2G8S1uQzPHc1jEpkhX/SvtJcrNoziKyI3duh0O68HH/PTntCC7A HhFWEAuF/F8XMuVPzUotLUFmqQBCgYsUABHlnowGoRbyJvkYwLy/c7eFlLe2N37FJH esRgDxLhw/k/5qwgKi+YppaPlRizL/qkiuhfXhlQ8KxKSk/SVl4v6Fl5u0Ls079B+7 ky6eQo+Pc551mW0UaX/GyQMEx3REVpJJ9RIIDRkXa52omiDeukj+bkWEMCttSIPQrS gOVpxP+WtQ4ew== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 21, 2018 at 06:01:49PM -0400, ryang wrote: > The current behavior is that clk_round_rate would return the same clock > rate passed to it for valid PLL configurations. This change will return > the exact rate the PLL will provide in accordance with clk API. > > Signed-off-by: ryang > --- > drivers/clk/tegra/clk-pll.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/tegra/clk-pll.c b/drivers/clk/tegra/clk-pll.c > index 17a058c3bbc1..36014a6ec42e 100644 > --- a/drivers/clk/tegra/clk-pll.c > +++ b/drivers/clk/tegra/clk-pll.c > @@ -595,7 +595,12 @@ static int _calc_rate(struct clk_hw *hw, struct tegra_clk_pll_freq_table *cfg, > return -EINVAL; > } > > - cfg->output_rate >>= p_div; > + if (cfg->m == 0) { > + cfg->output_rate = 0; I think a WARN_ON() is appropriate here. the input divider should never be 0. Peter. > + } else { > + cfg->output_rate = cfg->n * DIV_ROUND_UP(parent_rate, cfg->m); > + cfg->output_rate >>= p_div; > + } > > if (pll->params->pdiv_tohw) { > ret = _p_div_to_hw(hw, 1 << p_div); > -- > 2.17.1 >