ath11k: add thermal cooling device support
PATCH v2 1/2 ath11k: add thermal cooling device support
Thermal cooling device support is added to control the temperature by throttling the data transmission for the given duration. Throttling is done by suspending all data tx queues by given percentage of time. The thermal device allows user to configure duty cycle.
Throttling can be disabled by setting the duty cycle to 0. The cooling device can be found under /sys/class/thermal/cooling_deviceX/. Corresponding soft link to this device can be found under phy folder.
/sys/class/ieee80211/phy*/device/cooling_device.
To set duty cycle as 40%,
echo 40 >/sys/class/ieee80211/phy*/device/cooling_device/cur_state
---
v2:
- fix warnings and rebase
drivers/net/wireless/ath/ath11k/Makefile | 1 + drivers/net/wireless/ath/ath11k/core.c | 12 ++- drivers/net/wireless/ath/ath11k/core.h | 2 + drivers/net/wireless/ath/ath11k/thermal.c | 145 ++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath11k/thermal.h | 40 +++++++++ drivers/net/wireless/ath/ath11k/wmi.c | 64 +++++++++++++ drivers/net/wireless/ath/ath11k/wmi.h | 40 +++++++++ 7 files changed, 303 insertions(+), 1 deletion(-) create mode 100644 drivers/net/wireless/ath/ath11k/thermal.c create mode 100644 drivers/net/wireless/ath/ath11k/thermal.h
drivers/net/wireless/ath/ath11k/Makefile +1 -0
@@ -20,6 +20,7 @@ ath11k-y += core.o \ ath11k-$(CONFIG_ATH11K_DEBUGFS) += debug_htt_stats.o debugfs_sta.o ath11k-$(CONFIG_NL80211_TESTMODE) += testmode.o ath11k-$(CONFIG_ATH11K_TRACING) += trace.o +ath11k-$(CONFIG_THERMAL) += thermal.o # for tracing framework to find trace.h CFLAGS_trace.o := -I$(src)
drivers/net/wireless/ath/ath11k/core.c +11 -1
@@ -392,11 +392,19 @@ static int ath11k_core_pdev_create(struct ath11k_base *ab) goto err_mac_unregister; } + ret =ath11k_thermal_register (ab); +if (ret) { +ath11k_err (ab,"could not register thermal device: %d\n" , + ret); + goto err_dp_pdev_free; + } +return 0 ; +err_dp_pdev_free: +ath11k_dp_pdev_free (ab); err_mac_unregister:ath11k_mac_unregister (ab); - err_pdev_debug:ath11k_debug_pdev_destroy (ab);
@@ -405,6 +413,7 @@ static int ath11k_core_pdev_create(struct ath11k_base *ab)static void ath11k_core_pdev_destroy (struct ath11k_base *ab) { +ath11k_thermal_unregister (ab);ath11k_mac_unregister (ab);ath11k_ahb_ext_irq_disable (ab);ath11k_dp_pdev_free (ab);
@@ -569,6 +578,7 @@ static int ath11k_core_reconfigure_on_crash(struct ath11k_base *ab)int ret;mutex_lock (&ab->core_lock); +ath11k_thermal_unregister (ab);ath11k_ahb_ext_irq_disable (ab);ath11k_dp_pdev_free (ab);ath11k_ahb_stop (ab);
drivers/net/wireless/ath/ath11k/core.h +2 -0
@@ -20,6 +20,7 @@#include "hw.h" #include "hal_rx.h" #include "reg.h" +#include "thermal.h" #define SM (_v, _f) (((_v) << _f##_LSB) & _f##_MASK)
@@ -526,6 +527,7 @@ struct ath11k {struct ath11k_debug debug;#endif bool dfs_block_radar_events; +struct ath11k_thermal thermal; };struct ath11k_band_cap {
drivers/net/wireless/ath/ath11k/thermal.c new file +145 -0
145 lines not on this page · raw message
drivers/net/wireless/ath/ath11k/thermal.h new file +40 -0
@@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: BSD-3-Clause-Clear */ +/* +* Copyright (c) 2020 The Linux Foundation. All rights reserved. +*/ + +#ifndef _ATH11K_THERMAL_ +#define _ATH11K_THERMAL_ + +#define ATH11K_THERMAL_TEMP_LOW_MARK -100 +#define ATH11K_THERMAL_TEMP_HIGH_MARK 150 +#define ATH11K_THERMAL_THROTTLE_MAX 100 +#define ATH11K_THERMAL_DEFAULT_DUTY_CYCLE 100 + +struct ath11k_thermal { +struct thermal_cooling_device *cdev; + +/* protected by conf_mutex */ +u32 throttle_state; +}; + +#if IS_REACHABLE (CONFIG_THERMAL ) +int ath11k_thermal_register (struct ath11k_base *sc); +void ath11k_thermal_unregister (struct ath11k_base *sc); +int ath11k_thermal_set_throttling (struct ath11k *ar,u32 throttle_state); +#else +static inline int ath11k_thermal_register (struct ath11k_base *sc) +{ +return 0 ; +} + +static inline void ath11k_thermal_unregister (struct ath11k *ar) +{ +} + +static inline int ath11k_thermal_set_throttling (struct ath11k *ar,u32 throttle_state) +{ +} + +#endif +#endif /* _ATH11K_THERMAL_ */
drivers/net/wireless/ath/ath11k/wmi.c +64 -0
70 lines not on this page · raw message
drivers/net/wireless/ath/ath11k/wmi.h +40 -0
@@ -442,6 +442,10 @@ enum wmi_tlv_cmd_id {WMI_DBGLOG_TIME_STAMP_SYNC_CMDID ,WMI_SET_MULTIPLE_MCAST_FILTER_CMDID ,WMI_READ_DATA_FROM_FLASH_CMDID , +WMI_THERM_THROT_SET_CONF_CMDID , +WMI_RUNTIME_DPD_RECAL_CMDID , +WMI_GET_TPC_POWER_CMDID , +WMI_IDLE_TRIGGER_MONITOR_CMDID ,WMI_GPIO_CONFIG_CMDID =WMI_TLV_CMD (WMI_GRP_GPIO ),WMI_GPIO_OUTPUT_CMDID , WMI_TXBF_CMDID,
@@ -3605,6 +3609,39 @@ struct wmi_init_country_cmd { } cc_info; } __packed; +#define THERMAL_LEVELS 1 +struct tt_level_config { +u32 tmplwm; +u32 tmphwm; +u32 dcoffpercent; +u32 priority; +}; + +struct thermal_mitigation_params { +u32 pdev_id; +u32 enable; +u32 dc; +u32 dc_per_event; +struct tt_level_config levelconf[THERMAL_LEVELS ]; +}; + +struct wmi_therm_throt_config_request_cmd { +u32 tlv_header; +u32 pdev_id; +u32 enable; +u32 dc; +u32 dc_per_event; +u32 therm_throt_levels; +} __packed; + +struct wmi_therm_throt_level_config_info { +u32 tlv_header; +u32 temp_lwm; +u32 temp_hwm; +u32 dc_off_percent; +u32 prio; +} __packed; +struct wmi_pdev_pktlog_filter_info {u32 tlv_header;struct wmi_mac_addr peer_macaddr;
@@ -4740,6 +4777,9 @@ int ath11k_wmi_send_bcn_offload_control_cmd(struct ath11k *ar,int ath11k_wmi_send_init_country_cmd (struct ath11k *ar,struct wmi_init_country_params init_cc_param); +int +ath11k_wmi_send_thermal_mitigation_param_cmd (struct ath11k *ar, +struct thermal_mitigation_params *param);int ath11k_wmi_pdev_pktlog_enable (struct ath11k *ar,u32 pktlog_filter);int ath11k_wmi_pdev_pktlog_disable (struct ath11k *ar);int ath11k_wmi_pdev_peer_pktlog_filter (struct ath11k *ar,u8 *addr,u8 enable);
Signature · 6 lines
1.9.1 _______________________________________________ ath11k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath11k
PATCH v2 2/2 ath11k: add thermal sensor device support
Temperature sensor generates electrical analog voltage from temperature of each chain. The analog voltage is converted to digital value through ADC. For reading temperature values fom user space, hw monitoring device is used.
Whenever the user requests for current temperature, the driver sends WMI command and wait for response. For reading temperature,
cat /sys/class/ieee80211/phy*/device/hwmon/hwmon2/temp1_input
---
v2:
- fix warnings and rebase
drivers/net/wireless/ath/ath11k/core.c | 1 + drivers/net/wireless/ath/ath11k/mac.c | 2 + drivers/net/wireless/ath/ath11k/thermal.c | 79 ++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath11k/thermal.h | 13 +++++ drivers/net/wireless/ath/ath11k/wmi.c | 80 +++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath11k/wmi.h | 13 +++++ 6 files changed, 188 insertions(+)
drivers/net/wireless/ath/ath11k/core.c +1 -0
@@ -655,6 +655,7 @@ static void ath11k_core_restart(struct work_struct *work)complete (&ar->install_key_done);complete (&ar->vdev_setup_done);complete (&ar->bss_survey_done); +complete (&ar->thermal.wmi_sync);wake_up (&ar->dp.tx_empty_waitq); idr_for_each(&ar->txmgmt_idr,
drivers/net/wireless/ath/ath11k/mac.c +2 -0
@@ -5905,6 +5905,8 @@ int ath11k_mac_allocate(struct ath11k_base *ab)init_completion (&ar->bss_survey_done);init_completion (&ar->scan.started);init_completion (&ar->scan.completed); +init_completion (&ar->thermal.wmi_sync); +INIT_DELAYED_WORK (&ar->scan.timeout, ath11k_scan_timeout_work);INIT_WORK (&ar->regd_update_work, ath11k_regd_update_work);
drivers/net/wireless/ath/ath11k/thermal.c +79 -0
103 lines not on this page · raw message
drivers/net/wireless/ath/ath11k/thermal.h +13 -0
@@ -10,18 +10,26 @@#define ATH11K_THERMAL_TEMP_HIGH_MARK 150#define ATH11K_THERMAL_THROTTLE_MAX 100#define ATH11K_THERMAL_DEFAULT_DUTY_CYCLE 100 +#define ATH11K_HWMON_NAME_LEN 15 +#define ATH11K_THERMAL_SYNC_TIMEOUT_HZ (5 * HZ)struct ath11k_thermal {struct thermal_cooling_device *cdev; +struct completion wmi_sync;/* protected by conf_mutex */ u32 throttle_state; +/* temperature value in Celcius degree +* protected by data_lock +*/ +int temperature; };#if IS_REACHABLE (CONFIG_THERMAL )int ath11k_thermal_register (struct ath11k_base *sc);void ath11k_thermal_unregister (struct ath11k_base *sc);int ath11k_thermal_set_throttling (struct ath11k *ar,u32 throttle_state); +void ath11k_thermal_event_temperature (struct ath11k *ar,int temperature);#else static inline int ath11k_thermal_register (struct ath11k_base *sc) {
@@ -36,5 +44,10 @@ static inline int ath11k_thermal_set_throttling(struct ath11k *ar, u32 throttle_ { } +static inline void ath11k_thermal_event_temperature (struct ath11k *ar, +int temperature) +{ +} +#endif #endif /* _ATH11K_THERMAL_ */
drivers/net/wireless/ath/ath11k/wmi.c +80 -0
104 lines not on this page · raw message
drivers/net/wireless/ath/ath11k/wmi.h +13 -0
@@ -3304,6 +3304,12 @@ struct wmi_request_stats_cmd {u32 pdev_id; } __packed; +struct wmi_get_pdev_temperature_cmd { +u32 tlv_header; +u32 param; +u32 pdev_id; +} __packed; +#define WMI_BEACON_TX_BUFFER_SIZE 512struct wmi_bcn_tmpl_cmd {
@@ -4132,6 +4138,12 @@ struct wmi_pdev_radar_ev {s32 sidx; } __packed; +struct wmi_pdev_temperature_event { +/* temperature value in Celcius degree */ +s32 temp; +u32 pdev_id; +} __packed; +#define WMI_RX_STATUS_OK 0x00#define WMI_RX_STATUS_ERR_CRC 0x01#define WMI_RX_STATUS_ERR_DECRYPT 0x08
@@ -4763,6 +4775,7 @@ int ath11k_wmi_pdev_bss_chan_info_request(struct ath11k *ar, enum wmi_bss_chan_info_req_type type);int ath11k_wmi_send_stats_request_cmd (struct ath11k *ar,struct stats_request_params *param); +int ath11k_wmi_send_pdev_temperature_cmd (struct ath11k *ar);int ath11k_wmi_send_peer_flush_tids_cmd (struct ath11k *ar,u8 peer_addr[ETH_ALEN ],struct peer_flush_params *param);
Signature · 1 line
1.9.1
Quoted 9 lines · Pradeep Kumar Chitrapu
Thermal cooling device support is added to control the temperature by throttling the data transmission for the given duration. Throttling is done by suspending all data tx queues by given percentage of time. The thermal device allows user to configure duty cycle.
Throttling can be disabled by setting the duty cycle to 0. The cooling device can be found under
/sys/class/thermal/cooling_deviceX/. Corresponding soft link to this device can be found under phy folder.
Quoted 8 lines
/sys/class/ieee80211/phy*/device/cooling_device.To set duty cycle as 40%,
echo 40 >/sys/class/ieee80211/phy*/device/cooling_device/cur_state
Signed-off-by Pradeep Kumar Chitrapu <[email protected]>Signed-off-by Kalle Valo <[email protected]>
2 patches applied to ath-next branch of ath.git, thanks.
2a63bbca06b2 ath11k: add thermal cooling device support a41d10348b01 ath11k: add thermal sensor device support
Signature · 8 lines
https://patchwork.kernel.org/patch/11383647/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches _______________________________________________ ath11k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath11k
Quoted 9 lines · Pradeep Kumar Chitrapu
Thermal cooling device support is added to control the temperature by throttling the data transmission for the given duration. Throttling is done by suspending all data tx queues by given percentage of time. The thermal device allows user to configure duty cycle.
Throttling can be disabled by setting the duty cycle to 0. The cooling device can be found under
/sys/class/thermal/cooling_deviceX/. Corresponding soft link to this device can be found under phy folder.
Quoted 8 lines
/sys/class/ieee80211/phy*/device/cooling_device.To set duty cycle as 40%,
echo 40 >/sys/class/ieee80211/phy*/device/cooling_device/cur_state
Signed-off-by Pradeep Kumar Chitrapu <[email protected]>Signed-off-by Kalle Valo <[email protected]>
2 patches applied to ath-next branch of ath.git, thanks.
2a63bbca06b2 ath11k: add thermal cooling device support a41d10348b01 ath11k: add thermal sensor device support
Signature · 3 lines
https://patchwork.kernel.org/patch/11383647/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches