R4000SC ...
Subsystems (2)
Hi all,
accepting the danger that I'm going to frustrate someone on this list - I managed to get the R4000SC V3.0 going under Linux in less than two hours. I'm now typing this email logged on from my Indy running from local disk to another Linux machine. The worst part was actually to get rid of all the MIPS IV code on my machine before I could do anything useful again with a MIPS III CPU.
The patch which I'm going to commit will actually be quite a bit larger than the fixes for the SC actually needed to be because large parts of the support for the SC CPU were overly complex, better-than-nothing implementations or supporting CPU configurations that aren't possible at all. Benefit of all this for everybody is 10kb less kernel code.
Time to fix the "CPU too expensive" panic ;-)
Ralf
Quoted 2 lines · Ulf Carlsson
Can you please explain to me what the fixes actually needed for the SC were? I am quite interested.
Ok, here we go again. Attached the patch which I checked in yesterday. Should tell most easy what I've changed:
- The VCE exceptions need special handling in the general exception vector. In particular it's important that we cannot do any cached loads / stores before we've brought caches back to a sane state. So all the old handlers in entry.S and traps.c had to go away.
- Some of the cache operations defined in r4xx0.c use Hit_*_SD operations to work on the caches. These have the nice property that they will also invalidate any primary cache line in both icache and dcache that maps to the affected secondary cache line. In other words code sequences like
blast_dcache16_page(start);
if(text)
blast_icache16_page(start);
blast_scache16_page(start);can simply be replaced by
blast_scache16_page(start);
This change does not represent any kind of bug, it's just important performance work because cache instructions are expensive even if there is no work to do, that is no writebacks or invalidates. Aside due to the massive loop unrolling used in that code we just saved us close to 10kb in kernel size.
- We had code to support a cache configuration with a data cache linesize of 32 bytes and second level linesize of 16 bytes. Configurations where the second level linesize is smaller than the primary cache linesize are however forbidden, so away with the code.
- As you remember I disabled the use of the Create_Dirty_Excl_D based versions of clear_page and copy_page for R4000 / R4400 SC and MC versions as part of the first round of SC fixes. Now I implemented a set of four routines optimized for each possible second level cache linesize. Right now there are only new variants of clear_page; copy_page will come asap. I attempted to implement optimized variants using both Create_Dirty_Excl_SD and Create_Dirty_Excl_D in clear_page but the resulting kernel crashed immediately. Not shure what the cause is.
- The untested draft variant of head.S which I mailed to you was not word- aligning the address used to index the primary cache tag array. The effect is somewhat hidden, just occasionally programs will die with SIGBUS. No idea why this is necessary.
- One structure in sgiseeq needed extra padding. This was not an actual SC-bug; the driver would have failed on any machine with cachelines larger than 64 bytes. I increased the number of fill bytes to make the driver work with 128 byte linesized caches which is the largest available for the IP22.
Somebody asked me why the general exception handler or the VCED / VCEI exception handlers never crash with a VCE exception resulting in a infinite loop. First of all don't do any loads or stores before we've serviced a VCED / VCEI exception, so we can never catch any VCED exception. Second, a VCED / VCEI exception will only occur in case of both a primary and secondary cache hit where the second level cache virtual index is different from the actual virtual address' index bits. In normal live this will never happen since the exception handlers are only accessed via KSEG0 but never mapped. In other words mmaping /dev/mem and just _reading_ the wrong RAM addresses is a safe way to crash the machine. Well, you're not supposed to even try that.
Ralf
arch/mips/kernel/entry.S renamed from arch/mips/kernel/entry.S:1.14 +0 -2
@@ -152,10 +152,8 @@ BUILD_HANDLER(cpu,cpu,sti,silent) /* #11 */ BUILD_HANDLER(ov,ov,sti,silent) /* #12 */ BUILD_HANDLER(tr,tr,sti,silent) /* #13 */ - BUILD_HANDLER(vcei,vcei,sti,verbose) /* #14 */ BUILD_HANDLER(fpe,fpe,fpe,silent) /* #15 */ BUILD_HANDLER(watch,watch,sti,verbose) /* #23 */ - BUILD_HANDLER(vced,vced,sti,verbose) /* #31 */ BUILD_HANDLER(reserved,reserved,sti,verbose) /* others */ /*
arch/mips/kernel/head.S renamed from arch/mips/kernel/head.S:1.12 +40 -7
72 lines not on this page · raw message
arch/mips/kernel/proc.c renamed from arch/mips/kernel/proc.c:1.3 +7 -0
@@ -12,6 +12,7 @@#include <asm/watch.h> unsigned long unaligned_instructions; +unsigned int vced_count, vcei_count;/* * BUFFER is PAGE_SIZE bytes long.
@@ -21,6 +22,7 @@*/ int get_cpuinfo (char *buffer) { +char fmt [64 ];const char *cpu_name[] =CPU_NAMES ;const char *mach_group_names[] =GROUP_NAMES ;const char *mach_unknown_names[] =GROUP_UNKNOWN_NAMES ;
@@ -71,6 +73,11 @@ dedicated_iv_available ? "yes" : "no"); len +=sprintf (buffer + len,"hardware watchpoint\t: %s\n" , watch_available ?"yes" :"no" ); + +sprintf (fmt,"VCE%%c exceptions\t\t: %s\n" , + vce_available ?"%d" :"not available" ); + len +=sprintf (buffer + len, fmt,'D' , vced_count); + len +=sprintf (buffer + len, fmt,'I' , vcei_count);return len; }
arch/mips/kernel/traps.c renamed from arch/mips/kernel/traps.c:1.19 +12 -31
75 lines not on this page · raw message
arch/mips/mm/r4xx0.c renamed from arch/mips/mm/r4xx0.c:1.28 +354 -285
938 lines not on this page · raw message
drivers/net/sgiseeq.c renamed from drivers/net/sgiseeq.c:1.8 +1 -1
@@ -86,7 +86,7 @@/* Ptrs to the descriptors in KSEG1 uncached space. */ struct sgiseeq_rx_desc *rx_desc;struct sgiseeq_tx_desc *tx_desc; -unsigned long _padding[14 ];/* Pad out to largest cache line size. */ +unsigned long _padding[30 ];/* Pad out to largest cache line size. */ struct sgiseeq_rx_desc rxvector[SEEQ_RX_BUFFERS ];struct sgiseeq_tx_desc txvector[SEEQ_TX_BUFFERS ];
include/asm-mips/processor.h renamed from include/asm-mips/processor.h:1.17 +2 -0
@@ -30,8 +30,10 @@extern char wait_available;/* only available on R4[26]00 */ extern char cyclecounter_available;/* only available from R4000 upwards. */ extern char dedicated_iv_available;/* some embedded MIPS like Nevada */ +extern char vce_available;/* Supports VCED / VCEI exceptions */ extern struct mips_cpuinfo boot_cpu_data; +extern unsigned int vced_count, vcei_count;#ifdef __SMP__extern struct mips_cpuinfo cpu_data[];