linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] ath10k: thermal mitigation fixes
@ 2015-03-15 15:06 Rajkumar Manoharan
  2015-03-15 15:06 ` [PATCH 1/6] ath10k: add debugfs entry to configure quiet period Rajkumar Manoharan
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Rajkumar Manoharan @ 2015-03-15 15:06 UTC (permalink / raw)
  To: ath10k; +Cc: linux-wireless, Rajkumar Manoharan

Here are few enhancements in thermal throttling that allows
user to control throttling state and quiet period. Also enables
throttling for station mode. These patches are rebased on latest TOT.

Rajkumar Manoharan (6):
  ath10k: add debugfs entry to configure quiet period
  ath10k: Fix interpretation of cooling device state
  ath10k: configure thermal throttle while powering up
  ath10k: do not restrict thermal throttling to ap mode
  ath10k: cache throttle state when device is down
  ath10k: move driver state check before setting throttle

 drivers/net/wireless/ath/ath10k/debug.c   |  47 ++++++++++++
 drivers/net/wireless/ath/ath10k/mac.c     |   1 +
 drivers/net/wireless/ath/ath10k/thermal.c | 120 ++++++++++++------------------
 drivers/net/wireless/ath/ath10k/thermal.h |  10 ++-
 4 files changed, 102 insertions(+), 76 deletions(-)

-- 
2.3.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/6] ath10k: add debugfs entry to configure quiet period
  2015-03-15 15:06 [PATCH 0/6] ath10k: thermal mitigation fixes Rajkumar Manoharan
@ 2015-03-15 15:06 ` Rajkumar Manoharan
  2015-03-15 15:06 ` [PATCH 2/6] ath10k: Fix interpretation of cooling device state Rajkumar Manoharan
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Rajkumar Manoharan @ 2015-03-15 15:06 UTC (permalink / raw)
  To: ath10k; +Cc: linux-wireless, Rajkumar Manoharan

Add support to configure quiet period (in milliseconds) via debugfs.
This is useful to experiment different quiet period values along with
different throttle ratio.

echo 100 > /sys/kernel/debug/ieee80211/phyX/ath10k/quiet_period

Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
---
 drivers/net/wireless/ath/ath10k/debug.c   | 46 +++++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/thermal.c |  4 +--
 drivers/net/wireless/ath/ath10k/thermal.h |  1 +
 3 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index 301081d..812365c 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -1991,6 +1991,49 @@ static const struct file_operations fops_pktlog_filter = {
 	.open = simple_open
 };
 
+static ssize_t ath10k_write_quiet_period(struct file *file,
+					 const char __user *ubuf,
+					 size_t count, loff_t *ppos)
+{
+	struct ath10k *ar = file->private_data;
+	u32 period;
+
+	if (kstrtouint_from_user(ubuf, count, 0, &period))
+		return -EINVAL;
+
+	if (period < ATH10K_QUIET_PERIOD_MIN) {
+		ath10k_warn(ar, "Quiet period %u can not be lesser than 25ms\n",
+			    period);
+		return -EINVAL;
+	}
+	mutex_lock(&ar->conf_mutex);
+	ar->thermal.quiet_period = period;
+	mutex_unlock(&ar->conf_mutex);
+
+	return count;
+}
+
+static ssize_t ath10k_read_quiet_period(struct file *file, char __user *ubuf,
+					size_t count, loff_t *ppos)
+{
+	char buf[32];
+	struct ath10k *ar = file->private_data;
+	int len = 0;
+
+	mutex_lock(&ar->conf_mutex);
+	len = scnprintf(buf, sizeof(buf) - len, "%d\n",
+			ar->thermal.quiet_period);
+	mutex_unlock(&ar->conf_mutex);
+
+	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+}
+
+static const struct file_operations fops_quiet_period = {
+	.read = ath10k_read_quiet_period,
+	.write = ath10k_write_quiet_period,
+	.open = simple_open
+};
+
 int ath10k_debug_create(struct ath10k *ar)
 {
 	ar->debug.fw_crash_data = vzalloc(sizeof(*ar->debug.fw_crash_data));
@@ -2088,6 +2131,9 @@ int ath10k_debug_register(struct ath10k *ar)
 	debugfs_create_file("pktlog_filter", S_IRUGO | S_IWUSR,
 			    ar->debug.debugfs_phy, ar, &fops_pktlog_filter);
 
+	debugfs_create_file("quiet_period", S_IRUGO | S_IWUSR,
+			    ar->debug.debugfs_phy, ar, &fops_quiet_period);
+
 	return 0;
 }
 
diff --git a/drivers/net/wireless/ath/ath10k/thermal.c b/drivers/net/wireless/ath/ath10k/thermal.c
index 747fea7..d3fd2ab 100644
--- a/drivers/net/wireless/ath/ath10k/thermal.c
+++ b/drivers/net/wireless/ath/ath10k/thermal.c
@@ -96,8 +96,7 @@ static int ath10k_thermal_set_cur_dutycycle(struct thermal_cooling_device *cdev,
 		ret = -ENETDOWN;
 		goto out;
 	}
-	period = max(ATH10K_QUIET_PERIOD_MIN,
-		     (ATH10K_QUIET_PERIOD_DEFAULT / num_bss));
+	period = ar->thermal.quiet_period;
 	duration = (period * duty_cycle) / 100;
 	enabled = duration ? 1 : 0;
 
@@ -207,6 +206,7 @@ int ath10k_thermal_register(struct ath10k *ar)
 	}
 
 	ar->thermal.cdev = cdev;
+	ar->thermal.quiet_period = ATH10K_QUIET_PERIOD_DEFAULT;
 
 	/* Do not register hwmon device when temperature reading is not
 	 * supported by firmware
diff --git a/drivers/net/wireless/ath/ath10k/thermal.h b/drivers/net/wireless/ath/ath10k/thermal.h
index 5e87d9a..050f41d 100644
--- a/drivers/net/wireless/ath/ath10k/thermal.h
+++ b/drivers/net/wireless/ath/ath10k/thermal.h
@@ -29,6 +29,7 @@ struct ath10k_thermal {
 
 	/* protected by conf_mutex */
 	u32 duty_cycle;
+	u32 quiet_period;
 	/* temperature value in Celcius degree
 	 * protected by data_lock
 	 */
-- 
2.3.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/6] ath10k: Fix interpretation of cooling device state
  2015-03-15 15:06 [PATCH 0/6] ath10k: thermal mitigation fixes Rajkumar Manoharan
  2015-03-15 15:06 ` [PATCH 1/6] ath10k: add debugfs entry to configure quiet period Rajkumar Manoharan
@ 2015-03-15 15:06 ` Rajkumar Manoharan
  2015-03-15 15:06 ` [PATCH 3/6] ath10k: configure thermal throttle while powering up Rajkumar Manoharan
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Rajkumar Manoharan @ 2015-03-15 15:06 UTC (permalink / raw)
  To: ath10k; +Cc: linux-wireless, Rajkumar Manoharan, Matthias Kaehlcke

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: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
---
 drivers/net/wireless/ath/ath10k/thermal.c | 35 +++++++++++++++++--------------
 drivers/net/wireless/ath/ath10k/thermal.h |  4 ++--
 2 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/thermal.c b/drivers/net/wireless/ath/ath10k/thermal.c
index d3fd2ab..dc0ebf3 100644
--- a/drivers/net/wireless/ath/ath10k/thermal.c
+++ b/drivers/net/wireless/ath/ath10k/thermal.c
@@ -46,28 +46,31 @@ static int ath10k_thermal_get_active_vifs(struct ath10k *ar,
 	return count;
 }
 
-static int ath10k_thermal_get_max_dutycycle(struct thermal_cooling_device *cdev,
-					    unsigned long *state)
+static int
+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;
 }
 
-static int ath10k_thermal_get_cur_dutycycle(struct thermal_cooling_device *cdev,
-					    unsigned long *state)
+static int
+ath10k_thermal_get_cur_throttle_state(struct thermal_cooling_device *cdev,
+				      unsigned long *state)
 {
 	struct ath10k *ar = cdev->devdata;
 
 	mutex_lock(&ar->conf_mutex);
-	*state = ar->thermal.duty_cycle;
+	*state = ar->thermal.throttle_state;
 	mutex_unlock(&ar->conf_mutex);
 
 	return 0;
 }
 
-static int ath10k_thermal_set_cur_dutycycle(struct thermal_cooling_device *cdev,
-					    unsigned long duty_cycle)
+static int
+ath10k_thermal_set_cur_throttle_state(struct thermal_cooling_device *cdev,
+				      unsigned long throttle_state)
 {
 	struct ath10k *ar = cdev->devdata;
 	u32 period, duration, enabled;
@@ -79,9 +82,9 @@ static int ath10k_thermal_set_cur_dutycycle(struct thermal_cooling_device *cdev,
 		goto out;
 	}
 
-	if (duty_cycle > ATH10K_QUIET_DUTY_CYCLE_MAX) {
-		ath10k_warn(ar, "duty cycle %ld is exceeding the limit %d\n",
-			    duty_cycle, ATH10K_QUIET_DUTY_CYCLE_MAX);
+	if (throttle_state > ATH10K_THERMAL_THROTTLE_MAX) {
+		ath10k_warn(ar, "throttle state %ld is exceeding the limit %d\n",
+			    throttle_state, ATH10K_THERMAL_THROTTLE_MAX);
 		ret = -EINVAL;
 		goto out;
 	}
@@ -97,7 +100,7 @@ static int ath10k_thermal_set_cur_dutycycle(struct thermal_cooling_device *cdev,
 		goto out;
 	}
 	period = ar->thermal.quiet_period;
-	duration = (period * duty_cycle) / 100;
+	duration = (period * throttle_state) / 100;
 	enabled = duration ? 1 : 0;
 
 	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,
 			    period, duration, enabled, ret);
 		goto out;
 	}
-	ar->thermal.duty_cycle = duty_cycle;
+	ar->thermal.throttle_state = throttle_state;
 out:
 	mutex_unlock(&ar->conf_mutex);
 	return ret;
 }
 
 static struct thermal_cooling_device_ops ath10k_thermal_ops = {
-	.get_max_state = ath10k_thermal_get_max_dutycycle,
-	.get_cur_state = ath10k_thermal_get_cur_dutycycle,
-	.set_cur_state = ath10k_thermal_set_cur_dutycycle,
+	.get_max_state = ath10k_thermal_get_max_throttle_state,
+	.get_cur_state = ath10k_thermal_get_cur_throttle_state,
+	.set_cur_state = ath10k_thermal_set_cur_throttle_state,
 };
 
 static ssize_t ath10k_thermal_show_temp(struct device *dev,
diff --git a/drivers/net/wireless/ath/ath10k/thermal.h b/drivers/net/wireless/ath/ath10k/thermal.h
index 050f41d..5728010 100644
--- a/drivers/net/wireless/ath/ath10k/thermal.h
+++ b/drivers/net/wireless/ath/ath10k/thermal.h
@@ -19,16 +19,16 @@
 #define ATH10K_QUIET_PERIOD_DEFAULT     100
 #define ATH10K_QUIET_PERIOD_MIN         25
 #define ATH10K_QUIET_START_OFFSET       10
-#define ATH10K_QUIET_DUTY_CYCLE_MAX     100
 #define ATH10K_HWMON_NAME_LEN           15
 #define ATH10K_THERMAL_SYNC_TIMEOUT_HZ (5*HZ)
+#define ATH10K_THERMAL_THROTTLE_MAX     100
 
 struct ath10k_thermal {
 	struct thermal_cooling_device *cdev;
 	struct completion wmi_sync;
 
 	/* protected by conf_mutex */
-	u32 duty_cycle;
+	u32 throttle_state;
 	u32 quiet_period;
 	/* temperature value in Celcius degree
 	 * protected by data_lock
-- 
2.3.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/6] ath10k: configure thermal throttle while powering up
  2015-03-15 15:06 [PATCH 0/6] ath10k: thermal mitigation fixes Rajkumar Manoharan
  2015-03-15 15:06 ` [PATCH 1/6] ath10k: add debugfs entry to configure quiet period Rajkumar Manoharan
  2015-03-15 15:06 ` [PATCH 2/6] ath10k: Fix interpretation of cooling device state Rajkumar Manoharan
@ 2015-03-15 15:06 ` Rajkumar Manoharan
  2015-03-15 15:06 ` [PATCH 4/6] ath10k: do not restrict thermal throttling to ap mode Rajkumar Manoharan
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Rajkumar Manoharan @ 2015-03-15 15:06 UTC (permalink / raw)
  To: ath10k; +Cc: linux-wireless, Rajkumar Manoharan

Thermal throttling is not handled in software restart and device
bootup. Also it needs to be configured whenever quiet period got
updated. Fix that.

Reported-by: Matthias Kaehlcke <mka@google.com>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
---
 drivers/net/wireless/ath/ath10k/debug.c   |  1 +
 drivers/net/wireless/ath/ath10k/mac.c     |  1 +
 drivers/net/wireless/ath/ath10k/thermal.c | 34 +++++++++++++++++++------------
 drivers/net/wireless/ath/ath10k/thermal.h |  5 +++++
 4 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index 812365c..d684edf 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -2008,6 +2008,7 @@ static ssize_t ath10k_write_quiet_period(struct file *file,
 	}
 	mutex_lock(&ar->conf_mutex);
 	ar->thermal.quiet_period = period;
+	ath10k_thermal_set_throttling(ar);
 	mutex_unlock(&ar->conf_mutex);
 
 	return count;
diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index a2302bf..5cb0cb6 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -3159,6 +3159,7 @@ static int ath10k_start(struct ieee80211_hw *hw)
 	ath10k_regd_update(ar);
 
 	ath10k_spectral_start(ar);
+	ath10k_thermal_set_throttling(ar);
 
 	mutex_unlock(&ar->conf_mutex);
 	return 0;
diff --git a/drivers/net/wireless/ath/ath10k/thermal.c b/drivers/net/wireless/ath/ath10k/thermal.c
index dc0ebf3..8640f41 100644
--- a/drivers/net/wireless/ath/ath10k/thermal.c
+++ b/drivers/net/wireless/ath/ath10k/thermal.c
@@ -73,7 +73,6 @@ ath10k_thermal_set_cur_throttle_state(struct thermal_cooling_device *cdev,
 				      unsigned long throttle_state)
 {
 	struct ath10k *ar = cdev->devdata;
-	u32 period, duration, enabled;
 	int num_bss, ret = 0;
 
 	mutex_lock(&ar->conf_mutex);
@@ -99,19 +98,8 @@ ath10k_thermal_set_cur_throttle_state(struct thermal_cooling_device *cdev,
 		ret = -ENETDOWN;
 		goto out;
 	}
-	period = ar->thermal.quiet_period;
-	duration = (period * throttle_state) / 100;
-	enabled = duration ? 1 : 0;
-
-	ret = ath10k_wmi_pdev_set_quiet_mode(ar, period, duration,
-					     ATH10K_QUIET_START_OFFSET,
-					     enabled);
-	if (ret) {
-		ath10k_warn(ar, "failed to set quiet mode period %u duarion %u enabled %u ret %d\n",
-			    period, duration, enabled, ret);
-		goto out;
-	}
 	ar->thermal.throttle_state = throttle_state;
+	ath10k_thermal_set_throttling(ar);
 out:
 	mutex_unlock(&ar->conf_mutex);
 	return ret;
@@ -186,6 +174,26 @@ static struct attribute *ath10k_hwmon_attrs[] = {
 };
 ATTRIBUTE_GROUPS(ath10k_hwmon);
 
+void ath10k_thermal_set_throttling(struct ath10k *ar)
+{
+	u32 period, duration, enabled;
+	int ret;
+
+	lockdep_assert_held(&ar->conf_mutex);
+
+	period = ar->thermal.quiet_period;
+	duration = (period * ar->thermal.throttle_state) / 100;
+	enabled = duration ? 1 : 0;
+
+	ret = ath10k_wmi_pdev_set_quiet_mode(ar, period, duration,
+					     ATH10K_QUIET_START_OFFSET,
+					     enabled);
+	if (ret) {
+		ath10k_warn(ar, "failed to set quiet mode period %u duarion %u enabled %u ret %d\n",
+			    period, duration, enabled, ret);
+	}
+}
+
 int ath10k_thermal_register(struct ath10k *ar)
 {
 	struct thermal_cooling_device *cdev;
diff --git a/drivers/net/wireless/ath/ath10k/thermal.h b/drivers/net/wireless/ath/ath10k/thermal.h
index 5728010..b610ea5 100644
--- a/drivers/net/wireless/ath/ath10k/thermal.h
+++ b/drivers/net/wireless/ath/ath10k/thermal.h
@@ -40,6 +40,7 @@ struct ath10k_thermal {
 int ath10k_thermal_register(struct ath10k *ar);
 void ath10k_thermal_unregister(struct ath10k *ar);
 void ath10k_thermal_event_temperature(struct ath10k *ar, int temperature);
+void ath10k_thermal_set_throttling(struct ath10k *ar);
 #else
 static inline int ath10k_thermal_register(struct ath10k *ar)
 {
@@ -55,5 +56,9 @@ static inline void ath10k_thermal_event_temperature(struct ath10k *ar,
 {
 }
 
+static inline void ath10k_thermal_set_throttling(struct ath10k *ar)
+{
+}
+
 #endif
 #endif /* _THERMAL_ */
-- 
2.3.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/6] ath10k: do not restrict thermal throttling to ap mode
  2015-03-15 15:06 [PATCH 0/6] ath10k: thermal mitigation fixes Rajkumar Manoharan
                   ` (2 preceding siblings ...)
  2015-03-15 15:06 ` [PATCH 3/6] ath10k: configure thermal throttle while powering up Rajkumar Manoharan
@ 2015-03-15 15:06 ` Rajkumar Manoharan
  2015-03-15 15:06 ` [PATCH 5/6] ath10k: cache throttle state when device is down Rajkumar Manoharan
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Rajkumar Manoharan @ 2015-03-15 15:06 UTC (permalink / raw)
  To: ath10k; +Cc: linux-wireless, Rajkumar Manoharan

Recently thermal mitigation is validated in station mode as well.
Hence allowing thermal throttling for all interfaces. This enables
user to validate thermal mitigation with different modes.

Reported-by: Matthias Kaehlcke <mka@google.com>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
---
 drivers/net/wireless/ath/ath10k/thermal.c | 36 +------------------------------
 1 file changed, 1 insertion(+), 35 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/thermal.c b/drivers/net/wireless/ath/ath10k/thermal.c
index 8640f41..604ea00 100644
--- a/drivers/net/wireless/ath/ath10k/thermal.c
+++ b/drivers/net/wireless/ath/ath10k/thermal.c
@@ -23,29 +23,6 @@
 #include "debug.h"
 #include "wmi-ops.h"
 
-static int ath10k_thermal_get_active_vifs(struct ath10k *ar,
-					  enum wmi_vdev_type type)
-{
-	struct ath10k_vif *arvif;
-	int count = 0;
-
-	lockdep_assert_held(&ar->conf_mutex);
-
-	list_for_each_entry(arvif, &ar->arvifs, list) {
-		if (!arvif->is_started)
-			continue;
-
-		if (!arvif->is_up)
-			continue;
-
-		if (arvif->vdev_type != type)
-			continue;
-
-		count++;
-	}
-	return count;
-}
-
 static int
 ath10k_thermal_get_max_throttle_state(struct thermal_cooling_device *cdev,
 				      unsigned long *state)
@@ -73,7 +50,7 @@ ath10k_thermal_set_cur_throttle_state(struct thermal_cooling_device *cdev,
 				      unsigned long throttle_state)
 {
 	struct ath10k *ar = cdev->devdata;
-	int num_bss, ret = 0;
+	int ret = 0;
 
 	mutex_lock(&ar->conf_mutex);
 	if (ar->state != ATH10K_STATE_ON) {
@@ -87,17 +64,6 @@ ath10k_thermal_set_cur_throttle_state(struct thermal_cooling_device *cdev,
 		ret = -EINVAL;
 		goto out;
 	}
-	/* TODO: Right now, thermal mitigation is handled only for single/multi
-	 * vif AP mode. Since quiet param is not validated in STA mode, it needs
-	 * to be investigated further to handle multi STA and multi-vif (AP+STA)
-	 * mode properly.
-	 */
-	num_bss = ath10k_thermal_get_active_vifs(ar, WMI_VDEV_TYPE_AP);
-	if (!num_bss) {
-		ath10k_warn(ar, "no active AP interfaces\n");
-		ret = -ENETDOWN;
-		goto out;
-	}
 	ar->thermal.throttle_state = throttle_state;
 	ath10k_thermal_set_throttling(ar);
 out:
-- 
2.3.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/6] ath10k: cache throttle state when device is down
  2015-03-15 15:06 [PATCH 0/6] ath10k: thermal mitigation fixes Rajkumar Manoharan
                   ` (3 preceding siblings ...)
  2015-03-15 15:06 ` [PATCH 4/6] ath10k: do not restrict thermal throttling to ap mode Rajkumar Manoharan
@ 2015-03-15 15:06 ` Rajkumar Manoharan
  2015-03-15 15:06 ` [PATCH 6/6] ath10k: move driver state check before setting throttle Rajkumar Manoharan
  2015-03-23 15:17 ` [PATCH 0/6] ath10k: thermal mitigation fixes Kalle Valo
  6 siblings, 0 replies; 8+ messages in thread
From: Rajkumar Manoharan @ 2015-03-15 15:06 UTC (permalink / raw)
  To: ath10k; +Cc: linux-wireless, Rajkumar Manoharan

Allow driver to cache the throttle state when the devie is not
yet started. Configure the cached throttle state while powering
up the device. Since thermal daemon is unaware of the up/down cycle,
it assumes that device is throttled.

Reported-by: Matthias Kaehlcke <mka@google.com>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
---
 drivers/net/wireless/ath/ath10k/thermal.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/thermal.c b/drivers/net/wireless/ath/ath10k/thermal.c
index 604ea00..0b4cd3f 100644
--- a/drivers/net/wireless/ath/ath10k/thermal.c
+++ b/drivers/net/wireless/ath/ath10k/thermal.c
@@ -52,19 +52,19 @@ ath10k_thermal_set_cur_throttle_state(struct thermal_cooling_device *cdev,
 	struct ath10k *ar = cdev->devdata;
 	int ret = 0;
 
+	if (throttle_state > ATH10K_THERMAL_THROTTLE_MAX) {
+		ath10k_warn(ar, "throttle state %ld is exceeding the limit %d\n",
+			    throttle_state, ATH10K_THERMAL_THROTTLE_MAX);
+		return -EINVAL;
+	}
 	mutex_lock(&ar->conf_mutex);
+	ar->thermal.throttle_state = throttle_state;
+
 	if (ar->state != ATH10K_STATE_ON) {
 		ret = -ENETDOWN;
 		goto out;
 	}
 
-	if (throttle_state > ATH10K_THERMAL_THROTTLE_MAX) {
-		ath10k_warn(ar, "throttle state %ld is exceeding the limit %d\n",
-			    throttle_state, ATH10K_THERMAL_THROTTLE_MAX);
-		ret = -EINVAL;
-		goto out;
-	}
-	ar->thermal.throttle_state = throttle_state;
 	ath10k_thermal_set_throttling(ar);
 out:
 	mutex_unlock(&ar->conf_mutex);
-- 
2.3.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 6/6] ath10k: move driver state check before setting throttle
  2015-03-15 15:06 [PATCH 0/6] ath10k: thermal mitigation fixes Rajkumar Manoharan
                   ` (4 preceding siblings ...)
  2015-03-15 15:06 ` [PATCH 5/6] ath10k: cache throttle state when device is down Rajkumar Manoharan
@ 2015-03-15 15:06 ` Rajkumar Manoharan
  2015-03-23 15:17 ` [PATCH 0/6] ath10k: thermal mitigation fixes Kalle Valo
  6 siblings, 0 replies; 8+ messages in thread
From: Rajkumar Manoharan @ 2015-03-15 15:06 UTC (permalink / raw)
  To: ath10k; +Cc: linux-wireless, Rajkumar Manoharan

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>
---
 drivers/net/wireless/ath/ath10k/thermal.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/thermal.c b/drivers/net/wireless/ath/ath10k/thermal.c
index 0b4cd3f..c48c71d 100644
--- a/drivers/net/wireless/ath/ath10k/thermal.c
+++ b/drivers/net/wireless/ath/ath10k/thermal.c
@@ -50,7 +50,6 @@ ath10k_thermal_set_cur_throttle_state(struct thermal_cooling_device *cdev,
 				      unsigned long throttle_state)
 {
 	struct ath10k *ar = cdev->devdata;
-	int ret = 0;
 
 	if (throttle_state > ATH10K_THERMAL_THROTTLE_MAX) {
 		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);
 	ar->thermal.throttle_state = throttle_state;
-
-	if (ar->state != ATH10K_STATE_ON) {
-		ret = -ENETDOWN;
-		goto out;
-	}
-
 	ath10k_thermal_set_throttling(ar);
-out:
 	mutex_unlock(&ar->conf_mutex);
-	return ret;
+	return 0;
 }
 
 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);
 
+	if (ar->state != ATH10K_STATE_ON)
+		return;
+
 	period = ar->thermal.quiet_period;
 	duration = (period * ar->thermal.throttle_state) / 100;
 	enabled = duration ? 1 : 0;
-- 
2.3.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/6] ath10k: thermal mitigation fixes
  2015-03-15 15:06 [PATCH 0/6] ath10k: thermal mitigation fixes Rajkumar Manoharan
                   ` (5 preceding siblings ...)
  2015-03-15 15:06 ` [PATCH 6/6] ath10k: move driver state check before setting throttle Rajkumar Manoharan
@ 2015-03-23 15:17 ` Kalle Valo
  6 siblings, 0 replies; 8+ messages in thread
From: Kalle Valo @ 2015-03-23 15:17 UTC (permalink / raw)
  To: Rajkumar Manoharan; +Cc: ath10k, linux-wireless

Rajkumar Manoharan <rmanohar@qti.qualcomm.com> writes:

> Here are few enhancements in thermal throttling that allows
> user to control throttling state and quiet period. Also enables
> throttling for station mode. These patches are rebased on latest TOT.
>
> Rajkumar Manoharan (6):
>   ath10k: add debugfs entry to configure quiet period
>   ath10k: Fix interpretation of cooling device state
>   ath10k: configure thermal throttle while powering up
>   ath10k: do not restrict thermal throttling to ap mode
>   ath10k: cache throttle state when device is down
>   ath10k: move driver state check before setting throttle

Thanks, applied.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-03-23 15:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-15 15:06 [PATCH 0/6] ath10k: thermal mitigation fixes Rajkumar Manoharan
2015-03-15 15:06 ` [PATCH 1/6] ath10k: add debugfs entry to configure quiet period Rajkumar Manoharan
2015-03-15 15:06 ` [PATCH 2/6] ath10k: Fix interpretation of cooling device state Rajkumar Manoharan
2015-03-15 15:06 ` [PATCH 3/6] ath10k: configure thermal throttle while powering up Rajkumar Manoharan
2015-03-15 15:06 ` [PATCH 4/6] ath10k: do not restrict thermal throttling to ap mode Rajkumar Manoharan
2015-03-15 15:06 ` [PATCH 5/6] ath10k: cache throttle state when device is down Rajkumar Manoharan
2015-03-15 15:06 ` [PATCH 6/6] ath10k: move driver state check before setting throttle Rajkumar Manoharan
2015-03-23 15:17 ` [PATCH 0/6] ath10k: thermal mitigation fixes Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).