Subject: Work on IP30

From: Stanislaw Skowronek <[email-masked]>
Date: Mon, 12 Apr 2004 22:51:13 +0200 (MET DST)

My Octane got as far as 'Calibrating delay loop... ' now. It works with
ARCS graphical console, which is a Good Thing. Memory identification is
correct. Caches work OK. I'm going to do the IRQs tomorrow, but I foresee
it will be really hard as there is no documentation for the HEART. Well,
we shall experiment.

Fortunately, the Octane has one really nice feature: the power button is
hooked up to an interrupt source. It may prove quite useful for debugging.

Interesting note: the ARCS console breaks when I change KSEG0 cache
coherence in the CP0_CONFIG register (in c-r4k.c). Of course, it breaks
sooner or later, not exactly afterwards, unless I flush cache exactly
after changing; it breaks immediately then. I don't give a hoot, because
IP30 has almost no RAM in KSEG0 and the kernel runs in XKPHYS, always
cached copy-on-write. But those of you with another machines might be
interested.

Stanislaw Skowronek

--<=>--
  Paranoid: one who is truly in touch with reality.

---

From: Ralf Baechle <[email-masked]>
Date: Tue, 13 Apr 2004 01:13:09 +0200

> cached copy-on-write. But those of you with another machines might be

Most firmware breaks at some point due to Linux fiddling with it's
resources.  What differs is how and when it breaks.  In case of IP27 the
first TLB flush for example is going to kill ARC.

And remember, it's written ARC but pronounced ARGGHHHH ;)

  Ralf

---

From: "Bradley D. LaRonde" <[email-masked]>
Date: Mon, 12 Apr 2004 19:42:41 -0400

This 2.4 patch look OK?

Regards,
Brad

diff -u -r1.1.1.1 time.c
--- arch/mips/kernel/time.c     10 Nov 2003 21:06:52 -0000      1.1.1.1
+++ arch/mips/kernel/time.c     12 Apr 2004 23:41:38 -0000
@@ -242,7 +242,7 @@
        __asm__("multu  %1,%2"
                : "=h" (res)
                : "r" (count), "r" (sll32_usecs_per_cycle)
-               : "lo", "accum");
+               : "lo", "hi");

        /*
         * Due to possible jiffies inconsistencies, we need to check
@@ -297,7 +297,7 @@
        __asm__("multu  %1,%2"
                : "=h" (res)
                : "r" (count), "r" (quotient)
-               : "lo", "accum");
+               : "lo", "hi");

        /*
         * Due to possible jiffies inconsistencies, we need to check
@@ -339,7 +339,7 @@
                                : "r" (timerhi), "m" (timerlo),
                                  "r" (tmp), "r" (USECS_PER_JIFFY),
                                  "r" (USECS_PER_JIFFY_FRAC)
-                               : "hi", "lo", "accum");
+                               : "hi", "lo", "hi");
                        cached_quotient = quotient;
                }
        }
@@ -353,7 +353,7 @@
        __asm__("multu  %1,%2"
                : "=h" (res)
                : "r" (count), "r" (quotient)
-               : "lo", "accum");
+               : "lo", "hi");

        /*
         * Due to possible jiffies inconsistencies, we need to check

---

From: "Bradley D. LaRonde" <[email-masked]>
Date: Mon, 12 Apr 2004 20:53:03 -0400

Uh oh, with this patch:

...
time.c: In function `fixed_rate_gettimeoffset':
time.c:242: error: can't find a register in class `HI_REG' while reloading
`asm'
...

Regards,
Brad

---

From: Eric Christopher <[email-masked]>
Date: Mon, 12 Apr 2004 18:02:08 -0700

> >          * Due to possible jiffies inconsistencies, we need to check

Maybe this hunk where you use "hi" twice for the same asm statement?

-eric

-- 
Eric Christopher <[email-masked]>

---

From: "Bradley D. LaRonde" <[email-masked]>
Date: Mon, 12 Apr 2004 21:05:34 -0400

----- Original Message ----- 
From: "Eric Christopher" <[email-masked]>
To: "Bradley D. LaRonde" <[email-masked]>
Cc: <[email-masked]>
Sent: Monday, April 12, 2004 9:02 PM
Subject: Re: [PATCH] gcc 3.4 drops "accum" clobber, replace with "hi"
intime.c

> Maybe this hunk where you use "hi" twice for the same asm statement?

Yeah, that's messed up, but it fails here too:

@@ -242,7 +242,7 @@
        __asm__("multu  %1,%2"
                : "=h" (res)

Regards,
Brad

---

From: Daniel Jacobowitz <[email-masked]>
Date: Mon, 12 Apr 2004 21:07:32 -0400

> Yeah, that's messed up, but it fails here too:

Because the asm is outputting something in HI - see the =h?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

---

From: "Bradley D. LaRonde" <[email-masked]>
Date: Mon, 12 Apr 2004 21:12:04 -0400

----- Original Message ----- 
From: "Daniel Jacobowitz" <[email-masked]>
To: "Bradley D. LaRonde" <[email-masked]>
Cc: <[email-masked]>; "Eric Christopher" <[email-masked]>
Sent: Monday, April 12, 2004 9:07 PM
Subject: Re: [PATCH] gcc 3.4 drops "accum" clobber, replace with "hi"
intime.c

> Because the asm is outputting something in HI - see the =h?

Oh... yeah, I guess gcc knows that the output is clobbered.  :-P

So just remove the accum clobbers?

Regards,
Brad

---

From: "Bradley D. LaRonde" <[email-masked]>
Date: Mon, 12 Apr 2004 21:23:27 -0400

OK, so this patch actually builds, and it sounds like it will do the job,
since "accum" means "hi and low", "lo" is already clobbered in all cases,
and either "hi" is the output and doesn't need clobbering (hunks 1, 2, and
4), or "hi" is already clobbered (hunk 3).

Regards,
Brad

diff -u -r1.1.1.1 time.c
--- arch/mips/kernel/time.c     10 Nov 2003 21:06:52 -0000      1.1.1.1
+++ arch/mips/kernel/time.c     13 Apr 2004 01:19:15 -0000
@@ -242,7 +242,7 @@
        __asm__("multu  %1,%2"
                : "=h" (res)
                : "r" (count), "r" (sll32_usecs_per_cycle)
-               : "lo", "accum");
+               : "lo");

        /*
+               : "lo");

        /*
+                               : "hi", "lo");
+               : "lo");

        /*

----- Original Message ----- 
From: "Bradley D. LaRonde" <[email-masked]>
To: "Daniel Jacobowitz" <[email-masked]>
Cc: <[email-masked]>; "Eric Christopher" <[email-masked]>
Sent: Monday, April 12, 2004 9:12 PM
Subject: Re: [PATCH] gcc 3.4 drops "accum" clobber, replace with "hi"
intime.c

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Tue, 13 Apr 2004 14:57:07 +0200 (CEST)

> 4), or "hi" is already clobbered (hunk 3).

 There are more places this should be dealt with and I have the following 
preliminary patch for this, but I'm unsure about removal of "accum" being 
completely safe for older compilers.

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email-masked], PGP key available        +

patch-mips-2.4.24-pre2-20040116-mips-gcc3-2
diff -up --recursive --new-file linux-mips-2.4.24-pre2-20040116.macro/arch/mips/kernel/time.c linux-mips-2.4.24-pre2-20040116/arch/mips/kernel/time.c
--- linux-mips-2.4.24-pre2-20040116.macro/arch/mips/kernel/time.c	2004-01-15 03:56:58.000000000 +0000
+++ linux-mips-2.4.24-pre2-20040116/arch/mips/kernel/time.c	2004-02-02 04:38:34.000000000 +0000
@@ -242,7 +242,7 @@ static unsigned long fixed_rate_gettimeo
 	__asm__("multu	%1,%2"
 		: "=h" (res)
 		: "r" (count), "r" (sll32_usecs_per_cycle)
-		: "lo", "accum");
+		: "lo");
 
 	/*
 	 * Due to possible jiffies inconsistencies, we need to check
@@ -297,7 +297,7 @@ static unsigned long calibrate_div32_get
 	__asm__("multu  %1,%2"
 		: "=h" (res)
 		: "r" (count), "r" (quotient)
-		: "lo", "accum");
+		: "lo");
 
 	/*
 	 * Due to possible jiffies inconsistencies, we need to check
@@ -339,7 +339,7 @@ static unsigned long calibrate_div64_get
 				: "r" (timerhi), "m" (timerlo),
 				  "r" (tmp), "r" (USECS_PER_JIFFY),
 				  "r" (USECS_PER_JIFFY_FRAC)
-				: "hi", "lo", "accum");
+				: "hi", "lo");
 			cached_quotient = quotient;
 		}
 	}
@@ -353,7 +353,7 @@ static unsigned long calibrate_div64_get
 	__asm__("multu	%1,%2"
 		: "=h" (res)
 		: "r" (count), "r" (quotient)
-		: "lo", "accum");
+		: "lo");
 
 	/*
 	 * Due to possible jiffies inconsistencies, we need to check
diff -up --recursive --new-file linux-mips-2.4.24-pre2-20040116.macro/arch/mips64/kernel/cpu-probe.c linux-mips-2.4.24-pre2-20040116/arch/mips64/kernel/cpu-probe.c
--- linux-mips-2.4.24-pre2-20040116.macro/arch/mips64/kernel/cpu-probe.c	2003-12-11 03:56:36.000000000 +0000
+++ linux-mips-2.4.24-pre2-20040116/arch/mips64/kernel/cpu-probe.c	2004-02-02 04:44:30.000000000 +0000
@@ -177,7 +177,7 @@ static inline void mult_sh_align_mod(lon
 		".set	pop"
 		: "=&r" (lv1), "=r" (lw)
 		: "r" (m1), "r" (m2), "r" (s), "I" (0)
-		: "hi", "lo", "accum");
+		: "hi", "lo");
 	/* We have to use single integers for m1 and m2 and a double
 	 * one for p to be sure the mulsidi3 gcc's RTL multiplication
 	 * instruction has the workaround applied.  Older versions of
diff -up --recursive --new-file linux-mips-2.4.24-pre2-20040116.macro/arch/mips64/kernel/time.c linux-mips-2.4.24-pre2-20040116/arch/mips64/kernel/time.c
--- linux-mips-2.4.24-pre2-20040116.macro/arch/mips64/kernel/time.c	2004-01-15 03:57:03.000000000 +0000
+++ linux-mips-2.4.24-pre2-20040116/arch/mips64/kernel/time.c	2004-02-02 04:39:21.000000000 +0000
@@ -242,7 +242,7 @@ static unsigned long fixed_rate_gettimeo
 	__asm__("multu	%1,%2"
 		: "=h" (res)
 		: "r" (count), "r" (sll32_usecs_per_cycle)
-		: "lo", "accum");
+		: "lo");
 
 	/*
 	 * Due to possible jiffies inconsistencies, we need to check
@@ -297,7 +297,7 @@ static unsigned long calibrate_div32_get
 	__asm__("multu  %1,%2"
 		: "=h" (res)
 		: "r" (count), "r" (quotient)
-		: "lo", "accum");
+		: "lo");
 
 	/*
 	 * Due to possible jiffies inconsistencies, we need to check
@@ -339,7 +339,7 @@ static unsigned long calibrate_div64_get
 				: "r" (timerhi), "m" (timerlo),
 				  "r" (tmp), "r" (USECS_PER_JIFFY),
 				  "r" (USECS_PER_JIFFY_FRAC)
-				: "hi", "lo", "accum");
+				: "hi", "lo");
 			cached_quotient = quotient;
 		}
 	}
@@ -353,7 +353,7 @@ static unsigned long calibrate_div64_get
 	__asm__("multu	%1,%2"
 		: "=h" (res)
 		: "r" (count), "r" (quotient)
-		: "lo", "accum");
+		: "lo");
 
 	/*

---

From: "Steven J. Hill" <[email-masked]>
Date: Sat, 17 Apr 2004 22:39:27 -0400

> completely safe for older compilers.
Works fine for gcc-3.1.1 and my Swarm board boots just fine with this
change and it seems stable. I vote for you to go ahead and commit the
fixes to CVS. Thanks Maciej.

-Steve

---

From: Ralf Baechle <[email-masked]>
Date: Sun, 18 Apr 2004 15:00:30 +0200

> completely safe for older compilers.

From everything I know about the behavior of older compilers this should
be save.  "accum" was treated a little strage in some context anyway, so
I'm happy to see it go ...

  Ralf

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Mon, 19 Apr 2004 13:50:13 +0200 (CEST)

> fixes to CVS. Thanks Maciej.

 I'm worried more about 2.95.  And even if it works now, it may stop after
some changes, if the compiler decides it's safe to keep something in
"accum" across the asm.