xf86-video-intel: 7 commits - src/drmmode_display.c src/i830_accel.c src/i830_dri.c src/i830_driver.c src/i830.h src/i830_memory.c src/i830_uxa.c

Keith Packard keithp at kemper.freedesktop.org
Fri Jul 10 18:27:10 PDT 2009


 src/drmmode_display.c |   19 ++---
 src/i830.h            |   15 ----
 src/i830_accel.c      |   11 ---
 src/i830_dri.c        |    5 -
 src/i830_driver.c     |  183 ++++++++++++--------------------------------------
 src/i830_memory.c     |  153 +++++++++++++++++++++--------------------
 src/i830_uxa.c        |   38 +++-------
 7 files changed, 151 insertions(+), 273 deletions(-)

New commits:
commit ed8a9a94e1a670ca35311c9ed83d0c479530d41a
Author: Keith Packard <keithp at keithp.com>
Date:   Fri Jul 10 17:13:14 2009 -0700

    i830_uxa_prepare_access: Flush and wait for idle for non-bo pixmaps
    
    Without kernel support and explicit knowledge about where in the ring the
    last rendering operation for a specific pixmap was, we must synchronize with
    any outstanding rendering before accessing a pixmap which does not have a
    buffer object.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/src/i830_uxa.c b/src/i830_uxa.c
index c3fdcec..2050c48 100644
--- a/src/i830_uxa.c
+++ b/src/i830_uxa.c
@@ -477,13 +477,12 @@ static Bool
 i830_uxa_prepare_access (PixmapPtr pixmap, uxa_access_t access)
 {
     dri_bo *bo = i830_get_pixmap_bo (pixmap);
+    ScrnInfoPtr scrn = xf86Screens[pixmap->drawable.pScreen->myNum];
+
+    intel_batch_flush(scrn, FALSE);
 
     if (bo) {
-	ScreenPtr screen = pixmap->drawable.pScreen;
-	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
 	I830Ptr i830 = I830PTR(scrn);
-	
-	intel_batch_flush(scrn, FALSE);
 
 	/* No VT sema or GEM?  No GTT mapping. */
 	if (!scrn->vtSema || !i830->have_gem) {
@@ -517,7 +516,9 @@ i830_uxa_prepare_access (PixmapPtr pixmap, uxa_access_t access)
 	    drm_intel_gem_bo_start_gtt_access(bo, access == UXA_ACCESS_RW);
 	    pixmap->devPrivate.ptr = i830->FbBase + bo->offset;
 	}
-    }
+    } else
+	i830_wait_ring_idle(scrn);
+
     return TRUE;
 }
 
commit cb19ac207b784d814f6f389110fd1b21a0f34e8b
Author: Keith Packard <keithp at keithp.com>
Date:   Fri Jul 10 14:01:02 2009 -0700

    KMS: Keep screen pixmap devPrivate.ptr NULL during init and resize
    
    The frame buffer only has a valid address between prepare_access and
    finish_access calls, so remove all other attempts to compute an address from
    the driver.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 7cfdc5b..df10fb5 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1056,12 +1056,9 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height)
 		goto fail;
 
 	i830_set_pixmap_bo(screen->GetScreenPixmap(screen), pI830->front_buffer->bo);
-	scrn->fbOffset = pI830->front_buffer->offset;
 
 	screen->ModifyPixmapHeader(screen->GetScreenPixmap(screen),
 				   width, height, -1, -1, pitch * pI830->cpp, NULL);
-	xf86DrvMsg(scrn->scrnIndex, X_INFO, "New front buffer at 0x%lx\n",
-		   pI830->front_buffer->offset);
 
 	for (i = 0; i < xf86_config->num_crtc; i++) {
 		xf86CrtcPtr crtc = xf86_config->crtc[i];
commit 704b88dd50a7e7e3f362264b86d0401bee8603aa
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Jul 8 13:06:47 2009 -0700

    i830_bind_memory: Under UMS: Bind GEM bos with dri_bo_pin, else through the GART
    
    We only need to get static offsets for objects when not running KMS,
    otherwise the kernel will manage those as needed for us.
    
    Binding objects is done in one of two ways. For GEM buffer objects, we use
    dri_bo_pin. For GART allocated memory, we bind that to the GART.

diff --git a/src/i830_memory.c b/src/i830_memory.c
index 556b511..f2f3966 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -199,10 +199,11 @@ i830_bind_memory(ScrnInfoPtr pScrn, i830_memory *mem)
 {
     I830Ptr pI830 = I830PTR(pScrn);
 
-    if (mem == NULL || mem->bound)
+    if (mem == NULL || mem->bound || pI830->use_drm_mode)
 	return TRUE;
 
-    if (mem->bo != NULL && !pI830->use_drm_mode) {
+    if (pI830->have_gem && mem->bo != NULL) {
+
 	if (dri_bo_pin(mem->bo, mem->alignment) != 0) {
 	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 		       "Failed to pin %s: %s\n",
@@ -213,9 +214,7 @@ i830_bind_memory(ScrnInfoPtr pScrn, i830_memory *mem)
 	mem->bound = TRUE;
 	mem->offset = mem->bo->offset;
 	mem->end = mem->offset + mem->size;
-    }
-
-    if (!mem->bound) {
+    } else {
 	if (!pI830->gtt_acquired)
 	    return TRUE;
 
@@ -228,8 +227,7 @@ i830_bind_memory(ScrnInfoPtr pScrn, i830_memory *mem)
 	mem->bound = TRUE;
     }
 
-    if (mem->tiling != TILE_NONE && !pI830->use_drm_mode &&
-	!pI830->kernel_exec_fencing) {
+    if (mem->tiling != TILE_NONE && !pI830->kernel_exec_fencing) {
 	mem->fence_nr = i830_set_tiling(pScrn, mem->offset, mem->pitch,
 					mem->allocated_size, mem->tiling);
     }
@@ -1114,7 +1112,7 @@ i830_allocate_framebuffer(ScrnInfoPtr pScrn)
 	return NULL;
     }
 
-    if (!pI830->use_drm_mode && pI830->FbBase && front_buffer->bound)
+    if (pI830->FbBase && front_buffer->bound)
 	memset (pI830->FbBase + front_buffer->offset, 0, size);
 
     i830_set_max_gtt_map_size(pScrn);
commit 7b273732f70e91df8b41d5c48e1379271557dd8e
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Jul 8 11:53:13 2009 -0700

    Allocate GTT space for GEM only under UMS
    
    GEM requires GTT space to map objects. Under KMS, the kernel driver has
    already provided all available GTT space to GEM, so the X server need not do
    anything.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/src/i830_driver.c b/src/i830_driver.c
index e5e5fd7..fe2565c 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -2674,8 +2674,8 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
    if (!pI830->use_drm_mode)
        I830MapMMIO(pScrn);
 
-   /* Need FB mapped to set up the fake bufmgr if we end up doing that
-    * in i830_memory_init() -> i830_allocator_init().
+   /* Need FB mapped to access non-GEM objects like
+    * a UMS frame buffer, or the fake bufmgr.
     */
    if (!pI830->use_drm_mode) {
       if (!I830MapMem(pScrn))
@@ -2701,10 +2701,6 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
    if (!miSetPixmapDepths())
       return FALSE;
 
-   i830_init_bufmgr(pScrn);
-
-   pScrn->fbOffset = pI830->front_buffer->offset;
-
    if (!pI830->use_drm_mode) {
        vgaHWSetMmioFuncs(hwp, pI830->MMIOBase, 0);
        vgaHWGetIOBase(hwp);
diff --git a/src/i830_memory.c b/src/i830_memory.c
index 2953f3b..556b511 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -334,10 +334,8 @@ i830_reset_allocations(ScrnInfoPtr pScrn)
     }
 
     /* Free any allocations in buffer objects */
-    if (pI830->memory_manager) {
-	while (pI830->bo_list != NULL)
-	    i830_free_memory(pScrn, pI830->bo_list);
-    }
+    while (pI830->bo_list != NULL)
+        i830_free_memory(pScrn, pI830->bo_list);
 
     /* Null out the pointers for all the allocations we just freed.  This is
      * kind of gross, but at least it's just one place now.
@@ -405,12 +403,14 @@ i830_allocator_init(ScrnInfoPtr pScrn, unsigned long size)
 
     pI830->memory_list = start;
 
-    /* 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.
+    /* Now that we have our manager set up, give the kernel a piece of the
+     * aperture for GEM buffer object mapping. This is only needed for UXA
+     * and/or DRI2 when the kernel hasn't already managed this itself under
+     * KMS.  We need libdri interface5.4 or newer so we can rely on the lock
+     * being held after DRIScreenInit, rather than after DRIFinishScreenInit.
      */
-    if (pI830->directRenderingType == DRI_DRI2) {
+
+    if (!pI830->use_drm_mode) {
 	int mmsize;
 
 	/* Take over all of the graphics aperture minus enough to for
@@ -426,53 +426,49 @@ i830_allocator_init(ScrnInfoPtr pScrn, unsigned long size)
 	}
 	if (pI830->CursorNeedsPhysical) {
 	    mmsize -= 2 * (ROUND_TO(HWCURSOR_SIZE, GTT_PAGE_SIZE) +
-		    ROUND_TO(HWCURSOR_SIZE_ARGB, GTT_PAGE_SIZE));
+			   ROUND_TO(HWCURSOR_SIZE_ARGB, GTT_PAGE_SIZE));
 	}
 	if (pI830->fb_compression)
 	    mmsize -= MB(6) + ROUND_TO_PAGE(FBC_LL_SIZE + FBC_LL_PAD);
+
 	/* Can't do GEM on stolen memory */
 	mmsize -= pI830->stolen_size;
 
 	/* Create the aperture allocation */
 	pI830->memory_manager =
-	    i830_allocate_aperture(pScrn, "DRI memory manager",
-				   mmsize, 0, GTT_PAGE_SIZE,
-				   ALIGN_BOTH_ENDS | NEED_NON_STOLEN,
-				   TILE_NONE);
+		i830_allocate_aperture(pScrn, "DRI memory manager",
+				       mmsize, 0, GTT_PAGE_SIZE,
+				       ALIGN_BOTH_ENDS | NEED_NON_STOLEN,
+				       TILE_NONE);
 
 	if (pI830->memory_manager != NULL) {
-	    if (!pI830->use_drm_mode) {
-		struct drm_i915_gem_init init;
-		int ret;
-
-		sp.param = I915_SETPARAM_NUM_USED_FENCES;
-		sp.value = 0; /* kernel gets them all */
-
-		ret = drmCommandWrite(pI830->drmSubFD, DRM_I915_SETPARAM,
-				      &sp, sizeof(sp));
-		if (ret == 0)
-		    pI830->kernel_exec_fencing = TRUE;
-
-		init.gtt_start = pI830->memory_manager->offset;
-		init.gtt_end = pI830->memory_manager->offset +
-		    pI830->memory_manager->size;
-
-		/* Tell the kernel to manage it */
-		ret = ioctl(pI830->drmSubFD, DRM_IOCTL_I915_GEM_INIT, &init);
-		if (ret != 0) {
-		    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-			       "Failed to initialize kernel memory manager\n");
-		    i830_free_memory(pScrn, pI830->memory_manager);
-		    pI830->memory_manager = NULL;
-		}
+	    struct drm_i915_gem_init init;
+	    int ret;
+
+	    sp.param = I915_SETPARAM_NUM_USED_FENCES;
+	    sp.value = 0; /* kernel gets them all */
+
+	    ret = drmCommandWrite(pI830->drmSubFD, DRM_I915_SETPARAM,
+				  &sp, sizeof(sp));
+	    if (ret == 0)
+		pI830->kernel_exec_fencing = TRUE;
+	    init.gtt_start = pI830->memory_manager->offset;
+	    init.gtt_end = pI830->memory_manager->offset + pI830->memory_manager->size;
+
+	    /* Tell the kernel to manage it */
+	    ret = ioctl(pI830->drmSubFD, DRM_IOCTL_I915_GEM_INIT, &init);
+	    if (ret == 0) {
 		pI830->have_gem = TRUE;
 		i830_init_bufmgr(pScrn);
+	    } else {
+		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+			   "Failed to initialize kernel memory manager\n");
+		i830_free_memory(pScrn, pI830->memory_manager);
+		pI830->memory_manager = NULL;
 	    }
 	} else {
 	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 		       "Failed to allocate space for kernel memory manager\n");
-	    i830_free_memory(pScrn, pI830->memory_manager);
-	    pI830->memory_manager = NULL;
 	}
     }
 
@@ -842,9 +838,15 @@ i830_allocate_memory(ScrnInfoPtr pScrn, const char *name,
 	size = i830_get_fence_size(pI830, size);
 	alignment = i830_get_fence_alignment(pI830, size);
     }
-    if (pI830->use_drm_mode || (pI830->memory_manager &&
-				!(flags & NEED_PHYSICAL_ADDR) &&
-				!(flags & NEED_LIFETIME_FIXED)))
+    /*
+     * Create a kernel buffer object when suitable.
+     * Under KMS, all graphics memory must be managed by the
+     * kernel. Under UMS, we separately reserve space for
+     * a few objects (overlays, power context, cursors, etc).
+     */
+    if (pI830->have_gem &&
+	(pI830->use_drm_mode ||
+	 !(flags & (NEED_PHYSICAL_ADDR|NEED_LIFETIME_FIXED))))
     {
 	return i830_allocate_memory_bo(pScrn, name, size, pitch, alignment, flags, tile_format);
     } else
@@ -917,31 +919,33 @@ i830_describe_allocations(ScrnInfoPtr pScrn, int verbosity, const char *prefix)
 		   "%s0x%08lx:            end of aperture\n",
 		   prefix, pI830->FbMapSize);
 
+    xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
+		   "%sBO memory allocation layout:\n", prefix);
     if (pI830->memory_manager) {
 	xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
-		       "%sBO memory allocation layout:\n", prefix);
-	xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
 		       "%s0x%08lx:            start of memory manager\n",
 		       prefix, pI830->memory_manager->offset);
-	for (mem = pI830->bo_list; mem != NULL; mem = mem->next) {
-	    char *tile_suffix = "";
-
-	    if (mem->tiling == TILE_XMAJOR)
-		tile_suffix = " X tiled";
-	    else if (mem->tiling == TILE_YMAJOR)
-		tile_suffix = " Y tiled";
-
-	    if (mem->bound) {
-		xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
-			       "%s0x%08lx-0x%08lx: %s (%ld kB)%s\n", prefix,
-			       mem->offset, mem->end - 1, mem->name,
-			       mem->size / 1024, tile_suffix);
-	    } else {
-		xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
-			       "%sunpinned          : %s (%ld kB)%s\n", prefix,
-			       mem->name, mem->size / 1024, tile_suffix);
-	    }
+    }
+    for (mem = pI830->bo_list; mem != NULL; mem = mem->next) {
+	char *tile_suffix = "";
+
+	if (mem->tiling == TILE_XMAJOR)
+	    tile_suffix = " X tiled";
+	else if (mem->tiling == TILE_YMAJOR)
+	    tile_suffix = " Y tiled";
+
+	if (mem->bound) {
+	    xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
+			   "%s0x%08lx-0x%08lx: %s (%ld kB)%s\n", prefix,
+			   mem->offset, mem->end - 1, mem->name,
+			   mem->size / 1024, tile_suffix);
+	} else {
+	    xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
+			   "%sunpinned          : %s (%ld kB)%s\n", prefix,
+			   mem->name, mem->size / 1024, tile_suffix);
 	}
+    }
+    if (pI830->memory_manager) {
 	xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
 		       "%s0x%08lx:            end of memory manager\n",
 		       prefix, pI830->memory_manager->end);
@@ -953,7 +957,7 @@ i830_allocate_ringbuffer(ScrnInfoPtr pScrn)
 {
     I830Ptr pI830 = I830PTR(pScrn);
 
-    if (pI830->memory_manager || pI830->ring.mem != NULL)
+    if (pI830->have_gem || pI830->ring.mem != NULL)
 	return TRUE;
 
     /* We don't have any mechanism in the DRM yet to alert it that we've moved
@@ -1277,7 +1281,7 @@ i830_allocate_2d_memory(ScrnInfoPtr pScrn)
 	return FALSE;
     }
 
-    if (pI830->memory_manager == NULL) {
+    if (!pI830->have_gem) {
 	pI830->fake_bufmgr_mem = i830_allocate_memory(pScrn, "fake bufmgr",
 						      MB(8), PITCH_NONE, GTT_PAGE_SIZE, 0,
 						      TILE_NONE);
@@ -1286,6 +1290,7 @@ i830_allocate_2d_memory(ScrnInfoPtr pScrn)
 		       "Failed to allocate fake bufmgr space.\n");
 	    return FALSE;
 	}
+	i830_init_bufmgr(pScrn);
     }
 
     if (!pI830->use_drm_mode)
commit 56bfee8705f5d7d965227013b205dbc4c93e220c
Author: Keith Packard <keithp at keithp.com>
Date:   Fri Jul 10 14:49:20 2009 -0700

    Always set screen pixmap data pointer at init and resize times
    
    For non-DRM environments, the screen pixmap will be GART allocated memory
    and not a libdrm buffer object and so uxa will only use devPrivate.ptr to
    find the associated memory. Make sure devPrivate.ptr is set each time the
    framebuffer is allocated so that uxa will be able to draw to it.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/src/i830_driver.c b/src/i830_driver.c
index ee39a1b..e5e5fd7 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -880,7 +880,6 @@ i830_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height)
 	i830_memory *new_front, *old_front;
 	Bool	    tiled;
 	ScreenPtr   screen = screenInfo.screens[scrn->scrnIndex];
-	pointer	    data = NULL;
 
 	scrn->displayWidth = i830_pad_drawable_width(width, i830->cpp);
 	tiled = i830_tiled_width(i830, &scrn->displayWidth, i830->cpp);
@@ -900,15 +899,15 @@ i830_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height)
 	i830_set_pixmap_bo(screen->GetScreenPixmap(screen),
 			   new_front->bo);
 	scrn->fbOffset = i830->front_buffer->offset;
-	if (!new_front->bo)
-	    data = i830->FbBase + scrn->fbOffset;
+
 	screen->ModifyPixmapHeader(screen->GetScreenPixmap(screen),
 				   width, height, -1, -1, scrn->displayWidth * i830->cpp,
-				   data);
+				   i830->FbBase + scrn->fbOffset);
+
 	/* ick. xf86EnableDisableFBAccess smashes the screen pixmap devPrivate,
 	 * so update the value it uses
 	 */
-	scrn->pixmapPrivate.ptr = data;
+	scrn->pixmapPrivate.ptr = i830->FbBase + scrn->fbOffset;
 	xf86DrvMsg(scrn->scrnIndex, X_INFO, "New front buffer at 0x%lx\n",
 		   i830->front_buffer->offset);
 	i830_set_new_crtc_bo(scrn);
@@ -2719,6 +2718,12 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
     if (pScrn->virtualX > pScrn->displayWidth)
 	pScrn->displayWidth = pScrn->virtualX;
 
+   /* If the front buffer is not a BO, we need to
+    * set the initial framebuffer pixmap to point at
+    * it
+    */
+   pScrn->fbOffset = pI830->front_buffer->offset;
+
    DPRINTF(PFX, "assert( if(!fbScreenInit(pScreen, ...) )\n");
    if (!fbScreenInit(pScreen, pI830->FbBase + pScrn->fbOffset, 
                      pScrn->virtualX, pScrn->virtualY,
commit 98087a0b966d5dc69faf72719153a2c878ba3de1
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Jul 8 11:47:25 2009 -0700

    Make xorg.conf DRI option work under KMS. Fix name of I830AccelMethodInit
    
    KMS mode does not call I830AccelMethodInit as that does the user
    modesetting initialization (yes, it was misnamed), but that means that the DRI option
    was ignored. Create a new i830_check_dri_option function to do the option
    detection, then remove that from I830AccelMethodInit, which is renamed
    i830_user_modesetting_init to reflect what it actually does.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/src/i830_driver.c b/src/i830_driver.c
index cc0a1f6..ee39a1b 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -1301,12 +1301,10 @@ I830PreInitCrtcConfig(ScrnInfoPtr pScrn)
     xf86CrtcSetSizeRange (pScrn, 320, 200, max_width, max_height);
 }
 
-static Bool
-I830AccelMethodInit(ScrnInfoPtr pScrn)
+static void
+i830_check_dri_option(ScrnInfoPtr pScrn)
 {
     I830Ptr pI830 = I830PTR(pScrn);
-    int i, num_pipe;
-
     pI830->directRenderingType = DRI_NONE;
     if (!xf86ReturnOptValBool(pI830->Options, OPTION_DRI, TRUE))
 	pI830->directRenderingType = DRI_DISABLED;
@@ -1316,6 +1314,13 @@ I830AccelMethodInit(ScrnInfoPtr pScrn)
 		"runs only at depths 16 and 24.\n");
 	pI830->directRenderingType = DRI_DISABLED;
     }
+}
+
+static Bool
+i830_user_modesetting_init(ScrnInfoPtr pScrn)
+{
+    I830Ptr pI830 = I830PTR(pScrn);
+    int i, num_pipe;
 
     I830MapMMIO(pScrn);
 
@@ -1442,7 +1447,6 @@ I830DrmModeInit(ScrnInfoPtr pScrn)
 	return FALSE;
     }
 
-    pI830->directRenderingType = DRI_NONE;
     pI830->have_gem = TRUE;
 
     i830_init_bufmgr(pScrn);
@@ -1587,6 +1591,8 @@ I830PreInit(ScrnInfoPtr pScrn, int flags)
    if (!i830_detect_chipset(pScrn))
        return FALSE;
 
+   i830_check_dri_option(pScrn);
+
    if (pI830->use_drm_mode) {
        if (!I830DrmModeInit(pScrn))
 	   return FALSE;
@@ -1595,7 +1601,7 @@ I830PreInit(ScrnInfoPtr pScrn, int flags)
 	   xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
 		      "VBIOS initialization failed.\n");
       I830PreInitCrtcConfig(pScrn);
-      if (!I830AccelMethodInit(pScrn))
+      if (!i830_user_modesetting_init(pScrn))
          return FALSE;
    }
 
commit d655a3ff423e69c19a5dc07140cbf3caaa32cb86
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Jul 8 18:06:40 2009 -0700

    Remove NoAccel support
    
    This removes yet another 'debugging' option that hasn't seen real use in a
    long time, and wasn't supported under KMS in any case.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index e9296dc..7cfdc5b 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -329,8 +329,6 @@ drmmode_crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
 		return NULL;
 	}
 
-	drm_intel_gem_bo_map_gtt(drmmode_crtc->rotate_bo);
-
 	ret = drmModeAddFB(drmmode->fd, width, height, crtc->scrn->depth,
 			   crtc->scrn->bitsPerPixel, rotate_pitch,
 			   drmmode_crtc->rotate_bo->handle,
@@ -341,7 +339,7 @@ drmmode_crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
 		return NULL;
 	}
 
-	return drmmode_crtc->rotate_bo->virtual;
+	return drmmode_crtc->rotate_bo;
 }
 
 static PixmapPtr
@@ -353,8 +351,14 @@ drmmode_crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
 	unsigned long rotate_pitch;
 	PixmapPtr rotate_pixmap;
 
-	if (!data)
+	if (!data) {
 		data = drmmode_crtc_shadow_allocate (crtc, width, height);
+		if (!data) {
+			xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+				   "Couldn't allocate shadow pixmap for rotated CRTC\n");
+			return NULL;
+		}
+	}
 
 	rotate_pitch =
 		i830_pad_drawable_width(width, drmmode->cpp) * drmmode->cpp;
@@ -363,11 +367,12 @@ drmmode_crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
 					       pScrn->depth,
 					       pScrn->bitsPerPixel,
 					       rotate_pitch,
-					       data);
+					       NULL);
 
 	if (rotate_pixmap == NULL) {
 		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 			   "Couldn't allocate shadow pixmap for rotated CRTC\n");
+		return NULL;
 	}
 
 	if (drmmode_crtc->rotate_bo)
@@ -393,7 +398,6 @@ drmmode_crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *dat
 		 * unbound. */
 		drmModeRmFB(drmmode->fd, drmmode_crtc->rotate_fb_id);
 		drmmode_crtc->rotate_fb_id = 0;
-		drm_intel_gem_bo_unmap_gtt(drmmode_crtc->rotate_bo);
 		dri_bo_unreference(drmmode_crtc->rotate_bo);
 		drmmode_crtc->rotate_bo = NULL;
 	}
diff --git a/src/i830.h b/src/i830.h
index dc5e0c8..f7ca687 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -317,12 +317,6 @@ enum backlight_control {
     BCM_KERNEL,
 };
 
-typedef enum accel_method {
-    ACCEL_UNINIT = 0,
-    ACCEL_NONE,
-    ACCEL_UXA
-} accel_method_t;
-
 enum dri_type {
     DRI_DISABLED,
     DRI_NONE,
@@ -431,7 +425,6 @@ typedef struct _I830Rec {
 
    Bool fence_used[FENCE_NEW_NR];
 
-   accel_method_t accel;
    CloseScreenProcPtr CloseScreen;
 
    void (*batch_flush_notify)(ScrnInfoPtr pScrn);
@@ -827,8 +820,7 @@ i830_wait_ring_idle(ScrnInfoPtr pScrn)
 {
    I830Ptr pI830 = I830PTR(pScrn);
 
-   if (pI830->accel != ACCEL_NONE)
-       I830WaitLpRing(pScrn, pI830->ring.mem->size - 8, 0);
+   I830WaitLpRing(pScrn, pI830->ring.mem->size - 8, 0);
 }
 
 static inline int i830_fb_compression_supported(I830Ptr pI830)
@@ -841,10 +833,9 @@ static inline int i830_fb_compression_supported(I830Ptr pI830)
 	return FALSE;
     if (IS_IGDNG(pI830))
 	return FALSE;
-    /* fbc depends on tiled surface. And we don't support tiled
-     * front buffer with unaccelerated.
+    /* fbc depends on tiled surface.
      */
-    if (!pI830->tiling || (IS_I965G(pI830) && pI830->accel == ACCEL_NONE))
+    if (!pI830->tiling)
 	return FALSE;
     /* We have not gotten FBC to work consistently on 965GM. Our best
      * working theory right now is that FBC simply isn't reliable on
diff --git a/src/i830_accel.c b/src/i830_accel.c
index b365e3f..96a7bde 100644
--- a/src/i830_accel.c
+++ b/src/i830_accel.c
@@ -136,7 +136,7 @@ I830Sync(ScrnInfoPtr pScrn)
    if (I810_DEBUG & (DEBUG_VERBOSE_ACCEL | DEBUG_VERBOSE_SYNC))
       ErrorF("I830Sync\n");
 
-   if (pI830->accel == ACCEL_NONE || !pScrn->vtSema || !pI830->batch_bo)
+   if (!pScrn->vtSema || !pI830->batch_bo)
        return;
 
    I830EmitFlush(pScrn);
@@ -236,12 +236,5 @@ I830AccelInit(ScreenPtr pScreen)
     if (pI830->directRenderingType >= DRI_DRI2)
 	pI830->accel_pixmap_pitch_alignment = 512;
 
-    switch (pI830->accel) {
-    case ACCEL_UXA:
-	return i830_uxa_init(pScreen);
-    case ACCEL_UNINIT:
-    case ACCEL_NONE:
-	break;
-    }
-    return FALSE;
+    return i830_uxa_init(pScreen);
 }
diff --git a/src/i830_dri.c b/src/i830_dri.c
index 240c519..40d11e4 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -373,11 +373,6 @@ Bool I830DRI2ScreenInit(ScreenPtr pScreen)
     int dri2_minor = 0;
 #endif
 
-    if (pI830->accel != ACCEL_UXA) {
-	xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "DRI2 requires UXA\n");
-	return FALSE;
-    }
-
 #ifdef USE_DRI2_1_1_0
     if (xf86LoaderCheckSymbol("DRI2Version")) {
 	DRI2Version(& dri2_major, & dri2_minor);
diff --git a/src/i830_driver.c b/src/i830_driver.c
index 257bd6c..cc0a1f6 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -598,49 +598,6 @@ I830LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
    }
 }
 
-static void
-i830_update_front_offset(ScrnInfoPtr pScrn)
-{
-   ScreenPtr pScreen = pScrn->pScreen;
-   I830Ptr pI830 = I830PTR(pScrn);
-   int pitch = pScrn->displayWidth * pI830->cpp;
-   pointer data = NULL;
-
-   /* Update buffer locations, which may have changed as a result of
-    * i830_bind_all_memory().
-    */
-   pScrn->fbOffset = pI830->front_buffer->offset;
-
-   if (pI830->starting || pI830->accel == ACCEL_UXA)
-       return;
-
-   /* If we are still in ScreenInit, there is no screen pixmap to be updated
-    * yet.  We'll fix it up at CreateScreenResources.
-    */
-   if (!pI830->have_gem) {
-       data = pI830->FbBase + pScrn->fbOffset; /* default to legacy */
-   } else {
-      dri_bo *bo = pI830->front_buffer->bo;
-
-      if (bo) {
-	  if (pI830->kernel_exec_fencing) {
-	      if (drm_intel_gem_bo_map_gtt(bo))
-		  xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "%s: bo map failed\n",
-			     __FUNCTION__);
-	      data = bo->virtual;
-	  } else {
-	      /* Will already be pinned by bind_all_memory in this case */
-	      drm_intel_gem_bo_start_gtt_access(bo, 1);
-	      data = pI830->FbBase + bo->offset;
-	  }
-      }
-   }
-   if (!pScreen->ModifyPixmapHeader(pScreen->GetScreenPixmap(pScreen),
-				       pScrn->virtualX, pScrn->virtualY, -1, -1,
-				       pitch, data))
-       FatalError("Couldn't adjust screen pixmap\n");
-}
-
 /**
  * Adjust the screen pixmap for the current location of the front buffer.
  * This is done at EnterVT when buffers are bound as long as the resources
@@ -657,10 +614,7 @@ i830CreateScreenResources(ScreenPtr pScreen)
    if (!(*pScreen->CreateScreenResources)(pScreen))
       return FALSE;
 
-   i830_update_front_offset(pScrn);
-
-   if (pI830->accel == ACCEL_UXA)
-      i830_uxa_create_screen_resources(pScreen);
+   i830_uxa_create_screen_resources(pScreen);
 
    return TRUE;
 }
@@ -1265,13 +1219,6 @@ i830_detect_chipset(ScrnInfoPtr pScrn)
     return TRUE;
 }
 
-static const char *accel_name[] = 
-{
-   "unspecified",
-   "no",
-   "UXA",
-};
-
 static Bool
 I830LoadSyms(ScrnInfoPtr pScrn)
 {
@@ -1358,26 +1305,13 @@ static Bool
 I830AccelMethodInit(ScrnInfoPtr pScrn)
 {
     I830Ptr pI830 = I830PTR(pScrn);
-    MessageType from = X_PROBED;
     int i, num_pipe;
 
-    if (xf86ReturnOptValBool(pI830->Options, OPTION_NOACCEL, FALSE)) {
-	pI830->accel = ACCEL_NONE;
-    } else {
-       pI830->accel = ACCEL_UXA;
-	xf86DrvMsg(pScrn->scrnIndex, from, "Using %s for acceleration\n",
-		   accel_name[pI830->accel]);
-    }
-
     pI830->directRenderingType = DRI_NONE;
     if (!xf86ReturnOptValBool(pI830->Options, OPTION_DRI, TRUE))
 	pI830->directRenderingType = DRI_DISABLED;
 
-    if (pI830->accel == ACCEL_NONE) {
-	xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "DRI is disabled because it "
-		"needs 2D acceleration.\n");
-	pI830->directRenderingType = DRI_DISABLED;
-    } else if (pScrn->depth != 16 && pScrn->depth != 24) {
+    if (pScrn->depth != 16 && pScrn->depth != 24) {
 	xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "DRI is disabled because it "
 		"runs only at depths 16 and 24.\n");
 	pI830->directRenderingType = DRI_DISABLED;
@@ -1501,8 +1435,6 @@ I830DrmModeInit(ScrnInfoPtr pScrn)
 {
     I830Ptr pI830 = I830PTR(pScrn);
 
-    pI830->accel = ACCEL_UXA;
-
     if (drmmode_pre_init(pScrn, pI830->drmSubFD, pI830->cpp) == FALSE) {
 	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 		   "Kernel modesetting setup failed\n");
@@ -1681,11 +1613,6 @@ I830PreInit(ScrnInfoPtr pScrn, int flags)
    }
    pScrn->currentMode = pScrn->modes;
 
-   if (!IS_I965G(pI830) && pScrn->virtualY > 2048) {
-      xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Cannot support > 2048 vertical lines. disabling acceleration.\n");
-      pI830->accel = ACCEL_NONE;
-   }
-
    /* Set display resolution */
    xf86SetDpi(pScrn, 0, 0);
 
@@ -1731,19 +1658,17 @@ i830_stop_ring(ScrnInfoPtr pScrn, Bool flush)
 
    DPRINTF(PFX, "ResetState: flush is %s\n", BOOLTOSTRING(flush));
 
-   /* Flush the ring buffer (if enabled), then disable it. */
-   if (pI830->accel != ACCEL_NONE) {
-      temp = INREG(LP_RING + RING_LEN);
-      if (temp & RING_VALID) {
-	 i830_refresh_ring(pScrn);
-	 i830_wait_ring_idle(pScrn);
-      }
-
-      OUTREG(LP_RING + RING_LEN, 0);
-      OUTREG(LP_RING + RING_HEAD, 0);
-      OUTREG(LP_RING + RING_TAIL, 0);
-      OUTREG(LP_RING + RING_START, 0);
+   /* Flush the ring buffer, then disable it. */
+   temp = INREG(LP_RING + RING_LEN);
+   if (temp & RING_VALID) {
+      i830_refresh_ring(pScrn);
+      i830_wait_ring_idle(pScrn);
    }
+
+   OUTREG(LP_RING + RING_LEN, 0);
+   OUTREG(LP_RING + RING_HEAD, 0);
+   OUTREG(LP_RING + RING_TAIL, 0);
+   OUTREG(LP_RING + RING_START, 0);
 }
 
 static void
@@ -1754,9 +1679,6 @@ i830_start_ring(ScrnInfoPtr pScrn)
 
    DPRINTF(PFX, "SetRingRegs\n");
 
-   if (pI830->accel == ACCEL_NONE)
-      return;
-
    OUTREG(LP_RING + RING_LEN, 0);
    OUTREG(LP_RING + RING_TAIL, 0);
    OUTREG(LP_RING + RING_HEAD, 0);
@@ -2253,9 +2175,6 @@ IntelEmitInvarientState(ScrnInfoPtr pScrn)
 {
    I830Ptr pI830 = I830PTR(pScrn);
 
-   if (pI830->accel == ACCEL_NONE)
-      return;
-
    /* If we've emitted our state since the last clobber by another client,
     * skip it.
     */
@@ -2286,13 +2205,13 @@ I830BlockHandler(int i,
     pI830->BlockHandler = pScreen->BlockHandler;
     pScreen->BlockHandler = I830BlockHandler;
 
-    if (pScrn->vtSema && pI830->accel != ACCEL_NONE) {
+    if (pScrn->vtSema) {
        Bool flushed = FALSE;
        /* Emit a flush of the rendering cache, or on the 965 and beyond
 	* rendering results may not hit the framebuffer until significantly
 	* later.
 	*/
-       if (pI830->accel != ACCEL_NONE && (pI830->need_mi_flush || pI830->batch_used))
+       if (pI830->need_mi_flush || pI830->batch_used)
        {
 	  flushed = TRUE;
 	  I830EmitFlush(pScrn);
@@ -2308,8 +2227,7 @@ I830BlockHandler(int i,
        pI830->need_mi_flush = FALSE;
     }
 
-    if (pI830->accel == ACCEL_UXA)
-	i830_uxa_block_handler (pScreen);
+    i830_uxa_block_handler (pScreen);
 
     I830VideoBlockHandler(i, blockData, pTimeout, pReadmask);
 }
@@ -2778,20 +2696,6 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
    if (!miSetPixmapDepths())
       return FALSE;
 
-   if (pI830->accel == ACCEL_NONE) {
-      xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Xv is disabled because it "
-		 "needs 2D acceleration.\n");
-      pI830->XvEnabled = FALSE;
-   }
-
-   if (pI830->accel != ACCEL_NONE && !pI830->use_drm_mode) {
-      if (!pI830->have_gem && pI830->ring.mem->size == 0) {
-	  xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-		     "Disabling acceleration because the ring buffer "
-		      "allocation failed.\n");
-	   pI830->accel = ACCEL_NONE;
-      }
-   }
    i830_init_bufmgr(pScrn);
 
    pScrn->fbOffset = pI830->front_buffer->offset;
@@ -2837,11 +2741,10 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 
    xf86DiDGAInit (pScreen, pI830->LinearAddr + pScrn->fbOffset);
 
-   if (pI830->accel != ACCEL_NONE) {
-      if (!I830AccelInit(pScreen)) {
-	 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		    "Hardware acceleration initialization failed\n");
-      }
+   if (!I830AccelInit(pScreen)) {
+      xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+		 "Hardware acceleration initialization failed\n");
+      return FALSE;
    }
 
    if (IS_I965G(pI830))
@@ -3036,7 +2939,7 @@ I830LeaveVT(int scrnIndex, int flags)
 	 FatalError("DRM_I915_LEAVEVT failed: %s\n", strerror(ret));
    }
 
-   if (pI830->accel == ACCEL_UXA && IS_I965G(pI830))
+   if (IS_I965G(pI830))
       gen4_render_state_cleanup(pScrn);
 
    ret = drmDropMaster(pI830->drmSubFD);
@@ -3121,12 +3024,9 @@ I830EnterVT(int scrnIndex, int flags)
 
    i830_describe_allocations(pScrn, 1, "");
 
-   /* Update the screen pixmap in case the buffer moved */
-   i830_update_front_offset(pScrn);
-
    intel_batch_init(pScrn);
 
-   if (pI830->accel == ACCEL_UXA && IS_I965G(pI830))
+   if (IS_I965G(pI830))
       gen4_render_state_init(pScrn);
 
    if (!pI830->use_drm_mode) {
diff --git a/src/i830_memory.c b/src/i830_memory.c
index 387e52b..2953f3b 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -445,15 +445,14 @@ i830_allocator_init(ScrnInfoPtr pScrn, unsigned long size)
 		struct drm_i915_gem_init init;
 		int ret;
 
-		if (pI830->accel == ACCEL_UXA) {
-		    sp.param = I915_SETPARAM_NUM_USED_FENCES;
-		    sp.value = 0; /* kernel gets them all */
-
-		    ret = drmCommandWrite(pI830->drmSubFD, DRM_I915_SETPARAM,
-					  &sp, sizeof(sp));
-		    if (ret == 0)
-			pI830->kernel_exec_fencing = TRUE;
-		}
+		sp.param = I915_SETPARAM_NUM_USED_FENCES;
+		sp.value = 0; /* kernel gets them all */
+
+		ret = drmCommandWrite(pI830->drmSubFD, DRM_I915_SETPARAM,
+				      &sp, sizeof(sp));
+		if (ret == 0)
+		    pI830->kernel_exec_fencing = TRUE;
+
 		init.gtt_start = pI830->memory_manager->offset;
 		init.gtt_end = pI830->memory_manager->offset +
 		    pI830->memory_manager->size;
@@ -954,7 +953,7 @@ i830_allocate_ringbuffer(ScrnInfoPtr pScrn)
 {
     I830Ptr pI830 = I830PTR(pScrn);
 
-    if (pI830->accel == ACCEL_NONE || pI830->memory_manager || pI830->ring.mem != NULL)
+    if (pI830->memory_manager || pI830->ring.mem != NULL)
 	return TRUE;
 
     /* We don't have any mechanism in the DRM yet to alert it that we've moved
@@ -1264,7 +1263,8 @@ i830_allocate_2d_memory(ScrnInfoPtr pScrn)
 	}
 
 	/* Allocate the ring buffer first, so it ends up in stolen mem. */
-	i830_allocate_ringbuffer(pScrn);
+	if (!i830_allocate_ringbuffer(pScrn))
+	    return FALSE;
     }
 
     if (pI830->fb_compression)
diff --git a/src/i830_uxa.c b/src/i830_uxa.c
index f423805..c3fdcec 100644
--- a/src/i830_uxa.c
+++ b/src/i830_uxa.c
@@ -452,30 +452,19 @@ i830_transform_is_affine (PictTransformPtr t)
 dri_bo *
 i830_get_pixmap_bo(PixmapPtr pixmap)
 {
-    ScreenPtr screen = pixmap->drawable.pScreen;
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
-    I830Ptr i830 = I830PTR(scrn);
-
-    if (i830->accel == ACCEL_UXA)
-	return dixLookupPrivate(&pixmap->devPrivates, &uxa_pixmap_index);
-    else
-	return NULL;
+    return dixLookupPrivate(&pixmap->devPrivates, &uxa_pixmap_index);
 }
 
 void
 i830_set_pixmap_bo(PixmapPtr pixmap, dri_bo *bo)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pixmap->drawable.pScreen->myNum];
-    I830Ptr i830 = I830PTR(pScrn);
     dri_bo  *old_bo = i830_get_pixmap_bo (pixmap);
 
     if (old_bo)
 	dri_bo_unreference (old_bo);
-    if (i830->accel == ACCEL_UXA) {
-	if (bo != NULL)
-	    dri_bo_reference(bo);
-	dixSetPrivate(&pixmap->devPrivates, &uxa_pixmap_index, bo);
-    }
+    if (bo != NULL)
+	dri_bo_reference(bo);
+    dixSetPrivate(&pixmap->devPrivates, &uxa_pixmap_index, bo);
 }
 
 static void
@@ -698,10 +687,9 @@ i830_uxa_init (ScreenPtr pScreen)
 	return FALSE;
 
     i830->uxa_driver = uxa_driver_alloc();
-    if (i830->uxa_driver == NULL) {
-	i830->accel = ACCEL_NONE;
+    if (i830->uxa_driver == NULL)
 	return FALSE;
-    }
+
     memset(i830->uxa_driver, 0, sizeof(*i830->uxa_driver));
 
     i830->bufferOffset = 0;
@@ -743,10 +731,9 @@ i830_uxa_init (ScreenPtr pScreen)
     i830->uxa_driver->pixmap_is_offscreen = i830_uxa_pixmap_is_offscreen;
 
     if(!uxa_driver_init(pScreen, i830->uxa_driver)) {
-	xf86DrvMsg(scrn->scrnIndex, X_INFO,
+	xf86DrvMsg(scrn->scrnIndex, X_ERROR,
 		   "UXA initialization failed\n");
 	xfree(i830->uxa_driver);
-	i830->accel = ACCEL_NONE;
 	return FALSE;
     }
 


More information about the xorg-commit mailing list