Index: [thread] [date] [subject] [author]
  From: Jon M. Taylor <taylorj@ecs.csus.edu>
  To  : GGI mailing list <ggi-develop@eskimo.com>
  Date: Sat, 15 Aug 1998 19:06:31 -0700 (PDT)

kgicon and MTRRs

	For those who don't already know, a Memory Type Range Register
(MTRR) is a special type of register found in Intel PPro/PII processors. 
These registers can be used to define memory ranges where the processor's
memory writes are handled differently.  The memory can be made
uncacheable, write-through cached, write-back cached, write-protected and
write-combined.  

	That last is important for video cards, as they often have lots of
data thrown at them in big chunks.  If the processor can combine bus
writes into larger chunks before transferring, great speed increases can
often be achieved, 2.5x or more depending on the nature of the writing
being done.  Linux has MTRR support in the kernel, through a function-call
interface and also via /proc/mtrr. 

	Now that my Trio64V+ driver is working again, I decided to play
with this (I have a PPro 200).  I inserted the kgicon.o driver and then
echoed to /proc/mtrr a command string which turned on write-combining over
the 2MB PCI LAW region the video card occupies.  My consoles are quite
noticeably snappier now as a result.  As soon as I can get LibGGI to work,
I'll be able to use speed.c to come up with some benchmark numbers.  If
you have a PPro or PII, give it a try and see what you think.

	I'd like to add MTRR support to kgicon in some way.  Right now I
am leaning towards a call to mtrr_add() in fbcon-kgi.c, after the card has
been detected and initialized.  The necessary info - physical base
address, framebuffer size - are available then.  But there are some
potential issues with this approach: 

*  I don't know what happens if you don't have a PPro/PII or MTRR support
isn't compiled into the kernel and you call mtrr_add().  If a symbol is
missing, the module won't insert.

* Enabling write-combining over MMIO registers is a huge no-no because you
can't control the order in which the registers are written.  That's not a
problem for my S3 card because it maps the framebuffer and MMIO registers
into different address spaces, but I don't know about other cards. 

* Fixed VGA address ranges have to be handled a little bit differently. 
The "normal" MTRRs are a set of 16(?) variable type registers that can be
used with any MTRR type, address, etc.  But the VGA address space (0xa0000
- 0xbffff) is covered by a set of fixed MTRRs which can only be turned off
or on.

* Some older/buggy hardware might not be able to handle MTRRs correctly.  
In particular, I'm not at all sure how pseudo-linear framebuffers that 
switch banks on page faults will react to this, since the _physical_ 
memory is what needs to be MTRRed.

	Anyway, if can play with this please do and let me/us know what
happens.  MTRRs give such a dramatic performance increase that we should 
definitely use them if at all possible.

Jon

---
'Cloning and the reprogramming of DNA is the first serious step in 
becoming one with God.'
	- Scientist G. Richard Seed

Index: [thread] [date] [subject] [author]