Re: MTRR & NVTNT

Richard Gooch (rgooch@atnf.csiro.au)
Sat, 13 Mar 1999 09:45:20 +1100


Gerd Knorr writes:
> > > And secondly I noticed when I use the VESA fb console, it
> > > works fine, however when it tries to automatically set the MTRR at
> > > the 0xe6000000 base address it incorrectly tries to use size
> > > 0xff0000 like I was doing before and gets the same error. This
> > > would appear to be a bug. I know you didn't write this part of the
> > > kernel, but since I'm carboning this to the kernel list I figured
> > > I'd mention it in case it was significant.
> >
> > Which makes it look likely that you really do have a 0xff0000 byte
> > framebuffer. If the other 64KB is an MMIO area, write-combining it
> > could lead to problems.
>
> Ack, the 0xff0000 comes from the vesa bios, and it probably knows
> how much video memory it has...
>
> [ ... ]
>
> > # echo "base=0xe6000000 size=0x1000000 type=write-combining" >! /proc/mtrr
> > # echo "base=0xe6ff0000 size=0x10000 type=uncachable" >! /proc/mtrr
> >
> > It would be nice if something did this automatically. Working out the
> > minimum number of regions needed to cover a range of any size is a
> > tractable problem, but would require quite a bit of code.
>
> 100% agree. Would be nice if the mtrr code could handle this
> automatically and hide the implementation details, so this has to be
> implemented only once. And if the power-of-two-size limit goes away
> in the future, only the mtrr code must be adjusted, not all
> applications/drivers which are using this interface.

Yeah, OK. My first reaction was to leave it in user space, but since
this facility would be handy for the FBdev drivers as well, I guess it
needs to go into kernel space. Either the individual FBdev drivers do
it, or the MTRR driver does it once. The latter is probably better.

I didn't like the "virtual" MTRRs approach: it's getting really
complicated and starts hiding the details too much, IMO. I'd rather
implement a function that applied the necessary heuristics and created
two MTRRs if needed. So now you have <mtrr_add>, which is the "dumb"
interface, and add the following "smart" interface.

int mtrr_smart_add (unsigned long base, unsigned long size, unsigned int type,
char increment, int *registers, int max_registers)
/* [SUMMARY] Setup a memory region, using multiple MTRRs as required.
<base> The starting (base) address of the region.
<size> The size (in bytes) of the region.
<type> The type of the new region.
<increment> If true and the region already exists, the usage count will be
incremented.
<registers> The MTRR registers used are written here.
<max_registers> The size of the <<registers>> array.
[RETURNS] The number of MTRR registers used on success, else a negative
number indicating the error code.
[NOTE] This routine uses a spinlock.
*/

This even lets drivers keep track of which MTRRs they should release,
if required.

What do people think of this interface? If you're happy, I'll add it
once Linus applies the MTRR patch I recently sent him (adding Cyrix
and AMD support).

Regards,

Richard....

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