* [PATCH 1/7] iwlwifi: warn when send tx power settings during scan
@ 2010-10-22 15:04 Stanislaw Gruszka
2010-10-22 15:04 ` [PATCH 2/7] iwlwifi: send tx_power_cmd synchronously Stanislaw Gruszka
` (6 more replies)
0 siblings, 7 replies; 18+ messages in thread
From: Stanislaw Gruszka @ 2010-10-22 15:04 UTC (permalink / raw)
To: Wey-Yi Guy; +Cc: Johannes Berg, linux-wireless, Stanislaw Gruszka
Add WARN_ONCE when scanning is pending. Use STATUS_SCAN_HW bit since we
can have scan canceled or completed but STATUS_SCANNING bit still set.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
drivers/net/wireless/iwlwifi/iwl-3945.c | 4 ++++
drivers/net/wireless/iwlwifi/iwl-4965.c | 10 +++-------
drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 4 ++++
3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 176e525..93db6a0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -1451,6 +1451,10 @@ static int iwl3945_send_tx_power(struct iwl_priv *priv)
};
u16 chan;
+ if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &priv->status),
+ "TX Power requested while scanning!\n"))
+ return -EIO;
+
chan = le16_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.channel);
txpower.band = (priv->band == IEEE80211_BAND_5GHZ) ? 0 : 1;
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index b207e3e..924f335 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -1377,13 +1377,9 @@ static int iwl4965_send_tx_power(struct iwl_priv *priv)
u8 ctrl_chan_high = 0;
struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
- if (test_bit(STATUS_SCANNING, &priv->status)) {
- /* If this gets hit a lot, switch it to a BUG() and catch
- * the stack trace to find out who is calling this during
- * a scan. */
- IWL_WARN(priv, "TX Power requested while scanning!\n");
- return -EAGAIN;
- }
+ if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &priv->status),
+ "TX Power requested while scanning!\n"))
+ return -EIO;
band = priv->band == IEEE80211_BAND_2GHZ;
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
index b555edd..5d76a5b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
@@ -496,6 +496,10 @@ int iwlagn_send_tx_power(struct iwl_priv *priv)
struct iwlagn_tx_power_dbm_cmd tx_power_cmd;
u8 tx_ant_cfg_cmd;
+ if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &priv->status),
+ "TX Power requested while scanning!\n"))
+ return -EIO;
+
/* half dBm need to multiply */
tx_power_cmd.global_lmt = (s8)(2 * priv->tx_power_user_lmt);
--
1.7.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 2/7] iwlwifi: send tx_power_cmd synchronously
2010-10-22 15:04 [PATCH 1/7] iwlwifi: warn when send tx power settings during scan Stanislaw Gruszka
@ 2010-10-22 15:04 ` Stanislaw Gruszka
2010-10-25 14:46 ` Guy, Wey-Yi
2010-10-22 15:04 ` [PATCH 3/7] iwlwifi: fix set_tx_power vs scan Stanislaw Gruszka
` (5 subsequent siblings)
6 siblings, 1 reply; 18+ messages in thread
From: Stanislaw Gruszka @ 2010-10-22 15:04 UTC (permalink / raw)
To: Wey-Yi Guy; +Cc: Johannes Berg, linux-wireless, Stanislaw Gruszka
On 5xxx and 6xxx change to send tx_power_cmd command synchronously,
to do not start other commands when setting tx power is pending.
We currently do the same for 4956 and 3945.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
index 5d76a5b..925347a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
@@ -526,9 +526,8 @@ int iwlagn_send_tx_power(struct iwl_priv *priv)
else
tx_ant_cfg_cmd = REPLY_TX_POWER_DBM_CMD;
- return iwl_send_cmd_pdu_async(priv, tx_ant_cfg_cmd,
- sizeof(tx_power_cmd), &tx_power_cmd,
- NULL);
+ return iwl_send_cmd_pdu(priv, tx_ant_cfg_cmd, sizeof(tx_power_cmd),
+ &tx_power_cmd);
}
void iwlagn_temperature(struct iwl_priv *priv)
--
1.7.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 3/7] iwlwifi: fix set_tx_power vs scan
2010-10-22 15:04 [PATCH 1/7] iwlwifi: warn when send tx power settings during scan Stanislaw Gruszka
2010-10-22 15:04 ` [PATCH 2/7] iwlwifi: send tx_power_cmd synchronously Stanislaw Gruszka
@ 2010-10-22 15:04 ` Stanislaw Gruszka
2010-10-25 14:47 ` Guy, Wey-Yi
2010-10-22 15:04 ` [PATCH 4/7] iwlwifi: avoid commit rxon during scan in iwlagn_configure_filter Stanislaw Gruszka
` (4 subsequent siblings)
6 siblings, 1 reply; 18+ messages in thread
From: Stanislaw Gruszka @ 2010-10-22 15:04 UTC (permalink / raw)
To: Wey-Yi Guy; +Cc: Johannes Berg, linux-wireless, Stanislaw Gruszka
According to comment in iwl_bg_scan_completed, setting tx power should
be deferred during pending scan, but we are not doing this.
This patch change code to really defer setting tx power after scan
complete. Additionally refactor iwl_set_tx_power code and call
lib->send_tx_power() directly from iwlagn_commit_rxon.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
drivers/net/wireless/iwlwifi/iwl-agn.c | 10 ++---
drivers/net/wireless/iwlwifi/iwl-core.c | 54 +++++++++++++++------------
drivers/net/wireless/iwlwifi/iwl-dev.h | 1 +
drivers/net/wireless/iwlwifi/iwl-scan.c | 10 +++--
drivers/net/wireless/iwlwifi/iwl3945-base.c | 1 +
5 files changed, 42 insertions(+), 34 deletions(-)
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index c2636a7..d3435c4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -245,13 +245,10 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
/* If we issue a new RXON command which required a tune then we must
* send a new TXPOWER command or we won't be able to Tx any frames */
- ret = iwl_set_tx_power(priv, priv->tx_power_user_lmt, true);
- if (ret) {
+ ret = priv->cfg->ops->lib->send_tx_power(priv);
+ if (ret)
IWL_ERR(priv, "Error sending TX power (%d)\n", ret);
- return ret;
- }
-
- return 0;
+ return ret;
}
void iwl_update_chain_flags(struct iwl_priv *priv)
@@ -4179,6 +4176,7 @@ static int iwl_init_drv(struct iwl_priv *priv)
* this value will get overwritten by channel max power avg
* from eeprom */
priv->tx_power_user_lmt = IWLAGN_TX_POWER_TARGET_POWER_MIN;
+ priv->tx_power_next = IWLAGN_TX_POWER_TARGET_POWER_MIN;
ret = iwl_init_channel_map(priv);
if (ret) {
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 25fb391..8bbd152 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -1206,8 +1206,16 @@ EXPORT_SYMBOL(iwl_apm_init);
int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force)
{
- int ret = 0;
- s8 prev_tx_power = priv->tx_power_user_lmt;
+ int ret;
+ s8 prev_tx_power;
+
+ lockdep_assert_held(&priv->mutex);
+
+ if (priv->tx_power_user_lmt == tx_power && !force)
+ return 0;
+
+ if (!priv->cfg->ops->lib->send_tx_power)
+ return -EOPNOTSUPP;
if (tx_power < IWLAGN_TX_POWER_TARGET_POWER_MIN) {
IWL_WARN(priv,
@@ -1224,30 +1232,26 @@ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force)
return -EINVAL;
}
- if (priv->tx_power_user_lmt != tx_power)
- force = true;
+ if (!iwl_is_ready_rf(priv))
+ return -EIO;
- /* if nic is not up don't send command */
- if (iwl_is_ready_rf(priv)) {
- priv->tx_power_user_lmt = tx_power;
- if (force && priv->cfg->ops->lib->send_tx_power)
- ret = priv->cfg->ops->lib->send_tx_power(priv);
- else if (!priv->cfg->ops->lib->send_tx_power)
- ret = -EOPNOTSUPP;
- /*
- * if fail to set tx_power, restore the orig. tx power
- */
- if (ret)
- priv->tx_power_user_lmt = prev_tx_power;
+ /* scan complete use tx_power_next, need to be updated */
+ priv->tx_power_next = tx_power;
+ if (test_bit(STATUS_SCANNING, &priv->status) && !force) {
+ IWL_DEBUG_INFO(priv, "Deferring tx power set while scanning\n");
+ return 0;
}
- /*
- * Even this is an async host command, the command
- * will always report success from uCode
- * So once driver can placing the command into the queue
- * successfully, driver can use priv->tx_power_user_lmt
- * to reflect the current tx power
- */
+ prev_tx_power = priv->tx_power_user_lmt;
+ priv->tx_power_user_lmt = tx_power;
+
+ ret = priv->cfg->ops->lib->send_tx_power(priv);
+
+ /* if fail to set tx_power, restore the orig. tx power */
+ if (ret) {
+ priv->tx_power_user_lmt = prev_tx_power;
+ priv->tx_power_next = prev_tx_power;
+ }
return ret;
}
EXPORT_SYMBOL(iwl_set_tx_power);
@@ -2016,7 +2020,9 @@ int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
IWL_DEBUG_MAC80211(priv, "TX Power old=%d new=%d\n",
priv->tx_power_user_lmt, conf->power_level);
- iwl_set_tx_power(priv, conf->power_level, false);
+ ret = iwl_set_tx_power(priv, conf->power_level, false);
+ if (ret)
+ IWL_ERR(priv, "Error sending TX power (%d)\n", ret);
}
if (!iwl_is_ready(priv)) {
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 70e07fa..cd6daed 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -1517,6 +1517,7 @@ struct iwl_priv {
s8 tx_power_user_lmt;
s8 tx_power_device_lmt;
s8 tx_power_lmt_in_half_dbm; /* max tx power in half-dBm format */
+ s8 tx_power_next;
#ifdef CONFIG_IWLWIFI_DEBUG
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index 67da312..d63e30e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -603,13 +603,15 @@ out_settings:
if (!iwl_is_ready_rf(priv))
goto out;
- /* Since setting the TXPOWER may have been deferred while
- * performing the scan, fire one off */
- iwl_set_tx_power(priv, priv->tx_power_user_lmt, true);
+ /*
+ * We do not commit power settings while scan is pending,
+ * do it now if the settings changed.
+ */
+ iwl_set_tx_power(priv, priv->tx_power_next, false);
priv->cfg->ops->utils->post_scan(priv);
- out:
+out:
mutex_unlock(&priv->mutex);
}
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 8f8c4b7..a754291 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -3866,6 +3866,7 @@ static int iwl3945_init_drv(struct iwl_priv *priv)
priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF;
priv->tx_power_user_lmt = IWL_DEFAULT_TX_POWER;
+ priv->tx_power_next = IWL_DEFAULT_TX_POWER;
if (eeprom->version < EEPROM_3945_EEPROM_VERSION) {
IWL_WARN(priv, "Unsupported EEPROM version: 0x%04X\n",
--
1.7.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 4/7] iwlwifi: avoid commit rxon during scan in iwlagn_configure_filter
2010-10-22 15:04 [PATCH 1/7] iwlwifi: warn when send tx power settings during scan Stanislaw Gruszka
2010-10-22 15:04 ` [PATCH 2/7] iwlwifi: send tx_power_cmd synchronously Stanislaw Gruszka
2010-10-22 15:04 ` [PATCH 3/7] iwlwifi: fix set_tx_power vs scan Stanislaw Gruszka
@ 2010-10-22 15:04 ` Stanislaw Gruszka
2010-10-25 14:47 ` Guy, Wey-Yi
2010-10-22 15:04 ` [PATCH 5/7] iwlwifi: avoid commit rxon during scan in iwlagn_bt_traffic_change_work Stanislaw Gruszka
` (3 subsequent siblings)
6 siblings, 1 reply; 18+ messages in thread
From: Stanislaw Gruszka @ 2010-10-22 15:04 UTC (permalink / raw)
To: Wey-Yi Guy; +Cc: Johannes Berg, linux-wireless, Stanislaw Gruszka
Almost anywhere in the code we avoid committing rxon while performing
scan, and make rxon commit when scan complete. However in some places
in the code we do not follow that rule. This patch fix that problem in
iwlagn_configure_filter().
Since we do not commit directly in iwl3945_configure_filter, we can
also do the same for agn, so I just remove iwlcore_commit_rxon()
function and add a comment. Also change comment for iwl3945.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
drivers/net/wireless/iwlwifi/iwl-agn.c | 6 +++++-
drivers/net/wireless/iwlwifi/iwl3945-base.c | 6 +++---
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index d3435c4..0ba8083 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -3983,7 +3983,11 @@ static void iwlagn_configure_filter(struct ieee80211_hw *hw,
for_each_context(priv, ctx) {
ctx->staging.filter_flags &= ~filter_nand;
ctx->staging.filter_flags |= filter_or;
- iwlcore_commit_rxon(priv, ctx);
+
+ /*
+ * Not committing directly because hardware can perform a scan,
+ * but we'll eventually commit the filter flags change anyway.
+ */
}
mutex_unlock(&priv->mutex);
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index a754291..25f77e4 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -3407,9 +3407,9 @@ static void iwl3945_configure_filter(struct ieee80211_hw *hw,
ctx->staging.filter_flags |= filter_or;
/*
- * Committing directly here breaks for some reason,
- * but we'll eventually commit the filter flags
- * change anyway.
+ * Not committing directly because hardware can perform a scan,
+ * but even if hw is ready, committing here breaks for some reason,
+ * we'll eventually commit the filter flags change anyway.
*/
mutex_unlock(&priv->mutex);
--
1.7.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 5/7] iwlwifi: avoid commit rxon during scan in iwlagn_bt_traffic_change_work
2010-10-22 15:04 [PATCH 1/7] iwlwifi: warn when send tx power settings during scan Stanislaw Gruszka
` (2 preceding siblings ...)
2010-10-22 15:04 ` [PATCH 4/7] iwlwifi: avoid commit rxon during scan in iwlagn_configure_filter Stanislaw Gruszka
@ 2010-10-22 15:04 ` Stanislaw Gruszka
2010-10-25 14:47 ` Guy, Wey-Yi
2010-10-22 15:04 ` [PATCH 6/7] iwlwifi: defer update power mode while scan Stanislaw Gruszka
` (2 subsequent siblings)
6 siblings, 1 reply; 18+ messages in thread
From: Stanislaw Gruszka @ 2010-10-22 15:04 UTC (permalink / raw)
To: Wey-Yi Guy; +Cc: Johannes Berg, linux-wireless, Stanislaw Gruszka
Avoid sending commands to firmware (including commit_rxon) when scan
is pending and we are calling iwlagn_bt_traffic_change_work simultaneously.
Also comment some innocent race conditions.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
index 925347a..8257f36 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
@@ -1887,6 +1887,11 @@ static void iwlagn_bt_traffic_change_work(struct work_struct *work)
struct iwl_rxon_context *ctx;
int smps_request = -1;
+ /*
+ * Note: bt_traffic_load can be overridden by scan complete and
+ * coex profile notifications. Ignore that since only bad consequence
+ * can be not matching debug print with actual state.
+ */
IWL_DEBUG_INFO(priv, "BT traffic load changes: %d\n",
priv->bt_traffic_load);
@@ -1909,6 +1914,16 @@ static void iwlagn_bt_traffic_change_work(struct work_struct *work)
mutex_lock(&priv->mutex);
+ /*
+ * We can not send command to firmware while scanning. When the scan
+ * complete we will schedule this work again. We do check with mutex
+ * locked to prevent new scan request to arrive. We do not check
+ * STATUS_SCANNING to avoid race when queue_work two times from
+ * different notifications, but quit and not perform any work at all.
+ */
+ if (test_bit(STATUS_SCAN_HW, &priv->status))
+ goto out;
+
if (priv->cfg->ops->lib->update_chain_flags)
priv->cfg->ops->lib->update_chain_flags(priv);
@@ -1918,7 +1933,7 @@ static void iwlagn_bt_traffic_change_work(struct work_struct *work)
ieee80211_request_smps(ctx->vif, smps_request);
}
}
-
+out:
mutex_unlock(&priv->mutex);
}
--
1.7.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 6/7] iwlwifi: defer update power mode while scan
2010-10-22 15:04 [PATCH 1/7] iwlwifi: warn when send tx power settings during scan Stanislaw Gruszka
` (3 preceding siblings ...)
2010-10-22 15:04 ` [PATCH 5/7] iwlwifi: avoid commit rxon during scan in iwlagn_bt_traffic_change_work Stanislaw Gruszka
@ 2010-10-22 15:04 ` Stanislaw Gruszka
2010-10-22 15:33 ` Guy, Wey-Yi
2010-10-25 14:47 ` Guy, Wey-Yi
2010-10-22 15:04 ` [PATCH 7/7] iwlwifi: avoid commit rxon during scan in iwl_set_no_assoc Stanislaw Gruszka
2010-10-22 15:23 ` [PATCH 1/7] iwlwifi: warn when send tx power settings during scan Guy, Wey-Yi
6 siblings, 2 replies; 18+ messages in thread
From: Stanislaw Gruszka @ 2010-10-22 15:04 UTC (permalink / raw)
To: Wey-Yi Guy; +Cc: Johannes Berg, linux-wireless, Stanislaw Gruszka
Do not set power mode when scanning, and defer that when scan finish.
We still set power mode in force case i.e. when device is overheated.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
drivers/net/wireless/iwlwifi/iwl-power.c | 95 +++++++++++++++++++-----------
drivers/net/wireless/iwlwifi/iwl-power.h | 3 +
drivers/net/wireless/iwlwifi/iwl-scan.c | 1 +
3 files changed, 64 insertions(+), 35 deletions(-)
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
index 49d7788..b7abd86 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.c
+++ b/drivers/net/wireless/iwlwifi/iwl-power.c
@@ -263,70 +263,95 @@ static int iwl_set_power(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd)
sizeof(struct iwl_powertable_cmd), cmd);
}
-/* priv->mutex must be held */
-int iwl_power_update_mode(struct iwl_priv *priv, bool force)
+static void iwl_power_build_cmd(struct iwl_priv *priv,
+ struct iwl_powertable_cmd *cmd)
{
- int ret = 0;
bool enabled = priv->hw->conf.flags & IEEE80211_CONF_PS;
- bool update_chains;
- struct iwl_powertable_cmd cmd;
int dtimper;
- /* Don't update the RX chain when chain noise calibration is running */
- update_chains = priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE ||
- priv->chain_noise_data.state == IWL_CHAIN_NOISE_ALIVE;
-
dtimper = priv->hw->conf.ps_dtim_period ?: 1;
if (priv->cfg->base_params->broken_powersave)
- iwl_power_sleep_cam_cmd(priv, &cmd);
+ iwl_power_sleep_cam_cmd(priv, cmd);
else if (priv->cfg->base_params->supports_idle &&
priv->hw->conf.flags & IEEE80211_CONF_IDLE)
- iwl_static_sleep_cmd(priv, &cmd, IWL_POWER_INDEX_5, 20);
+ iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, 20);
else if (priv->cfg->ops->lib->tt_ops.lower_power_detection &&
priv->cfg->ops->lib->tt_ops.tt_power_mode &&
priv->cfg->ops->lib->tt_ops.lower_power_detection(priv)) {
/* in thermal throttling low power state */
- iwl_static_sleep_cmd(priv, &cmd,
+ iwl_static_sleep_cmd(priv, cmd,
priv->cfg->ops->lib->tt_ops.tt_power_mode(priv), dtimper);
} else if (!enabled)
- iwl_power_sleep_cam_cmd(priv, &cmd);
+ iwl_power_sleep_cam_cmd(priv, cmd);
else if (priv->power_data.debug_sleep_level_override >= 0)
- iwl_static_sleep_cmd(priv, &cmd,
+ iwl_static_sleep_cmd(priv, cmd,
priv->power_data.debug_sleep_level_override,
dtimper);
else if (no_sleep_autoadjust)
- iwl_static_sleep_cmd(priv, &cmd, IWL_POWER_INDEX_1, dtimper);
+ iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_1, dtimper);
else
- iwl_power_fill_sleep_cmd(priv, &cmd,
+ iwl_power_fill_sleep_cmd(priv, cmd,
priv->hw->conf.dynamic_ps_timeout,
priv->hw->conf.max_sleep_period);
+}
+
+int iwl_power_set_mode(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd,
+ bool force)
+{
+ int ret;
+ bool update_chains;
+
+ lockdep_assert_held(&priv->mutex);
+
+ /* Don't update the RX chain when chain noise calibration is running */
+ update_chains = priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE ||
+ priv->chain_noise_data.state == IWL_CHAIN_NOISE_ALIVE;
+
+ if (!memcmp(&priv->power_data.sleep_cmd, cmd, sizeof(*cmd)) && !force)
+ return 0;
+
+ if (!iwl_is_ready_rf(priv))
+ return -EIO;
+
+ /* scan complete use sleep_power_next, need to be updated */
+ memcpy(&priv->power_data.sleep_cmd_next, cmd, sizeof(*cmd));
+ if (test_bit(STATUS_SCANNING, &priv->status) && !force) {
+ IWL_DEBUG_INFO(priv, "Defer power set mode while scanning\n");
+ return 0;
+ }
+
+ if (cmd->flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK)
+ set_bit(STATUS_POWER_PMI, &priv->status);
- if (iwl_is_ready_rf(priv) &&
- (memcmp(&priv->power_data.sleep_cmd, &cmd, sizeof(cmd)) || force)) {
- if (cmd.flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK)
- set_bit(STATUS_POWER_PMI, &priv->status);
-
- ret = iwl_set_power(priv, &cmd);
- if (!ret) {
- if (!(cmd.flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK))
- clear_bit(STATUS_POWER_PMI, &priv->status);
-
- if (priv->cfg->ops->lib->update_chain_flags &&
- update_chains)
- priv->cfg->ops->lib->update_chain_flags(priv);
- else if (priv->cfg->ops->lib->update_chain_flags)
- IWL_DEBUG_POWER(priv,
+ ret = iwl_set_power(priv, cmd);
+ if (!ret) {
+ if (!(cmd->flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK))
+ clear_bit(STATUS_POWER_PMI, &priv->status);
+
+ if (priv->cfg->ops->lib->update_chain_flags && update_chains)
+ priv->cfg->ops->lib->update_chain_flags(priv);
+ else if (priv->cfg->ops->lib->update_chain_flags)
+ IWL_DEBUG_POWER(priv,
"Cannot update the power, chain noise "
"calibration running: %d\n",
priv->chain_noise_data.state);
- memcpy(&priv->power_data.sleep_cmd, &cmd, sizeof(cmd));
- } else
- IWL_ERR(priv, "set power fail, ret = %d", ret);
- }
+
+ memcpy(&priv->power_data.sleep_cmd, cmd, sizeof(*cmd));
+ } else
+ IWL_ERR(priv, "set power fail, ret = %d", ret);
return ret;
}
+EXPORT_SYMBOL(iwl_power_set_mode);
+
+int iwl_power_update_mode(struct iwl_priv *priv, bool force)
+{
+ struct iwl_powertable_cmd cmd;
+
+ iwl_power_build_cmd(priv, &cmd);
+ return iwl_power_set_mode(priv, &cmd, force);
+}
EXPORT_SYMBOL(iwl_power_update_mode);
/* initialize to default */
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.h b/drivers/net/wireless/iwlwifi/iwl-power.h
index df81565..fe01203 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.h
+++ b/drivers/net/wireless/iwlwifi/iwl-power.h
@@ -41,10 +41,13 @@ enum iwl_power_level {
struct iwl_power_mgr {
struct iwl_powertable_cmd sleep_cmd;
+ struct iwl_powertable_cmd sleep_cmd_next;
int debug_sleep_level_override;
bool pci_pm;
};
+int iwl_power_set_mode(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd,
+ bool force);
int iwl_power_update_mode(struct iwl_priv *priv, bool force);
void iwl_power_initialize(struct iwl_priv *priv);
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index d63e30e..e1aa0e1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -607,6 +607,7 @@ out_settings:
* We do not commit power settings while scan is pending,
* do it now if the settings changed.
*/
+ iwl_power_set_mode(priv, &priv->power_data.sleep_cmd_next, false);
iwl_set_tx_power(priv, priv->tx_power_next, false);
priv->cfg->ops->utils->post_scan(priv);
--
1.7.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 7/7] iwlwifi: avoid commit rxon during scan in iwl_set_no_assoc
2010-10-22 15:04 [PATCH 1/7] iwlwifi: warn when send tx power settings during scan Stanislaw Gruszka
` (4 preceding siblings ...)
2010-10-22 15:04 ` [PATCH 6/7] iwlwifi: defer update power mode while scan Stanislaw Gruszka
@ 2010-10-22 15:04 ` Stanislaw Gruszka
2010-10-25 14:48 ` Guy, Wey-Yi
2010-10-22 15:23 ` [PATCH 1/7] iwlwifi: warn when send tx power settings during scan Guy, Wey-Yi
6 siblings, 1 reply; 18+ messages in thread
From: Stanislaw Gruszka @ 2010-10-22 15:04 UTC (permalink / raw)
To: Wey-Yi Guy; +Cc: Johannes Berg, linux-wireless, Stanislaw Gruszka
Currently we are canceling scan when changing BSSID. Behave the same
when changing association and beacon enablement, to avoid committing
rxon during scan in iwl_set_no_assoc().
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
drivers/net/wireless/iwlwifi/iwl-core.c | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 8bbd152..87c1800 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -1590,6 +1590,19 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
mutex_lock(&priv->mutex);
+ if (changes & (BSS_CHANGED_BSSID | BSS_CHANGED_ASSOC |
+ BSS_CHANGED_BEACON_ENABLED)) {
+ /*
+ * If there is currently a HW scan going on in the
+ * background then we need to cancel it else the RXON
+ * below in post_associate or set_no_assoc can fail.
+ */
+ if (iwl_scan_cancel_timeout(priv, 200)) {
+ IWL_WARN(priv, "Can not cancel scan\n");
+ goto out;
+ }
+ }
+
if (changes & BSS_CHANGED_QOS) {
unsigned long flags;
@@ -1622,18 +1635,6 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
if (changes & BSS_CHANGED_BSSID) {
IWL_DEBUG_MAC80211(priv, "BSSID %pM\n", bss_conf->bssid);
- /*
- * If there is currently a HW scan going on in the
- * background then we need to cancel it else the RXON
- * below/in post_associate will fail.
- */
- if (iwl_scan_cancel_timeout(priv, 100)) {
- IWL_WARN(priv, "Aborted scan still in progress after 100ms\n");
- IWL_DEBUG_MAC80211(priv, "leaving - scan abort failed.\n");
- mutex_unlock(&priv->mutex);
- return;
- }
-
/* mac80211 only sets assoc when in STATION mode */
if (vif->type == NL80211_IFTYPE_ADHOC || bss_conf->assoc) {
memcpy(ctx->staging.bssid_addr,
@@ -1752,6 +1753,7 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
IWL_ERR(priv, "failed to update PAN params\n");
}
+out:
mutex_unlock(&priv->mutex);
IWL_DEBUG_MAC80211(priv, "leave\n");
--
1.7.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH 1/7] iwlwifi: warn when send tx power settings during scan
2010-10-22 15:04 [PATCH 1/7] iwlwifi: warn when send tx power settings during scan Stanislaw Gruszka
` (5 preceding siblings ...)
2010-10-22 15:04 ` [PATCH 7/7] iwlwifi: avoid commit rxon during scan in iwl_set_no_assoc Stanislaw Gruszka
@ 2010-10-22 15:23 ` Guy, Wey-Yi
2010-10-25 8:34 ` Stanislaw Gruszka
6 siblings, 1 reply; 18+ messages in thread
From: Guy, Wey-Yi @ 2010-10-22 15:23 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: Johannes Berg, linux-wireless@vger.kernel.org
Hi Stanislaw,
On Fri, 2010-10-22 at 08:04 -0700, Stanislaw Gruszka wrote:
> Add WARN_ONCE when scanning is pending. Use STATUS_SCAN_HW bit since we
> can have scan canceled or completed but STATUS_SCANNING bit still set.
>
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> ---
> drivers/net/wireless/iwlwifi/iwl-3945.c | 4 ++++
> drivers/net/wireless/iwlwifi/iwl-4965.c | 10 +++-------
> drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 4 ++++
> 3 files changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
> index 176e525..93db6a0 100644
> --- a/drivers/net/wireless/iwlwifi/iwl-3945.c
> +++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
> @@ -1451,6 +1451,10 @@ static int iwl3945_send_tx_power(struct iwl_priv *priv)
> };
> u16 chan;
>
> + if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &priv->status),
> + "TX Power requested while scanning!\n"))
> + return -EIO;
> +
> chan = le16_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.channel);
>
> txpower.band = (priv->band == IEEE80211_BAND_5GHZ) ? 0 : 1;
> diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
> index b207e3e..924f335 100644
> --- a/drivers/net/wireless/iwlwifi/iwl-4965.c
> +++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
> @@ -1377,13 +1377,9 @@ static int iwl4965_send_tx_power(struct iwl_priv *priv)
> u8 ctrl_chan_high = 0;
> struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
>
> - if (test_bit(STATUS_SCANNING, &priv->status)) {
> - /* If this gets hit a lot, switch it to a BUG() and catch
> - * the stack trace to find out who is calling this during
> - * a scan. */
> - IWL_WARN(priv, "TX Power requested while scanning!\n");
> - return -EAGAIN;
> - }
> + if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &priv->status),
> + "TX Power requested while scanning!\n"))
> + return -EIO;
what reason we want to return -EIO instead of -EAGAIN?
Wey
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 6/7] iwlwifi: defer update power mode while scan
2010-10-22 15:04 ` [PATCH 6/7] iwlwifi: defer update power mode while scan Stanislaw Gruszka
@ 2010-10-22 15:33 ` Guy, Wey-Yi
2010-10-25 8:18 ` Stanislaw Gruszka
2010-10-25 14:47 ` Guy, Wey-Yi
1 sibling, 1 reply; 18+ messages in thread
From: Guy, Wey-Yi @ 2010-10-22 15:33 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: Johannes Berg, linux-wireless@vger.kernel.org
Hi Stanislaw,
On Fri, 2010-10-22 at 08:04 -0700, Stanislaw Gruszka wrote:
> Do not set power mode when scanning, and defer that when scan finish.
> We still set power mode in force case i.e. when device is overheated.
>
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> ---
> drivers/net/wireless/iwlwifi/iwl-power.c | 95 +++++++++++++++++++-----------
> drivers/net/wireless/iwlwifi/iwl-power.h | 3 +
> drivers/net/wireless/iwlwifi/iwl-scan.c | 1 +
> 3 files changed, 64 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
> index 49d7788..b7abd86 100644
> --- a/drivers/net/wireless/iwlwifi/iwl-power.c
> +++ b/drivers/net/wireless/iwlwifi/iwl-power.c
> @@ -263,70 +263,95 @@ static int iwl_set_power(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd)
> sizeof(struct iwl_powertable_cmd), cmd);
> }
>
> -/* priv->mutex must be held */
> -int iwl_power_update_mode(struct iwl_priv *priv, bool force)
> +static void iwl_power_build_cmd(struct iwl_priv *priv,
> + struct iwl_powertable_cmd *cmd)
> {
> - int ret = 0;
> bool enabled = priv->hw->conf.flags & IEEE80211_CONF_PS;
> - bool update_chains;
> - struct iwl_powertable_cmd cmd;
> int dtimper;
>
> - /* Don't update the RX chain when chain noise calibration is running */
> - update_chains = priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE ||
> - priv->chain_noise_data.state == IWL_CHAIN_NOISE_ALIVE;
> -
> dtimper = priv->hw->conf.ps_dtim_period ?: 1;
>
> if (priv->cfg->base_params->broken_powersave)
> - iwl_power_sleep_cam_cmd(priv, &cmd);
> + iwl_power_sleep_cam_cmd(priv, cmd);
Is this right?
> else if (priv->cfg->base_params->supports_idle &&
> priv->hw->conf.flags & IEEE80211_CONF_IDLE)
> - iwl_static_sleep_cmd(priv, &cmd, IWL_POWER_INDEX_5, 20);
> + iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, 20);
> else if (priv->cfg->ops->lib->tt_ops.lower_power_detection &&
> priv->cfg->ops->lib->tt_ops.tt_power_mode &&
> priv->cfg->ops->lib->tt_ops.lower_power_detection(priv)) {
> /* in thermal throttling low power state */
> - iwl_static_sleep_cmd(priv, &cmd,
> + iwl_static_sleep_cmd(priv, cmd,
Same here and more
> priv->cfg->ops->lib->tt_ops.tt_power_mode(priv), dtimper);
> } else if (!enabled)
> - iwl_power_sleep_cam_cmd(priv, &cmd);
> + iwl_power_sleep_cam_cmd(priv, cmd);
> else if (priv->power_data.debug_sleep_level_override >= 0)
> - iwl_static_sleep_cmd(priv, &cmd,
> + iwl_static_sleep_cmd(priv, cmd,
> priv->power_data.debug_sleep_level_override,
> dtimper);
> else if (no_sleep_autoadjust)
> - iwl_static_sleep_cmd(priv, &cmd, IWL_POWER_INDEX_1, dtimper);
> + iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_1, dtimper);
> else
> - iwl_power_fill_sleep_cmd(priv, &cmd,
> + iwl_power_fill_sleep_cmd(priv, cmd,
> priv->hw->conf.dynamic_ps_timeout,
> priv->hw->conf.max_sleep_period);
> +}
> +
> +int iwl_power_set_mode(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd,
> + bool force)
> +{
> + int ret;
> + bool update_chains;
> +
> + lockdep_assert_held(&priv->mutex);
> +
> + /* Don't update the RX chain when chain noise calibration is running */
> + update_chains = priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE ||
> + priv->chain_noise_data.state == IWL_CHAIN_NOISE_ALIVE;
> +
> + if (!memcmp(&priv->power_data.sleep_cmd, cmd, sizeof(*cmd)) && !force)
> + return 0;
> +
> + if (!iwl_is_ready_rf(priv))
> + return -EIO;
> +
> + /* scan complete use sleep_power_next, need to be updated */
> + memcpy(&priv->power_data.sleep_cmd_next, cmd, sizeof(*cmd));
> + if (test_bit(STATUS_SCANNING, &priv->status) && !force) {
> + IWL_DEBUG_INFO(priv, "Defer power set mode while scanning\n");
> + return 0;
> + }
> +
> + if (cmd->flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK)
> + set_bit(STATUS_POWER_PMI, &priv->status);
>
> - if (iwl_is_ready_rf(priv) &&
> - (memcmp(&priv->power_data.sleep_cmd, &cmd, sizeof(cmd)) || force)) {
> - if (cmd.flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK)
> - set_bit(STATUS_POWER_PMI, &priv->status);
> -
> - ret = iwl_set_power(priv, &cmd);
> - if (!ret) {
> - if (!(cmd.flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK))
> - clear_bit(STATUS_POWER_PMI, &priv->status);
> -
> - if (priv->cfg->ops->lib->update_chain_flags &&
> - update_chains)
> - priv->cfg->ops->lib->update_chain_flags(priv);
> - else if (priv->cfg->ops->lib->update_chain_flags)
> - IWL_DEBUG_POWER(priv,
> + ret = iwl_set_power(priv, cmd);
> + if (!ret) {
> + if (!(cmd->flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK))
> + clear_bit(STATUS_POWER_PMI, &priv->status);
> +
> + if (priv->cfg->ops->lib->update_chain_flags && update_chains)
> + priv->cfg->ops->lib->update_chain_flags(priv);
> + else if (priv->cfg->ops->lib->update_chain_flags)
> + IWL_DEBUG_POWER(priv,
> "Cannot update the power, chain noise "
> "calibration running: %d\n",
> priv->chain_noise_data.state);
> - memcpy(&priv->power_data.sleep_cmd, &cmd, sizeof(cmd));
> - } else
> - IWL_ERR(priv, "set power fail, ret = %d", ret);
> - }
> +
> + memcpy(&priv->power_data.sleep_cmd, cmd, sizeof(*cmd));
> + } else
> + IWL_ERR(priv, "set power fail, ret = %d", ret);
>
> return ret;
> }
> +EXPORT_SYMBOL(iwl_power_set_mode);
> +
> +int iwl_power_update_mode(struct iwl_priv *priv, bool force)
> +{
> + struct iwl_powertable_cmd cmd;
> +
> + iwl_power_build_cmd(priv, &cmd);
> + return iwl_power_set_mode(priv, &cmd, force);
> +}
> EXPORT_SYMBOL(iwl_power_update_mode);
>
> /* initialize to default */
> diff --git a/drivers/net/wireless/iwlwifi/iwl-power.h b/drivers/net/wireless/iwlwifi/iwl-power.h
> index df81565..fe01203 100644
> --- a/drivers/net/wireless/iwlwifi/iwl-power.h
> +++ b/drivers/net/wireless/iwlwifi/iwl-power.h
> @@ -41,10 +41,13 @@ enum iwl_power_level {
>
> struct iwl_power_mgr {
> struct iwl_powertable_cmd sleep_cmd;
> + struct iwl_powertable_cmd sleep_cmd_next;
> int debug_sleep_level_override;
> bool pci_pm;
> };
>
> +int iwl_power_set_mode(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd,
> + bool force);
> int iwl_power_update_mode(struct iwl_priv *priv, bool force);
> void iwl_power_initialize(struct iwl_priv *priv);
>
> diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
> index d63e30e..e1aa0e1 100644
> --- a/drivers/net/wireless/iwlwifi/iwl-scan.c
> +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
> @@ -607,6 +607,7 @@ out_settings:
> * We do not commit power settings while scan is pending,
> * do it now if the settings changed.
> */
> + iwl_power_set_mode(priv, &priv->power_data.sleep_cmd_next, false);
> iwl_set_tx_power(priv, priv->tx_power_next, false);
>
> priv->cfg->ops->utils->post_scan(priv);
Wey
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 6/7] iwlwifi: defer update power mode while scan
2010-10-22 15:33 ` Guy, Wey-Yi
@ 2010-10-25 8:18 ` Stanislaw Gruszka
0 siblings, 0 replies; 18+ messages in thread
From: Stanislaw Gruszka @ 2010-10-25 8:18 UTC (permalink / raw)
To: Guy, Wey-Yi; +Cc: Johannes Berg, linux-wireless@vger.kernel.org
Hi Wey
On Fri, Oct 22, 2010 at 08:33:57AM -0700, Guy, Wey-Yi wrote:
> On Fri, 2010-10-22 at 08:04 -0700, Stanislaw Gruszka wrote:
> > -int iwl_power_update_mode(struct iwl_priv *priv, bool force)
> > +static void iwl_power_build_cmd(struct iwl_priv *priv,
> > + struct iwl_powertable_cmd *cmd)
> > {
> > - int ret = 0;
> > bool enabled = priv->hw->conf.flags & IEEE80211_CONF_PS;
> > - bool update_chains;
> > - struct iwl_powertable_cmd cmd;
> > int dtimper;
[snip]
> > if (priv->cfg->base_params->broken_powersave)
> > - iwl_power_sleep_cam_cmd(priv, &cmd);
> > + iwl_power_sleep_cam_cmd(priv, cmd);
> Is this right?
Yes, patch change "cmd" to be a pointer anywhere in this function.
Stanislaw
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/7] iwlwifi: warn when send tx power settings during scan
2010-10-22 15:23 ` [PATCH 1/7] iwlwifi: warn when send tx power settings during scan Guy, Wey-Yi
@ 2010-10-25 8:34 ` Stanislaw Gruszka
2010-10-25 14:38 ` Guy, Wey-Yi
0 siblings, 1 reply; 18+ messages in thread
From: Stanislaw Gruszka @ 2010-10-25 8:34 UTC (permalink / raw)
To: Guy, Wey-Yi; +Cc: Johannes Berg, linux-wireless@vger.kernel.org
Hi Wey
On Fri, Oct 22, 2010 at 08:23:05AM -0700, Guy, Wey-Yi wrote:
> On Fri, 2010-10-22 at 08:04 -0700, Stanislaw Gruszka wrote:
> > + if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &priv->status),
> > + "TX Power requested while scanning!\n"))
> > + return -EIO;
>
> what reason we want to return -EIO instead of -EAGAIN?
I though EAGAIN should be used for file nonblock I/O, but seems
it can be used anywhere when resources are unavailable. If it
make difference, we can apply this patch instead:
>From 7905309bfeae1a8374d3caa757d9f9383c15d700 Mon Sep 17 00:00:00 2001
From: Stanislaw Gruszka <sgruszka@redhat.com>
Date: Fri, 22 Oct 2010 13:23:41 +0200
Subject: [PATCH 1/7 v2] iwlwifi: warn when send tx power settings during scan
Add WARN_ONCE when scanning is pending. Use STATUS_SCAN_HW bit since we
can have scan canceled or completed but STATUS_SCANNING bit still set.
v1 -> v2: replace EIO to EAGAIN
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
drivers/net/wireless/iwlwifi/iwl-3945.c | 4 ++++
drivers/net/wireless/iwlwifi/iwl-4965.c | 10 +++-------
drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 4 ++++
3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 176e525..93db6a0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -1451,6 +1451,10 @@ static int iwl3945_send_tx_power(struct iwl_priv *priv)
};
u16 chan;
+ if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &priv->status),
+ "TX Power requested while scanning!\n"))
+ return -EAGAIN;
+
chan = le16_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.channel);
txpower.band = (priv->band == IEEE80211_BAND_5GHZ) ? 0 : 1;
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index b207e3e..924f335 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -1377,13 +1377,9 @@ static int iwl4965_send_tx_power(struct iwl_priv *priv)
u8 ctrl_chan_high = 0;
struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
- if (test_bit(STATUS_SCANNING, &priv->status)) {
- /* If this gets hit a lot, switch it to a BUG() and catch
- * the stack trace to find out who is calling this during
- * a scan. */
- IWL_WARN(priv, "TX Power requested while scanning!\n");
- return -EAGAIN;
- }
+ if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &priv->status),
+ "TX Power requested while scanning!\n"))
+ return -EAGAIN;
band = priv->band == IEEE80211_BAND_2GHZ;
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
index b555edd..5d76a5b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
@@ -496,6 +496,10 @@ int iwlagn_send_tx_power(struct iwl_priv *priv)
struct iwlagn_tx_power_dbm_cmd tx_power_cmd;
u8 tx_ant_cfg_cmd;
+ if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &priv->status),
+ "TX Power requested while scanning!\n"))
+ return -EAGAIN;
+
/* half dBm need to multiply */
tx_power_cmd.global_lmt = (s8)(2 * priv->tx_power_user_lmt);
--
1.7.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH 1/7] iwlwifi: warn when send tx power settings during scan
2010-10-25 8:34 ` Stanislaw Gruszka
@ 2010-10-25 14:38 ` Guy, Wey-Yi
0 siblings, 0 replies; 18+ messages in thread
From: Guy, Wey-Yi @ 2010-10-25 14:38 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: Johannes Berg, linux-wireless@vger.kernel.org
On Mon, 2010-10-25 at 01:34 -0700, Stanislaw Gruszka wrote:
> Hi Wey
>
> On Fri, Oct 22, 2010 at 08:23:05AM -0700, Guy, Wey-Yi wrote:
> > On Fri, 2010-10-22 at 08:04 -0700, Stanislaw Gruszka wrote:
> > > + if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &priv->status),
> > > + "TX Power requested while scanning!\n"))
> > > + return -EIO;
> >
> > what reason we want to return -EIO instead of -EAGAIN?
>
> I though EAGAIN should be used for file nonblock I/O, but seems
> it can be used anywhere when resources are unavailable. If it
> make difference, we can apply this patch instead:
>
> From 7905309bfeae1a8374d3caa757d9f9383c15d700 Mon Sep 17 00:00:00 2001
> From: Stanislaw Gruszka <sgruszka@redhat.com>
> Date: Fri, 22 Oct 2010 13:23:41 +0200
> Subject: [PATCH 1/7 v2] iwlwifi: warn when send tx power settings during scan
>
> Add WARN_ONCE when scanning is pending. Use STATUS_SCAN_HW bit since we
> can have scan canceled or completed but STATUS_SCANNING bit still set.
>
> v1 -> v2: replace EIO to EAGAIN
>
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
> ---
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 2/7] iwlwifi: send tx_power_cmd synchronously
2010-10-22 15:04 ` [PATCH 2/7] iwlwifi: send tx_power_cmd synchronously Stanislaw Gruszka
@ 2010-10-25 14:46 ` Guy, Wey-Yi
0 siblings, 0 replies; 18+ messages in thread
From: Guy, Wey-Yi @ 2010-10-25 14:46 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: Johannes Berg, linux-wireless@vger.kernel.org
On Fri, 2010-10-22 at 08:04 -0700, Stanislaw Gruszka wrote:
> On 5xxx and 6xxx change to send tx_power_cmd command synchronously,
> to do not start other commands when setting tx power is pending.
> We currently do the same for 4956 and 3945.
>
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
> ---
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 3/7] iwlwifi: fix set_tx_power vs scan
2010-10-22 15:04 ` [PATCH 3/7] iwlwifi: fix set_tx_power vs scan Stanislaw Gruszka
@ 2010-10-25 14:47 ` Guy, Wey-Yi
0 siblings, 0 replies; 18+ messages in thread
From: Guy, Wey-Yi @ 2010-10-25 14:47 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: Johannes Berg, linux-wireless@vger.kernel.org
On Fri, 2010-10-22 at 08:04 -0700, Stanislaw Gruszka wrote:
> According to comment in iwl_bg_scan_completed, setting tx power should
> be deferred during pending scan, but we are not doing this.
>
> This patch change code to really defer setting tx power after scan
> complete. Additionally refactor iwl_set_tx_power code and call
> lib->send_tx_power() directly from iwlagn_commit_rxon.
>
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
> ---
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 4/7] iwlwifi: avoid commit rxon during scan in iwlagn_configure_filter
2010-10-22 15:04 ` [PATCH 4/7] iwlwifi: avoid commit rxon during scan in iwlagn_configure_filter Stanislaw Gruszka
@ 2010-10-25 14:47 ` Guy, Wey-Yi
0 siblings, 0 replies; 18+ messages in thread
From: Guy, Wey-Yi @ 2010-10-25 14:47 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: Johannes Berg, linux-wireless@vger.kernel.org
On Fri, 2010-10-22 at 08:04 -0700, Stanislaw Gruszka wrote:
> Almost anywhere in the code we avoid committing rxon while performing
> scan, and make rxon commit when scan complete. However in some places
> in the code we do not follow that rule. This patch fix that problem in
> iwlagn_configure_filter().
>
> Since we do not commit directly in iwl3945_configure_filter, we can
> also do the same for agn, so I just remove iwlcore_commit_rxon()
> function and add a comment. Also change comment for iwl3945.
>
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
> ---
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 5/7] iwlwifi: avoid commit rxon during scan in iwlagn_bt_traffic_change_work
2010-10-22 15:04 ` [PATCH 5/7] iwlwifi: avoid commit rxon during scan in iwlagn_bt_traffic_change_work Stanislaw Gruszka
@ 2010-10-25 14:47 ` Guy, Wey-Yi
0 siblings, 0 replies; 18+ messages in thread
From: Guy, Wey-Yi @ 2010-10-25 14:47 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: Johannes Berg, linux-wireless@vger.kernel.org
On Fri, 2010-10-22 at 08:04 -0700, Stanislaw Gruszka wrote:
> Avoid sending commands to firmware (including commit_rxon) when scan
> is pending and we are calling iwlagn_bt_traffic_change_work simultaneously.
>
> Also comment some innocent race conditions.
>
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
> ---
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 6/7] iwlwifi: defer update power mode while scan
2010-10-22 15:04 ` [PATCH 6/7] iwlwifi: defer update power mode while scan Stanislaw Gruszka
2010-10-22 15:33 ` Guy, Wey-Yi
@ 2010-10-25 14:47 ` Guy, Wey-Yi
1 sibling, 0 replies; 18+ messages in thread
From: Guy, Wey-Yi @ 2010-10-25 14:47 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: Johannes Berg, linux-wireless@vger.kernel.org
On Fri, 2010-10-22 at 08:04 -0700, Stanislaw Gruszka wrote:
> Do not set power mode when scanning, and defer that when scan finish.
> We still set power mode in force case i.e. when device is overheated.
>
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
> ---
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 7/7] iwlwifi: avoid commit rxon during scan in iwl_set_no_assoc
2010-10-22 15:04 ` [PATCH 7/7] iwlwifi: avoid commit rxon during scan in iwl_set_no_assoc Stanislaw Gruszka
@ 2010-10-25 14:48 ` Guy, Wey-Yi
0 siblings, 0 replies; 18+ messages in thread
From: Guy, Wey-Yi @ 2010-10-25 14:48 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: Johannes Berg, linux-wireless@vger.kernel.org
On Fri, 2010-10-22 at 08:04 -0700, Stanislaw Gruszka wrote:
> Currently we are canceling scan when changing BSSID. Behave the same
> when changing association and beacon enablement, to avoid committing
> rxon during scan in iwl_set_no_assoc().
>
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
> ---
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2010-10-25 14:49 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-22 15:04 [PATCH 1/7] iwlwifi: warn when send tx power settings during scan Stanislaw Gruszka
2010-10-22 15:04 ` [PATCH 2/7] iwlwifi: send tx_power_cmd synchronously Stanislaw Gruszka
2010-10-25 14:46 ` Guy, Wey-Yi
2010-10-22 15:04 ` [PATCH 3/7] iwlwifi: fix set_tx_power vs scan Stanislaw Gruszka
2010-10-25 14:47 ` Guy, Wey-Yi
2010-10-22 15:04 ` [PATCH 4/7] iwlwifi: avoid commit rxon during scan in iwlagn_configure_filter Stanislaw Gruszka
2010-10-25 14:47 ` Guy, Wey-Yi
2010-10-22 15:04 ` [PATCH 5/7] iwlwifi: avoid commit rxon during scan in iwlagn_bt_traffic_change_work Stanislaw Gruszka
2010-10-25 14:47 ` Guy, Wey-Yi
2010-10-22 15:04 ` [PATCH 6/7] iwlwifi: defer update power mode while scan Stanislaw Gruszka
2010-10-22 15:33 ` Guy, Wey-Yi
2010-10-25 8:18 ` Stanislaw Gruszka
2010-10-25 14:47 ` Guy, Wey-Yi
2010-10-22 15:04 ` [PATCH 7/7] iwlwifi: avoid commit rxon during scan in iwl_set_no_assoc Stanislaw Gruszka
2010-10-25 14:48 ` Guy, Wey-Yi
2010-10-22 15:23 ` [PATCH 1/7] iwlwifi: warn when send tx power settings during scan Guy, Wey-Yi
2010-10-25 8:34 ` Stanislaw Gruszka
2010-10-25 14:38 ` Guy, Wey-Yi
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).