Skip to content

Commit 332704a

Browse files
Stanislaw Gruszkalinvjw
authored andcommitted
iwlegacy: fix tx_power initialization
priv->tx_power_next is not initialized to max supported power, but instead default value is used, what cause errors like [ 58.597834] iwl3945 0000:03:00.0: Requested user TXPOWER 15 above upper limit 14. [ 58.597839] iwl3945 0000:03:00.0: Error setting Tx power (-22). if maximum tx power read from the eeprom is smaller than default. In consequence card is unable to initialize properly. Fix the problem and cleanup tx power initialization. Reported-and-tested-by: Robin Dong <hao.bigrat@gmail.com> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 50f6871 commit 332704a

6 files changed

Lines changed: 11 additions & 28 deletions

File tree

‎drivers/net/wireless/iwlegacy/iwl-3945-hw.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@
7474
/* RSSI to dBm */
7575
#define IWL39_RSSI_OFFSET 95
7676

77-
#define IWL_DEFAULT_TX_POWER 0x0F
78-
7977
/*
8078
* EEPROM related constants, enums, and structures.
8179
*/

‎drivers/net/wireless/iwlegacy/iwl-4965-hw.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -804,9 +804,6 @@ struct iwl4965_scd_bc_tbl {
804804

805805
#define IWL4965_DEFAULT_TX_RETRY 15
806806

807-
/* Limit range of txpower output target to be between these values */
808-
#define IWL4965_TX_POWER_TARGET_POWER_MIN (0) /* 0 dBm: 1 milliwatt */
809-
810807
/* EEPROM */
811808
#define IWL4965_FIRST_AMPDU_QUEUE 10
812809

‎drivers/net/wireless/iwlegacy/iwl-core.c‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ int iwl_legacy_init_geos(struct iwl_priv *priv)
160160
struct ieee80211_channel *geo_ch;
161161
struct ieee80211_rate *rates;
162162
int i = 0;
163+
s8 max_tx_power = 0;
163164

164165
if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates ||
165166
priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) {
@@ -235,8 +236,8 @@ int iwl_legacy_init_geos(struct iwl_priv *priv)
235236

236237
geo_ch->flags |= ch->ht40_extension_channel;
237238

238-
if (ch->max_power_avg > priv->tx_power_device_lmt)
239-
priv->tx_power_device_lmt = ch->max_power_avg;
239+
if (ch->max_power_avg > max_tx_power)
240+
max_tx_power = ch->max_power_avg;
240241
} else {
241242
geo_ch->flags |= IEEE80211_CHAN_DISABLED;
242243
}
@@ -249,6 +250,10 @@ int iwl_legacy_init_geos(struct iwl_priv *priv)
249250
geo_ch->flags);
250251
}
251252

253+
priv->tx_power_device_lmt = max_tx_power;
254+
priv->tx_power_user_lmt = max_tx_power;
255+
priv->tx_power_next = max_tx_power;
256+
252257
if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) &&
253258
priv->cfg->sku & IWL_SKU_A) {
254259
IWL_INFO(priv, "Incorrectly detected BG card as ABG. "
@@ -1124,11 +1129,11 @@ int iwl_legacy_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force)
11241129
if (!priv->cfg->ops->lib->send_tx_power)
11251130
return -EOPNOTSUPP;
11261131

1127-
if (tx_power < IWL4965_TX_POWER_TARGET_POWER_MIN) {
1132+
/* 0 dBm mean 1 milliwatt */
1133+
if (tx_power < 0) {
11281134
IWL_WARN(priv,
1129-
"Requested user TXPOWER %d below lower limit %d.\n",
1130-
tx_power,
1131-
IWL4965_TX_POWER_TARGET_POWER_MIN);
1135+
"Requested user TXPOWER %d below 1 mW.\n",
1136+
tx_power);
11321137
return -EINVAL;
11331138
}
11341139

‎drivers/net/wireless/iwlegacy/iwl-eeprom.c‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -471,13 +471,6 @@ int iwl_legacy_init_channel_map(struct iwl_priv *priv)
471471
flags & EEPROM_CHANNEL_RADAR))
472472
? "" : "not ");
473473

474-
/* Set the tx_power_user_lmt to the highest power
475-
* supported by any channel */
476-
if (eeprom_ch_info[ch].max_power_avg >
477-
priv->tx_power_user_lmt)
478-
priv->tx_power_user_lmt =
479-
eeprom_ch_info[ch].max_power_avg;
480-
481474
ch_info++;
482475
}
483476
}

‎drivers/net/wireless/iwlegacy/iwl3945-base.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3825,10 +3825,6 @@ static int iwl3945_init_drv(struct iwl_priv *priv)
38253825
priv->force_reset[IWL_FW_RESET].reset_duration =
38263826
IWL_DELAY_NEXT_FORCE_FW_RELOAD;
38273827

3828-
3829-
priv->tx_power_user_lmt = IWL_DEFAULT_TX_POWER;
3830-
priv->tx_power_next = IWL_DEFAULT_TX_POWER;
3831-
38323828
if (eeprom->version < EEPROM_3945_EEPROM_VERSION) {
38333829
IWL_WARN(priv, "Unsupported EEPROM version: 0x%04X\n",
38343830
eeprom->version);

‎drivers/net/wireless/iwlegacy/iwl4965-base.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3140,12 +3140,6 @@ static int iwl4965_init_drv(struct iwl_priv *priv)
31403140

31413141
iwl_legacy_init_scan_params(priv);
31423142

3143-
/* Set the tx_power_user_lmt to the lowest power level
3144-
* this value will get overwritten by channel max power avg
3145-
* from eeprom */
3146-
priv->tx_power_user_lmt = IWL4965_TX_POWER_TARGET_POWER_MIN;
3147-
priv->tx_power_next = IWL4965_TX_POWER_TARGET_POWER_MIN;
3148-
31493143
ret = iwl_legacy_init_channel_map(priv);
31503144
if (ret) {
31513145
IWL_ERR(priv, "initializing regulatory failed: %d\n", ret);

0 commit comments

Comments
 (0)