All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chanwoo Choi <cw00.choi@samsung.com>
To: "Dmitry Osipenko" <digetx@gmail.com>,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"MyungJoo Ham" <myungjoo.ham@samsung.com>,
	"Kyungmin Park" <kyungmin.park@samsung.com>,
	"Jonathan Hunter" <jonathanh@nvidia.com>,
	"Tomeu Vizoso" <tomeu.vizoso@collabora.com>,
	"Peter Geis" <pgwipeout@gmail.com>,
	"Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: linux-pm@vger.kernel.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v9 15/19] PM / devfreq: tegra30: Use kHz units for dependency threshold
Date: Tue, 5 Nov 2019 13:02:48 +0900	[thread overview]
Message-ID: <503e756b-4bed-2cd9-a167-2cabfd739fc3@samsung.com> (raw)
In-Reply-To: <20191104215617.25544-16-digetx@gmail.com>

On 19. 11. 5. 오전 6:56, Dmitry Osipenko wrote:
> The dependency threshold designates a memory activity level below which
> CPU's frequency isn't accounted. Currently the threshold is given in
> "memory cycle" units and that value depends on the polling interval which
> is fixed to 12ms in the driver. Later on we'd want to add support for a
> variable polling interval and thus the threshold value either needs to be
> scaled in accordance to the polling interval or it needs to be represented
> in a units that do not depend on the polling interval.
> 
> It is nicer to have threshold value being defined independently of the
> polling interval, thus this patch converts the dependency threshold units
> from "cycle" to "kHz". Having this change as a separate-preparatory patch
> will make easier to follow further patches.
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/devfreq/tegra30-devfreq.c | 30 +++++++++++++++++-------------
>  1 file changed, 17 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/devfreq/tegra30-devfreq.c b/drivers/devfreq/tegra30-devfreq.c
> index 852bde6249c7..3bd920829bfd 100644
> --- a/drivers/devfreq/tegra30-devfreq.c
> +++ b/drivers/devfreq/tegra30-devfreq.c
> @@ -96,9 +96,10 @@ struct tegra_devfreq_device_config {
>  	unsigned int	boost_down_threshold;
>  
>  	/*
> -	 * Threshold of activity (cycles) below which the CPU frequency isn't
> -	 * to be taken into account. This is to avoid increasing the EMC
> -	 * frequency when the CPU is very busy but not accessing the bus often.
> +	 * Threshold of activity (cycles translated to kHz) below which the
> +	 * CPU frequency isn't to be taken into account. This is to avoid
> +	 * increasing the EMC frequency when the CPU is very busy but not
> +	 * accessing the bus often.
>  	 */
>  	u32		avg_dependency_threshold;
>  };
> @@ -126,7 +127,7 @@ static const struct tegra_devfreq_device_config actmon_device_configs[] = {
>  		.boost_down_coeff = 90,
>  		.boost_up_threshold = 27,
>  		.boost_down_threshold = 10,
> -		.avg_dependency_threshold = 50000,
> +		.avg_dependency_threshold = 16000, /* 16MHz in kHz units */
>  	},
>  };
>  
> @@ -311,7 +312,6 @@ static unsigned long actmon_device_target_freq(struct tegra_devfreq *tegra,
>  	target_freq = dev->avg_count / ACTMON_SAMPLING_PERIOD;
>  	avg_sustain_coef = 100 * 100 / dev->config->boost_up_threshold;
>  	target_freq = do_percent(target_freq, avg_sustain_coef);
> -	target_freq += dev->boost_freq;
>  
>  	return target_freq;
>  }
> @@ -322,15 +322,18 @@ static void actmon_update_target(struct tegra_devfreq *tegra,
>  	unsigned long cpu_freq = 0;
>  	unsigned long static_cpu_emc_freq = 0;
>  
> -	if (dev->config->avg_dependency_threshold) {
> +	dev->target_freq = actmon_device_target_freq(tegra, dev);
> +
> +	if (dev->config->avg_dependency_threshold &&
> +	    dev->config->avg_dependency_threshold <= dev->target_freq) {
>  		cpu_freq = cpufreq_quick_get(0);
>  		static_cpu_emc_freq = actmon_cpu_to_emc_rate(tegra, cpu_freq);
> -	}
>  
> -	dev->target_freq = actmon_device_target_freq(tegra, dev);
> -
> -	if (dev->avg_count >= dev->config->avg_dependency_threshold)
> +		dev->target_freq += dev->boost_freq;
>  		dev->target_freq = max(dev->target_freq, static_cpu_emc_freq);
> +	} else {
> +		dev->target_freq += dev->boost_freq;
> +	}
>  }
>  
>  static irqreturn_t actmon_thread_isr(int irq, void *data)
> @@ -396,15 +399,16 @@ static unsigned long
>  tegra_actmon_cpufreq_contribution(struct tegra_devfreq *tegra,
>  				  unsigned int cpu_freq)
>  {
> +	struct tegra_devfreq_device *actmon_dev = &tegra->devices[MCCPU];
>  	unsigned long static_cpu_emc_freq, dev_freq;
>  
> +	dev_freq = actmon_device_target_freq(tegra, actmon_dev);
> +
>  	/* check whether CPU's freq is taken into account at all */
> -	if (tegra->devices[MCCPU].avg_count <
> -	    tegra->devices[MCCPU].config->avg_dependency_threshold)
> +	if (dev_freq < actmon_dev->config->avg_dependency_threshold)
>  		return 0;
>  
>  	static_cpu_emc_freq = actmon_cpu_to_emc_rate(tegra, cpu_freq);
> -	dev_freq = actmon_device_target_freq(tegra, &tegra->devices[MCCPU]);
>  
>  	if (dev_freq >= static_cpu_emc_freq)
>  		return 0;
> 

Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

  reply	other threads:[~2019-11-05  4:02 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-04 21:55 [PATCH v9 00/19] More improvements for Tegra30 devfreq driver Dmitry Osipenko
2019-11-04 21:55 ` [PATCH v9 01/19] PM / devfreq: tegra30: Change irq type to unsigned int Dmitry Osipenko
2019-11-04 21:56 ` [PATCH v9 02/19] PM / devfreq: tegra30: Keep interrupt disabled while governor is stopped Dmitry Osipenko
2019-11-04 21:56 ` [PATCH v9 03/19] PM / devfreq: tegra30: Handle possible round-rate error Dmitry Osipenko
2019-11-04 21:56 ` [PATCH v9 04/19] PM / devfreq: tegra30: Drop write-barrier Dmitry Osipenko
2019-11-04 21:56 ` [PATCH v9 05/19] PM / devfreq: tegra30: Fix integer overflow on CPU's freq max out Dmitry Osipenko
2019-11-04 21:56 ` [PATCH v9 06/19] PM / devfreq: tegra30: Use kHz units uniformly in the code Dmitry Osipenko
2019-11-04 21:56 ` [PATCH v9 07/19] PM / devfreq: tegra30: Use CPUFreq notifier Dmitry Osipenko
2019-11-04 21:56 ` [PATCH v9 08/19] PM / devfreq: tegra30: Move clk-notifier's registration to governor's start Dmitry Osipenko
2019-11-04 21:56 ` [PATCH v9 09/19] PM / devfreq: tegra30: Reset boosting on startup Dmitry Osipenko
2019-11-04 21:56 ` [PATCH v9 10/19] PM / devfreq: tegra30: Don't enable consecutive-down interrupt " Dmitry Osipenko
2019-11-04 21:56 ` [PATCH v9 11/19] PM / devfreq: tegra30: Constify structs Dmitry Osipenko
2019-11-04 21:56 ` [PATCH v9 12/19] PM / devfreq: tegra30: Include appropriate header Dmitry Osipenko
2019-11-04 21:56 ` [PATCH v9 13/19] PM / devfreq: tegra30: Don't enable already enabled consecutive interrupts Dmitry Osipenko
2019-11-04 21:56 ` [PATCH v9 14/19] PM / devfreq: tegra30: Disable consecutive interrupts when appropriate Dmitry Osipenko
2019-11-04 21:56 ` [PATCH v9 15/19] PM / devfreq: tegra30: Use kHz units for dependency threshold Dmitry Osipenko
2019-11-05  4:02   ` Chanwoo Choi [this message]
2019-11-04 21:56 ` [PATCH v9 16/19] PM / devfreq: Add new interrupt_driven flag for governors Dmitry Osipenko
2019-11-05  4:01   ` Chanwoo Choi
2019-11-04 21:56 ` [PATCH v9 17/19] PM / devfreq: tegra30: Support variable polling interval Dmitry Osipenko
2019-11-05  4:02   ` Chanwoo Choi
2019-11-04 21:56 ` [PATCH v9 18/19] PM / devfreq: tegra30: Tune up MCCPU boost-down coefficient Dmitry Osipenko
2019-11-04 21:56 ` [PATCH v9 19/19] PM / devfreq: tegra20/30: Add Dmitry as a maintainer Dmitry Osipenko
2019-11-05  4:07   ` Chanwoo Choi
2019-11-05 13:29     ` Dmitry Osipenko
2019-11-06  1:24       ` Chanwoo Choi
2019-11-06 16:14         ` Dmitry Osipenko

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=503e756b-4bed-2cd9-a167-2cabfd739fc3@samsung.com \
    --to=cw00.choi@samsung.com \
    --cc=digetx@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mirq-linux@rere.qmqm.pl \
    --cc=myungjoo.ham@samsung.com \
    --cc=pgwipeout@gmail.com \
    --cc=thierry.reding@gmail.com \
    --cc=tomeu.vizoso@collabora.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.