[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xserver-xorg-video-intel: Changes to 'upstream-experimental'



 Makefile.am                   |    2 
 README                        |    2 
 RELEASING                     |   13 +++
 configure.ac                  |   11 +++
 src/bios_reader/bios_reader.c |    4 -
 src/drmmode_display.c         |   10 +++
 src/i810_reg.h                |   42 ++++++++++++
 src/i830.h                    |    8 +-
 src/i830_batchbuffer.c        |    4 -
 src/i830_batchbuffer.h        |   11 ++-
 src/i830_bios.c               |    4 -
 src/i830_cursor.c             |    8 +-
 src/i830_debug.c              |   10 ++-
 src/i830_dri.c                |   35 ----------
 src/i830_driver.c             |  139 +++++++++++++++++++++++++++++++-----------
 src/i830_exa.c                |   30 ++++++---
 src/i830_memory.c             |   59 +++++++++++------
 src/i830_render.c             |    2 
 src/i830_video.c              |   54 +++++++++-------
 src/i915_render.c             |    2 
 src/i915_video.c              |   18 ++++-
 src/i965_render.c             |   32 +++++----
 src/i965_video.c              |   13 ++-
 23 files changed, 353 insertions(+), 160 deletions(-)

New commits:
commit 8e942b70cb9a784b3f1311affd6fc74c4bcf68bb
Author: Carl Worth <cworth@cworth.org>
Date:   Thu May 21 13:12:52 2009 -0700

    Revert "Rely on BO pixmaps being present in acceleration paths."
    
    This reverts commit 4653a7db622ad54a3182d93c81331765d930db34.
    
    Eric was getting a little too ambitious about our brave, new world.
    We do still want the driver to work with old, non-GEM kernels
    after all.

diff --git a/src/i830_batchbuffer.h b/src/i830_batchbuffer.h
index 0283438..4903b8c 100644
--- a/src/i830_batchbuffer.h
+++ b/src/i830_batchbuffer.h
@@ -102,9 +102,16 @@ intel_batch_emit_reloc_pixmap(I830Ptr pI830, PixmapPtr pPixmap,
 			      uint32_t delta)
 {
     dri_bo *bo = i830_get_pixmap_bo(pPixmap);
+    uint32_t offset;
     assert(pI830->batch_ptr != NULL);
     assert(intel_batch_space(pI830) >= 4);
-    intel_batch_emit_reloc(pI830, bo, read_domains, write_domain, delta);
+    if (bo) {
+	intel_batch_emit_reloc(pI830, bo, read_domains, write_domain, delta);
+	return;
+    }
+    offset = intel_get_pixmap_offset(pPixmap);
+    *(uint32_t *)(pI830->batch_ptr + pI830->batch_used) = offset + delta;
+    pI830->batch_used += 4;
 }
 
 #define OUT_BATCH(dword) intel_batch_emit_dword(pI830, dword)
diff --git a/src/i965_render.c b/src/i965_render.c
index 7583af1..e527f11 100644
--- a/src/i965_render.c
+++ b/src/i965_render.c
@@ -923,7 +923,6 @@ i965_set_picture_surface_state(dri_bo *ss_bo, int ss_index,
     struct brw_surface_state_padded *ss;
     struct brw_surface_state local_ss;
     dri_bo *pixmap_bo = i830_get_pixmap_bo(pPixmap);
-    uint32_t write_domain, read_domains;
 
     ss = (struct brw_surface_state_padded *)ss_bo->virtual + ss_index;
 
@@ -953,7 +952,10 @@ i965_set_picture_surface_state(dri_bo *ss_bo, int ss_index,
     local_ss.ss0.vert_line_stride_ofs = 0;
     local_ss.ss0.mipmap_layout_mode = 0;
     local_ss.ss0.render_cache_read_mode = 0;
-    local_ss.ss1.base_addr = pixmap_bo->offset;
+    if (pixmap_bo != NULL)
+	local_ss.ss1.base_addr = pixmap_bo->offset;
+    else
+	local_ss.ss1.base_addr = intel_get_pixmap_offset(pPixmap);
 
     local_ss.ss2.mip_count = 0;
     local_ss.ss2.render_target_rotation = 0;
@@ -965,20 +967,22 @@ i965_set_picture_surface_state(dri_bo *ss_bo, int ss_index,
 
     memcpy(ss, &local_ss, sizeof(local_ss));
 
+    if (pixmap_bo != NULL) {
+	uint32_t write_domain, read_domains;
 
-    if (is_dst) {
-	write_domain = I915_GEM_DOMAIN_RENDER;
-	read_domains = I915_GEM_DOMAIN_RENDER;
-    } else {
-	write_domain = 0;
-	read_domains = I915_GEM_DOMAIN_SAMPLER;
+	if (is_dst) {
+	    write_domain = I915_GEM_DOMAIN_RENDER;
+	    read_domains = I915_GEM_DOMAIN_RENDER;
+	} else {
+	    write_domain = 0;
+	    read_domains = I915_GEM_DOMAIN_SAMPLER;
+	}
+	dri_bo_emit_reloc(ss_bo, read_domains, write_domain,
+			  0,
+			  ss_index * sizeof(*ss) +
+			  offsetof(struct brw_surface_state, ss1),
+			  pixmap_bo);
     }
-    drm_intel_bo_emit_reloc(ss_bo,
-			    ss_index * sizeof(*ss) +
-			    offsetof(struct brw_surface_state, ss1),
-			    pixmap_bo,
-			    0,
-			    read_domains, write_domain);
 }
 
 static void

commit 1a039f4371bec455cad43f0fb7b329f2ee09a974
Author: Eric Anholt <eric@anholt.net>
Date:   Mon Apr 27 17:45:02 2009 -0700

    Fold GEM detection into DRM master open.
    
    We don't have anything to do with the DRM unless it's GEM-enabled, unless
    we were to support GEM-but-not-DRI2, which doesn't seem useful.
    
    Compilation fixes by Carl Worth <cworth@cworth.org>

diff --git a/src/i830_driver.c b/src/i830_driver.c
index ef4d575..0b6bb71 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -1420,7 +1420,8 @@ i830_open_drm_master(ScrnInfoPtr scrn)
     struct pci_device *dev = i830->PciInfo;
     char *busid;
     drmSetVersion sv;
-    int err;
+    struct drm_i915_getparam gp;
+    int err, has_gem;
 
     /* We wish we had asprintf, but all we get is XNFprintf. */
     busid = XNFprintf("pci:%04x:%02x:%02x.%d",
@@ -1428,6 +1429,7 @@ i830_open_drm_master(ScrnInfoPtr scrn)
 
     i830->drmSubFD = drmOpen("i915", busid);
     if (i830->drmSubFD == -1) {
+	xfree(busid);
 	xf86DrvMsg(scrn->scrnIndex, X_ERROR,
 		   "[drm] Failed to open DRM device for %s\n", busid);
 	return FALSE;
@@ -1449,6 +1451,19 @@ i830_open_drm_master(ScrnInfoPtr scrn)
 	return FALSE;
     }
 
+    has_gem = FALSE;
+    gp.param = I915_PARAM_HAS_GEM;
+    gp.value = &has_gem;
+    (void)drmCommandWriteRead(i830->drmSubFD, DRM_I915_GETPARAM,
+			      &gp, sizeof(gp));
+    if (!has_gem) {
+	xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+		   "[drm] Failed to detect GEM.  Kernel 2.6.28 required.\n");
+	drmClose(i830->drmSubFD);
+	i830->drmSubFD = -1;
+	return FALSE;
+    }
+
     return TRUE;
 }
 
diff --git a/src/i830_memory.c b/src/i830_memory.c
index 99b9fc8..5e07213 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -368,9 +368,7 @@ i830_allocator_init(ScrnInfoPtr pScrn, unsigned long size)
 {
     I830Ptr pI830 = I830PTR(pScrn);
     i830_memory *start, *end;
-    struct drm_i915_getparam gp;
     struct drm_i915_setparam sp;
-    int has_gem;
 
     start = xcalloc(1, sizeof(*start));
     if (start == NULL)
@@ -407,24 +405,12 @@ i830_allocator_init(ScrnInfoPtr pScrn, unsigned long size)
 
     pI830->memory_list = start;
 
-    has_gem = FALSE;
-
-    if (pI830->directRenderingType >= DRI_DRI2)
-    {
-	has_gem = FALSE;
-	gp.param = I915_PARAM_HAS_GEM;
-	gp.value = &has_gem;
-    
-	(void)drmCommandWriteRead(pI830->drmSubFD, DRM_I915_GETPARAM,
-				  &gp, sizeof(gp));
-    }
-
     /* Now that we have our manager set up, initialize the kernel MM if
      * possible, covering almost all of the aperture.  We need libdri interface
      * 5.4 or newer so we can rely on the lock being held after DRIScreenInit,
      * rather than after DRIFinishScreenInit.
      */
-    if (pI830->directRenderingType == DRI_DRI2 && has_gem) {
+    if (pI830->directRenderingType == DRI_DRI2) {
 	int mmsize;
 
 	/* Take over all of the graphics aperture minus enough to for

commit a04a51c9bb6066454e0fda3c7897f97dab436358
Author: Eric Anholt <eric@anholt.net>
Date:   Mon Apr 27 17:29:36 2009 -0700

    Open the DRM and keep the handle throughout server startup to finish.
    
    This will let us configure the server from start to finish with the
    most pertinent information available (KMS vs UMS, DRI2 vs non-DRI).  Also,
    we now close the DRI2 fd at terminate, which we didn't before.
    
    This duplicates some code from DRI1 for getting a master FD like I'd done in
    DRI2, but given that we weren't loading DRI1 ourselves, this is also a
    bogosity cleanup, and avoids allocating the extra DRI1 private.

diff --git a/src/i830_dri.c b/src/i830_dri.c
index 0648249..fc059df 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -329,7 +329,7 @@ Bool I830DRI2ScreenInit(ScreenPtr pScreen)
     ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     I830Ptr pI830 = I830PTR(pScrn);
     DRI2InfoRec info;
-    char *p, buf[64];
+    char *p;
     int i;
     struct stat sbuf;
     dev_t d;
@@ -355,36 +355,7 @@ Bool I830DRI2ScreenInit(ScreenPtr pScreen)
     }
 #endif
 
-    sprintf(buf, "pci:%04x:%02x:%02x.%d",
-	    pI830->PciInfo->domain,
-	    pI830->PciInfo->bus,
-	    pI830->PciInfo->dev,
-	    pI830->PciInfo->func);
-
-    /* Use the already opened (master) fd from modesetting */
-    if (pI830->use_drm_mode) {
-	info.fd = pI830->drmSubFD;
-    } else {
-	info.fd = drmOpen("i915", buf);
-	drmSetVersion sv;
-	int err;
-
-	/* Check that what we opened was a master or a master-capable FD,
-	 * by setting the version of the interface we'll use to talk to it.
-	 * (see DRIOpenDRMMaster() in DRI1)
-	 */
-	sv.drm_di_major = 1;
-	sv.drm_di_minor = 1;
-	sv.drm_dd_major = -1;
-	err = drmSetInterfaceVersion(info.fd, &sv);
-	if (err != 0)
-	    return FALSE;
-    }
-
-    if (info.fd < 0) {
-	xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Failed to open DRM device\n");
-	return FALSE;
-    }
+    info.fd = pI830->drmSubFD;
 
     /* The whole drmOpen thing is a fiasco and we need to find a way
      * back to just using open(2).  For now, however, lets just make
@@ -423,8 +394,6 @@ Bool I830DRI2ScreenInit(ScreenPtr pScreen)
 
     info.CopyRegion = I830DRI2CopyRegion;
 
-    pI830->drmSubFD = info.fd;
-
     return DRI2ScreenInit(pScreen, &info);
 }
 
diff --git a/src/i830_driver.c b/src/i830_driver.c
index 854ad0f..ef4d575 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -1414,28 +1414,61 @@ I830AccelMethodInit(ScrnInfoPtr pScrn)
 }
 
 static Bool
-I830DrmModeInit(ScrnInfoPtr pScrn)
+i830_open_drm_master(ScrnInfoPtr scrn)
 {
-    I830Ptr pI830 = I830PTR(pScrn);
-    char *bus_id;
-    int ret;
+    I830Ptr i830 = I830PTR(scrn);
+    struct pci_device *dev = i830->PciInfo;
+    char *busid;
+    drmSetVersion sv;
+    int err;
+
+    /* We wish we had asprintf, but all we get is XNFprintf. */
+    busid = XNFprintf("pci:%04x:%02x:%02x.%d",
+		      dev->domain, dev->bus, dev->dev, dev->func);
+
+    i830->drmSubFD = drmOpen("i915", busid);
+    if (i830->drmSubFD == -1) {
+	xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+		   "[drm] Failed to open DRM device for %s\n", busid);
+	return FALSE;
+    }
 
-    pI830->accel = ACCEL_UXA;
+    xfree(busid);
 
-    bus_id = DRICreatePCIBusID(pI830->PciInfo);
+    /* Check that what we opened was a master or a master-capable FD,
+     * by setting the version of the interface we'll use to talk to it.
+     * (see DRIOpenDRMMaster() in DRI1)
+     */
+    sv.drm_di_major = 1;
+    sv.drm_di_minor = 1;
+    sv.drm_dd_major = -1;
+    err = drmSetInterfaceVersion(i830->drmSubFD, &sv);
+    if (err != 0) {
+	drmClose(i830->drmSubFD);
+	i830->drmSubFD = -1;
+	return FALSE;
+    }
 
-    /* Create a bus Id */
-    /* Low level DRM open */
-    ret = DRIOpenDRMMaster(pScrn, SAREA_MAX, bus_id, "i915");
-    xfree(bus_id);
-    if (!ret) {
-	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		       "[dri] DRIGetVersion failed to open the DRM\n"
-		       "[dri] Disabling DRI.\n");
-	    return FALSE;
+    return TRUE;
+}
+
+static void
+i830_close_drm_master(ScrnInfoPtr scrn)
+{
+    I830Ptr i830 = I830PTR(scrn);
+    if (i830->drmSubFD > 0) {
+	drmClose(i830->drmSubFD);
+	i830->drmSubFD = -1;
     }
+}
+
+static Bool
+I830DrmModeInit(ScrnInfoPtr pScrn)
+{
+    I830Ptr pI830 = I830PTR(pScrn);
+
+    pI830->accel = ACCEL_UXA;
 
-    pI830->drmSubFD = DRIMasterFD(pScrn);
     if (drmmode_pre_init(pScrn, pI830->drmSubFD, pI830->cpp) == FALSE) {
 	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 		   "Kernel modesetting setup failed\n");
@@ -1477,11 +1510,17 @@ I830XvInit(ScrnInfoPtr pScrn)
 }
 
 /**
- * This is called per zaphod head (so usually just once) to do initialization
- * before the Screen is created.
+ * This is called before ScreenInit to do any require probing of screen
+ * configuration.
  *
  * This code generally covers probing, module loading, option handling
  * card mapping, and RandR setup.
+ *
+ * Since xf86InitialConfiguration ends up requiring that we set video modes
+ * in order to detect configuration, we end up having to do a lot of driver
+ * setup (talking to the DRM, mapping the device, etc.) in this function.
+ * As a result, we want to set up that server initialization once rather
+ * that doing it per generation.
  */
 static Bool
 I830PreInit(ScrnInfoPtr pScrn, int flags)
@@ -1531,6 +1570,8 @@ I830PreInit(ScrnInfoPtr pScrn, int flags)
 
    pI830->PciInfo = xf86GetPciInfoForEntity(pI830->pEnt->index);
 
+   i830_open_drm_master(pScrn);
+
    if (xf86RegisterResources(pI830->pEnt->index, NULL, ResNone)) {
       PreInitCleanup(pScrn);
       return FALSE;
@@ -2839,12 +2880,15 @@ i830AdjustFrame(int scrnIndex, int x, int y, int flags)
 static void
 I830FreeScreen(int scrnIndex, int flags)
 {
-#ifdef INTEL_XVMC
     ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+#ifdef INTEL_XVMC
     I830Ptr pI830 = I830PTR(pScrn);
     if (pI830 && pI830->XvMCEnabled)
 	intel_xvmc_finish(xf86Screens[scrnIndex]);
 #endif
+
+    i830_close_drm_master(pScrn);
+
    I830FreeRec(xf86Screens[scrnIndex]);
    if (xf86LoaderCheckSymbol("vgaHWFreeHWRec"))
       vgaHWFreeHWRec(xf86Screens[scrnIndex]);

commit c3bf8b980134a2761701e4bc18235695a1cb07a4
Author: Eric Anholt <eric@anholt.net>
Date:   Thu May 21 11:05:01 2009 -0700

    Fix backwards logic on whether to sync to vblank or not.
    
    Thanks to Michel Dänzer for catching it.

diff --git a/src/i830_video.c b/src/i830_video.c
index 6fec8ff..5beee52 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -2497,7 +2497,7 @@ I830PutImage(ScrnInfoPtr pScrn,
 	    int y1, y2;
 	    int pipe = -1, event, load_scan_lines_pipe;
 
-	    if (pPixmap != pScreen->GetScreenPixmap(pScreen)) {
+	    if (pPixmap == pScreen->GetScreenPixmap(pScreen)) {
 		if (pI830->use_drm_mode)
 		    pipe = drmmode_get_pipe_from_crtc_id(pI830->bufmgr, crtc);
 		else {

commit ad2128825ba28551cfef203da017151e2eac32ef
Author: Kristian Høgsberg <krh@redhat.com>
Date:   Wed May 20 12:32:10 2009 -0400

    Only return FALSE when dri_bo_map() fails
    
    Small typo in the previous commit.

diff --git a/src/i830_exa.c b/src/i830_exa.c
index 3ca7933..d0ada02 100644
--- a/src/i830_exa.c
+++ b/src/i830_exa.c
@@ -514,11 +514,12 @@ i830_uxa_prepare_access (PixmapPtr pixmap, uxa_access_t access)
 		    return FALSE;
 		}
 	    } else {
-		if (dri_bo_map(bo, access == UXA_ACCESS_RW) != 0)
+		if (dri_bo_map(bo, access == UXA_ACCESS_RW) != 0) {
 		    xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 			       "%s: bo map failed\n",
 			       __FUNCTION__);
-		return FALSE;
+		    return FALSE;
+		}
 	    }
 	    pixmap->devPrivate.ptr = bo->virtual;
 	} else { /* or not... */

commit 09beee378cecd1079e7a9fa6eee8f084d680d37e
Author: Eric Anholt <eric@anholt.net>
Date:   Mon May 18 18:01:05 2009 -0700

    Don't do GTT maps on objects bigger than half the available aperture size.
    
    The basic problem is that software fallbacks will do single instructions that
    copy from one GTT-mapped BO into another GTT-mapped BO.  If we can't get both
    of them bound simultanously, we fault one in, retry the instruction, fault the
    other in (kicking out #1), retry the instruction, fault #1 back in
    (kicking out #2), etc.
    
    Note that we'll still get into a nasty spot if you do a composite operation
    with a mask where all 3 are big-but-less-than-half-available-aperture, where
    you'll thrash.  It at least means you'll make progress, though, since each
    instruction will only be operating on two BOs at at time, and the situation
    seems unlikely.
    
    Bug #20152 (3/3)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 7df7b6f..24e0e26 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -232,6 +232,8 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 		drmmode_output_dpms(output, DPMSModeOn);
 	}
 
+	i830_set_max_gtt_map_size(pScrn);
+
 done:
 	if (!ret) {
 		crtc->x = saved_x;
diff --git a/src/i830.h b/src/i830.h
index 0969c48..7c260de 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -437,6 +437,7 @@ typedef struct _I830Rec {
    int accel_pixmap_offset_alignment;
    int accel_max_x;
    int accel_max_y;
+   int max_gtt_map_size;
 
    I830WriteIndexedByteFunc writeControl;
    I830ReadIndexedByteFunc readControl;
@@ -748,6 +749,7 @@ Bool i830_bind_all_memory(ScrnInfoPtr pScrn);
 Bool i830_unbind_all_memory(ScrnInfoPtr pScrn);
 unsigned long i830_get_fence_size(I830Ptr pI830, unsigned long size);
 unsigned long i830_get_fence_pitch(I830Ptr pI830, unsigned long pitch, int format);
+void i830_set_max_gtt_map_size(ScrnInfoPtr pScrn);
 
 Bool I830BindAGPMemory(ScrnInfoPtr pScrn);
 Bool I830UnbindAGPMemory(ScrnInfoPtr pScrn);
diff --git a/src/i830_exa.c b/src/i830_exa.c
index 824f032..3ca7933 100644
--- a/src/i830_exa.c
+++ b/src/i830_exa.c
@@ -506,9 +506,18 @@ i830_uxa_prepare_access (PixmapPtr pixmap, uxa_access_t access)
 
 	/* Kernel manages fences at GTT map/fault time */
 	if (i830->kernel_exec_fencing) {
-	    if (drm_intel_gem_bo_map_gtt(bo)) {
-		xf86DrvMsg(scrn->scrnIndex, X_WARNING, "%s: bo map failed\n",
-			   __FUNCTION__);
+	    if (bo->size < i830->max_gtt_map_size) {
+		if (drm_intel_gem_bo_map_gtt(bo)) {
+		    xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+			       "%s: bo map failed\n",
+			       __FUNCTION__);
+		    return FALSE;
+		}
+	    } else {
+		if (dri_bo_map(bo, access == UXA_ACCESS_RW) != 0)
+		    xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+			       "%s: bo map failed\n",
+			       __FUNCTION__);
 		return FALSE;
 	    }
 	    pixmap->devPrivate.ptr = bo->virtual;
@@ -542,7 +551,10 @@ i830_uxa_finish_access (PixmapPtr pixmap)
 	}
 
 	if (i830->kernel_exec_fencing)
-	    drm_intel_gem_bo_unmap_gtt(bo);
+	    if (bo->size < i830->max_gtt_map_size)
+		drm_intel_gem_bo_unmap_gtt(bo);
+	    else
+		dri_bo_unmap(bo);
 	else
 	    drm_intel_bo_unpin(bo);
 	pixmap->devPrivate.ptr = NULL;
diff --git a/src/i830_memory.c b/src/i830_memory.c
index 2a697a7..99b9fc8 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -1128,6 +1128,8 @@ i830_allocate_framebuffer(ScrnInfoPtr pScrn)
     if (!pI830->use_drm_mode && pI830->FbBase && front_buffer->bound)
 	memset (pI830->FbBase + front_buffer->offset, 0, size);
 
+    i830_set_max_gtt_map_size(pScrn);
+
     return front_buffer;
 }
 
@@ -1588,6 +1590,7 @@ i830_bind_all_memory(ScrnInfoPtr pScrn)
     }
     if (!pI830->use_drm_mode)
 	i830_update_cursor_offsets(pScrn);
+    i830_set_max_gtt_map_size(pScrn);
 
     return TRUE;
 }
@@ -1672,3 +1675,26 @@ Bool i830_allocate_xvmc_buffer(ScrnInfoPtr pScrn, const char *name,
     return TRUE;
 }
 #endif
+
+void
+i830_set_max_gtt_map_size(ScrnInfoPtr pScrn)
+{
+    I830Ptr pI830 = I830PTR(pScrn);
+    struct drm_i915_gem_get_aperture aperture;
+    int ret;
+
+    /* Default low value in case it gets used during server init. */
+    pI830->max_gtt_map_size = 16 * 1024 * 1024;
+
+    if (!pI830->have_gem)
+	return;
+
+    ret = ioctl(pI830->drmSubFD, DRM_IOCTL_I915_GEM_GET_APERTURE, &aperture);
+    if (ret == 0) {
+	/* Let objects up get bound up to the size where only 2 would fit in
+	 * the aperture, but then leave slop to account for alignment like
+	 * libdrm does.
+	 */
+	pI830->max_gtt_map_size = aperture.aper_available_size * 3 / 4 / 2;
+    }
+}

commit 34660fd2df5d61b77ed7041d32ac29053fc94f5a
Author: Eric Anholt <eric@anholt.net>
Date:   Fri May 15 23:21:05 2009 -0700

    Only sync XV to vblank when drawing to the frontbuffer.
    
    This fixes emitting syncs to random pipes with boxes bigger than that
    pipe's vertical, leading to GPU hangs.
    
    Bug #21738

diff --git a/src/i830_video.c b/src/i830_video.c
index 1c3a5b7..6fec8ff 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -2495,13 +2495,15 @@ I830PutImage(ScrnInfoPtr pScrn,
         if (sync) {
 	    BoxPtr box;
 	    int y1, y2;
-            int pipe, event, load_scan_lines_pipe;
-
-	    if (pI830->use_drm_mode)
-		pipe = drmmode_get_pipe_from_crtc_id(pI830->bufmgr, crtc);
-	    else {
-		I830CrtcPrivatePtr intel_crtc = crtc->driver_private;
-		pipe = intel_crtc->pipe;
+	    int pipe = -1, event, load_scan_lines_pipe;
+
+	    if (pPixmap != pScreen->GetScreenPixmap(pScreen)) {
+		if (pI830->use_drm_mode)
+		    pipe = drmmode_get_pipe_from_crtc_id(pI830->bufmgr, crtc);
+		else {
+		    I830CrtcPrivatePtr intel_crtc = crtc->driver_private;
+		    pipe = intel_crtc->pipe;
+		}
 	    }
 
 	    if (pipe >= 0) {

commit 87332a7cc16af82aa47e07fbf90da3635b071dbf
Author: Keith Packard <keithp@keithp.com>
Date:   Mon May 11 13:52:00 2009 -0700

    Use drm_intel_bo_disable_reuse API to flag scanout and cursor buffers
    
    Buffers referenced by the kernel for scanout or cursor display should not be
    reused by the driver. Use the new drm API to disable reuse of these buffers.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>

diff --git a/src/i830.h b/src/i830.h
index 33a92c6..0969c48 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -902,6 +902,7 @@ extern const int I830CopyROP[16];
 #define NEED_NON_STOLEN			0x00000004
 #define NEED_LIFETIME_FIXED		0x00000008
 #define ALLOW_SHARING			0x00000010
+#define DISABLE_REUSE			0x00000020
 
 /* Chipset registers for VIDEO BIOS memory RW access */
 #define _855_DRAM_RW_CONTROL 0x58
diff --git a/src/i830_memory.c b/src/i830_memory.c
index 892c26e..2a697a7 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -799,6 +799,9 @@ i830_allocate_memory_bo(ScrnInfoPtr pScrn, const char *name,
 	}
     }
 
+    if (flags & DISABLE_REUSE)
+	drm_intel_bo_disable_reuse(mem->bo);
+
     /* Insert new allocation into the list */
     mem->prev = NULL;
     mem->next = pI830->bo_list;
@@ -1076,7 +1079,7 @@ i830_allocate_framebuffer(ScrnInfoPtr pScrn)
     i830_memory *front_buffer = NULL;
     enum tile_format tile_format = TILE_NONE;
 
-    flags = ALLOW_SHARING;
+    flags = ALLOW_SHARING|DISABLE_REUSE;
 
     /* We'll allocate the fb such that the root window will fit regardless of
      * rotation.
@@ -1142,6 +1145,8 @@ i830_allocate_cursor_buffers(ScrnInfoPtr pScrn)
 
     flags = pI830->CursorNeedsPhysical ? NEED_PHYSICAL_ADDR : 0;
 
+    flags |= DISABLE_REUSE;
+
     /* Try to allocate one big blob for our cursor memory.  This works
      * around a limitation in the FreeBSD AGP driver that allows only one
      * physical allocation larger than a page, and could allow us

commit ebe05200df381c0e6ee636f0f83440bfedea9bcb
Author: Jesse Barnes <jbarnes@virtuousgeek.org>
Date:   Fri May 15 08:50:17 2009 -0700

    Add --enable-debug flag to configure
    
    Defaults to enabled.

diff --git a/configure.ac b/configure.ac
index 028d17d..bb05d1e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,6 +70,14 @@ AC_ARG_ENABLE(video-debug, AC_HELP_STRING([--enable-video-debug],
               [VIDEO_DEBUG="$enableval"],
               [VIDEO_DEBUG=no])
 
+AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],
+				    [Compile with debug support [[default=yes]]]))
+if test "x$enableval" == "xyes" ; then
+	DEBUGFLAGS="-g"
+else
+	DEBUGFLAGS=""
+fi
+
 dnl AC_ARG_ENABLE(xvmc, AC_HELP_STRING([--disable-xvmc],
 dnl                                   [Disable XvMC support [[default=auto]]]),
 dnl               [XVMC="$enableval"],
@@ -116,7 +124,7 @@ if test x$DRI = xauto; then
         fi
 fi
 AC_MSG_RESULT([$DRI])
-CFLAGS="$save_CFLAGS"
+CFLAGS="$save_CFLAGS $DEBUGFLAGS"
 
 PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.10])
 

commit 04772b6c09a88f0483c2a7efc48029967c77b9bc
Author: Keith Packard <keithp@keithp.com>
Date:   Thu May 14 16:57:11 2009 -0700

    If DRM can't figure out which pipe to sync on, then don't sync at all.
    
    Syncing to the wrong pipe can wedge the hardware if the exclusion area is
    larger than the vtotal
    
    Signed-off-by: Keith Packard <keithp@keithp.com>

diff --git a/configure.ac b/configure.ac
index 8aef4cf..028d17d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -130,7 +130,7 @@ if test "x$GCC" = "xyes"; then
 	-Wnested-externs -fno-strict-aliasing"
 fi
 
-PKG_CHECK_MODULES(DRM, [libdrm >= 2.4.6])
+PKG_CHECK_MODULES(DRM, [libdrm >= 2.4.11])
 AM_CONDITIONAL(DRI, test x$DRI = xyes)
 if test "$DRI" = yes; then
         PKG_CHECK_MODULES(DRI, [xf86driproto glproto])
diff --git a/src/i830_video.c b/src/i830_video.c
index 64cea04..1c3a5b7 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -2504,27 +2504,29 @@ I830PutImage(ScrnInfoPtr pScrn,
 		pipe = intel_crtc->pipe;
 	    }
 
-	    if (pipe == 0) {
-		event = MI_WAIT_FOR_PIPEA_SCAN_LINE_WINDOW;
-		load_scan_lines_pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEA;
-	    } else {
-		event = MI_WAIT_FOR_PIPEB_SCAN_LINE_WINDOW;
-		load_scan_lines_pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEB;
-	    }
+	    if (pipe >= 0) {
+		if (pipe == 0) {
+		    event = MI_WAIT_FOR_PIPEA_SCAN_LINE_WINDOW;
+		    load_scan_lines_pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEA;
+		} else {
+		    event = MI_WAIT_FOR_PIPEB_SCAN_LINE_WINDOW;
+		    load_scan_lines_pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEB;
+		}
 
-	    box = REGION_EXTENTS(unused, clipBoxes);
-	    y1 = box->y1 - crtc->y;
-	    y2 = box->y2 - crtc->y;
-
-            BEGIN_BATCH(5);
-	    /* The documentation says that the LOAD_SCAN_LINES command
-	     * always comes in pairs. Don't ask me why. */
-	    OUT_BATCH(MI_LOAD_SCAN_LINES_INCL | load_scan_lines_pipe);
-	    OUT_BATCH((y1 << 16) | y2);
-	    OUT_BATCH(MI_LOAD_SCAN_LINES_INCL | load_scan_lines_pipe);
-	    OUT_BATCH((y1 << 16) | y2);
-            OUT_BATCH(MI_WAIT_FOR_EVENT | event);
-            ADVANCE_BATCH();
+		box = REGION_EXTENTS(unused, clipBoxes);
+		y1 = box->y1 - crtc->y;
+		y2 = box->y2 - crtc->y;
+
+		BEGIN_BATCH(5);
+		/* The documentation says that the LOAD_SCAN_LINES command
+		 * always comes in pairs. Don't ask me why. */
+		OUT_BATCH(MI_LOAD_SCAN_LINES_INCL | load_scan_lines_pipe);
+		OUT_BATCH((y1 << 16) | y2);
+		OUT_BATCH(MI_LOAD_SCAN_LINES_INCL | load_scan_lines_pipe);
+		OUT_BATCH((y1 << 16) | y2);
+		OUT_BATCH(MI_WAIT_FOR_EVENT | event);
+		ADVANCE_BATCH();
+	    }
         }
 
         if (IS_I965G(pI830)) {

commit 128c1c3b7d57b157604788f82bf9fd389839068f
Author: Carl Worth <cworth@cworth.org>
Date:   Wed Apr 29 14:43:56 2009 -0700

    Use libdrm to lookup pipe for tear-free sync of XV
    
    Previously, the code was trying to examine a driver_private field,
    but those fields are only set by the userland-modesetting code so
    would fail in the case of KMS. This fixes bug #21076:
    
    [945GME] [KMS] XV_SYNC_TO_VBLANK does not prevent tearing of xv video
    https://bugs.freedesktop.org/show_bug.cgi?id=21076

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 15ffc29..7df7b6f 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -920,3 +920,11 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, int fd, int cpp)
 
 	return TRUE;
 }
+
+int
+drmmode_get_pipe_from_crtc_id(drm_intel_bufmgr *bufmgr, xf86CrtcPtr crtc)
+{
+	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+	return drm_intel_get_pipe_from_crtc_id (bufmgr, drmmode_crtc->mode_crtc->crtc_id);
+}
diff --git a/src/i830.h b/src/i830.h
index 68bc0a5..33a92c6 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -679,6 +679,7 @@ Bool I830DRI2ScreenInit(ScreenPtr pScreen);
 void I830DRI2CloseScreen(ScreenPtr pScreen);
 
 extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, int fd, int cpp);
+extern int drmmode_get_pipe_from_crtc_id(drm_intel_bufmgr *bufmgr, xf86CrtcPtr crtc);
 
 extern Bool I830AccelInit(ScreenPtr pScreen);
 extern void I830SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir,
diff --git a/src/i830_video.c b/src/i830_video.c
index 1e05e9c..64cea04 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -2495,15 +2495,21 @@ I830PutImage(ScrnInfoPtr pScrn,
         if (sync) {
 	    BoxPtr box;
 	    int y1, y2;
-            int event, pipe;
-	    I830CrtcPrivatePtr intel_crtc = crtc->driver_private;
+            int pipe, event, load_scan_lines_pipe;
 
-	    if (intel_crtc->pipe == 0) {
+	    if (pI830->use_drm_mode)
+		pipe = drmmode_get_pipe_from_crtc_id(pI830->bufmgr, crtc);
+	    else {
+		I830CrtcPrivatePtr intel_crtc = crtc->driver_private;
+		pipe = intel_crtc->pipe;
+	    }
+
+	    if (pipe == 0) {
 		event = MI_WAIT_FOR_PIPEA_SCAN_LINE_WINDOW;
-		pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEA;
+		load_scan_lines_pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEA;
 	    } else {
 		event = MI_WAIT_FOR_PIPEB_SCAN_LINE_WINDOW;
-		pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEB;
+		load_scan_lines_pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEB;
 	    }
 
 	    box = REGION_EXTENTS(unused, clipBoxes);
@@ -2513,9 +2519,9 @@ I830PutImage(ScrnInfoPtr pScrn,
             BEGIN_BATCH(5);
 	    /* The documentation says that the LOAD_SCAN_LINES command
 	     * always comes in pairs. Don't ask me why. */
-	    OUT_BATCH(MI_LOAD_SCAN_LINES_INCL | pipe);
+	    OUT_BATCH(MI_LOAD_SCAN_LINES_INCL | load_scan_lines_pipe);
 	    OUT_BATCH((y1 << 16) | y2);
-	    OUT_BATCH(MI_LOAD_SCAN_LINES_INCL | pipe);
+	    OUT_BATCH(MI_LOAD_SCAN_LINES_INCL | load_scan_lines_pipe);
 	    OUT_BATCH((y1 << 16) | y2);
             OUT_BATCH(MI_WAIT_FOR_EVENT | event);
             ADVANCE_BATCH();

commit 2572fcc6196aff7a2f1095d211fd85d8668647ca
Author: Wu Fengguang <fengguang.wu@intel.com>
Date:   Thu Apr 30 19:51:26 2009 +0800

    README: kill an evil dot
    
    To make copy and paste a more pleasure.
    
    Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
    Signed-off-by: Eric Anholt <eric@anholt.net>

diff --git a/README b/README
index 96db084..8b0998f 100644
--- a/README
+++ b/README
@@ -31,7 +31,7 @@ documentation can be read with the following command:
 Mailing list for communication with users and developers of
 xf86-video-intel:
 
-	intel-gfx@lists.freedesktop.org.
+	intel-gfx@lists.freedesktop.org
 
 	Note: Subscription is required before posting, but anyone is
 	free to subscribe. See instructions (and archives) here:

commit b9462516d18bc57be5f33f57adb6c3e8beede5ff
Author: Eric Anholt <eric@anholt.net>
Date:   Tue May 12 18:53:27 2009 -0700

    Remove dead "avail" variable from XAA stuff.

diff --git a/src/i830_memory.c b/src/i830_memory.c
index 14e7f89..892c26e 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -1069,7 +1069,7 @@ i830_allocate_framebuffer(ScrnInfoPtr pScrn)
 {
     I830Ptr pI830 = I830PTR(pScrn);
     unsigned int pitch = pScrn->displayWidth * pI830->cpp;
-    unsigned long minspace, avail;
+    unsigned long minspace;
     int align;
     long size, fb_height;
     int flags;
@@ -1088,7 +1088,6 @@ i830_allocate_framebuffer(ScrnInfoPtr pScrn)
      * enough for the virtual screen size.
      */
     minspace = pitch * pScrn->virtualY;
-    avail = pScrn->videoRam * 1024;
 
     size = ROUND_TO_PAGE(pitch * fb_height);
 

commit 1c68bc376a9cb3c0a010c8e28f69a776755c8f64
Author: Jesse Barnes <jbarnes@virtuousgeek.org>
Date:   Wed May 13 13:19:53 2009 -0700

    Add new have_gem flag
    
    Prior to this patch, code that wanted to check whether GEM was present
    would look at pI830->memory_manager.  This turned out to be occasionally
    problematic in the KMS case, since memory_manager didn't always get set
    correctly.  So add a new pI830->have_gem flag to make things clear in
    the various code paths, and set it after GEM initializes or when KMS is
    detected.
    
    Reviewed-by: Eric Anholt <eric@anholt.net>
    Tested-by: Magnus Kessler <Magnus.Kessler@gmx.net>
    Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>

diff --git a/src/i830.h b/src/i830.h
index 0d8726c..68bc0a5 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -405,6 +405,7 @@ typedef struct _I830Rec {
 
    i830_memory *memory_manager;		/**< DRI memory manager aperture */
 
+   Bool have_gem;
    Bool need_mi_flush;
 
    Bool tiling;
diff --git a/src/i830_batchbuffer.c b/src/i830_batchbuffer.c
index 5a9f9c5..a6d9c6e 100644
--- a/src/i830_batchbuffer.c
+++ b/src/i830_batchbuffer.c
@@ -179,7 +179,7 @@ intel_batch_flush(ScrnInfoPtr pScrn, Bool flushed)
 	return;
 
     /* If we're not using GEM, then emit a flush after each batch buffer */
-    if (pI830->memory_manager == NULL && !flushed) {
+    if (!pI830->have_gem && !flushed) {
 	int flags = MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE;
 
 	if (IS_I965G(pI830))
@@ -219,7 +219,7 @@ intel_batch_flush(ScrnInfoPtr pScrn, Bool flushed)
      * blockhandler.  We could set this less often, but it's probably not worth


Reply to: