From: Imre Deak Date: Thu, 6 May 2010 11:47:49 +0000 (+0300) Subject: gpu: pvr: optimize pvr_lock() by inlining it X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32a469277fb7602f9d4e658bb6151e5abb8e9210;p=sgx.git gpu: pvr: optimize pvr_lock() by inlining it Also replace pvr_init_lock() by a static initializer. Signed-off-by: Imre Deak --- diff --git a/pvr/module.c b/pvr/module.c index 8357fcd..b7565dc 100644 --- a/pvr/module.c +++ b/pvr/module.c @@ -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 diff --git a/pvr/pvr_bridge_k.c b/pvr/pvr_bridge_k.c index 82b2d19..a7f0cf4 100644 --- a/pvr/pvr_bridge_k.c +++ b/pvr/pvr_bridge_k.c @@ -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 diff --git a/pvr/pvr_bridge_km.h b/pvr/pvr_bridge_km.h index b075628..0846f48 100644 --- a/pvr/pvr_bridge_km.h +++ b/pvr/pvr_bridge_km.h @@ -28,16 +28,49 @@ #define __PVR_BRIDGE_KM_H_ #include /* for struct file */ +#include +#include #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);