Received: from milmhbs1.lsil.com (147.145.21.209) by coscas01.lsi.com
 (172.21.36.60) with Microsoft SMTP Server id 8.1.393.1; Sat, 27 Mar 2010
 08:07:41 -0600
Received: from mail1.lsil.com (mail1.lsil.com [147.145.40.21])	by
 milmhbs1.lsil.com (8.12.11/8.12.11) with ESMTP id o2RE7ROJ013295	for
 <andy.sharp@lsi.com>; Sat, 27 Mar 2010 07:07:41 -0700
Received: from psmtp.com (na3sys009amx238.postini.com [74.125.149.122])	by
 mail1.lsil.com (8.12.11/8.12.11) with SMTP id o2RE7MOU025737	for
 <andy.sharp@lsi.com>; Sat, 27 Mar 2010 07:07:25 -0700 (PDT)
Received: from source ([78.24.191.182]) by na3sys009amx238.postini.com
 ([74.125.148.14]) with SMTP;	Sat, 27 Mar 2010 07:07:25 PDT
Received: from localhost.localdomain ([127.0.0.1]:60952 "EHLO
        eddie.linux-mips.org" rhost-flags-OK-OK-OK-FAIL)        by
 eddie.linux-mips.org with ESMTP id S1491958Ab0C0OHE (ORCPT
        <rfc822;andy.sharp@lsi.com>); Sat, 27 Mar 2010 15:07:04 +0100
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 27 Mar 2010 15:06:47
 +0100 (CET)
Received: from phoenix3.szarvasnet.hu ([87.101.127.16]:33810 "EHLO
        phoenix3.szarvasnet.hu" rhost-flags-OK-OK-OK-OK)        by
 eddie.linux-mips.org with ESMTP id S1491957Ab0C0OGn (ORCPT
        <rfc822;linux-mips@linux-mips.org>); Sat, 27 Mar 2010 15:06:43 +0100
Received: from mail.szarvas.hu (localhost [127.0.0.1])        by
 phoenix3.szarvasnet.hu (Postfix) with SMTP id 954CD3E5A15;        Sat, 27 Mar
 2010 15:06:38 +0100 (CET)
Received: from localhost.localdomain (catvpool-576570d8.szarvasnet.hu
 [87.101.112.216])        by phoenix3.szarvasnet.hu (Postfix) with ESMTP id
 27016370003;        Sat, 27 Mar 2010 15:06:38 +0100 (CET)
From: Gabor Juhos <juhosg@openwrt.org>
To: Ralf Baechle <ralf@linux-mips.org>
CC: "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>, Gabor Juhos
	<juhosg@openwrt.org>
Sender: "linux-mips-bounce@linux-mips.org" <linux-mips-bounce@linux-mips.org>
Date: Sat, 27 Mar 2010 08:06:37 -0600
Subject: [PATCH] MIPS: use compare_change_hazard in mips_next_event
Thread-Topic: [PATCH] MIPS: use compare_change_hazard in mips_next_event
Thread-Index: AcrNtt26pJHbarbZQPuxo9csKpZcCA==
Message-ID: <1269698797-5004-1-git-send-email-juhosg@openwrt.org>
Accept-Language: en-US
Content-Language: en-US
X-MS-Exchange-Organization-AuthAs: Anonymous
X-MS-Exchange-Organization-AuthSource: coscas01.lsi.com
X-MS-Has-Attach:
X-Auto-Response-Suppress: All
X-MS-TNEF-Correlator:
x-scanned-by: MIMEDefang 2.39
errors-to: linux-mips-bounce@linux-mips.org
x-pstn-levels: (S:99.90000/99.90000 CV:99.9000 FC:95.5390 LC:95.5390
 R:95.9108 P:95.9108 M:97.0282 C:98.6951 )
x-pstn-settings: 3 (1.0000:1.0000) s cv gt3 gt2 gt1 r p m c 
x-pstn-addresses: from <juhosg@openwrt.org> [22/1] 
x-pstn-neptune: 0/0/0.00/0
x-antivirus: avast! (VPS 100326-0, 2010.03.26), Outbound message
x-antivirus-status: Clean
x-list: linux-mips
x-original-sender: juhosg@openwrt.org
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

The compare_change_hazard() is used between write_c0_compare() and
read_c0_count() in c0_compare_int_usable(). The mips_next_event() uses
the same code sequence but without the compare_change_hazard call.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 arch/mips/kernel/cevt-r4k.c |   33 +++++++++++++++++----------------
 1 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c
index 0b2450c..16cd116 100644
--- a/arch/mips/kernel/cevt-r4k.c
+++ b/arch/mips/kernel/cevt-r4k.c
@@ -16,6 +16,22 @@
 #include <asm/cevt-r4k.h>
=20
 /*
+ * Compare interrupt can be routed and latched outside the core,
+ * so a single execution hazard barrier may not be enough to give
+ * it time to clear as seen in the Cause register.  4 time the
+ * pipeline depth seems reasonably conservative, and empirically
+ * works better in configurations with high CPU/bus clock ratios.
+ */
+
+#define compare_change_hazard() \
+	do { \
+		irq_disable_hazard(); \
+		irq_disable_hazard(); \
+		irq_disable_hazard(); \
+		irq_disable_hazard(); \
+	} while (0)
+
+/*
  * The SMTC Kernel for the 34K, 1004K, et. al. replaces several
  * of these routines with SMTC-specific variants.
  */
@@ -31,6 +47,7 @@ static int mips_next_event(unsigned long delta,
 	cnt =3D read_c0_count();
 	cnt +=3D delta;
 	write_c0_compare(cnt);
+	compare_change_hazard();
 	res =3D ((int)(read_c0_count() - cnt) > 0) ? -ETIME : 0;
 	return res;
 }
@@ -100,22 +117,6 @@ static int c0_compare_int_pending(void)
 	return (read_c0_cause() >> cp0_compare_irq_shift) & (1ul << CAUSEB_IP);
 }
=20
-/*
- * Compare interrupt can be routed and latched outside the core,
- * so a single execution hazard barrier may not be enough to give
- * it time to clear as seen in the Cause register.  4 time the
- * pipeline depth seems reasonably conservative, and empirically
- * works better in configurations with high CPU/bus clock ratios.
- */
-
-#define compare_change_hazard() \
-	do { \
-		irq_disable_hazard(); \
-		irq_disable_hazard(); \
-		irq_disable_hazard(); \
-		irq_disable_hazard(); \
-	} while (0)
-
 int c0_compare_int_usable(void)
 {
 	unsigned int delta;
--=20
1.5.3.2


