* [PATCH][respin] pnx8550: fix system timer support
@ 2006-12-28 14:14 Vitaly Wool
2006-12-28 16:16 ` Atsushi Nemoto
0 siblings, 1 reply; 9+ messages in thread
From: Vitaly Wool @ 2006-12-28 14:14 UTC (permalink / raw)
To: ralf; +Cc: linux-mips
Hello Ralf,
the patch inlined below restores proper time accounting for PNX8550-based boards. It also gets rid of #ifdef in the generic code which becomes unnecessary then.
It's functionally identical to the previous patch with the same name but it has minor comments from Atsushi and Sergei taken into account.
arch/mips/kernel/time.c | 2 -
arch/mips/philips/pnx8550/common/time.c | 45 +++++++++++++++++++++++++++-----
2 files changed, 38 insertions(+), 9 deletions(-)
Signed-off-by: Vitaly Wool <vwool@ru.mvista.com>
Index: linux-mips.git/arch/mips/kernel/time.c
===================================================================
--- linux-mips.git.orig/arch/mips/kernel/time.c
+++ linux-mips.git/arch/mips/kernel/time.c
@@ -94,10 +94,8 @@ static void c0_timer_ack(void)
{
unsigned int count;
-#ifndef CONFIG_SOC_PNX8550 /* pnx8550 resets to zero */
/* Ack this timer interrupt and set the next one. */
expirelo += cycles_per_jiffy;
-#endif
write_c0_compare(expirelo);
/* Check to see if we have missed any timer interrupts. */
Index: linux-mips.git/arch/mips/philips/pnx8550/common/time.c
===================================================================
--- linux-mips.git.orig/arch/mips/philips/pnx8550/common/time.c
+++ linux-mips.git/arch/mips/philips/pnx8550/common/time.c
@@ -29,11 +29,22 @@
#include <asm/hardirq.h>
#include <asm/div64.h>
#include <asm/debug.h>
+#include <asm/time.h>
#include <int.h>
#include <cm.h>
-extern unsigned int mips_hpt_frequency;
+static unsigned long cpj;
+
+static cycle_t hpt_read(void)
+{
+ return read_c0_count2();
+}
+
+static void timer_ack(void)
+{
+ write_c0_compare(cpj);
+}
/*
* pnx8550_time_init() - it does the following things:
@@ -68,27 +79,47 @@ void pnx8550_time_init(void)
* HZ timer interrupts per second.
*/
mips_hpt_frequency = 27UL * ((1000000UL * n)/(m * pow2p));
+ cpj = (mips_hpt_frequency + HZ / 2) / HZ;
+ timer_ack();
+
+ /* Setup Timer 2 */
+ write_c0_count2(0);
+ write_c0_compare2(0xffffffff);
+
+ clocksource_mips.read = hpt_read;
+ mips_timer_ack = timer_ack;
+}
+
+static irqreturn_t monotonic_interrupt(int irq, void *dev_id)
+{
+ /* Timer 2 clear interrupt */
+ write_c0_compare2(-1);
+ return IRQ_HANDLED;
}
+static struct irqaction monotonic_irqaction = {
+ .handler = monotonic_interrupt,
+ .flags = IRQF_DISABLED,
+ .name = "Monotonic timer",
+};
+
void __init plat_timer_setup(struct irqaction *irq)
{
int configPR;
setup_irq(PNX8550_INT_TIMER1, irq);
+ setup_irq(PNX8550_INT_TIMER2, &monotonic_irqaction);
- /* Start timer1 */
+ /* Timer 1 start */
configPR = read_c0_config7();
configPR &= ~0x00000008;
write_c0_config7(configPR);
- /* Timer 2 stop */
+ /* Timer 2 start */
configPR = read_c0_config7();
- configPR |= 0x00000010;
+ configPR &= ~0x00000010;
write_c0_config7(configPR);
- write_c0_count2(0);
- write_c0_compare2(0xffffffff);
-
/* Timer 3 stop */
configPR = read_c0_config7();
configPR |= 0x00000020;
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH][respin] pnx8550: fix system timer support
2006-12-28 14:14 [PATCH][respin] pnx8550: fix system timer support Vitaly Wool
@ 2006-12-28 16:16 ` Atsushi Nemoto
2006-12-28 16:20 ` Vitaly Wool
0 siblings, 1 reply; 9+ messages in thread
From: Atsushi Nemoto @ 2006-12-28 16:16 UTC (permalink / raw)
To: vitalywool; +Cc: ralf, linux-mips
On Thu, 28 Dec 2006 17:14:05 +0300, Vitaly Wool <vitalywool@gmail.com> wrote:
> --- linux-mips.git.orig/arch/mips/philips/pnx8550/common/time.c
> +++ linux-mips.git/arch/mips/philips/pnx8550/common/time.c
> @@ -29,11 +29,22 @@
> #include <asm/hardirq.h>
> #include <asm/div64.h>
> #include <asm/debug.h>
> +#include <asm/time.h>
As I said before, asm/time.h is already included just before there.
Why double inclusion?
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH][respin] pnx8550: fix system timer support
2006-12-28 16:16 ` Atsushi Nemoto
@ 2006-12-28 16:20 ` Vitaly Wool
2007-01-02 14:05 ` Daniel Laird
0 siblings, 1 reply; 9+ messages in thread
From: Vitaly Wool @ 2006-12-28 16:20 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: ralf, linux-mips
[-- Attachment #1: Type: text/plain, Size: 555 bytes --]
On 12/28/06, Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
>
> On Thu, 28 Dec 2006 17:14:05 +0300, Vitaly Wool <vitalywool@gmail.com>
> wrote:
> > --- linux-mips.git.orig/arch/mips/philips/pnx8550/common/time.c
> > +++ linux-mips.git/arch/mips/philips/pnx8550/common/time.c
> > @@ -29,11 +29,22 @@
> > #include <asm/hardirq.h>
> > #include <asm/div64.h>
> > #include <asm/debug.h>
> > +#include <asm/time.h>
>
> As I said before, asm/time.h is already included just before there.
> Why double inclusion?
>
>
Oh shoot, thanks, this hunk is bogus.
Vitaly
[-- Attachment #2: Type: text/html, Size: 1050 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH][respin] pnx8550: fix system timer support
2006-12-28 16:20 ` Vitaly Wool
@ 2007-01-02 14:05 ` Daniel Laird
2007-01-02 16:06 ` Atsushi Nemoto
0 siblings, 1 reply; 9+ messages in thread
From: Daniel Laird @ 2007-01-02 14:05 UTC (permalink / raw)
To: linux-mips
Vitaly Wool-4 wrote:
>
> On 12/28/06, Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
>>
>> On Thu, 28 Dec 2006 17:14:05 +0300, Vitaly Wool <vitalywool@gmail.com>
>> wrote:
>> > --- linux-mips.git.orig/arch/mips/philips/pnx8550/common/time.c
>> > +++ linux-mips.git/arch/mips/philips/pnx8550/common/time.c
>> > @@ -29,11 +29,22 @@
>> > #include <asm/hardirq.h>
>> > #include <asm/div64.h>
>> > #include <asm/debug.h>
>> > +#include <asm/time.h>
>>
>> As I said before, asm/time.h is already included just before there.
>> Why double inclusion?
>>
>>
> Oh shoot, thanks, this hunk is bogus.
>
> Vitaly
>
>
I have now tried this new patch and am still not having much success and am
still not understanding the patch very well.
First things first, if I do use the line
clocksource_mips.read = hpt_read;
It does not compile as this symbol is not in a header file and is a static
struct in arch/mips/kernel/time.c
I can make it not static and extern it from pnx8550/common/time.c is this
how I should do it?
Secondly I look at the logic for the arch/mips/kernel/time.c in the
time_init code
I think we want to follow the else branch (/* We know counter frequency. Or
we can get it. */)
In this case it then checks to see if mips_hpt_read is undefined which in
our case it is.
It then defines the mips_hpt_read to be c0_hpt_read
It then also overrides mips_timer_ack to be c0_timer_ack which i think is
wrong as we have already overridden this function in
arch/mips/philips/pnx8550/common/time.c. (Is this behaviour correct?)
I used the patch and ran the kernel, It does not work very well, Long Hang
after
Memory: ......
Very slow behaviour after this.
I tried the following:
else {
/* We know counter frequency. Or we can get it. */
if (!mips_hpt_read)
{
/* No external high precision timer -- use R4k. */
mips_hpt_read = c0_hpt_read;
if (!mips_timer_state) {
/* No external timer interrupt -- use R4k. */
mips_hpt_init = c0_hpt_timer_init;
+ if(!mips_timer_ack)
mips_timer_ack = c0_timer_ack;
}
}
This means it uses the mips_timer_ack function defined in
arch/mips/philips/pnx8550/common/time.c
(mips_timer_ack = timer_ack;)
If I use this patch then the kernel still hangs for a long time at
Memory: ...... (of the order of 12-14 secs)
It then seems to run at full speed and to a prompt.
In summary:
How do I override clocksource_mips.read properly?
Should mips_timer_ack = c0_timer_ack; be being done even though the board
specific mips_timer_ack = timer_ack; has been done?
Finally there is still the long hang which still looks top be related to
waiting for counter to cycle could ?
Any help with all three would be appreciated but 1 and 2 appear to be more
generic questions whilst 3 is PNX8550 specific (any help would be
appreciated there as well).
Cheers
Dan
--
View this message in context: http://www.nabble.com/-PATCH--respin--pnx8550%3A-fix-system-timer-support-tf2890537.html#a8124491
Sent from the linux-mips main mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH][respin] pnx8550: fix system timer support
2007-01-02 14:05 ` Daniel Laird
@ 2007-01-02 16:06 ` Atsushi Nemoto
2007-01-02 17:17 ` Daniel Laird
0 siblings, 1 reply; 9+ messages in thread
From: Atsushi Nemoto @ 2007-01-02 16:06 UTC (permalink / raw)
To: danieljlaird; +Cc: linux-mips
On Tue, 2 Jan 2007 06:05:55 -0800 (PST), Daniel Laird <danieljlaird@hotmail.com> wrote:
> First things first, if I do use the line
> clocksource_mips.read = hpt_read;
> It does not compile as this symbol is not in a header file and is a static
> struct in arch/mips/kernel/time.c
> I can make it not static and extern it from pnx8550/common/time.c is this
> how I should do it?
To fix the build problem, use latest linux-mips.org git-tree or use
2.6.20-rc3 from kernel.org, or import these patches:
http://www.linux-mips.org/git?p=linux.git;a=commit;h=c87b6ebaea034c0e0ce86127870cf1511a307b64
http://www.linux-mips.org/git?p=linux.git;a=commit;h=005985609ff72df3257fde6b29aa9d71342c2a6b
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH][respin] pnx8550: fix system timer support
2007-01-02 16:06 ` Atsushi Nemoto
@ 2007-01-02 17:17 ` Daniel Laird
2007-01-03 13:37 ` Daniel Laird
2007-01-03 13:57 ` Atsushi Nemoto
0 siblings, 2 replies; 9+ messages in thread
From: Daniel Laird @ 2007-01-02 17:17 UTC (permalink / raw)
To: linux-mips
Atsushi Nemoto wrote:
>
> On Tue, 2 Jan 2007 06:05:55 -0800 (PST), Daniel Laird
> <danieljlaird@hotmail.com> wrote:
>> First things first, if I do use the line
>> clocksource_mips.read = hpt_read;
>> It does not compile as this symbol is not in a header file and is a
>> static
>> struct in arch/mips/kernel/time.c
>> I can make it not static and extern it from pnx8550/common/time.c is this
>> how I should do it?
>
> To fix the build problem, use latest linux-mips.org git-tree or use
> 2.6.20-rc3 from kernel.org, or import these patches:
>
> http://www.linux-mips.org/git?p=linux.git;a=commit;h=c87b6ebaea034c0e0ce86127870cf1511a307b64
> http://www.linux-mips.org/git?p=linux.git;a=commit;h=005985609ff72df3257fde6b29aa9d71342c2a6b
>
> ---
> Atsushi Nemoto
>
>
>
Thanks, thats the build problem removed, I now have a kernel that builds
properly! (issues 1 and 2 appear to be closed)
Only issue remaining is that I still have a long hang (10 seconds ish)
after this
Memory: 53540k/57344k available (2156k kernel code, 3744k reserved, 383k
data, 128k init, 0k highmem)
I am investigating but any help is appreciated...
Dan
--
View this message in context: http://www.nabble.com/-PATCH--respin--pnx8550%3A-fix-system-timer-support-tf2890537.html#a8127168
Sent from the linux-mips main mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH][respin] pnx8550: fix system timer support
2007-01-02 17:17 ` Daniel Laird
@ 2007-01-03 13:37 ` Daniel Laird
2007-01-03 13:57 ` Atsushi Nemoto
1 sibling, 0 replies; 9+ messages in thread
From: Daniel Laird @ 2007-01-03 13:37 UTC (permalink / raw)
To: linux-mips
Daniel Laird wrote:
>
>
Thanks, thats the build problem removed, I now have a kernel that builds
properly! (issues 1 and 2 appear to be closed)
Only issue remaining is that I still have a long hang (10 seconds ish)
after this
Memory: 53540k/57344k available (2156k kernel code, 3744k reserved, 383k
data, 128k init, 0k highmem)
I am investigating but any help is appreciated...
Dan
I have been debugging this and the delay is all due to the calibrate_delay
function.
If I use a preset lpj all works fine (fast start up)
If I let it calculate it using the logic
while ((loops_per_jiffy <<= 1) != 0) {
/* wait for "start of" clock tick */
ticks = jiffies;
while (ticks == jiffies)
/* nothing */;
/* Go .. */
ticks = jiffies;
__delay(loops_per_jiffy);
ticks = jiffies - ticks;
if (ticks)
break;
}
Then I get the hang so it seems this is the culprit function, however as for
why this is happening I am still debugging
Cheers
Dan
--
View this message in context: http://www.nabble.com/-PATCH--respin--pnx8550%3A-fix-system-timer-support-tf2890537.html#a8140851
Sent from the linux-mips main mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH][respin] pnx8550: fix system timer support
2007-01-02 17:17 ` Daniel Laird
2007-01-03 13:37 ` Daniel Laird
@ 2007-01-03 13:57 ` Atsushi Nemoto
2007-01-03 14:34 ` Daniel Laird
1 sibling, 1 reply; 9+ messages in thread
From: Atsushi Nemoto @ 2007-01-03 13:57 UTC (permalink / raw)
To: danieljlaird; +Cc: linux-mips
On Tue, 2 Jan 2007 09:17:32 -0800 (PST), Daniel Laird <danieljlaird@hotmail.com> wrote:
> Thanks, thats the build problem removed, I now have a kernel that builds
> properly! (issues 1 and 2 appear to be closed)
> Only issue remaining is that I still have a long hang (10 seconds ish)
> after this
> Memory: 53540k/57344k available (2156k kernel code, 3744k reserved, 383k
> data, 128k init, 0k highmem)
> I am investigating but any help is appreciated...
Does this patch (on top of Vitaly's patch) solve remaining problem?
diff --git a/arch/mips/philips/pnx8550/common/time.c b/arch/mips/philips/pnx8550/common/time.c
index 08ebc3d..9d9fc71 100644
--- a/arch/mips/philips/pnx8550/common/time.c
+++ b/arch/mips/philips/pnx8550/common/time.c
@@ -80,6 +80,7 @@ void pnx8550_time_init(void)
*/
mips_hpt_frequency = 27UL * ((1000000UL * n)/(m * pow2p));
cpj = (mips_hpt_frequency + HZ / 2) / HZ;
+ write_c0_count(0);
timer_ack();
/* Setup Timer 2 */
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH][respin] pnx8550: fix system timer support
2007-01-03 13:57 ` Atsushi Nemoto
@ 2007-01-03 14:34 ` Daniel Laird
0 siblings, 0 replies; 9+ messages in thread
From: Daniel Laird @ 2007-01-03 14:34 UTC (permalink / raw)
To: linux-mips
Atsushi Nemoto wrote:
>
> On Tue, 2 Jan 2007 09:17:32 -0800 (PST), Daniel Laird
> <danieljlaird@hotmail.com> wrote:
>> Thanks, thats the build problem removed, I now have a kernel that builds
>> properly! (issues 1 and 2 appear to be closed)
>> Only issue remaining is that I still have a long hang (10 seconds ish)
>> after this
>> Memory: 53540k/57344k available (2156k kernel code, 3744k reserved, 383k
>> data, 128k init, 0k highmem)
>> I am investigating but any help is appreciated...
>
> Does this patch (on top of Vitaly's patch) solve remaining problem?
>
> diff --git a/arch/mips/philips/pnx8550/common/time.c
> b/arch/mips/philips/pnx8550/common/time.c
> index 08ebc3d..9d9fc71 100644
> --- a/arch/mips/philips/pnx8550/common/time.c
> +++ b/arch/mips/philips/pnx8550/common/time.c
> @@ -80,6 +80,7 @@ void pnx8550_time_init(void)
> */
> mips_hpt_frequency = 27UL * ((1000000UL * n)/(m * pow2p));
> cpj = (mips_hpt_frequency + HZ / 2) / HZ;
> + write_c0_count(0);
> timer_ack();
>
> /* Setup Timer 2 */
>
I too caqme to this conclusion and you are correct it does indeed fix the
problem. The kernel now boots straight through to the prompt.
Thanks
Dan
--
View this message in context: http://www.nabble.com/-PATCH--respin--pnx8550%3A-fix-system-timer-support-tf2890537.html#a8141727
Sent from the linux-mips main mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2007-01-03 14:34 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-28 14:14 [PATCH][respin] pnx8550: fix system timer support Vitaly Wool
2006-12-28 16:16 ` Atsushi Nemoto
2006-12-28 16:20 ` Vitaly Wool
2007-01-02 14:05 ` Daniel Laird
2007-01-02 16:06 ` Atsushi Nemoto
2007-01-02 17:17 ` Daniel Laird
2007-01-03 13:37 ` Daniel Laird
2007-01-03 13:57 ` Atsushi Nemoto
2007-01-03 14:34 ` Daniel Laird
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.