Mesa (refs/tags/segfault-fence_emit-2): Revert "nouveau: introduce nouveau_buffer_malloc helper"

Emil Velikov evelikov at kemper.freedesktop.org
Mon Sep 1 00:17:35 UTC 2014


Module: Mesa
Branch: refs/tags/segfault-fence_emit-2
Commit: 8b1701eb47cf2fb38144f9985c87e5e901438002
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8b1701eb47cf2fb38144f9985c87e5e901438002

Author: Emil Velikov <emil.l.velikov at gmail.com>
Date:   Thu Jun 13 10:51:44 2013 +0100

Revert "nouveau: introduce nouveau_buffer_malloc helper"

This reverts commit 4f70a1e89ef311981c3d704d2b8096a725fb2bbc.

Due to missaligned malloc & copy, we segfault in __memcpy_ssse3

---

 src/gallium/drivers/nouveau/nouveau_buffer.c |   28 +++++++++++++-------------
 src/gallium/drivers/nouveau/nouveau_winsys.h |    2 --
 src/gallium/drivers/nv50/nv50_screen.c       |    2 +-
 src/gallium/drivers/nvc0/nvc0_screen.c       |    2 +-
 4 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c b/src/gallium/drivers/nouveau/nouveau_buffer.c
index 63e4c25..4709443 100644
--- a/src/gallium/drivers/nouveau/nouveau_buffer.c
+++ b/src/gallium/drivers/nouveau/nouveau_buffer.c
@@ -22,14 +22,6 @@ nouveau_transfer(struct pipe_transfer *transfer)
 }
 
 static INLINE boolean
-nouveau_buffer_malloc(struct nv04_resource *buf)
-{
-   if (!buf->data)
-      buf->data = align_malloc(buf->base.width0, NOUVEAU_MIN_BUFFER_MAP_ALIGN);
-   return !!buf->data;
-}
-
-static INLINE boolean
 nouveau_buffer_allocate(struct nouveau_screen *screen,
                         struct nv04_resource *buf, unsigned domain)
 {
@@ -53,10 +45,13 @@ nouveau_buffer_allocate(struct nouveau_screen *screen,
       if (!buf->bo)
          return FALSE;
       NOUVEAU_DRV_STAT(screen, buf_obj_current_bytes_sys, buf->base.width0);
-   } else {
-      assert(domain == 0);
-      if (!nouveau_buffer_malloc(buf))
-         return FALSE;
+   }
+   if (domain != NOUVEAU_BO_GART) {
+      if (!buf->data) {
+         buf->data = align_malloc(buf->base.width0, 64);
+         if (!buf->data)
+            return FALSE;
+      }
    }
    buf->domain = domain;
    if (buf->bo)
@@ -504,15 +499,20 @@ nouveau_user_buffer_create(struct pipe_screen *pscreen, void *ptr,
    return &buffer->base;
 }
 
+/* Like download, but for GART buffers. Merge ? */
 static INLINE boolean
 nouveau_buffer_data_fetch(struct nouveau_context *nv, struct nv04_resource *buf,
                           struct nouveau_bo *bo, unsigned offset, unsigned size)
 {
-   if (!nouveau_buffer_malloc(buf))
-      return FALSE;
+   if (!buf->data) {
+      buf->data = MALLOC(size);
+      if (!buf->data)
+         return FALSE;
+   }
    if (nouveau_bo_map(bo, NOUVEAU_BO_RD, nv->client))
       return FALSE;
    memcpy(buf->data, (uint8_t *)bo->map + offset, size);
+
    return TRUE;
 }
 
diff --git a/src/gallium/drivers/nouveau/nouveau_winsys.h b/src/gallium/drivers/nouveau/nouveau_winsys.h
index 6d47f47..faaa524 100644
--- a/src/gallium/drivers/nouveau/nouveau_winsys.h
+++ b/src/gallium/drivers/nouveau/nouveau_winsys.h
@@ -12,8 +12,6 @@
 #define NV04_PFIFO_MAX_PACKET_LEN 2047
 #endif
 
-#define NOUVEAU_MIN_BUFFER_MAP_ALIGN      64
-
 static INLINE uint32_t
 PUSH_AVAIL(struct nouveau_pushbuf *push)
 {
diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c
index b6da303..1291083 100644
--- a/src/gallium/drivers/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nv50/nv50_screen.c
@@ -177,7 +177,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT:
       return 1; /* 256 for binding as RT, but that's not possible in GL */
    case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
-      return NOUVEAU_MIN_BUFFER_MAP_ALIGN;
+      return 64;
    case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
    case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
    case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
diff --git a/src/gallium/drivers/nvc0/nvc0_screen.c b/src/gallium/drivers/nvc0/nvc0_screen.c
index 97ce82c..31fde4a 100644
--- a/src/gallium/drivers/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nvc0/nvc0_screen.c
@@ -169,7 +169,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT:
       return 1; /* 256 for binding as RT, but that's not possible in GL */
    case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
-      return NOUVEAU_MIN_BUFFER_MAP_ALIGN;
+      return 64;
    case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
    case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
    case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:




More information about the mesa-commit mailing list