xf86-video-intel: Branch 'modesetting' - 2 commits - src/i810_reg.h src/i830_driver.c

Eric Anholt anholt at kemper.freedesktop.org
Thu Nov 30 01:09:47 EET 2006


 src/i810_reg.h    |    5 +++++
 src/i830_driver.c |   46 ++++++++++++++++++++++++++++++++--------------
 2 files changed, 37 insertions(+), 14 deletions(-)

New commits:
diff-tree b6fc8df9a52f5fe1b4d26ae06bc4d48235b44a67 (from 359dc81c07901665da0f86c573c096fa1661cdd2)
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Nov 29 15:06:32 2006 -0800

    Properly detect the GTT size on the G965.
    
    In the past, the GTT has always been sized just large enough to map the whole
    graphics aperture.  However, apparently on the G965 that isn't the case, and
    it is actually 512KB on hardware with a 256MB aperture.  This resulted in X
    not bothering to allocate memory for 256KB that it thought was already mapped
    into stolen memory, and thus garbage rendering (particularly visible in large
    video modes that displayed this unallocated memory).  The kernel happens to
    get the right answer by hardwiring a 512KB GTT size already, but that may not
    be true on future hardware.
    
    Instead, we use a convenient field in PGETBL_CTL that's specifically for the
    GTT size rather than the aperture size, which gets us the answer we want.

diff --git a/src/i810_reg.h b/src/i810_reg.h
index 53a063f..9c6e0dd 100644
--- a/src/i810_reg.h
+++ b/src/i810_reg.h
@@ -499,6 +499,11 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN
 #define PGETBL_ADDR_MASK    0xFFFFF000
 #define PGETBL_ENABLE_MASK  0x00000001
 #define PGETBL_ENABLED      0x00000001
+/** Added in 965G, this field has the actual size of the global GTT */
+#define PGETBL_SIZE_MASK    0x0000000e
+#define PGETBL_SIZE_512KB   (0 << 1)
+#define PGETBL_SIZE_256KB   (1 << 1)
+#define PGETBL_SIZE_128KB   (2 << 1)
 
 /* Register containing pge table error results, p276
  */
diff --git a/src/i830_driver.c b/src/i830_driver.c
index 39ffa54..55610f5 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -394,7 +394,7 @@ I830DetectMemory(ScrnInfoPtr pScrn)
    I830Ptr pI830 = I830PTR(pScrn);
    PCITAG bridge;
    CARD16 gmch_ctrl;
-   int memsize = 0;
+   int memsize = 0, gtt_size;
    int range;
 #if 0
    VbeInfoBlock *vbeInfo;
@@ -403,9 +403,35 @@ I830DetectMemory(ScrnInfoPtr pScrn)
    bridge = pciTag(0, 0, 0);		/* This is always the host bridge */
    gmch_ctrl = pciReadWord(bridge, I830_GMCH_CTRL);
 
-   /* We need to reduce the stolen size, by the GTT and the popup.
-    * The GTT varying according the the FbMapSize and the popup is 4KB */
-   range = (pI830->FbMapSize / (1024*1024)) + 4;
+   if (IS_I965G(pI830)) {
+      /* The 965 may have a GTT that is actually larger than is necessary
+       * to cover the aperture, so check the hardware's reporting of the
+       * GTT size.
+       */
+      switch (INREG(PGETBL_CTL) & PGETBL_SIZE_MASK) {
+      case PGETBL_SIZE_512KB:
+	 gtt_size = 512;
+	 break;
+      case PGETBL_SIZE_256KB:
+	 gtt_size = 256;
+	 break;
+      case PGETBL_SIZE_128KB:
+	 gtt_size = 128;
+	 break;
+      default:
+	 FatalError("Unknown GTT size value: %08x\n", (int)INREG(PGETBL_CTL));
+      }
+   } else {
+      /* Older chipsets only had GTT appropriately sized for the aperture. */
+      gtt_size = pI830->FbMapSize / (1024*1024);
+   }
+
+   xf86DrvMsg(pScrn->scrnIndex, X_INFO, "detected %d kB GTT.\n", gtt_size);
+
+   /* The stolen memory has the GTT at the top, and the 4KB popup below that.
+    * Everything else can be freely used by the graphics driver.
+    */
+   range = gtt_size + 4;
 
    if (IS_I85X(pI830) || IS_I865G(pI830) || IS_I9XX(pI830)) {
       switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
diff-tree 359dc81c07901665da0f86c573c096fa1661cdd2 (from 9e4e7d4fa25a64a2494e7531967599142e60e716)
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Nov 29 15:01:39 2006 -0800

    Revert "Don't allocate stuff in the first 256K of video memory (GATT?)"
    
    This reverts commit 997e8c9bb4235cab1fff4738387df9afcbea0a03.
    
    The GTT is definitely located at the end of stolen memory.  This commit
    apparently worked around mis-estimation of the GTT size.

diff --git a/src/i830_driver.c b/src/i830_driver.c
index 1e619e4..39ffa54 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -806,7 +806,6 @@ I830PreInit(ScrnInfoPtr pScrn, int flags
    pointer pVBEModule = NULL;
    Bool enable;
    const char *chipname;
-   int mem_skip;
 #ifdef XF86DRI
    unsigned long savedMMSize;
 #endif
@@ -1126,15 +1125,8 @@ I830PreInit(ScrnInfoPtr pScrn, int flags
    /*
     * Get the pre-allocated (stolen) memory size.
     */
-    
-   mem_skip = 0;
-   
-   /* On 965, it looks like the GATT table is inside the aperture? */
-   if (IS_I965G(pI830))
-      mem_skip = pI830->FbMapSize >> 10;
-    
-   pI830->StolenMemory.Size = I830DetectMemory(pScrn) - mem_skip;
-   pI830->StolenMemory.Start = mem_skip;
+   pI830->StolenMemory.Size = I830DetectMemory(pScrn);
+   pI830->StolenMemory.Start = 0;
    pI830->StolenMemory.End = pI830->StolenMemory.Size;
 
    /* Find the maximum amount of agpgart memory available. */



More information about the xorg-commit mailing list