[Top] [All Lists]

Re: PROPOSAL : multi-way cache support in Linux/MIPS

To: "Jun Sun" <>, <>, <>, <>
Subject: Re: PROPOSAL : multi-way cache support in Linux/MIPS
From: "Kevin D. Kissell" <>
Date: Wed, 2 Aug 2000 10:26:38 +0200
Rather than re-invent the wheel, please consider the
cache descriptor data structures we developed at
MIPS to deal with this problem.  I believe that the
updated cache.h file, and maybe even the cpu_probe.c
file, was checked into the 2.2 repository at SGI long ago.
There are also a set of initialisation and invalidation routines
that key off the cache descriptor structure, but those aren't
in the SGI  repository (though anyone can get them from or  The CPU probe
logic (also on those sites, and already integrated
into several variants because it also supports setting
up state needed by the software FPU emulation)
is table-based, and for each PrID value, there is
a template for the cache characteristics, which
can either be taken "as is" or probed, depending
on a flag in the descriptor.  Since the number of
"ways" cannot always be determined by probing,
if the number of ways is specified, it is preserved
even if a cache probe is performed.   I won't attach the
full set of cache probe routines (which would only confuse
things), but here is the cache data structure definition
and the CPU descriptor template table that we use.


            Kevin K.

-----Original Message-----
From: Jun Sun <>
To: <>; <>; <>
Date: Wednesday, August 02, 2000 2:01 AM
Subject: PROPOSAL : multi-way cache support in Linux/MIPS

>I have got NEC DDB5476 running stable enough that I am comfortable to
>check in
>my code.  Will you take it?
>Assuming the answer is yes, there are several issues regarding checking
>I will bring them up one by one.
>The first issue is multi-way cache support.  DDB5476 uses R5432 CPU
>has two-way set-associative cache.  The problematic part is the
>index-based cache operations in r4xxcache.h does not cover all ways in a
>I think this is a problem in general.  So far I have seen MIPS
>processors with
>2-way, 4-way and 8-way sets.  And I have seen them using ether least-
>significant-addressing-bits or most-significant-addressing-bits
>within a cache line to select ways.
>Here is my proposal :
>. introduce two variables,
>        cache_num_ways - number of ways in a set
>        cache_way_selection_offset - the offset added to the address to
>                next cache line in the same set.  For LSBs addressing,
>it is
>                equal to 1.  For MSBs addressing, it is equal to
>                cache_line_size / cache_num_ways.  (It can potentially
>                care of some future weired way-selection scheme as long
>                the offset is uniform)
>. These variables are initialized in cpu_probe().
>  (Alternatively, I think we should have cpu_info table, that contains
>   these cpu information.  Then a general routine can fill in the based
>   the cpu id.  This can get rid of a bunch of ugly switch/case
>. in the include/asm/r4kcache.h file, all Index-based cache operation
>  to changed like the following (for illustration only; need
>optimization) :
>        while(start < end) {
>                cache16_unroll32(start,Index_Writeback_Inv_D);
>                start += 0x200;
>        }
>        while(start < end) {
>                for (i=0; i< cache_num_ways; i++) {
>                        cache16_unroll32(start +
>                                         Index_Writeback_Inv_D);
>                }
>                start += 0x200;
>        }
>What do you think?  If it is OK, I can do the patch.  The cpu_info table
>is a nice wish, but I don't think I know enough to do that job yet.

Attachment: cache.h
Description: Binary data

Attachment: cpu.h
Description: Binary data

Attachment: cpu_probe.c
Description: Binary data

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