All of lore.kernel.org
 help / color / mirror / Atom feed
From: tomeu.vizoso@collabora.com (Tomeu Vizoso)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v7 3/8] cpufreq: kirkwood: Remove use of the clk provider API
Date: Thu, 21 Aug 2014 09:53:43 +0200	[thread overview]
Message-ID: <53F5A587.9030200@collabora.com> (raw)
In-Reply-To: <20140820225513.5251.284@quantum>

On 08/21/2014 12:55 AM, Mike Turquette wrote:
> Quoting Tomeu Vizoso (2014-08-18 08:30:29)
>> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
>> ---
>>   drivers/cpufreq/kirkwood-cpufreq.c | 3 +--
>>   1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
>> index 37a4806..f3d087f 100644
>> --- a/drivers/cpufreq/kirkwood-cpufreq.c
>> +++ b/drivers/cpufreq/kirkwood-cpufreq.c
>> @@ -12,7 +12,6 @@
>>   #include <linux/kernel.h>
>>   #include <linux/module.h>
>>   #include <linux/clk.h>
>> -#include <linux/clk-provider.h>
>>   #include <linux/cpufreq.h>
>>   #include <linux/of_device.h>
>>   #include <linux/platform_device.h>
>> @@ -50,7 +49,7 @@ static struct cpufreq_frequency_table kirkwood_freq_table[] = {
>>
>>   static unsigned int kirkwood_cpufreq_get_cpu_frequency(unsigned int cpu)
>>   {
>> -       if (__clk_is_enabled(priv.powersave_clk))
>> +       if (clk_is_enabled(priv.powersave_clk))
>>                  return kirkwood_freq_table[1].frequency;
>>          return kirkwood_freq_table[0].frequency;
>>   }
>> --
>> 1.9.3
>>
>
> Tomeu,
>
> After taking a second look at clk_is_enabled and the Kirkwood driver, I
> would prefer to not implement clk_is_enabled. The main reason is that it
> is racey, since the clock's status could of course change as soon as as
> that call completes. Furthermore I am worried that drivers might do
> something like:
>
> if (!clk_is_enabled(clk))
> 	clk_enable(clk);
>
> Which is crap and the driver should just call clk_enable any time it
> needs the clock. To that end I propose to drop "clk: provide public
> clk_is_enabled function" and replace your update to kirkwood-cpufreq.c
> with the following patch. Let me know what you think.

Yep, this looks much better to me. I will replace 2/8 and 3/8 with this 
one for v8.

Reviewed-By: Tomeu Vizoso <tomeu.vizoso@collabora.com>

Thanks!

Tomeu

> Regards,
> Mike
>
>
>
>  From 713b46fd66abd26a4e4d584a0b8a2a28c0459a60 Mon Sep 17 00:00:00 2001
> From: Mike Turquette <mturquette@linaro.org>
> Date: Mon, 18 Aug 2014 17:30:29 +0200
> Subject: [PATCH] cpufreq: kirkwood: Remove use of the clk provider API
>
> Instead of checking the clock framework to see if the clock is enabled,
> track the cpu frequency within the driver as the powersave_clk is
> enabled and disabled.
>
> Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Mike Turquette <mturquette@linaro.org>
> ---
>   drivers/cpufreq/kirkwood-cpufreq.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
> index 37a4806..88f4641 100644
> --- a/drivers/cpufreq/kirkwood-cpufreq.c
> +++ b/drivers/cpufreq/kirkwood-cpufreq.c
> @@ -12,7 +12,6 @@
>   #include <linux/kernel.h>
>   #include <linux/module.h>
>   #include <linux/clk.h>
> -#include <linux/clk-provider.h>
>   #include <linux/cpufreq.h>
>   #include <linux/of_device.h>
>   #include <linux/platform_device.h>
> @@ -33,6 +32,8 @@ static struct priv
>   #define STATE_CPU_FREQ 0x01
>   #define STATE_DDR_FREQ 0x02
>
> +static unsigned long cpu_frequency = 0;
> +
>   /*
>    * Kirkwood can swap the clock to the CPU between two clocks:
>    *
> @@ -50,9 +51,7 @@ static struct cpufreq_frequency_table kirkwood_freq_table[] = {
>
>   static unsigned int kirkwood_cpufreq_get_cpu_frequency(unsigned int cpu)
>   {
> -	if (__clk_is_enabled(priv.powersave_clk))
> -		return kirkwood_freq_table[1].frequency;
> -	return kirkwood_freq_table[0].frequency;
> +	return cpu_frequency;
>   }
>
>   static int kirkwood_cpufreq_target(struct cpufreq_policy *policy,
> @@ -71,9 +70,11 @@ static int kirkwood_cpufreq_target(struct cpufreq_policy *policy,
>   	switch (state) {
>   	case STATE_CPU_FREQ:
>   		clk_disable(priv.powersave_clk);
> +		cpu_frequency = kirkwood_freq_table[0].frequency;
>   		break;
>   	case STATE_DDR_FREQ:
>   		clk_enable(priv.powersave_clk);
> +		cpu_frequency = kirkwood_freq_table[1].frequency;
>   		break;
>   	}
>
> @@ -133,6 +134,7 @@ static int kirkwood_cpufreq_probe(struct platform_device *pdev)
>
>   	clk_prepare_enable(priv.cpu_clk);
>   	kirkwood_freq_table[0].frequency = clk_get_rate(priv.cpu_clk) / 1000;
> +	cpu_frequency = kirkwood_freq_table[0].frequency;
>
>   	priv.ddr_clk = of_clk_get_by_name(np, "ddrclk");
>   	if (IS_ERR(priv.ddr_clk)) {
>

WARNING: multiple messages have this Message-ID (diff)
From: Tomeu Vizoso <tomeu.vizoso@collabora.com>
To: Mike Turquette <mturquette@linaro.org>
Cc: Stephen Warren <swarren@wwwdotorg.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Javier Martinez Canillas <javier.martinez@collabora.co.uk>,
	Rabin Vincent <rabin@rab.in>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Tomasz Figa <t.figa@samsung.com>,
	Peter De Schrijver <pdeschrijver@nvidia.com>
Subject: Re: [PATCH v7 3/8] cpufreq: kirkwood: Remove use of the clk provider API
Date: Thu, 21 Aug 2014 09:53:43 +0200	[thread overview]
Message-ID: <53F5A587.9030200@collabora.com> (raw)
In-Reply-To: <20140820225513.5251.284@quantum>

On 08/21/2014 12:55 AM, Mike Turquette wrote:
> Quoting Tomeu Vizoso (2014-08-18 08:30:29)
>> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
>> ---
>>   drivers/cpufreq/kirkwood-cpufreq.c | 3 +--
>>   1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
>> index 37a4806..f3d087f 100644
>> --- a/drivers/cpufreq/kirkwood-cpufreq.c
>> +++ b/drivers/cpufreq/kirkwood-cpufreq.c
>> @@ -12,7 +12,6 @@
>>   #include <linux/kernel.h>
>>   #include <linux/module.h>
>>   #include <linux/clk.h>
>> -#include <linux/clk-provider.h>
>>   #include <linux/cpufreq.h>
>>   #include <linux/of_device.h>
>>   #include <linux/platform_device.h>
>> @@ -50,7 +49,7 @@ static struct cpufreq_frequency_table kirkwood_freq_table[] = {
>>
>>   static unsigned int kirkwood_cpufreq_get_cpu_frequency(unsigned int cpu)
>>   {
>> -       if (__clk_is_enabled(priv.powersave_clk))
>> +       if (clk_is_enabled(priv.powersave_clk))
>>                  return kirkwood_freq_table[1].frequency;
>>          return kirkwood_freq_table[0].frequency;
>>   }
>> --
>> 1.9.3
>>
>
> Tomeu,
>
> After taking a second look at clk_is_enabled and the Kirkwood driver, I
> would prefer to not implement clk_is_enabled. The main reason is that it
> is racey, since the clock's status could of course change as soon as as
> that call completes. Furthermore I am worried that drivers might do
> something like:
>
> if (!clk_is_enabled(clk))
> 	clk_enable(clk);
>
> Which is crap and the driver should just call clk_enable any time it
> needs the clock. To that end I propose to drop "clk: provide public
> clk_is_enabled function" and replace your update to kirkwood-cpufreq.c
> with the following patch. Let me know what you think.

Yep, this looks much better to me. I will replace 2/8 and 3/8 with this 
one for v8.

Reviewed-By: Tomeu Vizoso <tomeu.vizoso@collabora.com>

Thanks!

Tomeu

> Regards,
> Mike
>
>
>
>  From 713b46fd66abd26a4e4d584a0b8a2a28c0459a60 Mon Sep 17 00:00:00 2001
> From: Mike Turquette <mturquette@linaro.org>
> Date: Mon, 18 Aug 2014 17:30:29 +0200
> Subject: [PATCH] cpufreq: kirkwood: Remove use of the clk provider API
>
> Instead of checking the clock framework to see if the clock is enabled,
> track the cpu frequency within the driver as the powersave_clk is
> enabled and disabled.
>
> Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Mike Turquette <mturquette@linaro.org>
> ---
>   drivers/cpufreq/kirkwood-cpufreq.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
> index 37a4806..88f4641 100644
> --- a/drivers/cpufreq/kirkwood-cpufreq.c
> +++ b/drivers/cpufreq/kirkwood-cpufreq.c
> @@ -12,7 +12,6 @@
>   #include <linux/kernel.h>
>   #include <linux/module.h>
>   #include <linux/clk.h>
> -#include <linux/clk-provider.h>
>   #include <linux/cpufreq.h>
>   #include <linux/of_device.h>
>   #include <linux/platform_device.h>
> @@ -33,6 +32,8 @@ static struct priv
>   #define STATE_CPU_FREQ 0x01
>   #define STATE_DDR_FREQ 0x02
>
> +static unsigned long cpu_frequency = 0;
> +
>   /*
>    * Kirkwood can swap the clock to the CPU between two clocks:
>    *
> @@ -50,9 +51,7 @@ static struct cpufreq_frequency_table kirkwood_freq_table[] = {
>
>   static unsigned int kirkwood_cpufreq_get_cpu_frequency(unsigned int cpu)
>   {
> -	if (__clk_is_enabled(priv.powersave_clk))
> -		return kirkwood_freq_table[1].frequency;
> -	return kirkwood_freq_table[0].frequency;
> +	return cpu_frequency;
>   }
>
>   static int kirkwood_cpufreq_target(struct cpufreq_policy *policy,
> @@ -71,9 +70,11 @@ static int kirkwood_cpufreq_target(struct cpufreq_policy *policy,
>   	switch (state) {
>   	case STATE_CPU_FREQ:
>   		clk_disable(priv.powersave_clk);
> +		cpu_frequency = kirkwood_freq_table[0].frequency;
>   		break;
>   	case STATE_DDR_FREQ:
>   		clk_enable(priv.powersave_clk);
> +		cpu_frequency = kirkwood_freq_table[1].frequency;
>   		break;
>   	}
>
> @@ -133,6 +134,7 @@ static int kirkwood_cpufreq_probe(struct platform_device *pdev)
>
>   	clk_prepare_enable(priv.cpu_clk);
>   	kirkwood_freq_table[0].frequency = clk_get_rate(priv.cpu_clk) / 1000;
> +	cpu_frequency = kirkwood_freq_table[0].frequency;
>
>   	priv.ddr_clk = of_clk_get_by_name(np, "ddrclk");
>   	if (IS_ERR(priv.ddr_clk)) {
>


  parent reply	other threads:[~2014-08-21  7:53 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-18 15:30 [PATCH v7 0/8] Per-user clock constraints Tomeu Vizoso
2014-08-18 15:30 ` Tomeu Vizoso
2014-08-18 15:30 ` [PATCH v7 1/8] clk: Add temporary mapping to the existing API Tomeu Vizoso
2014-08-18 15:30   ` Tomeu Vizoso
2014-08-20 14:50   ` Mike Turquette
2014-08-21 18:04     ` Tony Lindgren
2014-08-21 18:04       ` Tony Lindgren
2014-08-21 18:10       ` Jason Cooper
2014-08-21 18:10         ` Jason Cooper
2014-08-22  3:49         ` Simon Horman
2014-08-22  3:49           ` Simon Horman
2014-08-25  9:18         ` Sebastian Hesselbarth
2014-08-25  9:18           ` Sebastian Hesselbarth
2014-08-18 15:30 ` [PATCH v7 2/8] clk: provide public clk_is_enabled function Tomeu Vizoso
2014-08-18 15:30   ` Tomeu Vizoso
2014-08-18 15:30 ` [PATCH v7 3/8] cpufreq: kirkwood: Remove use of the clk provider API Tomeu Vizoso
2014-08-18 15:30   ` Tomeu Vizoso
     [not found]   ` <20140820225513.5251.284@quantum>
2014-08-21  7:53     ` Tomeu Vizoso [this message]
2014-08-21  7:53       ` Tomeu Vizoso
2014-08-21 13:38       ` Andrew Lunn
2014-08-21 13:38         ` Andrew Lunn
2014-08-22 19:29         ` Mike Turquette
2014-08-22 19:29           ` Mike Turquette
2014-08-22 20:11           ` Andrew Lunn
2014-08-22 20:11             ` Andrew Lunn
2014-08-22 20:27             ` Andrew Lunn
2014-08-22 20:27               ` Andrew Lunn
2014-08-26 21:46             ` Mike Turquette
2014-08-26 22:36               ` Andrew Lunn
2014-08-26 22:36                 ` Andrew Lunn
2014-08-26 23:30                 ` Mike Turquette
2014-08-27  0:35                   ` Andrew Lunn
2014-08-27  0:35                     ` Andrew Lunn
2014-08-27  5:04                     ` Mike Turquette
2014-08-27  5:04                       ` Mike Turquette
2014-08-27 15:58                   ` Jason Gunthorpe
2014-08-27 15:58                     ` Jason Gunthorpe
2014-08-18 15:30 ` [PATCH v7 4/8] ASoC: mxs-saif: fix mixed use of public and provider clk API Tomeu Vizoso
2014-08-18 15:30   ` Tomeu Vizoso
2014-08-18 15:30 ` [PATCH v7 6/8] clk: use struct clk only for external API Tomeu Vizoso
2014-08-18 15:30   ` Tomeu Vizoso
2014-08-18 15:30 ` [PATCH v7 7/8] clk: per-user clock accounting for debug Tomeu Vizoso
2014-08-18 15:30   ` Tomeu Vizoso
2014-08-27 20:54   ` Mike Turquette
2014-08-18 15:30 ` [PATCH v7 8/8] clk: Add floor and ceiling constraints to clock rates Tomeu Vizoso
2014-08-18 15:30   ` Tomeu Vizoso
2014-08-21  2:12 ` [PATCH v7 0/8] Per-user clock constraints Andrew Lunn
2014-08-21  2:12   ` Andrew Lunn
2014-08-21  7:10   ` Tomeu Vizoso
2014-08-21  7:10     ` Tomeu Vizoso
2014-08-26 13:20 ` Heiko Stübner
2014-08-26 13:20   ` Heiko Stübner

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=53F5A587.9030200@collabora.com \
    --to=tomeu.vizoso@collabora.com \
    --cc=linux-arm-kernel@lists.infradead.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 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.