Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2937703imm; Mon, 24 Sep 2018 12:34:56 -0700 (PDT) X-Google-Smtp-Source: ACcGV62F9KoQ54tgZV2rov3a5iUWPyRytzhXl4jA/LafzRmITaSkFXLKhxu7mJ3C+rdaWCG94lOX X-Received: by 2002:a63:81c8:: with SMTP id t191-v6mr205565pgd.399.1537817696763; Mon, 24 Sep 2018 12:34:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537817696; cv=none; d=google.com; s=arc-20160816; b=wBNdmE58TY23/buKHWn4JbBD+TGiYFBmZLp0B5tV+SEVYMlU7hJ6hOR30FGVJD+j7f FndPONW4tMpk4VDT8ahkWrVsXXjsIOjpzsGPeizLZZJggw++hTpAw8/vigrwhSdgNkyk pMsSWqCo8S/OpqOU1BZJIfzNfSB5qk7EIS4GEq3iO7sZ9LNNSlBhuqnkTH3jIsOlMvU1 zx5tUSNXWJgyW8tIrrYob6zrNQMNXwtDSeI3jmmw+VZTwHyv1UI3WjePBVCWzJufhRtd BONTpXU6AjbFUb/iKGNoeAmgNOqWQxukQ7aDIue7AkZrFkewiV+1WPC43tMWR04pdi40 AnzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=EhO0/3mSuRoG627z5xnGrgaF/Hb/lTjMYfYD0g75Ctg=; b=niAMFz0Pd+NAEGnZC9W+PFUIz9YFCJnCOfG5eotXz2EZ/CzoYK4s528mkEHuKcazH0 fvqWovt3MRLRkwYARqIzvsJAA6UPSnxXXj8Xn1w/l8x1EvYVUbIWy8FU9FqMeU8fmrrH NB/4QNIOigIqe8gk9WRxl3Fe6VnlHsccKDRmJhL4BlDacAd89eX4QA389YbN10aDnYHJ boe71XvbnXbFcEhfJrF06coi//G4PGUsnr4DB4YCbtD2swC1RJIvpw8cP4nsuS5vHP5H JOl4nLcpcH1XjyXzsejNQM0EXrL7/N2O5qvFyaOw5ZZWdZ/GuxKGZo5b6YkZh85hWrpn CpsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OGA1CVwi; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z5-v6si115511pgf.561.2018.09.24.12.34.41; Mon, 24 Sep 2018 12:34:56 -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=@gmail.com header.s=20161025 header.b=OGA1CVwi; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731932AbeIYBVr (ORCPT + 99 others); Mon, 24 Sep 2018 21:21:47 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:46408 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730681AbeIYBVr (ORCPT ); Mon, 24 Sep 2018 21:21:47 -0400 Received: by mail-io1-f65.google.com with SMTP id y12-v6so18494904ioj.13; Mon, 24 Sep 2018 12:18:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=EhO0/3mSuRoG627z5xnGrgaF/Hb/lTjMYfYD0g75Ctg=; b=OGA1CVwi5MLh5ynp02rtK5I3KmZNhfrQlwOR84lNthjcDgQdmiVZmdIup5K9qHozws cHAoHj/995/3Vd+mH/5KqWwZrYxMMPax9jnTrz1Rc14BM1A9d1anyEN5SUWKmsbIqYXb a7l8kYPfyJAr1FSy8FhNK6zhBWT3nseiJJNyv/4l/d+ATq6soG9H2Uw7bYHGYAxIYPHi /MlqShHqVRUT8sEHH+oYmAYZyuudwzXrqhmqaRVwlw9bWn8z3rOTMhacu33tZPfwu0U+ xcL/IeEXbn8jFsbKouo+HFyEEXhJ0Z14FoiWyooK7As6NmRG/VQAlLFZkjMD2NEPUErm 996g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=EhO0/3mSuRoG627z5xnGrgaF/Hb/lTjMYfYD0g75Ctg=; b=UHqImH5WP2xJTGqPdJWlEno2BWSOWR+CM/n3DWkg6TYughdVq7Rp0AoHqrvpRArlz/ 0wrsSOCSp2GLrPEJbOSEVndqethWprcadOMbu02Prr+tmBK1b4RrlFDhIBlOOOJ7ai8Y cfhhVG021wyZbpFUq9Pq2T/HxIEmHBCX3mZsiBIdKdLRbqQ3M+Me51CfAQpvzZMxjKHg mI9aP2aQhZUppzTpgsoFEZJqXWQuaOC49kM8g6w6o70LszUreQLaJyGAmnm/wNAZD6jJ uZ4Kr7YzbFxMsMUM6/CrQQHfNeC2GLjIoR62vG0Gv4Nw3vdVu7x0mHJq8OSjf4yq+7i2 ITlQ== X-Gm-Message-State: ABuFfojvPpnOnoY2uddyBtnDQVhIft+2tfBbzl5Y1rnPPKJSn9se2OxU RhP/v8EUQdldALnap1wOnA== X-Received: by 2002:a6b:b955:: with SMTP id j82-v6mr251545iof.158.1537816688484; Mon, 24 Sep 2018 12:18:08 -0700 (PDT) Received: from r (CPE1cabc0918a93-CM1cabc0918a90.cpe.net.cable.rogers.com. [99.229.26.117]) by smtp.gmail.com with ESMTPSA id o127-v6sm2754852itg.24.2018.09.24.12.18.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Sep 2018 12:18:07 -0700 (PDT) Date: Mon, 24 Sep 2018 15:18:04 -0400 From: r yang To: Peter De Schrijver Cc: Prashant Gaikwad , Michael Turquette , Stephen Boyd , Thierry Reding , Jonathan Hunter , linux-clk@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] clk: tegra: Return the exact clock rate from clk_round_rate Message-ID: <20180924191804.GA20060@r> References: <20180921220149.17136-1-decatf@gmail.com> <20180924080803.GF7636@tbergstrom-lnx.Nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180924080803.GF7636@tbergstrom-lnx.Nvidia.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 24, 2018 at 11:08:03AM +0300, Peter De Schrijver wrote: > 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. > Should it return -EINVAL (or some error) too? _calc_rate is also in the clk_set_rate code path. I think we want to avoid programming the register to 0 input divider all together? > > + } 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 > >