pnx8550: fix system timer support
PATCH 1/1 pnx8550: fix system timer support
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(-)
arch/mips/kernel/time.c +0 -2
@@ -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. */
arch/mips/philips/pnx8550/common/time.c +38 -7
76 lines not on this page · raw message
arch/mips/philips/pnx8550/common/time.c line 32
Quoted 7 lines · Vitaly Wool
arch/mips/philips/pnx8550/common/time.c +1
-0@@ -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
Quoted 15 lines · Atsushi Nemoto
arch/mips/philips/pnx8550/common/time.c line 32
Quoted 7 lines · Vitaly Wool
arch/mips/philips/pnx8550/common/time.c +1
-0@@ -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.his already included just before there. Why double inclusion?
Oh shoot, thanks, this hunk is bogus.
Vitaly
Quoted 17 lines · Vitaly Wool-4 wrote:
Quoted 15 lines · Atsushi Nemoto
arch/mips/philips/pnx8550/common/time.c line 32
Quoted 7 lines · Vitaly Wool
arch/mips/philips/pnx8550/common/time.c +1
-0@@ -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.his already included just before there. Why double inclusion?
Quoted 5 lines
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
Signature · 2 lines
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.
Quoted 6 lines · Daniel Laird
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 inarch/mips/kernel/time.c
I can make it not static and extern it frompnx8550/common/time.cis 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
Quoted 11 lines · Atsushi Nemoto
Quoted 7 lines · Daniel Laird
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 inarch/mips/kernel/time.c
I can make it not static and extern it frompnx8550/common/time.cis this how I should do it?
Quoted 11 lines
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
Signature · 2 lines
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.
Quoted 2 lines · Daniel Laird
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
Signature · 2 lines
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.
Quoted 7 lines · Daniel Laird
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?
arch/mips/philips/pnx8550/common/time.c +1 -0
@@ -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 */
Quoted 20 lines · Atsushi Nemoto
Quoted 7 lines · Daniel Laird
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?
arch/mips/philips/pnx8550/common/time.c +0
-0
arch/mips/philips/pnx8550/common/time.c void pnx8550_time_init(void) · line 86
Quoted 7 lines
arch/mips/philips/pnx8550/common/time.c +1
-0@@ -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
Signature · 2 lines
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.