[openchrome-devel] xf86-video-openchrome: 6 commits - configure.ac src/via_dri.c src/via_driver.h src/via_memmgr.c src/via_ums.c

Kevin Brace kevinbrace at kemper.freedesktop.org
Wed Feb 12 21:22:36 UTC 2020


 configure.ac     |    2 
 src/via_dri.c    |    7 ++
 src/via_driver.h |    1 
 src/via_memmgr.c |  180 ++++++++++++++++++++++++++++++-------------------------
 src/via_ums.c    |    4 -
 5 files changed, 109 insertions(+), 85 deletions(-)

New commits:
commit ce80786883910e1b1de9a8732d2bc44ba252a1ca
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Wed Feb 12 13:17:13 2020 -0800

    Version bumped to 0.6.213
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/configure.ac b/configure.ac
index 60d9e9d..959e6d2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@
 # Initialize Autoconf
 AC_PREREQ([2.60])
 AC_INIT([xf86-video-openchrome],
-        [0.6.212],
+        [0.6.213],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/openchrome],
         [xf86-video-openchrome])
 
commit 1999a39fa59a43f88c16e8b72182ec12d1745613
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Wed Feb 12 13:12:55 2020 -0800

    Remove obsolete code comment from via_memmgr.c
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_memmgr.c b/src/via_memmgr.c
index 78c31d4..4fc42b7 100644
--- a/src/via_memmgr.c
+++ b/src/via_memmgr.c
@@ -42,15 +42,6 @@
 #include "drm_fourcc.h"
 #endif
 
-/*
- *	Isolate the wonders of X memory allocation and DRI memory allocation
- *	and 4.3 or 4.4 differences in one abstraction.
- *
- *	The pool code indicates who provided the memory:
- *	0  -  nobody
- *	1  -  xf86 linear
- *	2  -  DRM
- */
 static int
 viaOffScreenLinear(ScrnInfoPtr pScrn, struct buffer_object *obj,
                     unsigned long size)
commit 024604a73ef7a1720c08aa48103952c0047f6adb
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Wed Feb 12 13:10:55 2020 -0800

    Rewrite viaOffScreenLinear()
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_driver.h b/src/via_driver.h
index c7e1fe9..1e5c49d 100644
--- a/src/via_driver.h
+++ b/src/via_driver.h
@@ -468,7 +468,6 @@ Bool VIADRIBufferInit(ScrnInfoPtr pScrn);
 
 #endif /* HAVE_DRI */
 
-int viaOffScreenLinear(struct buffer_object *obj, ScrnInfoPtr pScrn, unsigned long size);
 void viaShowCursor(ScrnInfoPtr pScrn);
 void viaHideCursor(ScrnInfoPtr pScrn);
 Bool viaHWCursorInit(ScreenPtr pScreen);
diff --git a/src/via_memmgr.c b/src/via_memmgr.c
index a1dae77..78c31d4 100644
--- a/src/via_memmgr.c
+++ b/src/via_memmgr.c
@@ -51,23 +51,29 @@
  *	1  -  xf86 linear
  *	2  -  DRM
  */
-int
-viaOffScreenLinear(struct buffer_object *obj, ScrnInfoPtr pScrn,
-                   unsigned long size)
+static int
+viaOffScreenLinear(ScrnInfoPtr pScrn, struct buffer_object *obj,
+                    unsigned long size)
 {
-    int depth = pScrn->bitsPerPixel >> 3;
     FBLinearPtr linear;
+    int depth = pScrn->bitsPerPixel / 8;
+    int ret = 0;
 
     linear = xf86AllocateOffscreenLinear(pScrn->pScreen,
                                         (size + depth - 1) / depth,
                                         32, NULL, NULL, NULL);
-    if (!linear)
-        return BadAlloc;
+    if (!linear) {
+        ret = -ENOMEM;
+        goto exit;
+    }
+
     obj->offset = linear->offset * depth;
     obj->handle = (unsigned long) linear;
     obj->domain = TTM_PL_FLAG_VRAM;
     obj->size = size;
-    return Success;
+
+exit:
+    return ret;
 }
 
 struct buffer_object *
@@ -89,11 +95,11 @@ drm_bo_alloc(ScrnInfoPtr pScrn, unsigned int size, unsigned int alignment, int d
     case TTM_PL_FLAG_TT:
     case TTM_PL_FLAG_VRAM:
         if (pVia->directRenderingType == DRI_NONE) {
-            if (Success != viaOffScreenLinear(obj, pScrn, size)) {
+            ret = viaOffScreenLinear(pScrn, obj, size);
+            if (ret) {
                 DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
                                     "Linear memory allocation "
                                     "failed.\n"));
-                ret = -ENOMEM;
             } else
                 DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                                     "%lu bytes of linear memory "
commit 99059ff049211bf4407a40f3d61589967a101aa0
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Tue Feb 11 17:02:45 2020 -0800

    Update messages inside drm_bo_alloc()
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_memmgr.c b/src/via_memmgr.c
index 9c574a2..a1dae77 100644
--- a/src/via_memmgr.c
+++ b/src/via_memmgr.c
@@ -79,8 +79,9 @@ drm_bo_alloc(ScrnInfoPtr pScrn, unsigned int size, unsigned int alignment, int d
 
     obj = xnfcalloc(1, sizeof(*obj));
     if (!obj) {
-        DEBUG(ErrorF("Allocation of a buffer object used for memory "
-                        "allocation failed\n"));
+        DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                            "Allocation of a buffer object used for "
+                            "memory allocation failed.\n"));
         goto exit;
     }
 
@@ -89,10 +90,17 @@ drm_bo_alloc(ScrnInfoPtr pScrn, unsigned int size, unsigned int alignment, int d
     case TTM_PL_FLAG_VRAM:
         if (pVia->directRenderingType == DRI_NONE) {
             if (Success != viaOffScreenLinear(obj, pScrn, size)) {
-                ErrorF("Linear memory allocation failed\n");
+                DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                                    "Linear memory allocation "
+                                    "failed.\n"));
                 ret = -ENOMEM;
             } else
-                DEBUG(ErrorF("%lu bytes of Linear memory allocated at %lx, handle %lu\n", obj->size, obj->offset, obj->handle));
+                DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                                    "%lu bytes of linear memory "
+                                    "allocated at 0x%lx, "
+                                    "handle 0x%lx.\n",
+                                    obj->size, obj->offset,
+                                    obj->handle));
 #ifdef HAVE_DRI
         } else if (pVia->directRenderingType == DRI_1) {
             drm_via_mem_t drm;
@@ -110,8 +118,12 @@ drm_bo_alloc(ScrnInfoPtr pScrn, unsigned int size, unsigned int alignment, int d
                 obj->handle = drm.index;
                 obj->domain = domain;
                 obj->size = drm.size;
-                DEBUG(ErrorF("%lu bytes of DRI memory allocated at %lx, handle %lu\n",
-                            obj->size, obj->offset, obj->handle));
+                DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                                    "%lu bytes of DRI memory "
+                                    "allocated at 0x%lx, "
+                                    "handle 0x%lx.\n",
+                                    obj->size, obj->offset,
+                                    obj->handle));
             }
         } else if (pVia->directRenderingType == DRI_2) {
             struct drm_via_gem_object args;
@@ -131,8 +143,12 @@ drm_bo_alloc(ScrnInfoPtr pScrn, unsigned int size, unsigned int alignment, int d
                 obj->handle = args.handle;
                 obj->size = args.size;
                 obj->domain = domain;
-                DEBUG(ErrorF("%lu bytes of DRI2 memory allocated at %lx, handle %lu\n",
-                            obj->size, obj->offset, obj->handle));
+                DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                                    "%lu bytes of DRI2 memory "
+                                    "allocated at 0x%lx, "
+                                    "handle 0x%lx.\n",
+                                    obj->size, obj->offset,
+                                    obj->handle));
             }
 #endif
         }
@@ -145,7 +161,9 @@ drm_bo_alloc(ScrnInfoPtr pScrn, unsigned int size, unsigned int alignment, int d
     }
 
     if (ret) {
-        DEBUG(ErrorF("DRM memory allocation failed %d\n", ret));
+        DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                            "DRM memory allocation failed.\n"
+                            "Error Code: %d\n", ret));
         free(obj);
         obj = NULL;
         goto exit;
commit d9680b6b411c1014968ee0f14e36941e31e5711d
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon Feb 10 16:20:04 2020 -0800

    Change how error handling is done inside drm_bo_alloc()
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_memmgr.c b/src/via_memmgr.c
index 566b34e..9c574a2 100644
--- a/src/via_memmgr.c
+++ b/src/via_memmgr.c
@@ -78,74 +78,81 @@ drm_bo_alloc(ScrnInfoPtr pScrn, unsigned int size, unsigned int alignment, int d
     int ret = 0;
 
     obj = xnfcalloc(1, sizeof(*obj));
-    if (obj) {
-        switch (domain) {
-        case TTM_PL_FLAG_TT:
-        case TTM_PL_FLAG_VRAM:
-            if (pVia->directRenderingType == DRI_NONE) {
-                if (Success != viaOffScreenLinear(obj, pScrn, size)) {
-                    ErrorF("Linear memory allocation failed\n");
-                    ret = -ENOMEM;
-                } else
-                    DEBUG(ErrorF("%lu bytes of Linear memory allocated at %lx, handle %lu\n", obj->size, obj->offset, obj->handle));
-#ifdef HAVE_DRI
-            } else if (pVia->directRenderingType == DRI_1) {
-                drm_via_mem_t drm;
+    if (!obj) {
+        DEBUG(ErrorF("Allocation of a buffer object used for memory "
+                        "allocation failed\n"));
+        goto exit;
+    }
 
-                size = ALIGN_TO(size, alignment);
-                drm.context = DRIGetContext(pScrn->pScreen);
-                drm.size = size;
-                drm.type = (domain == TTM_PL_FLAG_TT ? VIA_MEM_AGP : VIA_MEM_VIDEO);
-                ret = drmCommandWriteRead(pVia->drmmode.fd, DRM_VIA_ALLOCMEM,
-                                            &drm, sizeof(drm_via_mem_t));
-                if (!ret && (size == drm.size)) {
-                    if (domain == TTM_PL_FLAG_VRAM)
-                        drm.offset -= pVia->FBFreeStart;
-                    obj->offset = ALIGN_TO(drm.offset, alignment);
-                    obj->handle = drm.index;
-                    obj->domain = domain;
-                    obj->size = drm.size;
-                    DEBUG(ErrorF("%lu bytes of DRI memory allocated at %lx, handle %lu\n",
-                                obj->size, obj->offset, obj->handle));
-                }
-            } else if (pVia->directRenderingType == DRI_2) {
-                struct drm_via_gem_object args;
-
-                /* Some day this will be moved to libdrm. */
-                args.domains = domain;
-                args.alignment = alignment;
-                args.size = size;
-                ret = drmCommandWriteRead(pVia->drmmode.fd, DRM_VIA_GEM_CREATE,
-                                        &args, sizeof(struct drm_via_gem_object));
-                if (!ret) {
-                    /* Okay the X server expects to know the offset because
-                     * of non-KMS. Once we have KMS working the offset
-                     * will not be valid. */
-                    obj->map_offset = args.map_handle;
-                    obj->offset = args.offset;
-                    obj->handle = args.handle;
-                    obj->size = args.size;
-                    obj->domain = domain;
-                    DEBUG(ErrorF("%lu bytes of DRI2 memory allocated at %lx, handle %lu\n",
-                                obj->size, obj->offset, obj->handle));
-                }
-#endif
+    switch (domain) {
+    case TTM_PL_FLAG_TT:
+    case TTM_PL_FLAG_VRAM:
+        if (pVia->directRenderingType == DRI_NONE) {
+            if (Success != viaOffScreenLinear(obj, pScrn, size)) {
+                ErrorF("Linear memory allocation failed\n");
+                ret = -ENOMEM;
+            } else
+                DEBUG(ErrorF("%lu bytes of Linear memory allocated at %lx, handle %lu\n", obj->size, obj->offset, obj->handle));
+#ifdef HAVE_DRI
+        } else if (pVia->directRenderingType == DRI_1) {
+            drm_via_mem_t drm;
+
+            size = ALIGN_TO(size, alignment);
+            drm.context = DRIGetContext(pScrn->pScreen);
+            drm.size = size;
+            drm.type = (domain == TTM_PL_FLAG_TT ? VIA_MEM_AGP : VIA_MEM_VIDEO);
+            ret = drmCommandWriteRead(pVia->drmmode.fd, DRM_VIA_ALLOCMEM,
+                                        &drm, sizeof(drm_via_mem_t));
+            if (!ret && (size == drm.size)) {
+                if (domain == TTM_PL_FLAG_VRAM)
+                    drm.offset -= pVia->FBFreeStart;
+                obj->offset = ALIGN_TO(drm.offset, alignment);
+                obj->handle = drm.index;
+                obj->domain = domain;
+                obj->size = drm.size;
+                DEBUG(ErrorF("%lu bytes of DRI memory allocated at %lx, handle %lu\n",
+                            obj->size, obj->offset, obj->handle));
             }
-            break;
-
-        case TTM_PL_FLAG_SYSTEM:
-        default:
-            ret = -ENXIO;
-            break;
+        } else if (pVia->directRenderingType == DRI_2) {
+            struct drm_via_gem_object args;
+
+            /* Some day this will be moved to libdrm. */
+            args.domains = domain;
+            args.alignment = alignment;
+            args.size = size;
+            ret = drmCommandWriteRead(pVia->drmmode.fd, DRM_VIA_GEM_CREATE,
+                                    &args, sizeof(struct drm_via_gem_object));
+            if (!ret) {
+                /* Okay the X server expects to know the offset because
+                 * of non-KMS. Once we have KMS working the offset
+                 * will not be valid. */
+                obj->map_offset = args.map_handle;
+                obj->offset = args.offset;
+                obj->handle = args.handle;
+                obj->size = args.size;
+                obj->domain = domain;
+                DEBUG(ErrorF("%lu bytes of DRI2 memory allocated at %lx, handle %lu\n",
+                            obj->size, obj->offset, obj->handle));
+            }
+#endif
         }
+        break;
 
-        if (ret) {
-            DEBUG(ErrorF("DRM memory allocation failed %d\n", ret));
-            free(obj);
-            obj = NULL;
-        };
+    case TTM_PL_FLAG_SYSTEM:
+    default:
+        ret = -ENXIO;
+        break;
     }
-    return obj;
+
+    if (ret) {
+        DEBUG(ErrorF("DRM memory allocation failed %d\n", ret));
+        free(obj);
+        obj = NULL;
+        goto exit;
+    }
+
+exit:
+     return obj;
 }
 
 void*
commit cd25726ec7f591463ee30a33ba36b5c92e8d8bdf
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon Feb 10 11:48:53 2020 -0800

    Initialize driSize member of VIARec struct inside VIADRI1ScreenInit()
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_dri.c b/src/via_dri.c
index e0f049a..ec46fa0 100644
--- a/src/via_dri.c
+++ b/src/via_dri.c
@@ -618,6 +618,13 @@ VIADRI1ScreenInit(ScreenPtr pScreen)
         return FALSE;
     }
 
+    if ((pVia->driSize > (pVia->maxDriSize * 1024)) &&
+        (pVia->maxDriSize > 0)) {
+        pVia->driSize = pVia->maxDriSize * 1024;
+    } else {
+        pVia->driSize = (pVia->FBFreeEnd - pVia->FBFreeStart) >> 2;
+    }
+
     if (!(VIAInitVisualConfigs(pScreen))) {
         VIADRICloseScreen(pScreen);
         return FALSE;
diff --git a/src/via_ums.c b/src/via_ums.c
index 3d1a3a9..1ddd74b 100644
--- a/src/via_ums.c
+++ b/src/via_ums.c
@@ -698,10 +698,6 @@ viaUMSCreate(ScrnInfoPtr pScrn)
 
 #ifdef HAVE_DRI
     if (pVia->directRenderingType == DRI_1) {
-        pVia->driSize = (pVia->FBFreeEnd - pVia->FBFreeStart) >> 2;
-        if ((pVia->driSize > (pVia->maxDriSize * 1024)) && pVia->maxDriSize > 0)
-            pVia->driSize = pVia->maxDriSize * 1024;
-
         /* In the case of DRI we handle all VRAM by the DRI ioctls */
         if (pVia->useEXA)
             goto exit;


More information about the openchrome-devel mailing list