ath10k: move driver state check before setting throttle

Since thermal daemon is unaware of the device state, it might
try to adjust the throttle state when the device is powered down.
So the driver caches the value and will configure it while
powering up the target. The cached value will be programed later
once the device is brought up. In such case, returning error
status is confusing and misleading the user application. Hence
moving the driver state check before sending wmi command to target.

Reported-by: Matthias Kaehlcke <mka@google.com>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
This commit is contained in:
Rajkumar Manoharan 2015-03-15 20:36:25 +05:30 committed by Kalle Valo
parent 28bf0c4e3f
commit 9936fa5908

View File

@ -50,7 +50,6 @@ ath10k_thermal_set_cur_throttle_state(struct thermal_cooling_device *cdev,
unsigned long throttle_state) unsigned long throttle_state)
{ {
struct ath10k *ar = cdev->devdata; struct ath10k *ar = cdev->devdata;
int ret = 0;
if (throttle_state > ATH10K_THERMAL_THROTTLE_MAX) { if (throttle_state > ATH10K_THERMAL_THROTTLE_MAX) {
ath10k_warn(ar, "throttle state %ld is exceeding the limit %d\n", ath10k_warn(ar, "throttle state %ld is exceeding the limit %d\n",
@ -59,16 +58,9 @@ ath10k_thermal_set_cur_throttle_state(struct thermal_cooling_device *cdev,
} }
mutex_lock(&ar->conf_mutex); mutex_lock(&ar->conf_mutex);
ar->thermal.throttle_state = throttle_state; ar->thermal.throttle_state = throttle_state;
if (ar->state != ATH10K_STATE_ON) {
ret = -ENETDOWN;
goto out;
}
ath10k_thermal_set_throttling(ar); ath10k_thermal_set_throttling(ar);
out:
mutex_unlock(&ar->conf_mutex); mutex_unlock(&ar->conf_mutex);
return ret; return 0;
} }
static struct thermal_cooling_device_ops ath10k_thermal_ops = { static struct thermal_cooling_device_ops ath10k_thermal_ops = {
@ -147,6 +139,9 @@ void ath10k_thermal_set_throttling(struct ath10k *ar)
lockdep_assert_held(&ar->conf_mutex); lockdep_assert_held(&ar->conf_mutex);
if (ar->state != ATH10K_STATE_ON)
return;
period = ar->thermal.quiet_period; period = ar->thermal.quiet_period;
duration = (period * ar->thermal.throttle_state) / 100; duration = (period * ar->thermal.throttle_state) / 100;
enabled = duration ? 1 : 0; enabled = duration ? 1 : 0;