Commit 3ad3b92a authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville

iwlwifi: refactor some thermal throttle code

Some of the thermal throttle data structures and code
are really very intermingled with the sleep (power)
control code. They really do belong together in a way
since the thermal throttle code uses powersaving to
achieve its goal, but it's making it hard to work on
the powersave code. Split this up to make that easier.
I've also changed the antenna defines to an enum and
used the same enum for RX and TX.
Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarReinette Chatre <reinette.chatre@intel.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 3a780d25
...@@ -1401,7 +1401,7 @@ static int rs_move_legacy_other(struct iwl_priv *priv, ...@@ -1401,7 +1401,7 @@ static int rs_move_legacy_other(struct iwl_priv *priv,
if (!iwl_ht_enabled(priv)) if (!iwl_ht_enabled(priv))
/* stay in Legacy */ /* stay in Legacy */
tbl->action = IWL_LEGACY_SWITCH_ANTENNA1; tbl->action = IWL_LEGACY_SWITCH_ANTENNA1;
else if (iwl_tx_ant_restriction(priv) == IWL_TX_SINGLE && else if (iwl_tx_ant_restriction(priv) == IWL_ANT_OK_SINGLE &&
tbl->action > IWL_LEGACY_SWITCH_SISO) tbl->action > IWL_LEGACY_SWITCH_SISO)
tbl->action = IWL_LEGACY_SWITCH_SISO; tbl->action = IWL_LEGACY_SWITCH_SISO;
for (; ;) { for (; ;) {
...@@ -1535,7 +1535,7 @@ static int rs_move_siso_to_other(struct iwl_priv *priv, ...@@ -1535,7 +1535,7 @@ static int rs_move_siso_to_other(struct iwl_priv *priv,
u8 update_search_tbl_counter = 0; u8 update_search_tbl_counter = 0;
int ret; int ret;
if (iwl_tx_ant_restriction(priv) == IWL_TX_SINGLE && if (iwl_tx_ant_restriction(priv) == IWL_ANT_OK_SINGLE &&
tbl->action > IWL_SISO_SWITCH_ANTENNA2) { tbl->action > IWL_SISO_SWITCH_ANTENNA2) {
/* stay in SISO */ /* stay in SISO */
tbl->action = IWL_SISO_SWITCH_ANTENNA1; tbl->action = IWL_SISO_SWITCH_ANTENNA1;
...@@ -1674,7 +1674,7 @@ static int rs_move_mimo2_to_other(struct iwl_priv *priv, ...@@ -1674,7 +1674,7 @@ static int rs_move_mimo2_to_other(struct iwl_priv *priv,
u8 update_search_tbl_counter = 0; u8 update_search_tbl_counter = 0;
int ret; int ret;
if ((iwl_tx_ant_restriction(priv) == IWL_TX_SINGLE) && if ((iwl_tx_ant_restriction(priv) == IWL_ANT_OK_SINGLE) &&
(tbl->action < IWL_MIMO2_SWITCH_SISO_A || (tbl->action < IWL_MIMO2_SWITCH_SISO_A ||
tbl->action > IWL_MIMO2_SWITCH_SISO_C)) { tbl->action > IWL_MIMO2_SWITCH_SISO_C)) {
/* switch in SISO */ /* switch in SISO */
...@@ -1816,7 +1816,7 @@ static int rs_move_mimo3_to_other(struct iwl_priv *priv, ...@@ -1816,7 +1816,7 @@ static int rs_move_mimo3_to_other(struct iwl_priv *priv,
int ret; int ret;
u8 update_search_tbl_counter = 0; u8 update_search_tbl_counter = 0;
if ((iwl_tx_ant_restriction(priv) == IWL_TX_SINGLE) && if ((iwl_tx_ant_restriction(priv) == IWL_ANT_OK_SINGLE) &&
(tbl->action < IWL_MIMO3_SWITCH_SISO_A || (tbl->action < IWL_MIMO3_SWITCH_SISO_A ||
tbl->action > IWL_MIMO3_SWITCH_SISO_C)) { tbl->action > IWL_MIMO3_SWITCH_SISO_C)) {
/* switch in SISO */ /* switch in SISO */
...@@ -2202,7 +2202,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, ...@@ -2202,7 +2202,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
/* If we are searching for better modulation mode, check success. */ /* If we are searching for better modulation mode, check success. */
if (lq_sta->search_better_tbl && if (lq_sta->search_better_tbl &&
(iwl_tx_ant_restriction(priv) == IWL_TX_MULTI)) { (iwl_tx_ant_restriction(priv) == IWL_ANT_OK_MULTI)) {
/* If good success, continue using the "search" mode; /* If good success, continue using the "search" mode;
* no need to send new link quality command, since we're * no need to send new link quality command, since we're
* continuing to use the setup that we've been trying. */ * continuing to use the setup that we've been trying. */
...@@ -2332,7 +2332,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, ...@@ -2332,7 +2332,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
scale_action = 0; scale_action = 0;
if (!iwl_ht_enabled(priv) && !is_legacy(tbl->lq_type)) if (!iwl_ht_enabled(priv) && !is_legacy(tbl->lq_type))
scale_action = -1; scale_action = -1;
if (iwl_tx_ant_restriction(priv) != IWL_TX_MULTI && if (iwl_tx_ant_restriction(priv) != IWL_ANT_OK_MULTI &&
(is_mimo2(tbl->lq_type) || is_mimo3(tbl->lq_type))) (is_mimo2(tbl->lq_type) || is_mimo3(tbl->lq_type)))
scale_action = -1; scale_action = -1;
switch (scale_action) { switch (scale_action) {
...@@ -2368,7 +2368,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, ...@@ -2368,7 +2368,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
rate = rs_update_rate_tbl(priv, lq_sta, rate = rs_update_rate_tbl(priv, lq_sta,
tbl, index, is_green); tbl, index, is_green);
if (iwl_tx_ant_restriction(priv) == IWL_TX_MULTI) { if (iwl_tx_ant_restriction(priv) == IWL_ANT_OK_MULTI) {
/* Should we stay with this modulation mode, /* Should we stay with this modulation mode,
* or search for a new one? */ * or search for a new one? */
rs_stay_in_table(lq_sta); rs_stay_in_table(lq_sta);
......
...@@ -2214,7 +2214,7 @@ void iwl_rf_kill_ct_config(struct iwl_priv *priv) ...@@ -2214,7 +2214,7 @@ void iwl_rf_kill_ct_config(struct iwl_priv *priv)
iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR,
CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT);
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
priv->power_data.ct_kill_toggle = false; priv->thermal_throttle.ct_kill_toggle = false;
switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) { switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
case CSR_HW_REV_TYPE_1000: case CSR_HW_REV_TYPE_1000:
......
...@@ -704,7 +704,7 @@ static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file, ...@@ -704,7 +704,7 @@ static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct iwl_priv *priv = (struct iwl_priv *)file->private_data; struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
struct iwl_tt_mgmt *tt = &priv->power_data.tt; struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
struct iwl_tt_restriction *restriction; struct iwl_tt_restriction *restriction;
char buf[100]; char buf[100];
int pos = 0; int pos = 0;
...@@ -713,12 +713,11 @@ static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file, ...@@ -713,12 +713,11 @@ static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
pos += scnprintf(buf + pos, bufsz - pos, pos += scnprintf(buf + pos, bufsz - pos,
"Thermal Throttling Mode: %s\n", "Thermal Throttling Mode: %s\n",
(priv->power_data.adv_tt) tt->advanced_tt ? "Advance" : "Legacy");
? "Advance" : "Legacy");
pos += scnprintf(buf + pos, bufsz - pos, pos += scnprintf(buf + pos, bufsz - pos,
"Thermal Throttling State: %d\n", "Thermal Throttling State: %d\n",
tt->state); tt->state);
if (priv->power_data.adv_tt) { if (tt->advanced_tt) {
restriction = tt->restriction + tt->state; restriction = tt->restriction + tt->state;
pos += scnprintf(buf + pos, bufsz - pos, pos += scnprintf(buf + pos, bufsz - pos,
"Tx mode: %d\n", "Tx mode: %d\n",
......
...@@ -1111,6 +1111,7 @@ struct iwl_priv { ...@@ -1111,6 +1111,7 @@ struct iwl_priv {
struct isr_statistics isr_stats; struct isr_statistics isr_stats;
struct iwl_power_mgr power_data; struct iwl_power_mgr power_data;
struct iwl_tt_mgmt thermal_throttle;
struct iwl_notif_statistics statistics; struct iwl_notif_statistics statistics;
unsigned long last_statistics_time; unsigned long last_statistics_time;
......
...@@ -132,10 +132,10 @@ static const struct iwl_tt_trans tt_range_3[IWL_TI_STATE_MAX - 1] = { ...@@ -132,10 +132,10 @@ static const struct iwl_tt_trans tt_range_3[IWL_TI_STATE_MAX - 1] = {
/* Advance Thermal Throttling default restriction table */ /* Advance Thermal Throttling default restriction table */
static const struct iwl_tt_restriction restriction_range[IWL_TI_STATE_MAX] = { static const struct iwl_tt_restriction restriction_range[IWL_TI_STATE_MAX] = {
{IWL_TX_MULTI, true, IWL_RX_MULTI}, {IWL_ANT_OK_MULTI, IWL_ANT_OK_MULTI, true },
{IWL_TX_SINGLE, true, IWL_RX_MULTI}, {IWL_ANT_OK_SINGLE, IWL_ANT_OK_MULTI, true },
{IWL_TX_SINGLE, false, IWL_RX_SINGLE}, {IWL_ANT_OK_SINGLE, IWL_ANT_OK_SINGLE, false },
{IWL_TX_NONE, false, IWL_RX_NONE} {IWL_ANT_OK_NONE, IWL_ANT_OK_NONE, false }
}; };
/* set card power command */ /* set card power command */
...@@ -251,7 +251,7 @@ int iwl_power_update_mode(struct iwl_priv *priv, bool force) ...@@ -251,7 +251,7 @@ int iwl_power_update_mode(struct iwl_priv *priv, bool force)
{ {
struct iwl_power_mgr *setting = &(priv->power_data); struct iwl_power_mgr *setting = &(priv->power_data);
int ret = 0; int ret = 0;
struct iwl_tt_mgmt *tt = &priv->power_data.tt; struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
u16 uninitialized_var(final_mode); u16 uninitialized_var(final_mode);
bool update_chains; bool update_chains;
...@@ -317,35 +317,35 @@ EXPORT_SYMBOL(iwl_power_set_user_mode); ...@@ -317,35 +317,35 @@ EXPORT_SYMBOL(iwl_power_set_user_mode);
bool iwl_ht_enabled(struct iwl_priv *priv) bool iwl_ht_enabled(struct iwl_priv *priv)
{ {
struct iwl_tt_mgmt *tt = &priv->power_data.tt; struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
struct iwl_tt_restriction *restriction; struct iwl_tt_restriction *restriction;
if (!priv->power_data.adv_tt) if (!priv->thermal_throttle.advanced_tt)
return true; return true;
restriction = tt->restriction + tt->state; restriction = tt->restriction + tt->state;
return restriction->is_ht; return restriction->is_ht;
} }
EXPORT_SYMBOL(iwl_ht_enabled); EXPORT_SYMBOL(iwl_ht_enabled);
u8 iwl_tx_ant_restriction(struct iwl_priv *priv) enum iwl_antenna_ok iwl_tx_ant_restriction(struct iwl_priv *priv)
{ {
struct iwl_tt_mgmt *tt = &priv->power_data.tt; struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
struct iwl_tt_restriction *restriction; struct iwl_tt_restriction *restriction;
if (!priv->power_data.adv_tt) if (!priv->thermal_throttle.advanced_tt)
return IWL_TX_MULTI; return IWL_ANT_OK_MULTI;
restriction = tt->restriction + tt->state; restriction = tt->restriction + tt->state;
return restriction->tx_stream; return restriction->tx_stream;
} }
EXPORT_SYMBOL(iwl_tx_ant_restriction); EXPORT_SYMBOL(iwl_tx_ant_restriction);
u8 iwl_rx_ant_restriction(struct iwl_priv *priv) enum iwl_antenna_ok iwl_rx_ant_restriction(struct iwl_priv *priv)
{ {
struct iwl_tt_mgmt *tt = &priv->power_data.tt; struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
struct iwl_tt_restriction *restriction; struct iwl_tt_restriction *restriction;
if (!priv->power_data.adv_tt) if (!priv->thermal_throttle.advanced_tt)
return IWL_RX_MULTI; return IWL_ANT_OK_MULTI;
restriction = tt->restriction + tt->state; restriction = tt->restriction + tt->state;
return restriction->rx_stream; return restriction->rx_stream;
} }
...@@ -364,21 +364,21 @@ EXPORT_SYMBOL(iwl_rx_ant_restriction); ...@@ -364,21 +364,21 @@ EXPORT_SYMBOL(iwl_rx_ant_restriction);
static void iwl_tt_check_exit_ct_kill(unsigned long data) static void iwl_tt_check_exit_ct_kill(unsigned long data)
{ {
struct iwl_priv *priv = (struct iwl_priv *)data; struct iwl_priv *priv = (struct iwl_priv *)data;
struct iwl_tt_mgmt *tt = &priv->power_data.tt; struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
unsigned long flags; unsigned long flags;
if (test_bit(STATUS_EXIT_PENDING, &priv->status)) if (test_bit(STATUS_EXIT_PENDING, &priv->status))
return; return;
if (tt->state == IWL_TI_CT_KILL) { if (tt->state == IWL_TI_CT_KILL) {
if (priv->power_data.ct_kill_toggle) { if (priv->thermal_throttle.ct_kill_toggle) {
iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR,
CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT);
priv->power_data.ct_kill_toggle = false; priv->thermal_throttle.ct_kill_toggle = false;
} else { } else {
iwl_write32(priv, CSR_UCODE_DRV_GP1_SET, iwl_write32(priv, CSR_UCODE_DRV_GP1_SET,
CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT);
priv->power_data.ct_kill_toggle = true; priv->thermal_throttle.ct_kill_toggle = true;
} }
iwl_read32(priv, CSR_UCODE_DRV_GP1); iwl_read32(priv, CSR_UCODE_DRV_GP1);
spin_lock_irqsave(&priv->reg_lock, flags); spin_lock_irqsave(&priv->reg_lock, flags);
...@@ -389,7 +389,7 @@ static void iwl_tt_check_exit_ct_kill(unsigned long data) ...@@ -389,7 +389,7 @@ static void iwl_tt_check_exit_ct_kill(unsigned long data)
/* Reschedule the ct_kill timer to occur in /* Reschedule the ct_kill timer to occur in
* CT_KILL_EXIT_DURATION seconds to ensure we get a * CT_KILL_EXIT_DURATION seconds to ensure we get a
* thermal update */ * thermal update */
mod_timer(&priv->power_data.ct_kill_exit_tm, jiffies + mod_timer(&priv->thermal_throttle.ct_kill_exit_tm, jiffies +
CT_KILL_EXIT_DURATION * HZ); CT_KILL_EXIT_DURATION * HZ);
} }
} }
...@@ -403,7 +403,7 @@ static void iwl_perform_ct_kill_task(struct iwl_priv *priv, ...@@ -403,7 +403,7 @@ static void iwl_perform_ct_kill_task(struct iwl_priv *priv,
ieee80211_stop_queues(priv->hw); ieee80211_stop_queues(priv->hw);
IWL_DEBUG_POWER(priv, IWL_DEBUG_POWER(priv,
"Schedule 5 seconds CT_KILL Timer\n"); "Schedule 5 seconds CT_KILL Timer\n");
mod_timer(&priv->power_data.ct_kill_exit_tm, jiffies + mod_timer(&priv->thermal_throttle.ct_kill_exit_tm, jiffies +
CT_KILL_EXIT_DURATION * HZ); CT_KILL_EXIT_DURATION * HZ);
} else { } else {
IWL_DEBUG_POWER(priv, "Wake all queues\n"); IWL_DEBUG_POWER(priv, "Wake all queues\n");
...@@ -427,7 +427,7 @@ static void iwl_perform_ct_kill_task(struct iwl_priv *priv, ...@@ -427,7 +427,7 @@ static void iwl_perform_ct_kill_task(struct iwl_priv *priv,
*/ */
static void iwl_legacy_tt_handler(struct iwl_priv *priv, s32 temp) static void iwl_legacy_tt_handler(struct iwl_priv *priv, s32 temp)
{ {
struct iwl_tt_mgmt *tt = &priv->power_data.tt; struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
enum iwl_tt_state old_state; enum iwl_tt_state old_state;
struct iwl_power_mgr *setting = &priv->power_data; struct iwl_power_mgr *setting = &priv->power_data;
...@@ -531,7 +531,7 @@ static void iwl_legacy_tt_handler(struct iwl_priv *priv, s32 temp) ...@@ -531,7 +531,7 @@ static void iwl_legacy_tt_handler(struct iwl_priv *priv, s32 temp)
*/ */
static void iwl_advance_tt_handler(struct iwl_priv *priv, s32 temp) static void iwl_advance_tt_handler(struct iwl_priv *priv, s32 temp)
{ {
struct iwl_tt_mgmt *tt = &priv->power_data.tt; struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
int i; int i;
bool changed = false; bool changed = false;
enum iwl_tt_state old_state; enum iwl_tt_state old_state;
...@@ -655,7 +655,7 @@ static void iwl_advance_tt_handler(struct iwl_priv *priv, s32 temp) ...@@ -655,7 +655,7 @@ static void iwl_advance_tt_handler(struct iwl_priv *priv, s32 temp)
static void iwl_bg_ct_enter(struct work_struct *work) static void iwl_bg_ct_enter(struct work_struct *work)
{ {
struct iwl_priv *priv = container_of(work, struct iwl_priv, ct_enter); struct iwl_priv *priv = container_of(work, struct iwl_priv, ct_enter);
struct iwl_tt_mgmt *tt = &priv->power_data.tt; struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
if (test_bit(STATUS_EXIT_PENDING, &priv->status)) if (test_bit(STATUS_EXIT_PENDING, &priv->status))
return; return;
...@@ -666,7 +666,7 @@ static void iwl_bg_ct_enter(struct work_struct *work) ...@@ -666,7 +666,7 @@ static void iwl_bg_ct_enter(struct work_struct *work)
if (tt->state != IWL_TI_CT_KILL) { if (tt->state != IWL_TI_CT_KILL) {
IWL_ERR(priv, "Device reached critical temperature " IWL_ERR(priv, "Device reached critical temperature "
"- ucode going to sleep!\n"); "- ucode going to sleep!\n");
if (!priv->power_data.adv_tt) if (!priv->thermal_throttle.advanced_tt)
iwl_legacy_tt_handler(priv, iwl_legacy_tt_handler(priv,
IWL_MINIMAL_POWER_THRESHOLD); IWL_MINIMAL_POWER_THRESHOLD);
else else
...@@ -683,7 +683,7 @@ static void iwl_bg_ct_enter(struct work_struct *work) ...@@ -683,7 +683,7 @@ static void iwl_bg_ct_enter(struct work_struct *work)
static void iwl_bg_ct_exit(struct work_struct *work) static void iwl_bg_ct_exit(struct work_struct *work)
{ {
struct iwl_priv *priv = container_of(work, struct iwl_priv, ct_exit); struct iwl_priv *priv = container_of(work, struct iwl_priv, ct_exit);
struct iwl_tt_mgmt *tt = &priv->power_data.tt; struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
if (test_bit(STATUS_EXIT_PENDING, &priv->status)) if (test_bit(STATUS_EXIT_PENDING, &priv->status))
return; return;
...@@ -692,13 +692,13 @@ static void iwl_bg_ct_exit(struct work_struct *work) ...@@ -692,13 +692,13 @@ static void iwl_bg_ct_exit(struct work_struct *work)
return; return;
/* stop ct_kill_exit_tm timer */ /* stop ct_kill_exit_tm timer */
del_timer_sync(&priv->power_data.ct_kill_exit_tm); del_timer_sync(&priv->thermal_throttle.ct_kill_exit_tm);
if (tt->state == IWL_TI_CT_KILL) { if (tt->state == IWL_TI_CT_KILL) {
IWL_ERR(priv, IWL_ERR(priv,
"Device temperature below critical" "Device temperature below critical"
"- ucode awake!\n"); "- ucode awake!\n");
if (!priv->power_data.adv_tt) if (!priv->thermal_throttle.advanced_tt)
iwl_legacy_tt_handler(priv, iwl_legacy_tt_handler(priv,
IWL_REDUCED_PERFORMANCE_THRESHOLD_2); IWL_REDUCED_PERFORMANCE_THRESHOLD_2);
else else
...@@ -737,7 +737,7 @@ static void iwl_bg_tt_work(struct work_struct *work) ...@@ -737,7 +737,7 @@ static void iwl_bg_tt_work(struct work_struct *work)
if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965)
temp = KELVIN_TO_CELSIUS(priv->temperature); temp = KELVIN_TO_CELSIUS(priv->temperature);
if (!priv->power_data.adv_tt) if (!priv->thermal_throttle.advanced_tt)
iwl_legacy_tt_handler(priv, temp); iwl_legacy_tt_handler(priv, temp);
else else
iwl_advance_tt_handler(priv, temp); iwl_advance_tt_handler(priv, temp);
...@@ -760,7 +760,7 @@ EXPORT_SYMBOL(iwl_tt_handler); ...@@ -760,7 +760,7 @@ EXPORT_SYMBOL(iwl_tt_handler);
*/ */
void iwl_tt_initialize(struct iwl_priv *priv) void iwl_tt_initialize(struct iwl_priv *priv)
{ {
struct iwl_tt_mgmt *tt = &priv->power_data.tt; struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
struct iwl_power_mgr *setting = &priv->power_data; struct iwl_power_mgr *setting = &priv->power_data;
int size = sizeof(struct iwl_tt_trans) * (IWL_TI_STATE_MAX - 1); int size = sizeof(struct iwl_tt_trans) * (IWL_TI_STATE_MAX - 1);
struct iwl_tt_trans *transaction; struct iwl_tt_trans *transaction;
...@@ -772,9 +772,9 @@ void iwl_tt_initialize(struct iwl_priv *priv) ...@@ -772,9 +772,9 @@ void iwl_tt_initialize(struct iwl_priv *priv)
tt->state = IWL_TI_0; tt->state = IWL_TI_0;
tt->sys_power_mode = setting->power_mode; tt->sys_power_mode = setting->power_mode;
tt->tt_power_mode = tt->sys_power_mode; tt->tt_power_mode = tt->sys_power_mode;
init_timer(&priv->power_data.ct_kill_exit_tm); init_timer(&priv->thermal_throttle.ct_kill_exit_tm);
priv->power_data.ct_kill_exit_tm.data = (unsigned long)priv; priv->thermal_throttle.ct_kill_exit_tm.data = (unsigned long)priv;
priv->power_data.ct_kill_exit_tm.function = iwl_tt_check_exit_ct_kill; priv->thermal_throttle.ct_kill_exit_tm.function = iwl_tt_check_exit_ct_kill;
/* setup deferred ct kill work */ /* setup deferred ct kill work */
INIT_WORK(&priv->tt_work, iwl_bg_tt_work); INIT_WORK(&priv->tt_work, iwl_bg_tt_work);
...@@ -792,7 +792,7 @@ void iwl_tt_initialize(struct iwl_priv *priv) ...@@ -792,7 +792,7 @@ void iwl_tt_initialize(struct iwl_priv *priv)
GFP_KERNEL); GFP_KERNEL);
if (!tt->restriction || !tt->transaction) { if (!tt->restriction || !tt->transaction) {
IWL_ERR(priv, "Fallback to Legacy Throttling\n"); IWL_ERR(priv, "Fallback to Legacy Throttling\n");
priv->power_data.adv_tt = false; priv->thermal_throttle.advanced_tt = false;
kfree(tt->restriction); kfree(tt->restriction);
tt->restriction = NULL; tt->restriction = NULL;
kfree(tt->transaction); kfree(tt->transaction);
...@@ -814,12 +814,12 @@ void iwl_tt_initialize(struct iwl_priv *priv) ...@@ -814,12 +814,12 @@ void iwl_tt_initialize(struct iwl_priv *priv)
IWL_TI_STATE_MAX; IWL_TI_STATE_MAX;
memcpy(tt->restriction, memcpy(tt->restriction,
&restriction_range[0], size); &restriction_range[0], size);
priv->power_data.adv_tt = true; priv->thermal_throttle.advanced_tt = true;
} }
break; break;
default: default:
IWL_DEBUG_POWER(priv, "Legacy Thermal Throttling\n"); IWL_DEBUG_POWER(priv, "Legacy Thermal Throttling\n");
priv->power_data.adv_tt = false; priv->thermal_throttle.advanced_tt = false;
break; break;
} }
} }
...@@ -828,15 +828,15 @@ EXPORT_SYMBOL(iwl_tt_initialize); ...@@ -828,15 +828,15 @@ EXPORT_SYMBOL(iwl_tt_initialize);
/* cleanup thermal throttling management related memory and timer */ /* cleanup thermal throttling management related memory and timer */
void iwl_tt_exit(struct iwl_priv *priv) void iwl_tt_exit(struct iwl_priv *priv)
{ {
struct iwl_tt_mgmt *tt = &priv->power_data.tt; struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
/* stop ct_kill_exit_tm timer if activated */ /* stop ct_kill_exit_tm timer if activated */
del_timer_sync(&priv->power_data.ct_kill_exit_tm); del_timer_sync(&priv->thermal_throttle.ct_kill_exit_tm);
cancel_work_sync(&priv->tt_work); cancel_work_sync(&priv->tt_work);
cancel_work_sync(&priv->ct_enter); cancel_work_sync(&priv->ct_enter);
cancel_work_sync(&priv->ct_exit); cancel_work_sync(&priv->ct_exit);
if (priv->power_data.adv_tt) { if (priv->thermal_throttle.advanced_tt) {
/* free advance thermal throttling memory */ /* free advance thermal throttling memory */
kfree(tt->restriction); kfree(tt->restriction);
tt->restriction = NULL; tt->restriction = NULL;
......
...@@ -37,13 +37,11 @@ struct iwl_priv; ...@@ -37,13 +37,11 @@ struct iwl_priv;
#define IWL_ABSOLUTE_MAX 0xFFFFFFFF #define IWL_ABSOLUTE_MAX 0xFFFFFFFF
#define IWL_TT_INCREASE_MARGIN 5 #define IWL_TT_INCREASE_MARGIN 5
/* Tx/Rx restrictions */ enum iwl_antenna_ok {
#define IWL_TX_MULTI 0x02 IWL_ANT_OK_NONE,
#define IWL_TX_SINGLE 0x01 IWL_ANT_OK_SINGLE,
#define IWL_TX_NONE 0x00 IWL_ANT_OK_MULTI,
#define IWL_RX_MULTI 0x02 };
#define IWL_RX_SINGLE 0x01
#define IWL_RX_NONE 0x00
/* Thermal Throttling State Machine states */ /* Thermal Throttling State Machine states */
enum iwl_tt_state { enum iwl_tt_state {
...@@ -55,27 +53,30 @@ enum iwl_tt_state { ...@@ -55,27 +53,30 @@ enum iwl_tt_state {
}; };
/** /**
* struct iwl_tt_restriction - Thermal Throttling restriction table used * struct iwl_tt_restriction - Thermal Throttling restriction table
* by advance thermal throttling management
* based on the current thermal throttling state, determine
* number of tx/rx streams; and the status of HT operation
* @tx_stream: number of tx stream allowed * @tx_stream: number of tx stream allowed
* @is_ht: ht enable/disable * @is_ht: ht enable/disable
* @rx_stream: number of rx stream allowed * @rx_stream: number of rx stream allowed
*
* This table is used by advance thermal throttling management
* based on the current thermal throttling state, and determines
* the number of tx/rx streams and the status of HT operation.
*/ */
struct iwl_tt_restriction { struct iwl_tt_restriction {
u8 tx_stream; enum iwl_antenna_ok tx_stream;
enum iwl_antenna_ok rx_stream;
bool is_ht; bool is_ht;
u8 rx_stream;
}; };
/** /**
* struct iwl_tt_trans - Thermal Throttling transaction table; used by * struct iwl_tt_trans - Thermal Throttling transaction table
* advance thermal throttling algorithm to determine next
* thermal state to go based on the current temperature
* @next_state: next thermal throttling mode * @next_state: next thermal throttling mode
* @tt_low: low temperature threshold to change state * @tt_low: low temperature threshold to change state
* @tt_high: high temperature threshold to change state * @tt_high: high temperature threshold to change state
*
* This is used by the advanced thermal throttling algorithm
* to determine the next thermal state to go based on the
* current temperature.
*/ */
struct iwl_tt_trans { struct iwl_tt_trans {
enum iwl_tt_state next_state; enum iwl_tt_state next_state;
...@@ -85,6 +86,7 @@ struct iwl_tt_trans { ...@@ -85,6 +86,7 @@ struct iwl_tt_trans {
/** /**
* struct iwl_tt_mgnt - Thermal Throttling Management structure * struct iwl_tt_mgnt - Thermal Throttling Management structure
* @advanced_tt: advanced thermal throttle required
* @state: current Thermal Throttling state * @state: current Thermal Throttling state
* @tt_power_mode: Thermal Throttling power mode index * @tt_power_mode: Thermal Throttling power mode index
* being used to set power level when * being used to set power level when
...@@ -99,16 +101,21 @@ struct iwl_tt_trans { ...@@ -99,16 +101,21 @@ struct iwl_tt_trans {
* should be used in tt state; and can HT be enabled or not * should be used in tt state; and can HT be enabled or not
* @iwl_tt_trans: ptr to adv trans table, used by advance thermal throttling * @iwl_tt_trans: ptr to adv trans table, used by advance thermal throttling
* state transaction * state transaction
* @ct_kill_toggle: used to toggle the CSR bit when checking uCode temperature
* @ct_kill_exit_tm: timer to exit thermal kill
*/ */
struct iwl_tt_mgmt { struct iwl_tt_mgmt {
enum iwl_tt_state state; enum iwl_tt_state state;
bool advanced_tt;
u8 tt_power_mode; u8 tt_power_mode;
u8 sys_power_mode; u8 sys_power_mode;
bool ct_kill_toggle;
#ifdef CONFIG_IWLWIFI_DEBUG #ifdef CONFIG_IWLWIFI_DEBUG
s32 tt_previous_temp; s32 tt_previous_temp;
#endif #endif
struct iwl_tt_restriction *restriction; struct iwl_tt_restriction *restriction;
struct iwl_tt_trans *transaction; struct iwl_tt_trans *transaction;
struct timer_list ct_kill_exit_tm;
}; };
enum { enum {
...@@ -137,20 +144,13 @@ struct iwl_power_mgr { ...@@ -137,20 +144,13 @@ struct iwl_power_mgr {
u8 power_mode; u8 power_mode;
u8 user_power_setting; /* set by user through sysfs */ u8 user_power_setting; /* set by user through sysfs */
u8 power_disabled; /* set by mac80211's CONF_PS */ u8 power_disabled; /* set by mac80211's CONF_PS */
struct iwl_tt_mgmt tt; /* Thermal Throttling Management */
bool adv_tt; /* false: legacy mode */
/* true: advance mode */
bool ct_kill_toggle; /* use to toggle the CSR bit when
* checking uCode temperature
*/
struct timer_list ct_kill_exit_tm;
}; };
int iwl_power_update_mode(struct iwl_priv *priv, bool force); int iwl_power_update_mode(struct iwl_priv *priv, bool force);
int iwl_power_set_user_mode(struct iwl_priv *priv, u16 mode); int iwl_power_set_user_mode(struct iwl_priv *priv, u16 mode);
bool iwl_ht_enabled(struct iwl_priv *priv); bool iwl_ht_enabled(struct iwl_priv *priv);
u8 iwl_tx_ant_restriction(struct iwl_priv *priv); enum iwl_antenna_ok iwl_tx_ant_restriction(struct iwl_priv *priv);
u8 iwl_rx_ant_restriction(struct iwl_priv *priv); enum iwl_antenna_ok iwl_rx_ant_restriction(struct iwl_priv *priv);
void iwl_tt_enter_ct_kill(struct iwl_priv *priv); void iwl_tt_enter_ct_kill(struct iwl_priv *priv);
void iwl_tt_exit_ct_kill(struct iwl_priv *priv); void iwl_tt_exit_ct_kill(struct iwl_priv *priv);
void iwl_tt_handler(struct iwl_priv *priv); void iwl_tt_handler(struct iwl_priv *priv);
......
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