From: Imre Deak Date: Mon, 5 Apr 2010 20:18:24 +0000 (+0300) Subject: gpu: pvr: fix locking on the DVFS path X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c9fb404c8192e6e5b35a77d65d092214e5d5ce5b;p=sgx.git gpu: pvr: fix locking on the DVFS path The HW state is protected by pvr_lock(), so acquire it for the duration of clock rate changes. We can also remove PVRSRVDvfsLock() that thus becomes unneded. Signed-off-by: Imre Deak CC: Mark Underwood CC: Mark Riding Reviewed-by: Topi Pohjolainen Reviewed-by: Ville Syrjälä --- diff --git a/pvr/power.c b/pvr/power.c index 35adf6a..17afd51 100644 --- a/pvr/power.c +++ b/pvr/power.c @@ -34,8 +34,6 @@ static IMG_BOOL gbInitServerRunning; static IMG_BOOL gbInitServerRan; static IMG_BOOL gbInitSuccessful; static DEFINE_MUTEX(hPowerAndFreqLock); -static DECLARE_WAIT_QUEUE_HEAD(hDvfsWq); -static IMG_BOOL gbDvfsActive; enum PVRSRV_ERROR PVRSRVSetInitServerState(enum PVRSRV_INIT_SERVER_STATE eInitServerState, IMG_BOOL bState) @@ -91,42 +89,15 @@ static IMG_BOOL _IsSystemStatePowered(enum PVR_POWER_STATE eSystemPowerState) return (IMG_BOOL)(eSystemPowerState < PVRSRV_POWER_STATE_D2); } -void PVRSRVDvfsLock(void) -{ - mutex_lock(&hPowerAndFreqLock); - gbDvfsActive = 1; - mutex_unlock(&hPowerAndFreqLock); -} - -void PVRSRVDvfsUnlock(void) -{ - mutex_lock(&hPowerAndFreqLock); - gbDvfsActive = 0; - wake_up(&hDvfsWq); - mutex_unlock(&hPowerAndFreqLock); -} - enum PVRSRV_ERROR PVRSRVPowerLock(u32 ui32CallerID, IMG_BOOL bSystemPowerEvent) { if (ui32CallerID == TIMER_ID) { if (!mutex_trylock(&hPowerAndFreqLock)) return PVRSRV_ERROR_RETRY; - - if (gbDvfsActive) { - mutex_unlock(&hPowerAndFreqLock); - return PVRSRV_ERROR_RETRY; - } - } else + } else { mutex_lock(&hPowerAndFreqLock); - - while (gbDvfsActive) { - DEFINE_WAIT(__wait); - prepare_to_wait(&hDvfsWq, &__wait, TASK_UNINTERRUPTIBLE); - mutex_unlock(&hPowerAndFreqLock); - schedule(); - mutex_lock(&hPowerAndFreqLock); - finish_wait(&hDvfsWq, &__wait); } + return PVRSRV_OK; } diff --git a/pvr/power.h b/pvr/power.h index 807f167..3ea861e 100644 --- a/pvr/power.h +++ b/pvr/power.h @@ -63,8 +63,6 @@ enum PVRSRV_ERROR PVRSRVSetInitServerState(enum PVRSRV_INIT_SERVER_STATE enum PVRSRV_ERROR PVRSRVPowerLock(u32 ui32CallerID, IMG_BOOL bSystemPowerEvent); void PVRSRVPowerUnlock(u32 ui32CallerID); -void PVRSRVDvfsLock(void); -void PVRSRVDvfsUnlock(void); enum PVRSRV_ERROR PVRSRVSetDevicePowerStateKM(u32 ui32DeviceIndex, enum PVR_POWER_STATE eNewPowerState, u32 ui32CallerID, diff --git a/pvr/sysutils.c b/pvr/sysutils.c index 6aa8ac1..874692d 100644 --- a/pvr/sysutils.c +++ b/pvr/sysutils.c @@ -144,16 +144,16 @@ static int vdd2_pre_post_func(struct notifier_block *n, unsigned long event, cnd->rate); if (CLK_PRE_RATE_CHANGE == event) { - PVRSRVDvfsLock(); + pvr_lock(); PVR_TRACE("vdd2_pre_post_func: CLK_PRE_RATE_CHANGE event"); vdd2_pre_func(n, event, ptr); } else if (CLK_POST_RATE_CHANGE == event) { PVR_TRACE("vdd2_pre_post_func: CLK_POST_RATE_CHANGE event"); vdd2_post_func(n, event, ptr); - PVRSRVDvfsUnlock(); + pvr_unlock(); } else if (CLK_ABORT_RATE_CHANGE == event) { PVR_TRACE("vdd2_pre_post_func: CLK_ABORT_RATE_CHANGE event"); - PVRSRVDvfsUnlock(); + pvr_unlock(); } else { printk(KERN_ERR "vdd2_pre_post_func: unexpected event (%lu)\n", event);