Commit 972f0513 authored by Rajkumar Manoharan's avatar Rajkumar Manoharan Committed by Kalle Valo

ath10k: fix interpretation of cooling device state

Setting the sysfs attribute ends up configuring the duty cycle,
but the interface through which the attribute is exposed
(cooling_device) is for setting the throttle/cooling state. This
is confusing the user. Hence renaming the cooling device interfaces
for better readability.

Cc: Matthias Kaehlcke <mka@google.com>
Signed-off-by: default avatarRajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: default avatarKalle Valo <kvalo@qca.qualcomm.com>
parent 63fb32df
...@@ -46,28 +46,31 @@ static int ath10k_thermal_get_active_vifs(struct ath10k *ar, ...@@ -46,28 +46,31 @@ static int ath10k_thermal_get_active_vifs(struct ath10k *ar,
return count; return count;
} }
static int ath10k_thermal_get_max_dutycycle(struct thermal_cooling_device *cdev, static int
unsigned long *state) ath10k_thermal_get_max_throttle_state(struct thermal_cooling_device *cdev,
unsigned long *state)
{ {
*state = ATH10K_QUIET_DUTY_CYCLE_MAX; *state = ATH10K_THERMAL_THROTTLE_MAX;
return 0; return 0;
} }
static int ath10k_thermal_get_cur_dutycycle(struct thermal_cooling_device *cdev, static int
unsigned long *state) ath10k_thermal_get_cur_throttle_state(struct thermal_cooling_device *cdev,
unsigned long *state)
{ {
struct ath10k *ar = cdev->devdata; struct ath10k *ar = cdev->devdata;
mutex_lock(&ar->conf_mutex); mutex_lock(&ar->conf_mutex);
*state = ar->thermal.duty_cycle; *state = ar->thermal.throttle_state;
mutex_unlock(&ar->conf_mutex); mutex_unlock(&ar->conf_mutex);
return 0; return 0;
} }
static int ath10k_thermal_set_cur_dutycycle(struct thermal_cooling_device *cdev, static int
unsigned long duty_cycle) ath10k_thermal_set_cur_throttle_state(struct thermal_cooling_device *cdev,
unsigned long throttle_state)
{ {
struct ath10k *ar = cdev->devdata; struct ath10k *ar = cdev->devdata;
u32 period, duration, enabled; u32 period, duration, enabled;
...@@ -79,9 +82,9 @@ static int ath10k_thermal_set_cur_dutycycle(struct thermal_cooling_device *cdev, ...@@ -79,9 +82,9 @@ static int ath10k_thermal_set_cur_dutycycle(struct thermal_cooling_device *cdev,
goto out; goto out;
} }
if (duty_cycle > ATH10K_QUIET_DUTY_CYCLE_MAX) { if (throttle_state > ATH10K_THERMAL_THROTTLE_MAX) {
ath10k_warn(ar, "duty cycle %ld is exceeding the limit %d\n", ath10k_warn(ar, "throttle state %ld is exceeding the limit %d\n",
duty_cycle, ATH10K_QUIET_DUTY_CYCLE_MAX); throttle_state, ATH10K_THERMAL_THROTTLE_MAX);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
...@@ -97,7 +100,7 @@ static int ath10k_thermal_set_cur_dutycycle(struct thermal_cooling_device *cdev, ...@@ -97,7 +100,7 @@ static int ath10k_thermal_set_cur_dutycycle(struct thermal_cooling_device *cdev,
goto out; goto out;
} }
period = ar->thermal.quiet_period; period = ar->thermal.quiet_period;
duration = (period * duty_cycle) / 100; duration = (period * throttle_state) / 100;
enabled = duration ? 1 : 0; enabled = duration ? 1 : 0;
ret = ath10k_wmi_pdev_set_quiet_mode(ar, period, duration, ret = ath10k_wmi_pdev_set_quiet_mode(ar, period, duration,
...@@ -108,16 +111,16 @@ static int ath10k_thermal_set_cur_dutycycle(struct thermal_cooling_device *cdev, ...@@ -108,16 +111,16 @@ static int ath10k_thermal_set_cur_dutycycle(struct thermal_cooling_device *cdev,
period, duration, enabled, ret); period, duration, enabled, ret);
goto out; goto out;
} }
ar->thermal.duty_cycle = duty_cycle; ar->thermal.throttle_state = throttle_state;
out: out:
mutex_unlock(&ar->conf_mutex); mutex_unlock(&ar->conf_mutex);
return ret; return ret;
} }
static struct thermal_cooling_device_ops ath10k_thermal_ops = { static struct thermal_cooling_device_ops ath10k_thermal_ops = {
.get_max_state = ath10k_thermal_get_max_dutycycle, .get_max_state = ath10k_thermal_get_max_throttle_state,
.get_cur_state = ath10k_thermal_get_cur_dutycycle, .get_cur_state = ath10k_thermal_get_cur_throttle_state,
.set_cur_state = ath10k_thermal_set_cur_dutycycle, .set_cur_state = ath10k_thermal_set_cur_throttle_state,
}; };
static ssize_t ath10k_thermal_show_temp(struct device *dev, static ssize_t ath10k_thermal_show_temp(struct device *dev,
......
...@@ -19,16 +19,16 @@ ...@@ -19,16 +19,16 @@
#define ATH10K_QUIET_PERIOD_DEFAULT 100 #define ATH10K_QUIET_PERIOD_DEFAULT 100
#define ATH10K_QUIET_PERIOD_MIN 25 #define ATH10K_QUIET_PERIOD_MIN 25
#define ATH10K_QUIET_START_OFFSET 10 #define ATH10K_QUIET_START_OFFSET 10
#define ATH10K_QUIET_DUTY_CYCLE_MAX 100
#define ATH10K_HWMON_NAME_LEN 15 #define ATH10K_HWMON_NAME_LEN 15
#define ATH10K_THERMAL_SYNC_TIMEOUT_HZ (5*HZ) #define ATH10K_THERMAL_SYNC_TIMEOUT_HZ (5*HZ)
#define ATH10K_THERMAL_THROTTLE_MAX 100
struct ath10k_thermal { struct ath10k_thermal {
struct thermal_cooling_device *cdev; struct thermal_cooling_device *cdev;
struct completion wmi_sync; struct completion wmi_sync;
/* protected by conf_mutex */ /* protected by conf_mutex */
u32 duty_cycle; u32 throttle_state;
u32 quiet_period; u32 quiet_period;
/* temperature value in Celcius degree /* temperature value in Celcius degree
* protected by data_lock * protected by data_lock
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment