Skip to contentSkip to conversation

Bring back R4600 V1.7 support

PATCH In review Jan-Benedict Glaw 3 participants 8 messages Aug 18, 2002 – Aug 20, 2002 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bring back R4600 V1.7 support

Hi!

Here's my current patch to bring back R4600 V1.7 support.

MfG, JBG

Index: include/asm-mips/war.h
===================================================================
RCS file: /usr/src/packages/foreign_CVS_reps/oss.sgi.com/linux/include/asm-mips/war.h,v retrieving revision 1.1.2.3

asm-mips/war.h +19 -1
diff -u -r1.1.2.3 war.h
@@ -65,6 +65,24 @@
  */
 #define	R5432_CP0_INTERRUPT_WAR
 
-#endif
+#endif /* CONFIG_CPU_R5432 */
+
+#ifdef R4600_V1_HIT_DCACHE_WAR
+#define r4600_v1_7_cache_war_disable_irq(CACHE_FLAGS)	\
+	do {						\
+		__save_and_cli(CACHE_FLAGS);		\
+	} while (0)
+#define r4600_v1_7_cache_war_enable_irq(CACHE_FLAGS)	\
+	do {						\
+		__restore_flags(CACHE_FLAGS);		\
+	} while (0)
+#else
+#define r4600_v1_7_cache_war_disable_irq(CACHE_FLAGS)	\
+	do {} while (0)
+#define r4600_v1_7_cache_war_enable_irq(CACHE_FLAGS)	\
+	do {} while (0)
+#endif /* R4600_V1_HIT_DCACHE_WAR */
+			
+	
 
 #endif /* _ASM_WAR_H */

Index: arch/mips/mm/c-r4k.c
===================================================================
RCS file: /usr/src/packages/foreign_CVS_reps/oss.sgi.com/linux/arch/mips/mm/c-r4k.c,v retrieving revision 1.3.2.6

mips/mm/c-r4k.c +96 -1

478 lines not on this page · raw message

Signature · 3 lines
Jan-Benedict Glaw   .   [email protected]   .   +49-172-7608481
	 -- New APT-Proxy written in shell script --
	   http://lug-owl.de/~jbglaw/software/ap2/
#1 lore raw

On Sun, 2002-08-18 02:28:34 +0200, Jan-Benedict Glaw <[email protected]> wrote in message <[email protected]>:

Quoted 3 lines

Hi!

Here's my current patch to bring back R4600 V1.7 support.

[snip]

Hi Ralf!

Please accept the patch (from my previous mail). I'm using it now for two days, and I've got one mail telling me that it works for its sender. No mails about crashed systems so far...

MfG, JBG

Signature · 3 lines
Jan-Benedict Glaw   .   [email protected]   .   +49-172-7608481
	 -- New APT-Proxy written in shell script --
	   http://lug-owl.de/~jbglaw/software/ap2/
#2 lore raw
Quoted 2 lines · Jan-Benedict Glaw

Please accept the patch (from my previous mail). I'm using it now for two days, and I've got one mail telling me that it works for its sender.

Ugh, this should be a separate set of functions selected at the run time.
It should be fairly trivial to rewrite it this way (best done with processor-specific functions expanded from common templates for ease of maintenance), but the size of the resulting interrupt masking window is unacceptable. A more finegrained implementation is really desireable, with an interrupt enable window every page or so, but your proposal should be fair enough for the sake of usability once rewritten as I suggested.

Signature · 3 lines
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email protected], PGP key available        +
#3 lore raw
Quoted 10 lines · Maciej W. Rozycki
Quoted 2 lines

Please accept the patch (from my previous mail). I'm using it now for two days, and I've got one mail telling me that it works for its sender.

Ugh, this should be a separate set of functions selected at the run time.
It should be fairly trivial to rewrite it this way (best done with processor-specific functions expanded from common templates for ease of maintenance), but the size of the resulting interrupt masking window is unacceptable. A more finegrained implementation is really desireable, with an interrupt enable window every page or so, but your proposal should be fair enough for the sake of usability once rewritten as I suggested.

An additional thought that just came to my mind: it might be possible to
avoid masking interrupts with a dummy ll/sc pair only checking if an interrupt happened within the critical code. It should be easy to validate since only a single mask of a processor would make use of the code. The real question is: "Do the affected cache operations corrupt any state or do they only work on wrong lines?" If the latter, the approach should work for all operations except from "Hit_Invalidate_D" that corrupts state by definition (but it isn't used by any R4k processor, so it may simply be replaced with a panic()). Unfortunately, the knowledge does no longer exist within IDT, but maybe someone else knows?

Signature · 3 lines
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email protected], PGP key available        +
#6 lore raw
In reply to Maciej W. Rozycki

On Tue, 2002-08-20 15:30:22 +0200, Maciej W. Rozycki <[email protected]> wrote in message <[email protected]>:

Quoted 8 lines · Jan-Benedict Glaw
Quoted 3 lines

Please accept the patch (from my previous mail). I'm using it now for two days, and I've got one mail telling me that it works for its sender.

Ugh, this should be a separate set of functions selected at the run time.
It should be fairly trivial to rewrite it this way (best done with processor-specific functions expanded from common templates for ease of

Actually, I had written all that using separate functions before, but neither I nor Ralf liked this approach (because it adds hundreds LOC to .../c-r4k.c). Ralf then suggested writing it using macros, so I did.

-*- Proposal -*-
There are IMHO two goals, one for near future, one for following day (after first goal has reached):

1. There are many (equally looking) functions in c-r4k.c . It would be nice to not have the (more-or-less) function body 10 times there.
2. it would be nice to not have like 50 functions around, but to better have a flexible way to do what needs to be done. Something like an (initdata) array containing PRId and function pointers (or other info) on "what needs to be done".

The first one seems quite easy. Looking eg. at Alphas, they have a macro defining a whole function (which inserts a correct function name by supplied arguments etc.). This way,

static inline void r4k_flush_cache_all_s128d16i16(void) static inline void r4k_flush_cache_all_s32d32i32(void) static inline void r4k_flush_cache_all_s64d32i32(void) ..

could go away by: (there _will_ be bugs. 100% untested, and I'm a bad preprocessor coder:-)

#define FUNC_R4K_FLUSH_CACHE_ALL(NAME, SC, DC, IC)		\
	static inline void					\
	r4k_flush_cache_all_##NAME(void)			\
	{							\
		blast_dcache##DC();				\
		blast_icache##IC();				\
		blase_scache##SC();				\
	}

and then writing:

FUNC_R4K_FLUSH_CACHE_ALL(s128d16i16, 128, 16, 16)
FUNC_R4K_FLUSH_CACHE_ALL(s32d32i32, 32, 32, 32)
FUNC_R4K_FLUSH_CACHE_ALL(s64d32i32, 64, 32, 32)
...

instead. The __save_and_cli()/__restore_flags() functions could be done as well as all the remaining others. That would pollute namespace like it does today, but the .c file will be 80% smaller or so:

$ wc -l c-r4k.c 
   2422 c-r4k.c

MfG, JBG

Signature · 3 lines
Jan-Benedict Glaw   .   [email protected]   .   +49-172-7608481
	 -- New APT-Proxy written in shell script --
	   http://lug-owl.de/~jbglaw/software/ap2/
#4 lore raw
In reply to Maciej W. Rozycki
Quoted 10 lines · Maciej W. Rozycki

An additional thought that just came to my mind: it might be possible to
avoid masking interrupts with a dummy ll/sc pair only checking if an interrupt happened within the critical code. It should be easy to validate since only a single mask of a processor would make use of the code. The real question is: "Do the affected cache operations corrupt any state or do they only work on wrong lines?" If the latter, the approach should work for all operations except from "Hit_Invalidate_D" that corrupts state by definition (but it isn't used by any R4k processor, so it may simply be replaced with a panic()). Unfortunately, the knowledge does no longer exist within IDT, but maybe someone else knows?

I was thinking about that already but the erratas don't provide enough details. The only problem I can see is that ll/sc are fairly slow on some architectures. They're supposed to be quite light according to the docs but in reality I benchmarked ~ 13 cycles for a spinlock on a R10000 and ~ 44 on a more recent chip.

Ralf

#5 lore raw
Quoted 2 lines · Ralf Baechle

I was thinking about that already but the erratas don't provide enough details. The only problem I can see is that ll/sc are fairly slow on some

Well, IDT didn't seem much mobilized with my single query. Maybe if
there was more interest expressed, someone would go digging through old resources for real.

Quoted 3 lines

architectures. They're supposed to be quite light according to the docs but in reality I benchmarked ~ 13 cycles for a spinlock on a R10000 and ~ 44 on a more recent chip.

Well, the code would only execute on an R4600 V1.7...

Signature · 3 lines
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email protected], PGP key available        +
#7 lore raw
In reply to Jan-Benedict Glaw
Quoted 3 lines · Jan-Benedict Glaw

Actually, I had written all that using separate functions before, but neither I nor Ralf liked this approach (because it adds hundreds LOC to .../c-r4k.c). Ralf then suggested writing it using macros, so I did.

Obviously you'd put all the R4600 stuff in a separate file (the second
and the third being the regular R4k stuff and the template macros sourced by the first and the second one). That would aid diffing as well.

Quoted 13 lines

-*- Proposal -*-
There are IMHO two goals, one for near future, one for following day (after first goal has reached):

1. There are many (equally looking) functions in c-r4k.c . It would be nice to not have the (more-or-less) function body 10 times there.
2. it would be nice to not have like 50 functions around, but to better have a flexible way to do what needs to be done. Something like an (initdata) array containing PRId and function pointers (or other info) on "what needs to be done".

Quoted 3 lines

The first one seems quite easy. Looking eg. at Alphas, they have a macro defining a whole function (which inserts a correct function name by supplied arguments etc.). This way,

[...]

Definitely. The other one is done by Alphas as well since RTH wrote
generic kernel support. I consider such a feature one of goals for MIPS as well, so such a rewrite would be a necessary part of the design sooner or later anyway.

Signature · 3 lines
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email protected], PGP key available        +