1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-10 23:08:07 +00:00

Do not bother resetting values to old ones if changes to GPU parameters report failure, instead returning a failure code only if the return value from get() differs.

This commit is contained in:
Con Kolivas 2011-09-11 11:38:02 +10:00
parent dff1a81da7
commit ebae03f22b

62
adl.c
View File

@ -605,19 +605,10 @@ static int set_engineclock(int gpu, int iEngineClock)
lpOdPerformanceLevels->aLevels[i].iEngineClock = iEngineClock; lpOdPerformanceLevels->aLevels[i].iEngineClock = iEngineClock;
} }
lpOdPerformanceLevels->aLevels[lev].iEngineClock = iEngineClock; lpOdPerformanceLevels->aLevels[lev].iEngineClock = iEngineClock;
if (ADL_Overdrive5_ODPerformanceLevels_Set(ga->iAdapterIndex, lpOdPerformanceLevels) != ADL_OK) ADL_Overdrive5_ODPerformanceLevels_Set(ga->iAdapterIndex, lpOdPerformanceLevels);
goto out;
ADL_Overdrive5_ODPerformanceLevels_Get(ga->iAdapterIndex, 0, lpOdPerformanceLevels); ADL_Overdrive5_ODPerformanceLevels_Get(ga->iAdapterIndex, 0, lpOdPerformanceLevels);
/* Reset to old value if it fails! */ if (lpOdPerformanceLevels->aLevels[lev].iEngineClock == iEngineClock)
if (lpOdPerformanceLevels->aLevels[lev].iEngineClock != iEngineClock) { ret = 0;
/* Set all the parameters in case they're linked somehow */
lpOdPerformanceLevels->aLevels[lev].iEngineClock = ga->iEngineClock;
lpOdPerformanceLevels->aLevels[lev].iMemoryClock = ga->iMemoryClock;
lpOdPerformanceLevels->aLevels[lev].iVddc = ga->iVddc;
ADL_Overdrive5_ODPerformanceLevels_Set(ga->iAdapterIndex, lpOdPerformanceLevels);
ADL_Overdrive5_ODPerformanceLevels_Get(ga->iAdapterIndex, 0, lpOdPerformanceLevels);
goto out;
}
ga->iEngineClock = lpOdPerformanceLevels->aLevels[lev].iEngineClock; ga->iEngineClock = lpOdPerformanceLevels->aLevels[lev].iEngineClock;
if (ga->iEngineClock > ga->maxspeed) if (ga->iEngineClock > ga->maxspeed)
ga->maxspeed = ga->iEngineClock; ga->maxspeed = ga->iEngineClock;
@ -626,7 +617,6 @@ static int set_engineclock(int gpu, int iEngineClock)
ga->iMemoryClock = lpOdPerformanceLevels->aLevels[lev].iMemoryClock; ga->iMemoryClock = lpOdPerformanceLevels->aLevels[lev].iMemoryClock;
ga->iVddc = lpOdPerformanceLevels->aLevels[lev].iVddc; ga->iVddc = lpOdPerformanceLevels->aLevels[lev].iVddc;
ga->managed = true; ga->managed = true;
ret = 0;
out: out:
unlock_adl(); unlock_adl();
return ret; return ret;
@ -671,24 +661,14 @@ static int set_memoryclock(int gpu, int iMemoryClock)
if (lpOdPerformanceLevels->aLevels[i].iMemoryClock > iMemoryClock) if (lpOdPerformanceLevels->aLevels[i].iMemoryClock > iMemoryClock)
lpOdPerformanceLevels->aLevels[i].iMemoryClock = iMemoryClock; lpOdPerformanceLevels->aLevels[i].iMemoryClock = iMemoryClock;
} }
if (ADL_Overdrive5_ODPerformanceLevels_Set(ga->iAdapterIndex, lpOdPerformanceLevels) != ADL_OK) ADL_Overdrive5_ODPerformanceLevels_Set(ga->iAdapterIndex, lpOdPerformanceLevels);
goto out;
ADL_Overdrive5_ODPerformanceLevels_Get(ga->iAdapterIndex, 0, lpOdPerformanceLevels); ADL_Overdrive5_ODPerformanceLevels_Get(ga->iAdapterIndex, 0, lpOdPerformanceLevels);
/* Reset to old value if it fails! */ if (lpOdPerformanceLevels->aLevels[lev].iMemoryClock == iMemoryClock)
if (lpOdPerformanceLevels->aLevels[lev].iMemoryClock != iMemoryClock) { ret = 0;
/* Set all the parameters in case they're linked somehow */
lpOdPerformanceLevels->aLevels[lev].iMemoryClock = ga->iEngineClock;
lpOdPerformanceLevels->aLevels[lev].iMemoryClock = ga->iMemoryClock;
lpOdPerformanceLevels->aLevels[lev].iVddc = ga->iVddc;
ADL_Overdrive5_ODPerformanceLevels_Set(ga->iAdapterIndex, lpOdPerformanceLevels);
ADL_Overdrive5_ODPerformanceLevels_Get(ga->iAdapterIndex, 0, lpOdPerformanceLevels);
goto out;
}
ga->iEngineClock = lpOdPerformanceLevels->aLevels[lev].iEngineClock; ga->iEngineClock = lpOdPerformanceLevels->aLevels[lev].iEngineClock;
ga->iMemoryClock = lpOdPerformanceLevels->aLevels[lev].iMemoryClock; ga->iMemoryClock = lpOdPerformanceLevels->aLevels[lev].iMemoryClock;
ga->iVddc = lpOdPerformanceLevels->aLevels[lev].iVddc; ga->iVddc = lpOdPerformanceLevels->aLevels[lev].iVddc;
ga->managed = true; ga->managed = true;
ret = 0;
out: out:
unlock_adl(); unlock_adl();
return ret; return ret;
@ -744,24 +724,14 @@ static int set_vddc(int gpu, float fVddc)
lpOdPerformanceLevels->aLevels[i].iVddc = iVddc; lpOdPerformanceLevels->aLevels[i].iVddc = iVddc;
} }
lpOdPerformanceLevels->aLevels[lev].iVddc = iVddc; lpOdPerformanceLevels->aLevels[lev].iVddc = iVddc;
if (ADL_Overdrive5_ODPerformanceLevels_Set(ga->iAdapterIndex, lpOdPerformanceLevels) != ADL_OK) ADL_Overdrive5_ODPerformanceLevels_Set(ga->iAdapterIndex, lpOdPerformanceLevels);
goto out;
ADL_Overdrive5_ODPerformanceLevels_Get(ga->iAdapterIndex, 0, lpOdPerformanceLevels); ADL_Overdrive5_ODPerformanceLevels_Get(ga->iAdapterIndex, 0, lpOdPerformanceLevels);
/* Reset to old value if it fails! */ if (lpOdPerformanceLevels->aLevels[lev].iVddc == iVddc)
if (lpOdPerformanceLevels->aLevels[lev].iVddc != iVddc) { ret = 0;
/* Set all the parameters in case they're linked somehow */
lpOdPerformanceLevels->aLevels[lev].iEngineClock = ga->iEngineClock;
lpOdPerformanceLevels->aLevels[lev].iMemoryClock = ga->iMemoryClock;
lpOdPerformanceLevels->aLevels[lev].iVddc = ga->iVddc;
ADL_Overdrive5_ODPerformanceLevels_Set(ga->iAdapterIndex, lpOdPerformanceLevels);
ADL_Overdrive5_ODPerformanceLevels_Get(ga->iAdapterIndex, 0, lpOdPerformanceLevels);
goto out;
}
ga->iEngineClock = lpOdPerformanceLevels->aLevels[lev].iEngineClock; ga->iEngineClock = lpOdPerformanceLevels->aLevels[lev].iEngineClock;
ga->iMemoryClock = lpOdPerformanceLevels->aLevels[lev].iMemoryClock; ga->iMemoryClock = lpOdPerformanceLevels->aLevels[lev].iMemoryClock;
ga->iVddc = lpOdPerformanceLevels->aLevels[lev].iVddc; ga->iVddc = lpOdPerformanceLevels->aLevels[lev].iVddc;
ga->managed = true; ga->managed = true;
ret = 0;
out: out:
unlock_adl(); unlock_adl();
return ret; return ret;
@ -809,10 +779,9 @@ static int set_fanspeed(int gpu, int iFanSpeed)
} else } else
ga->lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT; ga->lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
ga->lpFanSpeedValue.iFanSpeed = iFanSpeed; ga->lpFanSpeedValue.iFanSpeed = iFanSpeed;
if (ADL_Overdrive5_FanSpeed_Set(ga->iAdapterIndex, 0, &ga->lpFanSpeedValue) != ADL_OK) if (ADL_Overdrive5_FanSpeed_Set(ga->iAdapterIndex, 0, &ga->lpFanSpeedValue) == ADL_OK)
goto out; ret = 0;
ga->managed = true; ga->managed = true;
ret = 0;
out: out:
unlock_adl(); unlock_adl();
return ret; return ret;
@ -833,14 +802,11 @@ static int set_powertune(int gpu, int iPercentage)
oldPercentage = ga->iPercentage; oldPercentage = ga->iPercentage;
lock_adl(); lock_adl();
if (ADL_Overdrive5_PowerControl_Set(ga->iAdapterIndex, iPercentage) != ADL_OK) { ADL_Overdrive5_PowerControl_Set(ga->iAdapterIndex, iPercentage);
ADL_Overdrive5_PowerControl_Set(ga->iAdapterIndex, ga->iPercentage);
goto out;
}
ADL_Overdrive5_PowerControl_Get(ga->iAdapterIndex, &ga->iPercentage, &dummy); ADL_Overdrive5_PowerControl_Get(ga->iAdapterIndex, &ga->iPercentage, &dummy);
if (ga->iPercentage == iPercentage)
ret = 0;
ga->managed = true; ga->managed = true;
ret = 0;
out:
unlock_adl(); unlock_adl();
return ret; return ret;
} }