From 33585d73b1ce3c9480d2cb928a75fb409ebd8717 Mon Sep 17 00:00:00 2001
From: Alberto Milone <alberto.milone@canonical.com>
Date: Tue, 14 Jun 2011 19:47:56 +0200
Subject: [PATCH 1/1] replace global lock with a driver specific mutex

---
 drmP.h          |    2 +-
 firegl_public.c |   11 +++++------
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drmP.h b/drmP.h
index b18e7e8..a8e9cae 100644
--- a/drmP.h
+++ b/drmP.h
@@ -57,7 +57,7 @@
 #include <linux/pci.h>
 #include <linux/version.h>
 #include <linux/sched.h>
-#include <linux/smp_lock.h>	/* For (un)lock_kernel */
+#include <linux/mutex.h>
 #include <linux/mm.h>
 #include <linux/pagemap.h>
 #if defined(__alpha__) || defined(__powerpc__)
diff --git a/firegl_public.c b/firegl_public.c
index 66ae0c6..d9b19a2 100644
--- a/firegl_public.c
+++ b/firegl_public.c
@@ -114,7 +114,7 @@
 #include <linux/pci.h>
 #include <linux/wait.h>
 #include <linux/miscdevice.h>
-#include <linux/smp_lock.h>
+#include <linux/mutex.h>
 // newer SuSE kernels need this
 #include <linux/highmem.h>
 
@@ -289,6 +289,8 @@ typedef enum
     KCL_MEM_PAT_ENABLED_KERNEL
 } kcl_mem_pat_status_t;
 
+static DEFINE_MUTEX(ati_mutex);
+
 static kcl_mem_pat_status_t kcl_mem_pat_status = KCL_MEM_PAT_DISABLED;
 static u64 kcl_mem_pat_orig_val; 
 
@@ -1048,9 +1050,6 @@ static int __init firegl_init_module(void)
 
     dev->pubdev.signature = FGL_DEVICE_SIGNATURE;
 
-    for (i = 0; i < __KE_MAX_SPINLOCKS; i++)
-        dev->spinlock[i] = SPIN_LOCK_UNLOCKED;
-
     for (i=0; i < __KE_MAX_SEMAPHORES; i++)
         sema_init(&dev->struct_sem[i], 1);
 
@@ -1900,13 +1899,13 @@ void ATI_API_CALL KCL_spin_unlock(void *lock)
 /** \brief Grab global kernel lock */
 void ATI_API_CALL KCL_GlobalKernelLock(void)
 {
-    lock_kernel();
+    mutex_lock(&ati_mutex);
 }
 
 /** \brief Release global kernel lock */
 void ATI_API_CALL KCL_GlobalKernelUnlock(void)
 {
-    unlock_kernel();
+    mutex_unlock(&ati_mutex);
 }
 
 /*****************************************************************************/
-- 
1.7.4.1

