gpu: pvr: optimize pvr_lock() by inlining it
authorImre Deak <imre.deak@nokia.com>
Thu, 6 May 2010 11:47:49 +0000 (14:47 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Sun, 20 May 2012 18:09:41 +0000 (21:09 +0300)
Also replace pvr_init_lock() by a static initializer.

Signed-off-by: Imre Deak <imre.deak@nokia.com>
pvr/module.c
pvr/pvr_bridge_k.c
pvr/pvr_bridge_km.h

index 8357fcd..b7565dc 100644 (file)
@@ -225,8 +225,6 @@ static int __init pvr_init(void)
 
        PVR_TRACE("pvr_init");
 
-       pvr_init_lock();
-
 #ifdef CONFIG_PVR_DEBUG_EXTRA
        PVRDebugSetLevel(debug);
 #endif
index 82b2d19..a7f0cf4 100644 (file)
@@ -41,9 +41,9 @@
 #include "bridged_pvr_bridge.h"
 
 /* Global driver lock protecting all HW and SW state tracking objects. */
-static struct mutex gPVRSRVLock;
-static int pvr_dvfs_active;
-static DECLARE_WAIT_QUEUE_HEAD(pvr_dvfs_wq);
+DEFINE_MUTEX(gPVRSRVLock);
+int pvr_dvfs_active;
+DECLARE_WAIT_QUEUE_HEAD(pvr_dvfs_wq);
 
 /*
  * The pvr_dvfs_* interface is needed to suppress a lockdep warning in
@@ -62,23 +62,10 @@ static DECLARE_WAIT_QUEUE_HEAD(pvr_dvfs_wq);
  * lead to a dead lock though since at 3. we always release A, before it's
  * again acquired at 4. To avoid the warning use a wait queue based approach
  * so that we can unlock B before 3.
+ *
+ * Must be called with gPVRSRVLock held.
  */
-void pvr_dvfs_lock(void)
-{
-       mutex_lock(&gPVRSRVLock);
-       pvr_dvfs_active = 1;
-       mutex_unlock(&gPVRSRVLock);
-}
-
-void pvr_dvfs_unlock(void)
-{
-       mutex_lock(&gPVRSRVLock);
-       pvr_dvfs_active = 0;
-       wake_up(&pvr_dvfs_wq);
-       mutex_unlock(&gPVRSRVLock);
-}
-
-static void pvr_dvfs_wait_active(void)
+void pvr_dvfs_wait_active(void)
 {
        while (pvr_dvfs_active) {
                DEFINE_WAIT(pvr_dvfs_wait);
@@ -91,28 +78,6 @@ static void pvr_dvfs_wait_active(void)
        }
 }
 
-void pvr_lock(void)
-{
-       mutex_lock(&gPVRSRVLock);
-       pvr_dvfs_wait_active();
-}
-
-void pvr_unlock(void)
-{
-       mutex_unlock(&gPVRSRVLock);
-}
-
-int pvr_is_locked(void)
-{
-       return mutex_is_locked(&gPVRSRVLock);
-}
-
-void pvr_init_lock(void)
-{
-       mutex_init(&gPVRSRVLock);
-}
-
-
 #if defined(DEBUG_BRIDGE_KM)
 static off_t printLinuxBridgeStats(char *buffer, size_t size, off_t off);
 #endif
index b075628..0846f48 100644 (file)
 #define __PVR_BRIDGE_KM_H_
 
 #include <linux/fs.h>                  /* for struct file */
+#include <linux/wait.h>
+#include <linux/sched.h>
 
 #include "pvr_bridge.h"
 #include "perproc.h"
 
-void pvr_lock(void);
-void pvr_unlock(void);
-int pvr_is_locked(void);
-void pvr_init_lock(void);
-void pvr_dvfs_lock(void);
-void pvr_dvfs_unlock(void);
+extern int pvr_dvfs_active;
+extern struct mutex gPVRSRVLock;
+extern wait_queue_head_t pvr_dvfs_wq;
+
+void pvr_dvfs_wait_active(void);
+
+static inline void pvr_dvfs_lock(void)
+{
+       mutex_lock(&gPVRSRVLock);
+       pvr_dvfs_active = 1;
+       mutex_unlock(&gPVRSRVLock);
+}
+
+static inline void pvr_dvfs_unlock(void)
+{
+       mutex_lock(&gPVRSRVLock);
+       pvr_dvfs_active = 0;
+       wake_up(&pvr_dvfs_wq);
+       mutex_unlock(&gPVRSRVLock);
+}
+
+static inline void pvr_lock(void)
+{
+       mutex_lock(&gPVRSRVLock);
+       if (pvr_dvfs_active)
+               pvr_dvfs_wait_active();
+}
+
+static inline void pvr_unlock(void)
+{
+       mutex_unlock(&gPVRSRVLock);
+}
+
+static inline int pvr_is_locked(void)
+{
+       return mutex_is_locked(&gPVRSRVLock);
+}
 
 enum PVRSRV_ERROR LinuxBridgeInit(void);
 void LinuxBridgeDeInit(void);