setup.c cache detection cleanup.

Jones D (djones2@glam.ac.uk)
Wed, 6 Oct 1999 17:13:58 +0100


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01BF1015.CB6FD608
Content-Type: text/plain;
charset="iso-8859-1"

Hi all,
I've cleaned up the code that detects the size of
CPU cache in arch/i386/kernel/setup.c
It eliminates a variable, and moved the whole cache
detecting code out of the for loop, as I see no reason
for redetecting it with each iteration.

This is against 2.3.19, but should work against 2.2.x
too, with some offsets.

regards,

Dave.

------_=_NextPart_000_01BF1015.CB6FD608
Content-Type: application/octet-stream;
name="setup.c.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="setup.c.diff"
Content-Location: ATT-0-FDF2652EF97BD311A3BD00805F85FBB8-S
ETUPC%7E1.DIF

--- setup.c~ Wed Sep 15 20:28:18 1999=0A=
+++ setup.c Wed Sep 15 20:33:06 1999=0A=
@@ -25,6 +25,9 @@=0A=
*=0A=
* Memory region support=0A=
* David Parsons <orc@pell.chi.il.us>, July-August 1999=0A=
+ *=0A=
+ * Improved cache size detection.=0A=
+ * Dave Jones <dave@powertweak.com>, September 1999=0A=
*/=0A=
=0A=
/*=0A=
@@ -1114,7 +1117,7 @@=0A=
centaur_model(c);=0A=
return;=0A=
}=0A=
- =0A=
+=0A=
if (c->cpuid_level > 0 && c->x86_vendor =3D=3D X86_VENDOR_INTEL)=0A=
{=0A=
if(c->x86_capability&(1<<18))=0A=
@@ -1129,49 +1132,47 @@=0A=
}=0A=
}=0A=
=0A=
- for (i =3D 0; i < sizeof(cpu_models)/sizeof(struct cpu_model_info); =
i++) {=0A=
- if (c->cpuid_level > 1) {=0A=
- /* supports eax=3D2 call */=0A=
- int edx, cache_size, dummy;=0A=
- =0A=
- cpuid(2, &dummy, &dummy, &dummy, &edx);=0A=
-=0A=
- /* We need only the LSB */=0A=
- edx &=3D 0xff;=0A=
-=0A=
- switch (edx) {=0A=
- case 0x40:=0A=
- cache_size =3D 0;=0A=
- break;=0A=
-=0A=
- case 0x41:=0A=
- cache_size =3D 128;=0A=
- break;=0A=
+ if (c->cpuid_level > 1) {=0A=
+ /* supports eax=3D2 call */=0A=
+ int edx, dummy;=0A=
+=0A=
+ cpuid(2, &dummy, &dummy, &dummy, &edx);=0A=
+=0A=
+ /* We need only the LSB */=0A=
+ edx &=3D 0xff;=0A=
+=0A=
+ switch (edx) {=0A=
+ case 0x40:=0A=
+ c->x86_cache_size =3D 0;=0A=
+ break;=0A=
=0A=
- case 0x42:=0A=
- cache_size =3D 256;=0A=
- break;=0A=
+ case 0x41:=0A=
+ c->x86_cache_size =3D 128;=0A=
+ break;=0A=
=0A=
- case 0x43:=0A=
- cache_size =3D 512;=0A=
- break;=0A=
+ case 0x42:=0A=
+ c->x86_cache_size =3D 256;=0A=
+ break;=0A=
=0A=
- case 0x44:=0A=
- cache_size =3D 1024;=0A=
- break;=0A=
+ case 0x43:=0A=
+ c->x86_cache_size =3D 512;=0A=
+ break;=0A=
=0A=
- case 0x45:=0A=
- cache_size =3D 2048;=0A=
- break;=0A=
+ case 0x44:=0A=
+ c->x86_cache_size =3D 1024;=0A=
+ break;=0A=
=0A=
- default:=0A=
- cache_size =3D 0;=0A=
- break;=0A=
- }=0A=
+ case 0x45:=0A=
+ c->x86_cache_size =3D 2048;=0A=
+ break;=0A=
=0A=
- c->x86_cache_size =3D cache_size; =0A=
+ default:=0A=
+ c->x86_cache_size =3D 0;=0A=
+ break;=0A=
}=0A=
+ }=0A=
=0A=
+ for (i =3D 0; i < sizeof(cpu_models)/sizeof(struct cpu_model_info); =
i++) {=0A=
if (cpu_models[i].vendor =3D=3D c->x86_vendor &&=0A=
cpu_models[i].x86 =3D=3D c->x86) {=0A=
if (c->x86_model <=3D 16)=0A=

------_=_NextPart_000_01BF1015.CB6FD608--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/