Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH] Make c0_compare_int_usable faster
@ 2007-10-22 16:14 Atsushi Nemoto
  2007-10-22 21:04 ` Ralf Baechle
  0 siblings, 1 reply; 4+ messages in thread
From: Atsushi Nemoto @ 2007-10-22 16:14 UTC (permalink / raw)
  To: linux-mips; +Cc: ralf

Use delta value based on its speed for faster probing.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c
index ae2984f..46a896f 100644
--- a/arch/mips/kernel/cevt-r4k.c
+++ b/arch/mips/kernel/cevt-r4k.c
@@ -179,7 +179,7 @@ static int c0_compare_int_pending(void)
 
 static int c0_compare_int_usable(void)
 {
-	const unsigned int delta = 0x300000;
+	unsigned int delta;
 	unsigned int cnt;
 
 	/*
@@ -192,6 +192,8 @@ static int c0_compare_int_usable(void)
 			return 0;
 	}
 
+	delta = read_c0_count();
+	delta = ((read_c0_count() - delta) ?: 1) << 8;
 	cnt = read_c0_count();
 	cnt += delta;
 	write_c0_compare(cnt);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Make c0_compare_int_usable faster
  2007-10-22 16:14 [PATCH] Make c0_compare_int_usable faster Atsushi Nemoto
@ 2007-10-22 21:04 ` Ralf Baechle
  2007-10-23 12:55   ` Atsushi Nemoto
  0 siblings, 1 reply; 4+ messages in thread
From: Ralf Baechle @ 2007-10-22 21:04 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: linux-mips

On Tue, Oct 23, 2007 at 01:14:16AM +0900, Atsushi Nemoto wrote:

> Use delta value based on its speed for faster probing.

Still the same issue, it breaks with Qemu.  You probably don't see this
if you're testing on a desktop where the TSC is used for timing but on
a laptop it breaks big time.  I need to increase the shift value to at
least like 15 to get it to work more or less reliably with Qemu, so a
somewhat different approach is needed.

  Ralf

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Make c0_compare_int_usable faster
  2007-10-22 21:04 ` Ralf Baechle
@ 2007-10-23 12:55   ` Atsushi Nemoto
  2007-10-28 23:57     ` Ralf Baechle
  0 siblings, 1 reply; 4+ messages in thread
From: Atsushi Nemoto @ 2007-10-23 12:55 UTC (permalink / raw)
  To: ralf; +Cc: linux-mips

On Mon, 22 Oct 2007 22:04:00 +0100, Ralf Baechle <ralf@linux-mips.org> wrote:
> > Use delta value based on its speed for faster probing.
> 
> Still the same issue, it breaks with Qemu.  You probably don't see this
> if you're testing on a desktop where the TSC is used for timing but on
> a laptop it breaks big time.  I need to increase the shift value to at
> least like 15 to get it to work more or less reliably with Qemu, so a
> somewhat different approach is needed.

OK, Here is the different approach.

---
Subject: [PATCH] Make c0_compare_int_usable faster (take 2)

Try to increase delta value step by step until we can make sure the
counter is not expired.

 arch/mips/kernel/cevt-r4k.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c
index 47c8c0e..fa3b9b2 100644
--- a/arch/mips/kernel/cevt-r4k.c
+++ b/arch/mips/kernel/cevt-r4k.c
@@ -179,7 +179,7 @@ static int c0_compare_int_pending(void)
 
 static int c0_compare_int_usable(void)
 {
-	const unsigned int delta = 0x300000;
+	unsigned int delta;
 	unsigned int cnt;
 
 	/*
@@ -192,9 +192,15 @@ static int c0_compare_int_usable(void)
 			return 0;
 	}
 
-	cnt = read_c0_count();
-	cnt += delta;
-	write_c0_compare(cnt);
+	for (delta = 0x10; delta <= 0x400000; delta <<= 1) {
+		cnt = read_c0_count();
+		cnt += delta;
+		write_c0_compare(cnt);
+		irq_disable_hazard();
+		if ((int)(read_c0_count() - cnt) < 0)
+		    break;
+		/* increase delta if the timer was already expired */
+	}
 
 	while ((int)(read_c0_count() - cnt) <= 0)
 		;	/* Wait for expiry  */

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Make c0_compare_int_usable faster
  2007-10-23 12:55   ` Atsushi Nemoto
@ 2007-10-28 23:57     ` Ralf Baechle
  0 siblings, 0 replies; 4+ messages in thread
From: Ralf Baechle @ 2007-10-28 23:57 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: linux-mips

On Tue, Oct 23, 2007 at 09:55:42PM +0900, Atsushi Nemoto wrote:

> On Mon, 22 Oct 2007 22:04:00 +0100, Ralf Baechle <ralf@linux-mips.org> wrote:
> > > Use delta value based on its speed for faster probing.
> > 
> > Still the same issue, it breaks with Qemu.  You probably don't see this
> > if you're testing on a desktop where the TSC is used for timing but on
> > a laptop it breaks big time.  I need to increase the shift value to at
> > least like 15 to get it to work more or less reliably with Qemu, so a
> > somewhat different approach is needed.
> 
> OK, Here is the different approach.

Looks like it's going to work.  Applied.

Thanks,

  Ralf

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-10-29 11:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-22 16:14 [PATCH] Make c0_compare_int_usable faster Atsushi Nemoto
2007-10-22 21:04 ` Ralf Baechle
2007-10-23 12:55   ` Atsushi Nemoto
2007-10-28 23:57     ` Ralf Baechle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox