gpu: pvr: add pvr_lock/remove unneeded lock headers
authorImre Deak <imre.deak@nokia.com>
Wed, 31 Mar 2010 11:55:54 +0000 (14:55 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Sun, 20 May 2012 18:09:40 +0000 (21:09 +0300)
- Add a public interface for accessing this lock. It has been used
  as a public interface anyway and an upcoming patch needs to access
  it as well.

- Remove headers becoming unnecessary by this refactoring.

Note:
  Currently this lock provides for a course level locking protecting
  all HW and SW state tracking objects. We'll need to revise the use
  of the following additional locks in the driver. Their existance
  might not be justified, in which case we could just substitute
  them with pvr_lock:

  PVRSRVDvfsLock
  PVRSRVPowerLock

Signed-off-by: Imre Deak <imre.deak@nokia.com>
pvr/event.c
pvr/lock.h [deleted file]
pvr/mm.c
pvr/mmap.c
pvr/module.c
pvr/mutex.h [deleted file]
pvr/osfunc.c
pvr/pvr_bridge_k.c
pvr/pvr_bridge_km.h
pvr/pvr_debug.c

index e538100..3dc4ab5 100644 (file)
@@ -50,9 +50,8 @@
 #include "mmap.h"
 #include "env_data.h"
 #include "proc.h"
-#include "mutex.h"
-#include "lock.h"
 #include "event.h"
+#include "pvr_bridge_km.h"
 
 struct PVRSRV_LINUX_EVENT_OBJECT_LIST {
        rwlock_t sLock;
@@ -249,12 +248,12 @@ enum PVRSRV_ERROR LinuxEventObjectWait(void *hOSEventObject, u32 ui32MSTimeout)
                if (psLinuxEventObject->ui32TimeStampPrevious != ui32TimeStamp)
                        break;
 
-               mutex_unlock(&gPVRSRVLock);
+               pvr_unlock();
 
                ui32TimeOutJiffies =
                    (u32) schedule_timeout((s32) ui32TimeOutJiffies);
 
-               mutex_lock(&gPVRSRVLock);
+               pvr_lock();
 #if defined(DEBUG)
                psLinuxEventObject->ui32Stats++;
 #endif
diff --git a/pvr/lock.h b/pvr/lock.h
deleted file mode 100644 (file)
index c3b6ff3..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/**********************************************************************
- *
- * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful but, except
- * as otherwise stated in writing, without any warranty; without even the
- * implied warranty of merchantability or fitness for a particular purpose.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * The full GNU General Public License is included in this distribution in
- * the file called "COPYING".
- *
- * Contact Information:
- * Imagination Technologies Ltd. <gpl-support@imgtec.com>
- * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK
- *
- ******************************************************************************/
-#ifndef __LOCK_H__
-#define __LOCK_H__
-
-extern struct mutex gPVRSRVLock;
-
-#endif
index 29bdd93..c0a92f2 100644 (file)
--- a/pvr/mm.c
+++ b/pvr/mm.c
@@ -44,8 +44,6 @@
 #include "osfunc.h"
 #include "pvr_debug.h"
 #include "proc.h"
-#include "mutex.h"
-#include "lock.h"
 
 #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS)
 enum DEBUG_MEM_ALLOC_TYPE {
index 7b3b784..240d121 100644 (file)
@@ -46,7 +46,6 @@
 #include "pvr_debug.h"
 #include "osfunc.h"
 #include "proc.h"
-#include "mutex.h"
 #include "handle.h"
 #include "perproc.h"
 #include "env_perproc.h"
index c630f4d..29062b2 100644 (file)
@@ -43,7 +43,6 @@
 #include "mutils.h"
 #include "mm.h"
 #include "mmap.h"
-#include "mutex.h"
 #include "pvr_debug.h"
 #include "srvkm.h"
 #include "perproc.h"
@@ -53,7 +52,6 @@
 #include "proc.h"
 #include "pvrmodule.h"
 #include "private_data.h"
-#include "lock.h"
 
 #define DRVNAME                "pvrsrvkm"
 
@@ -63,8 +61,6 @@ static int debug = DBGPRIV_WARNING;
 module_param(debug, int, 0);
 #endif
 
-struct mutex gPVRSRVLock;
-
 static int pvr_open(struct inode unref__ * inode, struct file *filp)
 {
        struct PVRSRV_FILE_PRIVATE_DATA *priv;
@@ -73,7 +69,7 @@ static int pvr_open(struct inode unref__ * inode, struct file *filp)
        enum PVRSRV_ERROR err;
        u32 pid;
 
-       mutex_lock(&gPVRSRVLock);
+       pvr_lock();
 
        pid = OSGetCurrentProcessIDKM();
 
@@ -93,7 +89,8 @@ static int pvr_open(struct inode unref__ * inode, struct file *filp)
 
        ret = 0;
 err_unlock:
-       mutex_unlock(&gPVRSRVLock);
+       pvr_unlock();
+
        return ret;
 }
 
@@ -101,7 +98,7 @@ static int pvr_release(struct inode unref__ * inode, struct file *filp)
 {
        struct PVRSRV_FILE_PRIVATE_DATA *priv;
 
-       mutex_lock(&gPVRSRVLock);
+       pvr_lock();
 
        priv = filp->private_data;
 
@@ -111,7 +108,8 @@ static int pvr_release(struct inode unref__ * inode, struct file *filp)
                  sizeof(*priv),
                  priv, priv->hBlockAlloc);
 
-       mutex_unlock(&gPVRSRVLock);
+       pvr_unlock();
+
        return 0;
 }
 
@@ -218,7 +216,7 @@ static int __init pvr_init(void)
 
        PVR_TRACE("pvr_init");
 
-       mutex_init(&gPVRSRVLock);
+       pvr_init_lock();
 
 #ifdef DEBUG
        PVRDebugSetLevel(debug);
diff --git a/pvr/mutex.h b/pvr/mutex.h
deleted file mode 100644 (file)
index cbd963a..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/**********************************************************************
- *
- * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful but, except
- * as otherwise stated in writing, without any warranty; without even the
- * implied warranty of merchantability or fitness for a particular purpose.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * The full GNU General Public License is included in this distribution in
- * the file called "COPYING".
- *
- * Contact Information:
- * Imagination Technologies Ltd. <gpl-support@imgtec.com>
- * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK
- *
- ******************************************************************************/
-
-#ifndef __INCLUDED_LINUX_MUTEX_H_
-#define __INCLUDED_LINUX_MUTEX_H_
-
-#include <linux/version.h>
-
-#include <linux/mutex.h>
-
-extern struct mutex gPVRSRVLock;
-
-#endif
index 07f1662..c0d0ba7 100644 (file)
@@ -52,7 +52,6 @@
 #include "mmap.h"
 #include "env_data.h"
 #include "proc.h"
-#include "mutex.h"
 #include "event.h"
 
 #define EVENT_OBJECT_TIMEOUT_MS                (100)
index 9053a3e..7099647 100644 (file)
@@ -29,7 +29,6 @@
 #include "pvr_bridge.h"
 #include "pvr_bridge_km.h"
 #include "perproc.h"
-#include "mutex.h"
 #include "syscommon.h"
 #include "pvr_debug.h"
 #include "proc.h"
@@ -39,6 +38,8 @@
 
 #include "bridged_pvr_bridge.h"
 
+/* Global driver lock protecting all HW and SW state tracking objects. */
+struct mutex gPVRSRVLock;
 
 #if defined(DEBUG_BRIDGE_KM)
 static off_t printLinuxBridgeStats(char *buffer, size_t size, off_t off);
@@ -71,7 +72,7 @@ static off_t printLinuxBridgeStats(char *buffer, size_t count, off_t off)
        struct PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY *psEntry;
        off_t Ret;
 
-       mutex_lock(&gPVRSRVLock);
+       pvr_lock();
 
        if (!off) {
                if (count < 500) {
@@ -116,7 +117,8 @@ static off_t printLinuxBridgeStats(char *buffer, size_t count, off_t off)
                          psEntry->ui32CopyToUserTotalBytes);
 
 unlock_and_return:
-       mutex_unlock(&gPVRSRVLock);
+       pvr_unlock();
+
        return Ret;
 }
 #endif
@@ -132,7 +134,7 @@ long PVRSRV_BridgeDispatchKM(struct file *file, unsigned int cmd,
        struct PVRSRV_PER_PROCESS_DATA *psPerProc;
        int err = -EFAULT;
 
-       mutex_lock(&gPVRSRVLock);
+       pvr_lock();
 
        if (!OSAccessOK(PVR_VERIFY_WRITE, psBridgePackageUM,
                        sizeof(struct PVRSRV_BRIDGE_PACKAGE))) {
@@ -186,6 +188,7 @@ long PVRSRV_BridgeDispatchKM(struct file *file, unsigned int cmd,
                goto unlock_and_return;
 
 unlock_and_return:
-       mutex_unlock(&gPVRSRVLock);
+       pvr_unlock();
+
        return err;
 }
index 0c60a42..dfae4f4 100644 (file)
 #include "pvr_bridge.h"
 #include "perproc.h"
 
+extern struct mutex gPVRSRVLock;
+
+static inline void pvr_lock(void)
+{
+       mutex_lock(&gPVRSRVLock);
+}
+
+static inline void pvr_unlock(void)
+{
+       mutex_unlock(&gPVRSRVLock);
+}
+
+static inline void pvr_init_lock(void)
+{
+       mutex_init(&gPVRSRVLock);
+}
+
 enum PVRSRV_ERROR LinuxBridgeInit(void);
 void LinuxBridgeDeInit(void);
 
index eec9075..5dff963 100644 (file)
@@ -37,7 +37,6 @@
 #include "servicesext.h"
 #include "pvr_debug.h"
 #include "proc.h"
-#include "mutex.h"
 #include "syscommon.h"
 #include "sgxinfokm.h"
 #include "sgxutils.h"