r600g: Check for other references before checking for existing mappings in radeon_bo_...
authorHenri Verbeet <hverbeet@gmail.com>
Sun, 19 Sep 2010 17:27:30 +0000 (19:27 +0200)
committerHenri Verbeet <hverbeet@gmail.com>
Sun, 19 Sep 2010 17:43:05 +0000 (19:43 +0200)
Having a non-NULL data pointer doesn't imply it's safe to reuse that mapping,
it may have been unmapped but not flushed yet.

src/gallium/winsys/r600/drm/radeon_bo_pb.c

index 65ba96233d5e6b6ae00be4984e2fd5a0bfb5421e..8cf6a781306bf8dc1e24145bf245f27e81686f83 100644 (file)
@@ -53,11 +53,16 @@ radeon_bo_pb_map_internal(struct pb_buffer *_buf,
                          unsigned flags, void *ctx)
 {
        struct radeon_bo_pb *buf = radeon_bo_pb(_buf);
-       
-       if (flags & PB_USAGE_DONTBLOCK) {
-               if (p_atomic_read(&buf->bo->reference.count) > 1)
+
+       if (p_atomic_read(&buf->bo->reference.count) > 1) {
+               if (flags & PB_USAGE_DONTBLOCK) {
                        return NULL;
+               }
+               if (ctx) {
+                       r600_flush_ctx(ctx);
+               }
        }
+
        if (buf->bo->data != NULL) {
                LIST_DELINIT(&buf->maplist);
                return buf->bo->data;
@@ -69,9 +74,6 @@ radeon_bo_pb_map_internal(struct pb_buffer *_buf,
                        return NULL;
        }
 
-       if (p_atomic_read(&buf->bo->reference.count) > 1 && ctx) {
-               r600_flush_ctx(ctx);
-       }
        if (radeon_bo_map(buf->mgr->radeon, buf->bo)) {
                return NULL;
        }