Test for TTM presence initially rather than test for lack of classic aperture.
authorEric Anholt <eric@anholt.net>
Mon, 18 Jun 2007 19:19:42 +0000 (12:19 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 18 Jun 2007 19:19:42 +0000 (12:19 -0700)
src/mesa/drivers/dri/common/dri_bufmgr_ttm.c
src/mesa/drivers/dri/i915tex/intel_screen.c

index a721a7c..508d4f5 100644 (file)
@@ -353,6 +353,7 @@ dri_bufmgr_ttm_init(int fd, unsigned int fence_type,
                    unsigned int fence_type_flush)
 {
    dri_bufmgr_ttm *bufmgr_ttm;
+   dri_bo *test_alloc;
 
    bufmgr_ttm = malloc(sizeof(*bufmgr_ttm));
    bufmgr_ttm->fd = fd;
@@ -372,5 +373,17 @@ dri_bufmgr_ttm_init(int fd, unsigned int fence_type,
    bufmgr_ttm->bufmgr.fence_unreference = dri_ttm_fence_unreference;
    bufmgr_ttm->bufmgr.fence_wait = dri_ttm_fence_wait;
 
+   /* Attempt an allocation to make sure that the DRM was actually set up for
+    * TTM.
+    */
+   test_alloc = dri_bo_alloc((dri_bufmgr *)bufmgr_ttm, "test allocation",
+     4096, 4096, DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_MEM_TT);
+   if (test_alloc == NULL) {
+      _glthread_DESTROY_MUTEX(bufmgr_ttm->mutex);
+      free(bufmgr_ttm);
+      return NULL;
+   }
+   dri_bo_unreference(test_alloc);
+
    return &bufmgr_ttm->bufmgr;
 }
index 4d61407..1ae2819 100644 (file)
@@ -123,8 +123,6 @@ intelMapScreenRegions(__DRIscreenPrivate * sPriv)
    if (0)
       _mesa_printf("TEX 0x%08x ", intelScreen->tex.handle);
    if (intelScreen->tex.size != 0) {
-      intelScreen->ttm = GL_FALSE;
-
       if (drmMap(sPriv->fd,
                 intelScreen->tex.handle,
                 intelScreen->tex.size,
@@ -132,8 +130,6 @@ intelMapScreenRegions(__DRIscreenPrivate * sPriv)
         intelUnmapScreenRegions(intelScreen);
         return GL_FALSE;
       }
-   } else {
-      intelScreen->ttm = GL_TRUE;
    }
 
    if (0)
@@ -530,12 +526,16 @@ intelInitDriver(__DRIscreenPrivate * sPriv)
       (*glx_enable_extension) (psc, "GLX_SGI_make_current_read");
    }
 
-   if (intelScreen->ttm) {
-      intelScreen->bufmgr = dri_bufmgr_ttm_init(sPriv->fd,
-                                               DRM_FENCE_TYPE_EXE,
-                                               DRM_FENCE_TYPE_EXE |
-                                               DRM_I915_FENCE_TYPE_RW);
-   } else {
+   intelScreen->bufmgr = dri_bufmgr_ttm_init(sPriv->fd,
+                                            DRM_FENCE_TYPE_EXE,
+                                            DRM_FENCE_TYPE_EXE |
+                                            DRM_I915_FENCE_TYPE_RW);
+   if (intelScreen->bufmgr == NULL) {
+      if (intelScreen->tex.size == 0) {
+        fprintf(stderr, "[%s:%u] Error initializing buffer manager.\n",
+                __func__, __LINE__);
+        return GL_FALSE;
+      }
       intelScreen->bufmgr = dri_bufmgr_fake_init(intelScreen->tex.offset,
                                                 intelScreen->tex.map,
                                                 intelScreen->tex.size,