devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Peter De Schrijver <pdeschrijver@nvidia.com>,
	Prashant Gaikwad <pgaikwad@nvidia.com>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>, Rob Herring <robh+dt@kernel.org>,
	linux-tegra@vger.kernel.org, linux-clk@vger.kernel.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v7 6/8] clk: tegra: cclk: Handle thermal DIV2 CPU frequency throttling
Date: Tue, 11 May 2021 18:23:24 +0300	[thread overview]
Message-ID: <04bc9e16-be7e-cf18-9fff-436dd063bf10@gmail.com> (raw)
In-Reply-To: <20210511144139.GB4413@qmqm.qmqm.pl>

11.05.2021 17:41, Michał Mirosław пишет:
> On Tue, May 11, 2021 at 02:17:35AM +0300, Dmitry Osipenko wrote:
>> Check whether thermal DIV2 throttle is active in order to report
>> the CPU frequency properly. This very useful for userspace tools
>> like cpufreq-info which show actual frequency asserted from hardware.
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>>  drivers/clk/tegra/clk-tegra-super-cclk.c | 16 ++++++++++++++--
>>  drivers/clk/tegra/clk-tegra30.c          |  2 +-
>>  2 files changed, 15 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/clk/tegra/clk-tegra-super-cclk.c b/drivers/clk/tegra/clk-tegra-super-cclk.c
>> index a03119c30456..f75822b71d0e 100644
>> --- a/drivers/clk/tegra/clk-tegra-super-cclk.c
>> +++ b/drivers/clk/tegra/clk-tegra-super-cclk.c
>> @@ -25,6 +25,8 @@
>>  
>>  #define SUPER_CDIV_ENB		BIT(31)
>>  
>> +#define TSENSOR_SLOWDOWN	BIT(23)
>> +
>>  static struct tegra_clk_super_mux *cclk_super;
>>  static bool cclk_on_pllx;
>>  
>> @@ -47,10 +49,20 @@ static int cclk_super_set_rate(struct clk_hw *hw, unsigned long rate,
>>  static unsigned long cclk_super_recalc_rate(struct clk_hw *hw,
>>  					    unsigned long parent_rate)
>>  {
>> +	struct tegra_clk_super_mux *super = to_clk_super_mux(hw);
>> +	u32 val = readl_relaxed(super->reg);
>> +	unsigned int div2;
>> +
>> +	/* check whether thermal throttling is active */
>> +	if (val & TSENSOR_SLOWDOWN)
>> +		div2 = 2;
>> +	else
>> +		div2 = 1;
>> +
>>  	if (cclk_super_get_parent(hw) == PLLX_INDEX)
>> -		return parent_rate;
>> +		return parent_rate / div2;
>>  
>> -	return tegra_clk_super_ops.recalc_rate(hw, parent_rate);
>> +	return tegra_clk_super_ops.recalc_rate(hw, parent_rate) / div2;
>>  }
> 
> Could you check if the compiler can optimize out the division? I know this
> is a slow path, but nevertheless the 'shr' version would be the same amount
> of source code.

Hello Michał,

GCC can't optimize that division. I'll wait for more comments and then
update this patch in v8 with yours suggestion. Thank you for taking a
look at the patches.

  reply	other threads:[~2021-05-11 15:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-10 23:17 [PATCH v7 0/8] Couple improvements for Tegra clk driver Dmitry Osipenko
2021-05-10 23:17 ` [PATCH v7 1/8] clk: tegra30: Use 300MHz for video decoder by default Dmitry Osipenko
2021-05-10 23:17 ` [PATCH v7 2/8] clk: tegra: Fix refcounting of gate clocks Dmitry Osipenko
2021-05-10 23:17 ` [PATCH v7 3/8] clk: tegra: Ensure that PLLU configuration is applied properly Dmitry Osipenko
2021-05-10 23:17 ` [PATCH v7 4/8] clk: tegra: Halve SCLK rate on Tegra20 Dmitry Osipenko
2021-05-10 23:17 ` [PATCH v7 5/8] clk: tegra: Don't allow zero clock rate for PLLs Dmitry Osipenko
2021-05-10 23:17 ` [PATCH v7 6/8] clk: tegra: cclk: Handle thermal DIV2 CPU frequency throttling Dmitry Osipenko
2021-05-11 14:41   ` Michał Mirosław
2021-05-11 15:23     ` Dmitry Osipenko [this message]
2021-05-10 23:17 ` [PATCH v7 7/8] clk: tegra: Mark external clocks as not having reset control Dmitry Osipenko
2021-05-10 23:17 ` [PATCH v7 8/8] dt-bindings: clock: tegra: Convert to schema Dmitry Osipenko
2021-05-11 13:40   ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=04bc9e16-be7e-cf18-9fff-436dd063bf10@gmail.com \
    --to=digetx@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mirq-linux@rere.qmqm.pl \
    --cc=mturquette@baylibre.com \
    --cc=pdeschrijver@nvidia.com \
    --cc=pgaikwad@nvidia.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).