All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tero Kristo <t-kristo@ti.com>
To: Tony Lindgren <tony@atomide.com>, Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org,
	Mike Turquette <mturquette@linaro.org>,
	Paul Walmsley <paul@pwsan.com>
Subject: Re: [PATCH 2/2] ARM: OMAP2+: fix dpll round_rate() to actually round
Date: Fri, 14 Feb 2014 15:32:18 +0200	[thread overview]
Message-ID: <52FE1AE2.8010902@ti.com> (raw)
In-Reply-To: <20140213230011.GH28216@atomide.com>

On 02/14/2014 01:00 AM, Tony Lindgren wrote:
> * Tomi Valkeinen <tomi.valkeinen@ti.com> [140116 23:47]:
>> omap2_dpll_round_rate() doesn't actually round the given rate, even if
>> the name and the description so hints. Instead it only tries to find an
>> exact rate match, or if that fails, return ~0 as an error.
>>
>> What this basically means is that the user of the clock needs to know
>> what rates the dpll can support, which obviously isn't right.
>>
>> This patch adds a simple method of rounding: during the iteration, the
>> code keeps track of the closest rate match. If no exact match is found,
>> the closest is returned.
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
>
> Paul & Tero, please ack if you want me to queue this.

The patches look good to me and based on quick testing they don't seem 
to cause any visible problems (namely this one), so acked.

-Tero

>
> Tony
>
>> ---
>>   arch/arm/mach-omap2/clkt_dpll.c | 17 ++++++++++++-----
>>   1 file changed, 12 insertions(+), 5 deletions(-)
>>
>> diff --git a/arch/arm/mach-omap2/clkt_dpll.c b/arch/arm/mach-omap2/clkt_dpll.c
>> index 1f1708ef77bb..1b4e68dfb713 100644
>> --- a/arch/arm/mach-omap2/clkt_dpll.c
>> +++ b/arch/arm/mach-omap2/clkt_dpll.c
>> @@ -298,6 +298,7 @@ long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate,
>>   	struct dpll_data *dd;
>>   	unsigned long ref_rate;
>>   	const char *clk_name;
>> +	unsigned long diff, closest_diff = ~0;
>>
>>   	if (!clk || !clk->dpll_data)
>>   		return ~0;
>> @@ -345,20 +346,26 @@ long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate,
>>   		pr_debug("clock: %s: m = %d: n = %d: new_rate = %lu\n",
>>   			 clk_name, m, n, new_rate);
>>
>> -		if (target_rate == new_rate) {
>> +		diff = max(target_rate, new_rate) - min(target_rate, new_rate);
>> +
>> +		if (diff < closest_diff) {
>> +			closest_diff = diff;
>> +
>>   			dd->last_rounded_m = m;
>>   			dd->last_rounded_n = n;
>> -			dd->last_rounded_rate = target_rate;
>> -			break;
>> +			dd->last_rounded_rate = new_rate;
>> +
>> +			if (diff == 0)
>> +				break;
>>   		}
>>   	}
>>
>> -	if (target_rate != new_rate) {
>> +	if (closest_diff == ~0) {
>>   		pr_debug("clock: %s: cannot round to rate %lu\n",
>>   			 clk_name, target_rate);
>>   		return ~0;
>>   	}
>>
>> -	return target_rate;
>> +	return dd->last_rounded_rate;
>>   }
>>
>> --
>> 1.8.3.2
>>


WARNING: multiple messages have this Message-ID (diff)
From: t-kristo@ti.com (Tero Kristo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] ARM: OMAP2+: fix dpll round_rate() to actually round
Date: Fri, 14 Feb 2014 15:32:18 +0200	[thread overview]
Message-ID: <52FE1AE2.8010902@ti.com> (raw)
In-Reply-To: <20140213230011.GH28216@atomide.com>

On 02/14/2014 01:00 AM, Tony Lindgren wrote:
> * Tomi Valkeinen <tomi.valkeinen@ti.com> [140116 23:47]:
>> omap2_dpll_round_rate() doesn't actually round the given rate, even if
>> the name and the description so hints. Instead it only tries to find an
>> exact rate match, or if that fails, return ~0 as an error.
>>
>> What this basically means is that the user of the clock needs to know
>> what rates the dpll can support, which obviously isn't right.
>>
>> This patch adds a simple method of rounding: during the iteration, the
>> code keeps track of the closest rate match. If no exact match is found,
>> the closest is returned.
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
>
> Paul & Tero, please ack if you want me to queue this.

The patches look good to me and based on quick testing they don't seem 
to cause any visible problems (namely this one), so acked.

-Tero

>
> Tony
>
>> ---
>>   arch/arm/mach-omap2/clkt_dpll.c | 17 ++++++++++++-----
>>   1 file changed, 12 insertions(+), 5 deletions(-)
>>
>> diff --git a/arch/arm/mach-omap2/clkt_dpll.c b/arch/arm/mach-omap2/clkt_dpll.c
>> index 1f1708ef77bb..1b4e68dfb713 100644
>> --- a/arch/arm/mach-omap2/clkt_dpll.c
>> +++ b/arch/arm/mach-omap2/clkt_dpll.c
>> @@ -298,6 +298,7 @@ long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate,
>>   	struct dpll_data *dd;
>>   	unsigned long ref_rate;
>>   	const char *clk_name;
>> +	unsigned long diff, closest_diff = ~0;
>>
>>   	if (!clk || !clk->dpll_data)
>>   		return ~0;
>> @@ -345,20 +346,26 @@ long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate,
>>   		pr_debug("clock: %s: m = %d: n = %d: new_rate = %lu\n",
>>   			 clk_name, m, n, new_rate);
>>
>> -		if (target_rate == new_rate) {
>> +		diff = max(target_rate, new_rate) - min(target_rate, new_rate);
>> +
>> +		if (diff < closest_diff) {
>> +			closest_diff = diff;
>> +
>>   			dd->last_rounded_m = m;
>>   			dd->last_rounded_n = n;
>> -			dd->last_rounded_rate = target_rate;
>> -			break;
>> +			dd->last_rounded_rate = new_rate;
>> +
>> +			if (diff == 0)
>> +				break;
>>   		}
>>   	}
>>
>> -	if (target_rate != new_rate) {
>> +	if (closest_diff == ~0) {
>>   		pr_debug("clock: %s: cannot round to rate %lu\n",
>>   			 clk_name, target_rate);
>>   		return ~0;
>>   	}
>>
>> -	return target_rate;
>> +	return dd->last_rounded_rate;
>>   }
>>
>> --
>> 1.8.3.2
>>

  reply	other threads:[~2014-02-14 13:32 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-17  7:44 [PATCH 0/2] ARM: OMAP2+: Fix dpll rounding Tomi Valkeinen
2014-01-17  7:44 ` Tomi Valkeinen
2014-01-17  7:44 ` [PATCH 1/2] ARM: OMAP2+: fix rate prints Tomi Valkeinen
2014-01-17  7:44   ` Tomi Valkeinen
2014-02-19 19:25   ` Paul Walmsley
2014-02-19 19:25     ` Paul Walmsley
2014-01-17  7:44 ` [PATCH 2/2] ARM: OMAP2+: fix dpll round_rate() to actually round Tomi Valkeinen
2014-01-17  7:44   ` Tomi Valkeinen
2014-02-13 23:00   ` Tony Lindgren
2014-02-13 23:00     ` Tony Lindgren
2014-02-14 13:32     ` Tero Kristo [this message]
2014-02-14 13:32       ` Tero Kristo
2014-02-19 19:49   ` Paul Walmsley
2014-02-19 19:49     ` Paul Walmsley
2014-02-20 19:30     ` Paul Walmsley
2014-02-20 19:30       ` Paul Walmsley
2014-02-26 11:48       ` Tomi Valkeinen
2014-02-26 11:48         ` Tomi Valkeinen
2014-03-05 13:50       ` Tomi Valkeinen
2014-03-05 13:50         ` Tomi Valkeinen
2014-04-30 15:38         ` Felipe Balbi
2014-04-30 15:38           ` Felipe Balbi
2014-04-30 15:40         ` Nishanth Menon
2014-04-30 15:40           ` Nishanth Menon
2014-02-26 11:42     ` Tomi Valkeinen
2014-02-26 11:42       ` Tomi Valkeinen
2014-04-24 18:34       ` Felipe Balbi
2014-04-24 18:34         ` Felipe Balbi
2014-04-24 18:29   ` Felipe Balbi
2014-04-24 18:29     ` Felipe Balbi
2014-04-24 18:44     ` Tony Lindgren
2014-04-24 18:44       ` Tony Lindgren
2014-04-29 15:51       ` Felipe Balbi
2014-04-29 15:51         ` Felipe Balbi
2014-04-29 16:27         ` Tomi Valkeinen
2014-04-29 16:27           ` Tomi Valkeinen
2014-05-07 22:16           ` Paul Walmsley
2014-05-07 22:16             ` Paul Walmsley
2014-05-12 12:11             ` Tomi Valkeinen
2014-05-12 12:11               ` Tomi Valkeinen

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=52FE1AE2.8010902@ti.com \
    --to=t-kristo@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mturquette@linaro.org \
    --cc=paul@pwsan.com \
    --cc=tomi.valkeinen@ti.com \
    --cc=tony@atomide.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.