linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Valentin <edubezval@gmail.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Rafael Wysocki <rjw@rjwysocki.net>,
	linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org,
	l.majewski@samsung.com
Subject: Re: [PATCH] cpufreq-dt: register cooling device after validating cpufreq table
Date: Mon, 24 Nov 2014 14:10:51 -0400	[thread overview]
Message-ID: <20141124181049.GB1449@developer> (raw)
In-Reply-To: <b4a56cad08c5ef701cf268881697caabe5229994.1416826729.git.viresh.kumar@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 3899 bytes --]

Viresh

On Mon, Nov 24, 2014 at 04:29:13PM +0530, Viresh Kumar wrote:
> of_cpufreq_cooling_register() can use frequency values from
> policy->min/max/cpuinfo.min_freq/cpuinfo.max_freq, which are available only
> after calling cpufreq_table_validate_and_show().
> 
> The right order of calling should be: cpufreq_table_validate_and_show() followed
> by of_cpufreq_cooling_register(). Fix it.
> 
> Reported-by: Lukasz Majewski <l.majewski@samsung.com>
> Reported-by: Eduardo Valentin <edubezval@gmail.com>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> 
> ---
> For 3.18.
> ---
>  drivers/cpufreq/cpufreq-dt.c | 35 +++++++++++++++++------------------
>  1 file changed, 17 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
> index 8cba13d..22eb6e5 100644
> --- a/drivers/cpufreq/cpufreq-dt.c
> +++ b/drivers/cpufreq/cpufreq-dt.c
> @@ -186,7 +186,6 @@ static int cpufreq_init(struct cpufreq_policy *policy)
>  {
>  	struct cpufreq_dt_platform_data *pd;
>  	struct cpufreq_frequency_table *freq_table;
> -	struct thermal_cooling_device *cdev;
>  	struct device_node *np;
>  	struct private_data *priv;
>  	struct device *cpu_dev;
> @@ -269,20 +268,6 @@ static int cpufreq_init(struct cpufreq_policy *policy)
>  		goto out_free_priv;
>  	}
>  
> -	/*
> -	 * For now, just loading the cooling device;
> -	 * thermal DT code takes care of matching them.
> -	 */
> -	if (of_find_property(np, "#cooling-cells", NULL)) {
> -		cdev = of_cpufreq_cooling_register(np, cpu_present_mask);
> -		if (IS_ERR(cdev))
> -			dev_err(cpu_dev,
> -				"running cpufreq without cooling device: %ld\n",
> -				PTR_ERR(cdev));
> -		else
> -			priv->cdev = cdev;
> -	}
> -
>  	priv->cpu_dev = cpu_dev;
>  	priv->cpu_reg = cpu_reg;
>  	policy->driver_data = priv;
> @@ -292,7 +277,22 @@ static int cpufreq_init(struct cpufreq_policy *policy)
>  	if (ret) {
>  		dev_err(cpu_dev, "%s: invalid frequency table: %d\n", __func__,
>  			ret);
> -		goto out_cooling_unregister;
> +		goto out_free_cpufreq_table;
> +	}
> +
> +	/*
> +	 * For now, just loading the cooling device;
> +	 * thermal DT code takes care of matching them.
> +	 */
> +	if (of_find_property(np, "#cooling-cells", NULL)) {
> +		priv->cdev = of_cpufreq_cooling_register(np, cpu_present_mask);
> +		if (IS_ERR(priv->cdev)) {
> +			dev_err(cpu_dev,
> +				"running cpufreq without cooling device: %ld\n",
> +				PTR_ERR(priv->cdev));
> +
> +			priv->cdev = NULL;
> +		}

Is it possible to have this registration only when we have a
cpufreq driver up and running? The reasoning is that only after we have
a way to control cpu frequencies, it makes sense to have the cpu_cooling
device.

I am planing to have the following check in the cpu cooling code:
	if (!cpufreq_get_current_driver()) {
		dev_dbg(bgp->dev, "no cpufreq driver yet\n");
		return -EPROBE_DEFER;
	}

that is the way I think of checking if the cpufreq layer is ready to
have a cpu cooling on top of it. Currently, thermal drivers check this
before calling cpu cooling registration. But instead of having this
check in every driver, I would like to move it to cpu cooling.

However, for cpufreq-dt, the registration currently happens in the
init phase, not in probe, so cpufreq driver is not registered, and thus
the check won't work.

In this way, I believe the sequencing between cpu cooling and cpufreq-dt
would work fine.


>  	}
>  
>  	policy->cpuinfo.transition_latency = transition_latency;
> @@ -305,8 +305,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
>  
>  	return 0;
>  
> -out_cooling_unregister:
> -	cpufreq_cooling_unregister(priv->cdev);
> +out_free_cpufreq_table:
>  	dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
>  out_free_priv:
>  	kfree(priv);
> -- 
> 2.0.3.693.g996b0fd
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2014-11-24 18:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-24 10:59 [PATCH] cpufreq-dt: register cooling device after validating cpufreq table Viresh Kumar
2014-11-24 18:10 ` Eduardo Valentin [this message]
2014-11-25 10:57   ` Viresh Kumar
2014-11-25  1:44     ` Eduardo Valentin
2014-11-25 15:26       ` Viresh Kumar
2014-11-25 20:47         ` Rafael J. Wysocki
2014-11-26  3:28           ` Viresh Kumar
2014-11-25 10:56 ` Lukasz Majewski
2014-11-25 21:49 ` Rafael J. Wysocki
2014-11-25 22:05   ` Rafael J. Wysocki
2014-11-26  5:57     ` Viresh Kumar
2014-11-26  6:02       ` Viresh Kumar
2014-11-26 15:10       ` Eduardo Valentin
2014-11-26 22:57         ` Rafael J. Wysocki
2014-11-26  3:30   ` Viresh Kumar

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=20141124181049.GB1449@developer \
    --to=edubezval@gmail.com \
    --cc=l.majewski@samsung.com \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=viresh.kumar@linaro.org \
    /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).