linux-mips
[Top] [All Lists]

[PATCH] Make c0_compare_int_usable more bullet proof

To: linux-mips@linux-mips.org
Subject: [PATCH] Make c0_compare_int_usable more bullet proof
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Date: Sat, 20 Oct 2007 00:54:45 +0900 (JST)
Cc: ralf@linux-mips.org
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
Use write_c0_compare(read_c0_count()) to clear interrupt.
And 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 a915e56..46a896f 100644
--- a/arch/mips/kernel/cevt-r4k.c
+++ b/arch/mips/kernel/cevt-r4k.c
@@ -179,19 +179,21 @@ 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;
 
        /*
         * IP7 already pending?  Try to clear it by acking the timer.
         */
        if (c0_compare_int_pending()) {
-               write_c0_compare(read_c0_compare());
+               write_c0_compare(read_c0_count());
                irq_disable_hazard();
                if (c0_compare_int_pending())
                        return 0;
        }
 
+       delta = read_c0_count();
+       delta = ((read_c0_count() - delta) ?: 1) << 8;
        cnt = read_c0_count();
        cnt += delta;
        write_c0_compare(cnt);
@@ -202,7 +204,7 @@ static int c0_compare_int_usable(void)
        if (!c0_compare_int_pending())
                return 0;
 
-       write_c0_compare(read_c0_compare());
+       write_c0_compare(read_c0_count());
        irq_disable_hazard();
        if (c0_compare_int_pending())
                return 0;

<Prev in Thread] Current Thread [Next in Thread>