2010-11-12 12:39:54

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH] [ARM] twd: Allow twd rescaling to match cpu frequency

Hi Colin,

2010/9/2 Colin Cross <[email protected]>:

> The clock to the ARM TWD local timer scales with the cpu
> frequency. ?To allow the cpu frequency to change while
> maintaining a constant TWD frequency, pick a lower target
> frequency for the TWD and use the prescaler to divide down
> to the closest lower frequency.
>
> This patch provides a new initialization function that takes
> a target TWD frequency and the relation between the cpu
> clock and the TWD clock, required to be an integer divider
>>= 2 by the ARM spec. ?It also provides a function to be
> called from cpufreq drivers to set the prescaler whenever
> the cpu frequency changes.

What's the status of this patch?

We have basically the same problem so we'd really like
a generic solution to this problem.

Our only comment is that we cannot see the reason for
not using the CPUfreq notifiers as most scaling code
is, but I assume there is some specific reason for this?

Unless something holds this back, could you post it to
Russells patch tracker, we might have an add-on patch
for the U8500 later.

Yours,
Linus Walleij


2010-11-12 12:53:32

by Harald Gustafsson

[permalink] [raw]
Subject: RE: [PATCH] [ARM] twd: Allow twd rescaling to match cpu frequency

Hi,

Don't forget the other patches to make this work:

[ARM] twd: Always calibrate local timer
[ARM] twd: Fix updating control register in set_mode
[ARM] twd: Fix prescaler getting cleared by set_mode

/Harald Gustafsson
________________________________________
From: Linus Walleij [[email protected]]
Sent: Friday, November 12, 2010 1:39 PM
To: Colin Cross
Cc: [email protected]; [email protected]; Russell King; srinidhi kasagar; Varun Swara; Catalin Marinas; Harald Gustafsson; Rickard ANDERSSON
Subject: Re: [PATCH] [ARM] twd: Allow twd rescaling to match cpu frequency

Hi Colin,

2010/9/2 Colin Cross <[email protected]>:

> The clock to the ARM TWD local timer scales with the cpu
> frequency. To allow the cpu frequency to change while
> maintaining a constant TWD frequency, pick a lower target
> frequency for the TWD and use the prescaler to divide down
> to the closest lower frequency.
>
> This patch provides a new initialization function that takes
> a target TWD frequency and the relation between the cpu
> clock and the TWD clock, required to be an integer divider
>>= 2 by the ARM spec. It also provides a function to be
> called from cpufreq drivers to set the prescaler whenever
> the cpu frequency changes.

What's the status of this patch?

We have basically the same problem so we'd really like
a generic solution to this problem.

Our only comment is that we cannot see the reason for
not using the CPUfreq notifiers as most scaling code
is, but I assume there is some specific reason for this?

Unless something holds this back, could you post it to
Russells patch tracker, we might have an add-on patch
for the U8500 later.

Yours,
Linus Walleij

2010-11-12 12:59:21

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH] [ARM] twd: Allow twd rescaling to match cpu frequency

On Fri, Nov 12, 2010 at 01:49:50PM +0100, Harald Gustafsson wrote:
> Hi,
>
> Don't forget the other patches to make this work:
>
> [ARM] twd: Always calibrate local timer
> [ARM] twd: Fix updating control register in set_mode
> [ARM] twd: Fix prescaler getting cleared by set_mode

... which have never been posted to this mailing list, so no one here
knows of them.

2010-11-12 13:06:05

by Harald Gustafsson

[permalink] [raw]
Subject: RE: [PATCH] [ARM] twd: Allow twd rescaling to match cpu frequency

> > Don't forget the other patches to make this work:
> >
> > [ARM] twd: Always calibrate local timer [ARM] twd: Fix updating
> > control register in set_mode [ARM] twd: Fix prescaler
> getting cleared
> > by set_mode
>
> ... which have never been posted to this mailing list, so no
> one here knows of them.

They are on the tegra branch git also authored by Colin. So I would suggest that Colin make all the changes into a new patch.

http://android.git.kernel.org/?p=kernel%2Ftegra.git&a=search&h=refs%2Fheads%2Flinux-tegra-2.6.35&st=commit&s=twd

/Harald-

2010-11-17 03:56:05

by Colin Cross

[permalink] [raw]
Subject: Re: [PATCH] [ARM] twd: Allow twd rescaling to match cpu frequency

On Fri, Nov 12, 2010 at 5:05 AM, Harald Gustafsson
<[email protected]> wrote:
>> > Don't forget the other patches to make this work:
>> >
>> > [ARM] twd: Always calibrate local timer [ARM] twd: Fix updating
>> > control register in set_mode [ARM] twd: Fix prescaler
>> getting cleared
>> > by set_mode
>>
>> ... which have never been posted to this mailing list, so no
>> one here knows of them.
>
> They are on the tegra branch git also authored by Colin. So I would suggest that Colin make all the changes into a new patch.
>
> http://android.git.kernel.org/?p=kernel%2Ftegra.git&a=search&h=refs%2Fheads%2Flinux-tegra-2.6.35&st=commit&s=twd
>
> /Harald

I'm not happy with the current implementation, which is why it hasn't
been posted. I'm planning to rewrite it with cpufreq notifiers, but
that brings us back to the periphclk divider problem discussed in
http://comments.gmane.org/gmane.linux.ports.arm.kernel/91827

If the frequency is going to change, using clk_get_rate on periphclk
is not sufficient, because the clock will not have been updated when
the prechange cpufreq notifier is called. If the cpu frequency is
increasing, the twd divider must be recalculated before the frequency
changes to avoid timers expiring early. Either the clock used by the
twd driver must be updated before prechange notifiers and after
postchange notifiers, which is difficult to fit in to all the
different implementations of the clock api, or the twd driver needs to
know the ratio between the cpu frequency and the periphclk frequency.