Commit 26d14a20 authored by Changbin Du's avatar Changbin Du Committed by Jonathan Corbet
Browse files

Documentation: x86: convert mtrr.txt to reST



This converts the plain text documentation to reStructuredText format and
add it to Sphinx TOC tree. No essential content change.

Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent 17156044
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -16,3 +16,4 @@ x86-specific Documentation
   earlyprintk
   zero-page
   tlb
   mtrr
+354 −0
Original line number Diff line number Diff line
.. SPDX-License-Identifier: GPL-2.0

=========================================
MTRR (Memory Type Range Register) control
=========================================

:Authors: - Richard Gooch <rgooch@atnf.csiro.au> - 3 Jun 1999
          - Luis R. Rodriguez <mcgrof@do-not-panic.com> - April 9, 2015

Richard Gooch <rgooch@atnf.csiro.au> - 3 Jun 1999
Luis R. Rodriguez <mcgrof@do-not-panic.com> - April 9, 2015

===============================================================================
Phasing out MTRR use
====================

MTRR use is replaced on modern x86 hardware with PAT. Direct MTRR use by
drivers on Linux is now completely phased out, device drivers should use
@@ -23,10 +28,9 @@ are aligned with platform MTRR setup. If MTRRs are only set up by the platform
firmware code though and the OS does not make any specific MTRR mapping
requests mtrr_type_lookup() should always return MTRR_TYPE_INVALID.

For details refer to Documentation/x86/pat.txt.

===============================================================================
For details refer to :doc:`pat`.

.. tip::
  On Intel P6 family processors (Pentium Pro, Pentium II and later)
  the Memory Type Range Registers (MTRRs) may be used to control
  processor access to memory ranges. This is most useful when you have
@@ -54,26 +58,31 @@ For details refer to Documentation/x86/pat.txt.
  similar control registers on other processors can be easily
  supported.


There are two interfaces to /proc/mtrr: one is an ASCII interface
which allows you to read and write. The other is an ioctl()
interface. The ASCII interface is meant for administration. The
ioctl() interface is meant for C programs (i.e. the X server). The
interfaces are described below, with sample commands and C code.

===============================================================================
Reading MTRRs from the shell:

Reading MTRRs from the shell
============================
::

  % cat /proc/mtrr
  reg00: base=0x00000000 (   0MB), size= 128MB: write-back, count=1
  reg01: base=0x08000000 ( 128MB), size=  64MB: write-back, count=1
===============================================================================
Creating MTRRs from the C-shell:

Creating MTRRs from the C-shell::

  # echo "base=0xf8000000 size=0x400000 type=write-combining" >! /proc/mtrr
or if you use bash:

or if you use bash::

  # echo "base=0xf8000000 size=0x400000 type=write-combining" >| /proc/mtrr

And the result thereof:
And the result thereof::

  % cat /proc/mtrr
  reg00: base=0x00000000 (   0MB), size= 128MB: write-back, count=1
  reg01: base=0x08000000 ( 128MB), size=  64MB: write-back, count=1
@@ -82,7 +91,7 @@ reg02: base=0xf8000000 (3968MB), size= 4MB: write-combining, count=1
This is for video RAM at base address 0xf8000000 and size 4 megabytes. To
find out your base address, you need to look at the output of your X
server, which tells you where the linear framebuffer address is. A
typical line that you may get is:
typical line that you may get is::

  (--) S3: PCI: 968 rev 0, Linear FB @ 0xf8000000

@@ -91,7 +100,7 @@ move the framebuffer base address, so the only value you can trust is
that reported by the X server.

To find out the size of your framebuffer (what, you don't actually
know?), the following line will tell you:
know?), the following line will tell you::

  (--) S3: videoram:  4096k

@@ -100,13 +109,18 @@ A patch is being written for XFree86 which will make this automatic:
in other words the X server will manipulate /proc/mtrr using the
ioctl() interface, so users won't have to do anything. If you use a
commercial X server, lobby your vendor to add support for MTRRs.
===============================================================================
Creating overlapping MTRRs:


Creating overlapping MTRRs
==========================
::

  %echo "base=0xfb000000 size=0x1000000 type=write-combining" >/proc/mtrr
  %echo "base=0xfb000000 size=0x1000 type=uncachable" >/proc/mtrr

And the results: cat /proc/mtrr
And the results::

  % cat /proc/mtrr
  reg00: base=0x00000000 (   0MB), size=  64MB: write-back, count=1
  reg01: base=0xfb000000 (4016MB), size=  16MB: write-combining, count=1
  reg02: base=0xfb000000 (4016MB), size=   4kB: uncachable, count=1
@@ -117,13 +131,22 @@ registers.

NOTE: You can only create type=uncachable region, if the first
region that you created is type=write-combining.
===============================================================================
Removing MTRRs from the C-shell:


Removing MTRRs from the C-shel
==============================
::

  % echo "disable=2" >! /proc/mtrr
or using bash:

or using bash::

  % echo "disable=2" >| /proc/mtrr
===============================================================================
Reading MTRRs from a C program using ioctl()'s:


Reading MTRRs from a C program using ioctl()'s
==============================================
::

  /*  mtrr-show.c

@@ -218,8 +241,11 @@ int main ()
      fprintf (stderr, "Error doing ioctl(2) on /dev/mtrr\t%s\n", ERRSTRING);
      exit (3);
  }   /*  End Function main  */
===============================================================================
Creating MTRRs from a C programme using ioctl()'s:


Creating MTRRs from a C programme using ioctl()'s
=================================================
::

  /*  mtrr-add.c

@@ -326,4 +352,3 @@ int main (int argc, char **argv)
      fputs ("I've just closed /proc/mtrr so now the new entry should be gone\n",
      stderr);
  }   /*  End Function main  */
===============================================================================