RE: [PATCH] AMD K6 write allocate

Alexey Vyskubov (alexey@alv.stud.pu.ru)
Sun, 17 Jan 1999 15:25:09 +0300 (MSK)


This message is in MIME format
--_=XFMail.1.3.p0.Linux:990117152509:367=_
Content-Type: text/plain; charset=KOI8-R

Hello.

On 17-Jan-99 Alexey Vyskubov wrote:
> Well, now this patch is in the right file (I hope).

Sorry. that was an old version, it doesn't check correctly "memory hole"
and WCDE bit (well, it works correctly, it just may say about warning
incorrectly :))

The right version follows.

Do not forget to substitute your RAM size in
#define WRITE_ALLOCATE_LIMIT

--
With best wishes,
Alexey Vyskubov.
This is a message. Or something silly like that.

--_=XFMail.1.3.p0.Linux:990117152509:367=_ Content-Disposition: attachment; filename="k6-patch" Content-Description: k6-patch Content-Type: text/plain; charset=KOI8-R; name=k6-patch; SizeOnDisk=2312 Content-Transfer-Encoding: 7bit

--- linux/arch/i386/kernel/setup.c.was Sun Jan 17 12:17:11 1999 +++ linux/arch/i386/kernel/setup.c Sun Jan 17 14:57:52 1999 @@ -601,6 +601,31 @@ static char *cpu_vendor_names[] __initdata = { "Intel", "Cyrix", "AMD", "UMC", "NexGen", "Centaur" }; +#define AMD_WHCR 0xc0000082 /* AMD MSR WHCR */ + +int enable_write_allocate (int size) +{ + u32 ra, rd; + rd = 0; + + ra = size >> 2; /* EAX = 2*(RAM/4) */ + ra = (ra << 1) + 1; /* +1 for no memory hole at 15-16MB */ + + +#define walloc(msr, val1, val2) __asm__ __volatile__ (" pushf + cli + wbinvd + wrmsr + popf"\ + : /* no outputs */\ + : "c" (msr),\ + "a" (val1), "d" (val2)) + walloc(AMD_WHCR, ra, rd); + rdmsr(AMD_WHCR, ra, rd); /* Let's see what's happened */ + ra = ra & 0xfe; /* Drop last bit (memory hole) */ + ra = ra << 1; + return((int)ra); +} __initfunc(void print_cpu_info(struct cpuinfo_x86 *c)) { @@ -621,8 +646,52 @@ if (c->x86_mask || c->cpuid_level>=0) printk(" stepping %02x", c->x86_mask); + + if ( (c->x86_vendor == X86_VENDOR_AMD) && + ((c->x86_model == 6) || (c->x86_model == 7))) + { + + u32 ra, rd; + int mem; + + printk("\nAMD K6 processor, model %d found.", c->x86_model); + printk("\nChecking write allocate state... "); + +#define WRITE_ALLOCATE_LIMIT 48 +/* FIXME We should use real memory size instead of fixed limit */ + + rdmsr(AMD_WHCR, ra, rd); + mem = (ra & 0xfe) << 1; + + if (mem) { + printk("Write allocate is enabled for %d MB of memory", mem); + } else { + printk("Write allocate is disabled."); + } + + if (!(mem == WRITE_ALLOCATE_LIMIT)) { + printk("\nTrying to enable write alocate for %d MB of memory", WRITE_ALLOCAT E_LIMIT); + mem = WRITE_ALLOCATE_LIMIT; + mem = enable_write_allocate(mem); + + if (!(mem == WRITE_ALLOCATE_LIMIT)) { + printk("\nFailed!!!"); + } + printk("\nWrite allocate is enabled for %d MB of memory", mem); + } - if(c->x86_vendor == X86_VENDOR_CENTAUR) + rdmsr(AMD_WHCR, ra, rd); + + if (ra & 0x100) { + printk("\nWARNING: WCDE bit is 1."); + } + + if (!(ra & 0x1)) { + printk("\nWARNING: Memory hole at 15-16M is enabled."); + } + } + + if (c->x86_vendor == X86_VENDOR_CENTAUR) { u32 hv,lv; rdmsr(0x107, lv, hv); @@ -735,3 +804,4 @@ } return p - buffer; } +

--_=XFMail.1.3.p0.Linux:990117152509:367=_-- End of MIME message

- 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/