r300g: fixup long-lived BO maps being incorrectly unmapped when flushing
authorMarek Olšák <maraeo@gmail.com>
Thu, 23 Sep 2010 11:59:42 +0000 (13:59 +0200)
committerMarek Olšák <maraeo@gmail.com>
Fri, 24 Sep 2010 00:29:04 +0000 (02:29 +0200)
Based on commit 3ddc714b20ac4e28b80c6f88d1993445fff2262c by Dave Airlie.

NOTE: This is a candidate for the 7.9 branch.

src/gallium/winsys/radeon/drm/radeon_drm_buffer.c

index cf665241c4892bced114f32da054261b1f6721b9..075ab5cb324bf810e5dc62ce99d18fd33ef1bd42 100644 (file)
@@ -118,8 +118,10 @@ radeon_drm_buffer_map_internal(struct pb_buffer *_buf,
                return NULL;
     }
 
-    if (buf->bo->ptr != NULL)
+    if (buf->bo->ptr != NULL) {
+        remove_from_list(buf);
        return buf->bo->ptr;
+    }
 
     if (flags & PB_USAGE_DONTBLOCK) {
         uint32_t domain;
@@ -142,14 +144,18 @@ radeon_drm_buffer_map_internal(struct pb_buffer *_buf,
     if (radeon_bo_map(buf->bo, write)) {
         return NULL;
     }
-    insert_at_tail(&buf->mgr->buffer_map_list, buf);
+
+    remove_from_list(buf);
     return buf->bo->ptr;
 }
 
 static void
 radeon_drm_buffer_unmap_internal(struct pb_buffer *_buf)
 {
-    (void)_buf;
+    struct radeon_drm_buffer *buf = radeon_drm_buffer(_buf);
+    if (is_empty_list(buf)) { /* = is not inserted... */
+        insert_at_tail(&buf->mgr->buffer_map_list, buf);
+    }
 }
 
 static void
@@ -163,7 +169,7 @@ radeon_drm_buffer_get_base_buffer(struct pb_buffer *buf,
 
 
 static enum pipe_error
-radeon_drm_buffer_validate(struct pb_buffer *_buf, 
+radeon_drm_buffer_validate(struct pb_buffer *_buf,
                           struct pb_validate *vl,
                           unsigned flags)
 {