xf86-video-intel: 4 commits - src/drmmode_display.h src/i830_batchbuffer.c src/i830_batchbuffer.h src/i830_dri.c src/i830_driver.c src/i830.h src/i830_memory.c src/Makefile.am

Eric Anholt anholt at kemper.freedesktop.org
Wed Sep 10 14:09:58 PDT 2008


 src/Makefile.am        |    2 
 src/drmmode_display.h  |    2 
 src/i830.h             |    1 
 src/i830_batchbuffer.c |  136 ++++++++++++++++++++++++++++---------------------
 src/i830_batchbuffer.h |    4 -
 src/i830_dri.c         |    7 ++
 src/i830_driver.c      |   44 +--------------
 src/i830_memory.c      |    6 +-
 8 files changed, 97 insertions(+), 105 deletions(-)

New commits:
commit 58a3817305ef1455a11be6ead8a8521dfc5875c7
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Sep 9 11:02:49 2008 -0700

    Track move of exec to bufmgr, and restoration of emit/wait funcs for non-drm.

diff --git a/src/i830_batchbuffer.c b/src/i830_batchbuffer.c
index 75e98e0..3727f0e 100644
--- a/src/i830_batchbuffer.c
+++ b/src/i830_batchbuffer.c
@@ -39,6 +39,65 @@
 #include "i830_ring.h"
 #include "i915_drm.h"
 
+static int
+intel_nondrm_exec(dri_bo *bo, unsigned int used, void *priv)
+{
+    ScrnInfoPtr pScrn = priv;
+    I830Ptr pI830 = I830PTR(pScrn);
+
+    BEGIN_LP_RING(2);
+    OUT_RING(MI_BATCH_BUFFER_START | (2 << 6));
+    OUT_RING(bo->offset);
+    ADVANCE_LP_RING();
+
+    return 0;
+}
+
+static int
+intel_nondrm_exec_i830(dri_bo *bo, unsigned int used, void *priv)
+{
+    ScrnInfoPtr pScrn = priv;
+    I830Ptr pI830 = I830PTR(pScrn);
+
+    BEGIN_LP_RING(4);
+    OUT_RING(MI_BATCH_BUFFER);
+    OUT_RING(bo->offset);
+    OUT_RING(bo->offset + pI830->batch_used - 4);
+    OUT_RING(MI_NOOP);
+
+    return 0;
+}
+
+/**
+ * Creates a fence value representing a request to be passed.
+ *
+ * Stub implementation that should be avoided when DRM functions are available.
+ */
+static unsigned int
+intel_nondrm_emit(void *priv)
+{
+    static unsigned int fence = 0;
+
+    /* Match DRM in not using half the range. The fake bufmgr relies on this. */
+    if (++fence >= 0x8000000)
+	fence = 1;
+
+    return fence;
+}
+
+/**
+ * Waits on a fence representing a request to be passed.
+ *
+ * Stub implementation that should be avoided when DRM functions are available.
+ */
+static void
+intel_nondrm_wait(unsigned int fence, void *priv)
+{
+    ScrnInfoPtr pScrn = priv;
+
+    i830_wait_ring_idle(pScrn);
+}
+
 static void
 intel_next_batch(ScrnInfoPtr pScrn)
 {
@@ -64,6 +123,22 @@ intel_batch_init(ScrnInfoPtr pScrn)
     pI830->batch_emitting = 0;
 
     intel_next_batch(pScrn);
+
+    if (!pI830->directRenderingEnabled) {
+	if (IS_I830(pI830) || IS_845G(pI830)) {
+	    intel_bufmgr_fake_set_exec_callback(pI830->bufmgr,
+						intel_nondrm_exec_i830,
+						pScrn);
+	} else {
+	    intel_bufmgr_fake_set_exec_callback(pI830->bufmgr,
+						intel_nondrm_exec,
+						pScrn);
+	}
+	intel_bufmgr_fake_set_fence_callback(pI830->bufmgr,
+					     intel_nondrm_emit,
+					     intel_nondrm_wait,
+					     pScrn);
+    }
 }
 
 void
@@ -81,6 +156,7 @@ void
 intel_batch_flush(ScrnInfoPtr pScrn)
 {
     I830Ptr pI830 = I830PTR(pScrn);
+    int ret;
 
     if (pI830->batch_used == 0)
 	return;
@@ -98,63 +174,9 @@ intel_batch_flush(ScrnInfoPtr pScrn)
     dri_bo_unmap(pI830->batch_bo);
     pI830->batch_ptr = NULL;
 
-    if (pI830->memory_manager) {
-	struct drm_i915_gem_execbuffer *exec;
-	int ret;
-
-	exec = dri_process_relocs(pI830->batch_bo);
-
-	exec->batch_start_offset = 0;
-	exec->batch_len = pI830->batch_used;
-	exec->cliprects_ptr = 0;
-	exec->num_cliprects = 0;
-	exec->DR1 = 0;
-	exec->DR4 = 0xffffffff;
-
-	do {
-	    ret = drmCommandWriteRead(pI830->drmSubFD, DRM_I915_GEM_EXECBUFFER,
-				      exec, sizeof(*exec));
-	} while (ret == -EINTR);
-	if (ret != 0)
-	    FatalError("Failed to submit batchbuffer: %s\n", strerror(errno));
-    } else {
-	dri_process_relocs(pI830->batch_bo);
-
-	if (pI830->directRenderingEnabled) {
-	    drm_i915_batchbuffer_t batch;
-	    int ret;
-
-	    batch.start = pI830->batch_bo->offset;
-	    batch.used = pI830->batch_used;
-	    batch.cliprects = NULL;
-	    batch.num_cliprects = 0;
-	    batch.DR1 = 0;
-	    batch.DR4 = 0xffffffff;
-
-	    ret = drmCommandWrite(pI830->drmSubFD, DRM_I915_BATCHBUFFER,
-				  &batch, sizeof(batch));
-	    if (ret != 0)
-		FatalError("Failed to submit batchbuffer: %s\n", strerror(errno));
-
-	    i830_refresh_ring(pScrn);
-	} else {
-	    if (!IS_I830(pI830) && !IS_845G(pI830)) {
-		BEGIN_LP_RING(2);
-		OUT_RING(MI_BATCH_BUFFER_START | (2 << 6));
-		OUT_RING(pI830->batch_bo->offset);
-		ADVANCE_LP_RING();
-	    } else {
-		BEGIN_LP_RING(4);
-		OUT_RING(MI_BATCH_BUFFER);
-		OUT_RING(pI830->batch_bo->offset);
-		OUT_RING(pI830->batch_bo->offset + pI830->batch_used - 4);
-		OUT_RING(MI_NOOP);
-		ADVANCE_LP_RING();
-	    }
-	}
-    }
-
-    dri_post_submit(pI830->batch_bo);
+    ret = dri_bo_exec(pI830->batch_bo, pI830->batch_used, NULL, 0, 0xffffffff);
+    if (ret != 0)
+	FatalError("Failed to submit batchbuffer: %s\n", strerror(-ret));
 
     dri_bo_unreference(pI830->batch_bo);
     intel_next_batch(pScrn);
commit f367334c6392a717f6cd2f4ed02200be1c6d356a
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Sep 9 11:01:33 2008 -0700

    Track the move of irq emit/wait to fake bufmgr.

diff --git a/src/i830_dri.c b/src/i830_dri.c
index d068271..fb9b6f6 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -834,6 +834,11 @@ I830DRIDoMappings(ScreenPtr pScreen)
       return FALSE;
    }
 
+   if (pI830->memory_manager == NULL)
+       intel_bufmgr_fake_set_last_dispatch(pI830->bufmgr,
+					   (volatile unsigned int *)
+					   &sarea->last_dispatch);
+
    /* init to zero to be safe */
    sarea->front_handle = 0;
    sarea->back_handle = 0;
diff --git a/src/i830_driver.c b/src/i830_driver.c
index b9705cf..491ec5e 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -2886,39 +2886,6 @@ i830_memory_init(ScrnInfoPtr pScrn)
     return FALSE;
 }
 
-/**
- * Returns a cookie to be waited on.  This is just a stub implementation, and
- * should be hooked up to the emit/wait irq functions when available (DRI
- * enabled).
- */
-static unsigned int
-i830_fake_fence_emit(void *priv)
-{
-   static unsigned int fence = 0;
-
-   /* Match DRM in not using half the range. The fake bufmgr relies on this. */
-   if (++fence >= 0x8000000)
-      fence = 1;
-
-   return fence;
-}
-
-/**
- * Waits on a cookie representing a request to be passed.
- *
- * Stub implementation that should be replaced with DRM functions when
- * available.
- */
-static int
-i830_fake_fence_wait(void *priv, unsigned int fence)
-{
-   ScrnInfoPtr pScrn = priv;
-
-   i830_wait_ring_idle(pScrn);
-
-   return 0;
-}
-
 void
 i830_init_bufmgr(ScrnInfoPtr pScrn)
 {
@@ -2940,13 +2907,12 @@ i830_init_bufmgr(ScrnInfoPtr pScrn)
       intel_bufmgr_gem_enable_reuse(pI830->bufmgr);
    } else {
       assert(pI830->FbBase != NULL);
-      pI830->bufmgr = intel_bufmgr_fake_init(pI830->fake_bufmgr_mem->offset,
+      pI830->bufmgr = intel_bufmgr_fake_init(pI830->drmSubFD,
+					     pI830->fake_bufmgr_mem->offset,
 					     pI830->FbBase +
 					     pI830->fake_bufmgr_mem->offset,
 					     pI830->fake_bufmgr_mem->size,
-					     i830_fake_fence_emit,
-					     i830_fake_fence_wait,
-					     pScrn);
+					     NULL);
    }
 }
 
commit 0b4f7b630312b148ce4e172cb7cd9f673751b2a3
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Sep 9 10:57:08 2008 -0700

    Track move of bufmgr functions to libdrm_intel.

diff --git a/src/Makefile.am b/src/Makefile.am
index 97feea4..8966bd6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -39,7 +39,7 @@ intel_drv_la_LDFLAGS = -module -avoid-version
 intel_drv_ladir = @moduledir@/drivers
 intel_drv_la_LIBADD = -lm ../uxa/libuxa.la
 if XSERVER_LIBPCIACCESS
-intel_drv_la_LIBADD += @PCIACCESS_LIBS@
+intel_drv_la_LIBADD += @PCIACCESS_LIBS@ @DRM_LIBS@ -ldrm_intel
 endif
 
 XMODE_SRCS=\
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index fc7c1df..ee51c95 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -29,7 +29,7 @@
 
 #ifdef XF86DRM_MODE
 
-#include "dri_bufmgr.h"
+#include "intel_bufmgr.h"
 #include "xf86drmMode.h"
 
 typedef struct {
diff --git a/src/i830.h b/src/i830.h
index f0efc4e..5fb7e24 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -79,7 +79,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #endif
 #include "drmmode_display.h"
 #endif
-#include "dri_bufmgr.h"
 #include "intel_bufmgr.h"
 #include "i915_drm.h"
 
diff --git a/src/i830_batchbuffer.h b/src/i830_batchbuffer.h
index 2a23cae..3c7a69b 100644
--- a/src/i830_batchbuffer.h
+++ b/src/i830_batchbuffer.h
@@ -68,8 +68,8 @@ intel_batch_emit_reloc (I830Ptr  pI830,
 {
     assert(intel_batch_space(pI830) >= 4);
     *(uint32_t *)(pI830->batch_ptr + pI830->batch_used) = bo->offset + delta;
-    intel_bo_emit_reloc (pI830->batch_bo, read_domains, write_domains, delta,
-			 pI830->batch_used, bo);
+    dri_bo_emit_reloc(pI830->batch_bo, read_domains, write_domains, delta,
+		      pI830->batch_used, bo);
     pI830->batch_used += 4;
 }
 
diff --git a/src/i830_dri.c b/src/i830_dri.c
index ca3bc62..d068271 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -1542,7 +1542,7 @@ i830_name_buffer (ScrnInfoPtr pScrn, i830_memory *mem)
 	if (!mem->gem_name)
 	{
 	    int ret;
-	    ret = intel_bo_flink(mem->bo, &mem->gem_name);
+	    ret = dri_bo_flink(mem->bo, &mem->gem_name);
 	    if (ret != 0)
 	    {
 		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
diff --git a/src/i830_memory.c b/src/i830_memory.c
index 443cc4e..2cbdd17 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -167,7 +167,7 @@ i830_bind_memory(ScrnInfoPtr pScrn, i830_memory *mem)
 
 #ifdef XF86DRI
     if (mem->bo != NULL) {
-	if (intel_bo_pin (mem->bo, mem->alignment) != 0) {
+	if (dri_bo_pin(mem->bo, mem->alignment) != 0) {
 	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 		       "Failed to pin %s: %s\n",
 		       mem->name, strerror(errno));
@@ -214,7 +214,7 @@ i830_unbind_memory(ScrnInfoPtr pScrn, i830_memory *mem)
 
 #ifdef XF86DRI
     if (mem->bo != NULL) {
-	if (intel_bo_unpin (mem->bo) == 0) {
+	if (dri_bo_unpin(mem->bo) == 0) {
 	    mem->bound = FALSE;
 	    /* Give buffer obviously wrong offset/end until it's re-pinned. */
 	    mem->offset = -1;
@@ -897,7 +897,7 @@ i830_allocate_memory_tiled(ScrnInfoPtr pScrn, const char *name,
 	else
 	    tiling_mode = I915_TILING_Y;
 
-	ret = intel_bo_set_tiling (mem->bo, &tiling_mode);
+	ret = dri_bo_set_tiling(mem->bo, &tiling_mode);
 	if (ret != 0 || tiling_mode == I915_TILING_NONE) {
 		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 			   "Failed to set tiling on %s: %s\n",
commit 0f804bfa1e1e972e9b4e3b7c8db61e9877c50f50
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Sep 9 19:17:05 2008 -0700

    Bug #17446: Don't try to manage IRQs in GEM mode.
    
    The kernel told us that it was already doing so, resulting in failure.

diff --git a/src/i830_driver.c b/src/i830_driver.c
index 1a50d7b..b9705cf 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -3702,8 +3702,8 @@ I830EnterVT(int scrnIndex, int flags)
        /* HW status is fixed, we need to set it up before any drm
 	* operation which accessing that page, like irq install, etc.
 	*/
-       if (pI830->starting) {
-	   if (pI830->hw_status != NULL && !I830DRISetHWS(pScrn)) {
+       if (pI830->starting && !pI830->memory_manager) {
+	   if (!I830DRISetHWS(pScrn)) {
 		   xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 			   "Fail to setup hardware status page.\n");
 		   I830DRICloseScreen(pScrn->pScreen);


More information about the xorg-commit mailing list