Mesa (master): Revert "intel: Remove unneded pthread mutex in LOCK_HARDWARE ."

Eric Anholt anholt at kemper.freedesktop.org
Mon Jun 29 18:39:25 UTC 2009


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

Author: Eric Anholt <eric at anholt.net>
Date:   Mon Jun 29 11:37:21 2009 -0700

Revert "intel: Remove unneded pthread mutex in LOCK_HARDWARE."

This reverts commit de447afff26706e3bf8bdcd5cfb8b1daf49b4b21 but
puts the lock under DRI1-only.

>From keithw:
> It's there because the DRI1 code doesn't actually achieve the mutexing
> which it looks as if it should.  For multi-threaded applications it was
> always possible to get two threads inside locked regions -- I have no
> idea how, but it certainly was and presumably still is possible.

---

 src/mesa/drivers/dri/intel/intel_context.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
index 64d28cf..f77e823 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -1038,6 +1038,8 @@ intelContendedLock(struct intel_context *intel, GLuint flags)
 }
 
 
+_glthread_DECLARE_STATIC_MUTEX(lockMutex);
+
 /* Lock the hardware and validate our state.  
  */
 void LOCK_HARDWARE( struct intel_context *intel )
@@ -1052,6 +1054,9 @@ void LOCK_HARDWARE( struct intel_context *intel )
     if (intel->locked >= 2)
        return;
 
+    if (!sPriv->dri2.enabled)
+       _glthread_LOCK_MUTEX(lockMutex);
+
     if (intel->driDrawable) {
        intel_fb = intel->driDrawable->driverPrivate;
 
@@ -1103,8 +1108,10 @@ void UNLOCK_HARDWARE( struct intel_context *intel )
 
    assert(intel->locked == 0);
 
-   if (!sPriv->dri2.enabled)
+   if (!sPriv->dri2.enabled) {
       DRM_UNLOCK(intel->driFd, intel->driHwLock, intel->hHWContext);
+      _glthread_UNLOCK_MUTEX(lockMutex);
+   }
 
    if (INTEL_DEBUG & DEBUG_LOCK)
       _mesa_printf("%s - unlocked\n", __progname);




More information about the mesa-commit mailing list