Mesa (master): r300g: avoid mapping the same buffer twice

Marek Olšák mareko at kemper.freedesktop.org
Sun Apr 3 10:36:03 PDT 2011


Module: Mesa
Branch: master
Commit: 652bf121f2124ec92b74f6e3e40e6aefcc1c50dc
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=652bf121f2124ec92b74f6e3e40e6aefcc1c50dc

Author: Marek Olšák <maraeo at gmail.com>
Date:   Sun Apr  3 19:17:19 2011 +0200

r300g: avoid mapping the same buffer twice

Shouldn't happen, but you never know.

---

 src/gallium/winsys/radeon/drm/radeon_drm_bo.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index eb7225b..4fd8220 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -191,6 +191,11 @@ static void *radeon_bo_map_internal(struct pb_buffer *_buf,
 
     /* Map the buffer. */
     pipe_mutex_lock(bo->map_mutex);
+    /* Return the pointer if it's already mapped (in case of a race). */
+    if (bo->ptr) {
+        pipe_mutex_unlock(bo->map_mutex);
+        return bo->ptr;
+    }
     args.handle = bo->handle;
     args.offset = 0;
     args.size = (uint64_t)bo->size;



More information about the mesa-commit mailing list