xf86-video-intel: Branch 'intel-kernelmode' - 9 commits - configure.ac src/i830_dri.c src/i830.h src/i830_memory.c src/i830_render.c src/i830_video.c src/i830_video.h src/i915_render.c src/i965_render.c src/i965_video.c src/intel_bufmgr_ttm.c

Dave Airlie airlied at kemper.freedesktop.org
Mon Mar 31 15:05:03 PDT 2008


 configure.ac           |    4 ++--
 src/i830.h             |    2 +-
 src/i830_dri.c         |    9 +++------
 src/i830_memory.c      |    2 ++
 src/i830_render.c      |    3 ++-
 src/i830_video.c       |   22 ----------------------
 src/i830_video.h       |    1 -
 src/i915_render.c      |    3 ++-
 src/i965_render.c      |    4 ++++
 src/i965_video.c       |   31 +++++++++++++++++++++----------
 src/intel_bufmgr_ttm.c |   18 +++++++++++++++---
 11 files changed, 52 insertions(+), 47 deletions(-)

New commits:
commit 58956cac49492c6205a56ef7747464395fbd5984
Merge: e0317e0... 1704921...
Author: Dave Airlie <airlied at linux.ie>
Date:   Tue Apr 1 07:58:58 2008 +1000

    Merge remote branch 'origin/intel-batchbuffer' into intel-kernelmode

commit 17049213a384a4fa6909d7f7fd66bbed3d449a3d
Author: Kristian Høgsberg <krh at redhat.com>
Date:   Thu Mar 27 10:25:28 2008 -0400

    Stop using kernel side drm contexts.
    
    Make space in the DRI2 lock block for a running lock ID integer and use
    it for allocating the server context instead of the drm functions.

diff --git a/src/i830_dri.c b/src/i830_dri.c
index f739b44..186a5c0 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -1940,6 +1940,7 @@ I830DRI2Prepare(ScreenPtr pScreen)
 struct __DRILock {
     unsigned int block_header;
     drm_hw_lock_t lock;
+    unsigned int next_id;
 };
 
 #define DRI2_SAREA_BLOCK_HEADER(type, size) (((type) << 16) | (size))
@@ -1980,11 +1981,8 @@ I830DRI2ScreenInit(ScreenPtr pScreen)
     pI830->lockRefCount = 0;
     pI830->lockingContext = 0;
     
-    if (drmCreateContext(pI830->drmSubFD, &pI830->context)) {
-	pI830->directRendering = DRI_TYPE_NONE;
-	return;
-    }
-
+    pI830->context = 1;
+    driLock->next_id = 2;
     I830DRI2Lock(pScreen);
 
     /* Get sarea BO handle... maybe we need a dedicated function for
@@ -2023,7 +2021,6 @@ I830DRI2CloseScreen(ScreenPtr pScreen)
 
     drmCtlUninstHandler(pI830->drmSubFD);
     I830CleanupDma(pScrn);
-    drmDestroyContext(pI830->drmSubFD, pI830->context);
     I830DRI2Unlock(pScreen);
     DRI2CloseScreen(pScreen);
     drmClose(pI830->drmSubFD);
diff --git a/src/intel_bufmgr_ttm.c b/src/intel_bufmgr_ttm.c
index 1926bca..c1ad8c7 100644
--- a/src/intel_bufmgr_ttm.c
+++ b/src/intel_bufmgr_ttm.c
@@ -350,7 +350,7 @@ dri_ttm_alloc(dri_bufmgr *bufmgr, const char *name,
      * just pass all of the allocation class flags.
      */
     flags = location_mask | DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE |
-	DRM_BO_FLAG_EXE;
+	DRM_BO_FLAG_EXE | DRM_BO_FLAG_SHAREABLE;
     /* No hints we want to use. */
     hint = 0;
 
commit ad76f6fb5a34c19bbf9d5ca8a3cd8c0b79788b29
Author: Kristian Høgsberg <krh at redhat.com>
Date:   Mon Mar 31 12:08:56 2008 -0400

    Force unmap and mark BOs as shared when we get the underlying handle.
    
    The bufmgr optimizes mapping and unmapping for unshared buffer objects.
    When it's the only user of a buffer object, it delays the actual
    drmBOUnmap call until absolutely necessary, which is when we need to
    submit it.  So when we pass the drm bo handle to the DRI driver, we
    need to force unmap it and mark it shared.

diff --git a/src/intel_bufmgr_ttm.c b/src/intel_bufmgr_ttm.c
index 6d8719d..1926bca 100644
--- a/src/intel_bufmgr_ttm.c
+++ b/src/intel_bufmgr_ttm.c
@@ -554,9 +554,21 @@ dri_ttm_bo_unmap(dri_bo *buf)
 static unsigned int
 dri_ttm_bo_get_handle(dri_bo *buf)
 {
-   dri_bo_ttm *ttm_buf = (dri_bo_ttm *)buf;
+    dri_bufmgr_ttm *bufmgr_ttm;
+    dri_bo_ttm *ttm_buf = (dri_bo_ttm *)buf;
+
+    if (buf == NULL)
+	return 0;
+
+    bufmgr_ttm = (dri_bufmgr_ttm *)buf->bufmgr;
+    if (ttm_buf->delayed_unmap) {
+	drmBOUnmap(bufmgr_ttm->fd, &ttm_buf->drm_bo);
+	ttm_buf->delayed_unmap = GL_FALSE;
+    }
+
+    ttm_buf->shared = GL_TRUE;
 
-   return ttm_buf->drm_bo.handle;
+    return ttm_buf->drm_bo.handle;
 }
 
 /**
commit 1c541d7d1f2f8d54ec6f9c4309d44e069b17514e
Author: Kristian Høgsberg <krh at jiraiya.boston.redhat.com>
Date:   Thu Mar 27 19:18:01 2008 -0400

    textured xv: Allocate state buffer per frame instead of reusing it.
    
    Relocations are never cleared since batch/state buffers aren't supposed
    to be reused.  This leads to a crash after approximately 30 seconds of
    video when we run out of relocs.
    
    This fixes the textured video to just allocated the state buffer on the fly,
    which is also a nice cleanup and avoid unnecessary syncing.

diff --git a/src/i830_video.c b/src/i830_video.c
index 645e25c..dc7c773 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -842,7 +842,6 @@ I830SetupImageVideoOverlay(ScreenPtr pScreen)
     pPriv->current_crtc = NULL;
     pPriv->desired_crtc = NULL;
     pPriv->buf = NULL;
-    pPriv->state = NULL;
     pPriv->currentBuf = 0;
     pPriv->gamma5 = 0xc0c0c0;
     pPriv->gamma4 = 0x808080;
@@ -956,7 +955,6 @@ I830SetupImageVideoTextured(ScreenPtr pScreen)
 	pPriv->textured = TRUE;
 	pPriv->videoStatus = 0;
 	pPriv->buf = NULL;
-	pPriv->state = NULL;
 	pPriv->currentBuf = 0;
 	pPriv->doubleBuffer = 0;
 
@@ -1023,10 +1021,6 @@ I830StopVideo(ScrnInfoPtr pScrn, pointer data, Bool shutdown)
 	I830Sync(pScrn);
 	dri_bo_unreference(pPriv->buf);
 	pPriv->buf = NULL;
-	if (pPriv->state) {
-	    dri_bo_unreference(pPriv->state);
-	    pPriv->state = NULL;
-	}
 	pPriv->videoStatus = 0;
     } else {
 	if (pPriv->videoStatus & CLIENT_VIDEO_ON) {
@@ -2360,18 +2354,6 @@ I830PutImage(ScrnInfoPtr pScrn,
     if (pPriv->buf == NULL)
 	return BadAlloc;
 
-    if (pPriv->state == NULL && IS_I965G(pI830)) {
-	pPriv->state = dri_bo_alloc(pI830->bufmgr,
-				    "xv buffer", BRW_LINEAR_EXTRA, 4096,
-				    DRM_BO_FLAG_MEM_LOCAL |
-				    DRM_BO_FLAG_CACHED |
-				    DRM_BO_FLAG_CACHED_MAPPED);
-	if (pPriv->state == NULL) {
-	    dri_bo_unreference(pPriv->buf);
-	    return BadAlloc;
-	}
-    }
-
     /* fixup pointers */
     pPriv->YBuf0offset = 0;
     if (pPriv->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
@@ -2614,10 +2596,6 @@ I830VideoBlockHandler(int i, pointer blockData, pointer pTimeout,
 		I830Sync(pScrn);
 		dri_bo_unreference(pPriv->buf);
 		pPriv->buf = NULL;
-		if (pPriv->state) {
-		    dri_bo_unreference(pPriv->state);
-		    pPriv->state = NULL;
-		}
 		pPriv->videoStatus = 0;
 	    }
 	}
diff --git a/src/i830_video.h b/src/i830_video.h
index b5f6a47..9921847 100644
--- a/src/i830_video.h
+++ b/src/i830_video.h
@@ -59,7 +59,6 @@ typedef struct {
    Time offTime;
    Time freeTime;
    dri_bo *buf; /** YUV data buffer */
-   dri_bo *state; /** State buffer */
 
    Bool overlayOK;
    int oneLineMode;
diff --git a/src/i965_video.c b/src/i965_video.c
index 91b9f39..70b7b53 100644
--- a/src/i965_video.c
+++ b/src/i965_video.c
@@ -183,6 +183,7 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
     int next_offset, total_state_size;
     int vb_size = (4 * 4) * 4; /* 4 DWORDS per vertex */
     char *state_base;
+    dri_bo *state; /** State buffer */
 
 #if 0
     ErrorF("BroadwaterDisplayVideoTextured: %dx%d (pitch %d)\n", width, height,
@@ -199,6 +200,14 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
 
     assert((id == FOURCC_UYVY) || (id == FOURCC_YUY2));
 
+    state = dri_bo_alloc(pI830->bufmgr,
+			 "xv buffer", BRW_LINEAR_EXTRA, 4096,
+			 DRM_BO_FLAG_MEM_LOCAL |
+			 DRM_BO_FLAG_CACHED |
+			 DRM_BO_FLAG_CACHED_MAPPED);
+    if (state == NULL)
+      return 
+
     IntelEmitInvarientState(pScrn);
     *pI830->last_3d = LAST_3D_VIDEO;
 
@@ -241,11 +250,11 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
     next_offset = binding_table_offset + (WM_BINDING_TABLE_ENTRIES * 4);
 
     total_state_size = next_offset;
-    assert (total_state_size < pPriv->state->size);
+    assert (total_state_size < state->size);
 
-    dri_bo_map(pPriv->state, TRUE);
+    dri_bo_map(state, TRUE);
     
-    state_base = (char *) pPriv->state->virtual;
+    state_base = (char *) state->virtual;
     /* Set up our pointers to state structures in framebuffer.  It would
      * probably be a good idea to fill these structures out in system memory
      * and then dump them there, instead.
@@ -370,7 +379,7 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
 					     DRM_BO_FLAG_MEM_TT |
 					     DRM_BO_FLAG_WRITE |
 					     DRM_BO_FLAG_READ,
-					     pPriv->state,
+					     state,
 					     (char *) &dest_surf_state->ss1.base_addr -
 					     state_base,
 					     0);
@@ -409,7 +418,7 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
     src_surf_state->ss0.render_cache_read_mode = 0;
 
     if (pI830->use_ttm_batch) {
-	dri_emit_reloc(pPriv->state,
+	dri_emit_reloc(state,
 		       DRM_BO_FLAG_MEM_TT |
 		       DRM_BO_FLAG_WRITE | 
 		       DRM_BO_FLAG_READ,
@@ -513,7 +522,7 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
     wm_state->wm5.enable_8_pix = 0;
     wm_state->wm5.early_depth_test = 1;
 
-    dri_bo_unmap(pPriv->state);
+    dri_bo_unmap(state);
 
     {
 	BEGIN_BATCH(2);
@@ -543,10 +552,10 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
 	 * to our buffer.
 	 */
 	OUT_BATCH(BRW_STATE_BASE_ADDRESS | 4);
-	OUT_RELOC(pPriv->state,	/* General state base address */
+	OUT_RELOC(state,	/* General state base address */
 		  DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
 		  BASE_ADDRESS_MODIFY);
-	OUT_RELOC(pPriv->state,	/* Surface state base address */
+	OUT_RELOC(state,	/* Surface state base address */
 		  DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
 		  BASE_ADDRESS_MODIFY);
 	OUT_BATCH(0 | BASE_ADDRESS_MODIFY);  /* media base addr, don't care */
@@ -558,7 +567,7 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
 	/* Set system instruction pointer */
 	OUT_BATCH(BRW_STATE_SIP | 0);
 	/* system instruction pointer */
-	OUT_RELOC(pPriv->state,
+	OUT_RELOC(state,
 		  DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
 		  sip_kernel_offset);
 	OUT_BATCH(MI_NOOP);
@@ -650,7 +659,7 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
        OUT_BATCH((0 << VB0_BUFFER_INDEX_SHIFT) |
 		VB0_VERTEXDATA |
 		((4 * 4) << VB0_BUFFER_PITCH_SHIFT));
-       OUT_RELOC(pPriv->state,
+       OUT_RELOC(state,
 		 DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
 		 vb_offset);
        OUT_BATCH(3); /* four corners to our rectangle */
@@ -682,6 +691,8 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
        ADVANCE_BATCH();
     }
 
+    dri_bo_unreference(state);
+
    /* Set up the offset for translating from the given region (in screen
     * coordinates) to the backing pixmap.
     */
commit e0317e0a828e65bbc6352ad199693440e79d0c09
Merge: 6ee8da0... abf16e2...
Author: Dave Airlie <airlied at linux.ie>
Date:   Wed Mar 12 16:36:14 2008 +1000

    Merge branch 'intel-batchbuffer' into intel-kernelmode
    
    Conflicts:
    
    	src/i830.h
    	src/i830_memory.c

commit abf16e22cc781fa1655508ac87c21dd9845e710a
Author: Kristian Høgsberg <krh at redhat.com>
Date:   Tue Mar 11 13:35:29 2008 -0400

    Silence warnings about possible uninitialize use of dst_format.
    
    Whoa, gcc got a lot smarter about warnings.  If iXXX_get_dest_format()
    doesn't support the picture format passed in it won't initialize the
    uint32_t pointed to by dst_format and return FALSE.
    
    What gcc now can detect is if dst_format is used without checking the
    return value, it might be used uninitialized.  This patch makes sure
    we always check the return value before using dst_format.
    
    However, notice how the fix in i965_render.c checks the return value in
    early on in i965_prepare_composite() so that the unchecked use that
    happens later in i965_set_picture_surface_state() wont get a warning.
    
    I need more coffee.

diff --git a/src/i830_render.c b/src/i830_render.c
index 24ad262..956ab92 100644
--- a/src/i830_render.c
+++ b/src/i830_render.c
@@ -405,7 +405,8 @@ i830_prepare_composite(int op, PicturePtr pSrcPicture,
     IntelEmitInvarientState(pScrn);
     *pI830->last_3d = LAST_3D_RENDER;
 
-    i830_get_dest_format(pDstPicture, &dst_format);
+    if (!i830_get_dest_format(pDstPicture, &dst_format))
+	return FALSE;
     dst_pitch = intel_get_pixmap_pitch(pDst);
 
     if (!i830_texture_setup(pSrcPicture, pSrc, 0))
diff --git a/src/i915_render.c b/src/i915_render.c
index 151f89d..52c688e 100644
--- a/src/i915_render.c
+++ b/src/i915_render.c
@@ -322,7 +322,8 @@ i915_prepare_composite(int op, PicturePtr pSrcPicture,
     IntelEmitInvarientState(pScrn);
     *pI830->last_3d = LAST_3D_RENDER;
 
-    i915_get_dest_format(pDstPicture, &dst_format);
+    if (!i915_get_dest_format(pDstPicture, &dst_format))
+	return FALSE;
     dst_offset = intel_get_pixmap_offset(pDst);
     dst_pitch = intel_get_pixmap_pitch(pDst);
     FS_LOCALS(20);
diff --git a/src/i965_render.c b/src/i965_render.c
index 00463e8..94eb189 100644
--- a/src/i965_render.c
+++ b/src/i965_render.c
@@ -1009,6 +1009,7 @@ i965_prepare_composite(int op, PicturePtr pSrcPicture,
     CARD32 *binding_table;
     CARD32 src_blend, dst_blend;
     int binding_table_offset;
+    uint32_t dst_format;
 
     /* We cannot handle a flush occuring anytime during the
      * prepare_composite/composite/done_composite handling. So make
@@ -1072,6 +1073,9 @@ i965_prepare_composite(int op, PicturePtr pSrcPicture,
 			    pI830->exa965->num_ops);
     binding_table = (void *)((char *)surface_map + binding_table_offset);
 
+    if (!i965_get_dest_format(pDstPicture, &dst_format))
+	return FALSE;
+
     /* Set up and bind the state buffer for the destination surface */
     binding_table[0] = i965_set_picture_surface_state(pScrn, 0,
 						      pDstPicture, pDst, TRUE);
commit 033517fa3b36cad29afee8ba9f8d26ce1d17e085
Author: Dave Airlie <airlied at redhat.com>
Date:   Fri Mar 7 08:04:37 2008 +1000

    fixup pciaccess version detect

diff --git a/configure.ac b/configure.ac
index c9773e6..847a39f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -124,9 +124,9 @@ AC_CHECK_DECL(XSERVER_LIBPCIACCESS,
 CFLAGS="$save_CFLAGS"
 
 if test x$XSERVER_LIBPCIACCESS = xyes; then
-	PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.10.0])
+	PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.10])
 else
-	PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.10.0],
+	PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.10],
 				       have_libpciaccess=yes,
 				       have_libpciaccess=no)
 fi
commit d84fac6b1c32f53a8a00519c59a8aa53e1cf6e32
Author: Kristian Høgsberg <krh at redhat.com>
Date:   Mon Mar 10 16:19:42 2008 -0400

    Add need_vram field for the validate workaround.

diff --git a/src/i830.h b/src/i830.h
index 63ba9f0..5bc1139 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -199,6 +199,7 @@ struct _i830_memory {
 #ifdef XF86DRI_MM
     drmBO bo;
     Bool lifetime_fixed_offset;
+    Bool need_vram;
 #endif
 };
 
diff --git a/src/i830_memory.c b/src/i830_memory.c
index 1610e2f..018a64c 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -793,6 +793,7 @@ i830_allocate_memory_bo(ScrnInfoPtr pScrn, const char *name,
     mem->end = -1;
     mem->size = size;
     mem->allocated_size = size;
+    mem->need_vram = (flags & NEED_PHYSICAL_ADDR) ? 1 : 0;
     if (flags & NEED_LIFETIME_FIXED)
 	mem->lifetime_fixed_offset = TRUE;
 
commit cccceab77882042448ddc615b7a686dd92e3ccd3
Author: Dave Airlie <airlied at redhat.com>
Date:   Fri Mar 7 17:41:28 2008 +1100

    validate buffers into TTM space only.
    
    If we validate into both VRAM and TTM here, then later one we emit a relocation
    to only one of the memory types (i.e. TTM) the memory manager seems to lose
    the plot and keep allocating memory blocks in the TTM space even though the
    buffer is already there.

diff --git a/src/i830_memory.c b/src/i830_memory.c
index 634a796..1610e2f 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -165,13 +165,17 @@ i830_bind_memory(ScrnInfoPtr pScrn, i830_memory *mem)
     if (mem->bo.size != 0) {
 	I830Ptr pI830 = I830PTR(pScrn);
 	int ret;
+	int flags = DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE;
+
+	if (mem->need_vram)
+	   flags |= DRM_BO_FLAG_MEM_VRAM;
+	else
+	   flags |= DRM_BO_FLAG_MEM_TT;
+
+	flags |= DRM_BO_FLAG_NO_EVICT;
 
 	ret = drmBOSetStatus(pI830->drmSubFD, &mem->bo,
-			     DRM_BO_FLAG_MEM_VRAM |
-			     DRM_BO_FLAG_MEM_TT |
-			     DRM_BO_FLAG_READ |
-			     DRM_BO_FLAG_WRITE |
-			     DRM_BO_FLAG_NO_EVICT,
+			     flags,
 			     DRM_BO_MASK_MEM |
 			     DRM_BO_FLAG_READ |
 			     DRM_BO_FLAG_WRITE |


More information about the xorg-commit mailing list