Browse Source

adl: Properly restore default perf levels

We were copying the *pointer* to the perf levels structure rather
than the structure itself, and thus restoring the perf levels
did basically nothing.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
nfactor-troky
Benjamin Herrenschmidt 11 years ago
parent
commit
4256bd10d8
  1. 18
      adl.c

18
adl.c

@ -349,6 +349,7 @@ void init_adl(int nDevs)
int lpAdapterID; int lpAdapterID;
ADLODPerformanceLevels *lpOdPerformanceLevels; ADLODPerformanceLevels *lpOdPerformanceLevels;
int lev, adlGpu; int lev, adlGpu;
size_t plsize;
adlGpu = gpus[gpu].virtual_adl; adlGpu = gpus[gpu].virtual_adl;
i = vadapters[adlGpu].id; i = vadapters[adlGpu].id;
@ -396,8 +397,9 @@ void init_adl(int nDevs)
lev = ga->lpOdParameters.iNumberOfPerformanceLevels - 1; lev = ga->lpOdParameters.iNumberOfPerformanceLevels - 1;
/* We're only interested in the top performance level */ /* We're only interested in the top performance level */
lpOdPerformanceLevels = malloc(sizeof(ADLODPerformanceLevels) + (lev * sizeof(ADLODPerformanceLevel))); plsize = sizeof(ADLODPerformanceLevels) + lev * sizeof(ADLODPerformanceLevel);
lpOdPerformanceLevels->iSize = sizeof(ADLODPerformanceLevels) + sizeof(ADLODPerformanceLevel) * lev; lpOdPerformanceLevels = malloc(plsize);
lpOdPerformanceLevels->iSize = plsize;
/* Get default performance levels first */ /* Get default performance levels first */
if (ADL_Overdrive5_ODPerformanceLevels_Get(iAdapterIndex, 1, lpOdPerformanceLevels) != ADL_OK) if (ADL_Overdrive5_ODPerformanceLevels_Get(iAdapterIndex, 1, lpOdPerformanceLevels) != ADL_OK)
@ -410,10 +412,15 @@ void init_adl(int nDevs)
ga->lpFanSpeedValue.iSize = ga->DefFanSpeedValue.iSize = sizeof(ADLFanSpeedValue); ga->lpFanSpeedValue.iSize = ga->DefFanSpeedValue.iSize = sizeof(ADLFanSpeedValue);
ga->lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT; ga->lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
ga->DefFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT; ga->DefFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
/* Now get the current performance levels for any existing overclock */ /* Now get the current performance levels for any existing overclock */
ADL_Overdrive5_ODPerformanceLevels_Get(iAdapterIndex, 0, lpOdPerformanceLevels); if (ADL_Overdrive5_ODPerformanceLevels_Get(iAdapterIndex, 0, lpOdPerformanceLevels) != ADL_OK)
applog(LOG_INFO, "Failed to ADL_Overdrive5_ODPerformanceLevels_Get");
else {
/* Save these values as the defaults in case we wish to reset to defaults */ /* Save these values as the defaults in case we wish to reset to defaults */
ga->DefPerfLev = lpOdPerformanceLevels; ga->DefPerfLev = malloc(plsize);
memcpy(ga->DefPerfLev, lpOdPerformanceLevels, plsize);
}
if (gpus[gpu].gpu_engine) { if (gpus[gpu].gpu_engine) {
int setengine = gpus[gpu].gpu_engine * 100; int setengine = gpus[gpu].gpu_engine * 100;
@ -1248,6 +1255,7 @@ void set_defaultengine(int gpu)
ga = &gpus[gpu].adl; ga = &gpus[gpu].adl;
lock_adl(); lock_adl();
if (ga->DefPerfLev)
ADL_Overdrive5_ODPerformanceLevels_Set(ga->iAdapterIndex, ga->DefPerfLev); ADL_Overdrive5_ODPerformanceLevels_Set(ga->iAdapterIndex, ga->DefPerfLev);
unlock_adl(); unlock_adl();
} }
@ -1435,7 +1443,7 @@ void clear_adl(int nDevs)
for (i = 0; i < nDevs; i++) { for (i = 0; i < nDevs; i++) {
ga = &gpus[i].adl; ga = &gpus[i].adl;
/* Only reset the values if we've changed them at any time */ /* Only reset the values if we've changed them at any time */
if (!gpus[i].has_adl || !ga->managed) if (!gpus[i].has_adl || !ga->managed || !ga->DefPerfLev)
continue; continue;
ADL_Overdrive5_ODPerformanceLevels_Set(ga->iAdapterIndex, ga->DefPerfLev); ADL_Overdrive5_ODPerformanceLevels_Set(ga->iAdapterIndex, ga->DefPerfLev);
free(ga->DefPerfLev); free(ga->DefPerfLev);

Loading…
Cancel
Save