Skip to content

Commit

Permalink
Bugfix: opencl/adl: Set iSpeedType for get-fanspeed requests, and ens…
Browse files Browse the repository at this point in the history
…ure we don't change do something weird with the fan when initially setting user-defined speed flag.

Fixes crash on R9 cards. Thanks to tkg for hints on what was wrong!
RPM preferred over percent since writing RPM back is always supported (while percent is not in some cases).
  • Loading branch information
luke-jr committed Jan 14, 2014
1 parent 84c0c3a commit b888ed9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions adl.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ void init_adl(int nDevs)
ga->has_fanspeed = true;

/* Save the fanspeed values as defaults in case we reset later */
ga->DefFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_RPM;
ADL_Overdrive5_FanSpeed_Get(ga->iAdapterIndex, 0, &ga->DefFanSpeedValue);
if (gpus[gpu].gpu_fan)
set_fanspeed(gpu, gpus[gpu].gpu_fan);
Expand Down Expand Up @@ -998,20 +999,21 @@ int set_fanspeed(int gpu, int iFanSpeed)
ga->targetfan = iFanSpeed;

lock_adl();
ga->lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_RPM;
if (ADL_Overdrive5_FanSpeed_Get(ga->iAdapterIndex, 0, &ga->lpFanSpeedValue) != ADL_OK) {
applog(LOG_DEBUG, "GPU %d call to fanspeed get failed", gpu);
}
if (!(ga->lpFanSpeedValue.iFlags & ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED)) {
/* If user defined is not already specified, set it first */
ga->lpFanSpeedValue.iFlags |= ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
ADL_Overdrive5_FanSpeed_Set(ga->iAdapterIndex, 0, &ga->lpFanSpeedValue);
}
if (!(ga->lpFanSpeedInfo.iFlags & ADL_DL_FANCTRL_SUPPORTS_PERCENT_WRITE)) {
/* Must convert speed to an RPM */
iFanSpeed = ga->lpFanSpeedInfo.iMaxRPM * iFanSpeed / 100;
ga->lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_RPM;
} else
ga->lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
if (!(ga->lpFanSpeedValue.iFlags & ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED)) {
/* If user defined is not already specified, set it first */
ga->lpFanSpeedValue.iFlags = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
ADL_Overdrive5_FanSpeed_Set(ga->iAdapterIndex, 0, &ga->lpFanSpeedValue);
}
ga->lpFanSpeedValue.iFanSpeed = iFanSpeed;
ret = ADL_Overdrive5_FanSpeed_Set(ga->iAdapterIndex, 0, &ga->lpFanSpeedValue);
ga->managed = true;
Expand Down

1 comment on commit b888ed9

@nwoolls
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted to say thank you for this @luke-jr

Please sign in to comment.