diff options
author | Johannes Berg <johannes.berg@intel.com> | 2010-02-19 14:42:32 -0500 |
---|---|---|
committer | Reinette Chatre <reinette.chatre@intel.com> | 2010-03-09 19:12:08 -0500 |
commit | 72e15d71b02a21fd7b94ee1af4ba3a41f722b1f3 (patch) | |
tree | 9e0435e3fba955ea598b637ac53fe8f0b879d22f /drivers | |
parent | 4967c31677cf3c6c49aadf205f1a31d15d7610da (diff) |
iwlwifi: change WEP key protection to use mutex
For later station notification support we would like WEP key setting to be
done synchronously always. Currently all places from which WEP key is set
can sleep, but the usage of sta_lock prevents it to do so. Modify the
locking to use priv->mutex instead and thus enable this call to sleep.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-agn.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-dev.h | 2 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-sta.c | 18 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl3945-base.c | 2 |
4 files changed, 12 insertions, 12 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index bc84fd4a8d29..d6e1a059b9b0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c | |||
@@ -2869,7 +2869,6 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
2869 | 2869 | ||
2870 | mutex_lock(&priv->mutex); | 2870 | mutex_lock(&priv->mutex); |
2871 | iwl_scan_cancel_timeout(priv, 100); | 2871 | iwl_scan_cancel_timeout(priv, 100); |
2872 | mutex_unlock(&priv->mutex); | ||
2873 | 2872 | ||
2874 | /* If we are getting WEP group key and we didn't receive any key mapping | 2873 | /* If we are getting WEP group key and we didn't receive any key mapping |
2875 | * so far, we are in legacy wep mode (group key only), otherwise we are | 2874 | * so far, we are in legacy wep mode (group key only), otherwise we are |
@@ -2905,6 +2904,7 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
2905 | ret = -EINVAL; | 2904 | ret = -EINVAL; |
2906 | } | 2905 | } |
2907 | 2906 | ||
2907 | mutex_unlock(&priv->mutex); | ||
2908 | IWL_DEBUG_MAC80211(priv, "leave\n"); | 2908 | IWL_DEBUG_MAC80211(priv, "leave\n"); |
2909 | 2909 | ||
2910 | return ret; | 2910 | return ret; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 90d2b6e0df76..bac8e7cc46ce 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h | |||
@@ -1220,7 +1220,7 @@ struct iwl_priv { | |||
1220 | spinlock_t sta_lock; | 1220 | spinlock_t sta_lock; |
1221 | int num_stations; | 1221 | int num_stations; |
1222 | struct iwl_station_entry stations[IWL_STATION_COUNT]; | 1222 | struct iwl_station_entry stations[IWL_STATION_COUNT]; |
1223 | struct iwl_wep_key wep_keys[WEP_KEYS_MAX]; | 1223 | struct iwl_wep_key wep_keys[WEP_KEYS_MAX]; /* protected by mutex */ |
1224 | u8 default_wep_key; | 1224 | u8 default_wep_key; |
1225 | u8 key_mapping_key; | 1225 | u8 key_mapping_key; |
1226 | unsigned long ucode_key_table; | 1226 | unsigned long ucode_key_table; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c index 4a6686fa6b36..b1aad306efa9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-sta.c | |||
@@ -549,9 +549,11 @@ int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty) | |||
549 | struct iwl_host_cmd cmd = { | 549 | struct iwl_host_cmd cmd = { |
550 | .id = REPLY_WEPKEY, | 550 | .id = REPLY_WEPKEY, |
551 | .data = wep_cmd, | 551 | .data = wep_cmd, |
552 | .flags = CMD_ASYNC, | 552 | .flags = CMD_SYNC, |
553 | }; | 553 | }; |
554 | 554 | ||
555 | might_sleep(); | ||
556 | |||
555 | memset(wep_cmd, 0, cmd_size + | 557 | memset(wep_cmd, 0, cmd_size + |
556 | (sizeof(struct iwl_wep_key) * WEP_KEYS_MAX)); | 558 | (sizeof(struct iwl_wep_key) * WEP_KEYS_MAX)); |
557 | 559 | ||
@@ -587,9 +589,9 @@ int iwl_remove_default_wep_key(struct iwl_priv *priv, | |||
587 | struct ieee80211_key_conf *keyconf) | 589 | struct ieee80211_key_conf *keyconf) |
588 | { | 590 | { |
589 | int ret; | 591 | int ret; |
590 | unsigned long flags; | ||
591 | 592 | ||
592 | spin_lock_irqsave(&priv->sta_lock, flags); | 593 | WARN_ON(!mutex_is_locked(&priv->mutex)); |
594 | |||
593 | IWL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n", | 595 | IWL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n", |
594 | keyconf->keyidx); | 596 | keyconf->keyidx); |
595 | 597 | ||
@@ -601,13 +603,12 @@ int iwl_remove_default_wep_key(struct iwl_priv *priv, | |||
601 | memset(&priv->wep_keys[keyconf->keyidx], 0, sizeof(priv->wep_keys[0])); | 603 | memset(&priv->wep_keys[keyconf->keyidx], 0, sizeof(priv->wep_keys[0])); |
602 | if (iwl_is_rfkill(priv)) { | 604 | if (iwl_is_rfkill(priv)) { |
603 | IWL_DEBUG_WEP(priv, "Not sending REPLY_WEPKEY command due to RFKILL.\n"); | 605 | IWL_DEBUG_WEP(priv, "Not sending REPLY_WEPKEY command due to RFKILL.\n"); |
604 | spin_unlock_irqrestore(&priv->sta_lock, flags); | 606 | /* but keys in device are clear anyway so return success */ |
605 | return 0; | 607 | return 0; |
606 | } | 608 | } |
607 | ret = iwl_send_static_wepkey_cmd(priv, 1); | 609 | ret = iwl_send_static_wepkey_cmd(priv, 1); |
608 | IWL_DEBUG_WEP(priv, "Remove default WEP key: idx=%d ret=%d\n", | 610 | IWL_DEBUG_WEP(priv, "Remove default WEP key: idx=%d ret=%d\n", |
609 | keyconf->keyidx, ret); | 611 | keyconf->keyidx, ret); |
610 | spin_unlock_irqrestore(&priv->sta_lock, flags); | ||
611 | 612 | ||
612 | return ret; | 613 | return ret; |
613 | } | 614 | } |
@@ -617,7 +618,8 @@ int iwl_set_default_wep_key(struct iwl_priv *priv, | |||
617 | struct ieee80211_key_conf *keyconf) | 618 | struct ieee80211_key_conf *keyconf) |
618 | { | 619 | { |
619 | int ret; | 620 | int ret; |
620 | unsigned long flags; | 621 | |
622 | WARN_ON(!mutex_is_locked(&priv->mutex)); | ||
621 | 623 | ||
622 | if (keyconf->keylen != WEP_KEY_LEN_128 && | 624 | if (keyconf->keylen != WEP_KEY_LEN_128 && |
623 | keyconf->keylen != WEP_KEY_LEN_64) { | 625 | keyconf->keylen != WEP_KEY_LEN_64) { |
@@ -629,12 +631,11 @@ int iwl_set_default_wep_key(struct iwl_priv *priv, | |||
629 | keyconf->hw_key_idx = HW_KEY_DEFAULT; | 631 | keyconf->hw_key_idx = HW_KEY_DEFAULT; |
630 | priv->stations[IWL_AP_ID].keyinfo.alg = ALG_WEP; | 632 | priv->stations[IWL_AP_ID].keyinfo.alg = ALG_WEP; |
631 | 633 | ||
632 | spin_lock_irqsave(&priv->sta_lock, flags); | ||
633 | priv->default_wep_key++; | 634 | priv->default_wep_key++; |
634 | 635 | ||
635 | if (test_and_set_bit(keyconf->keyidx, &priv->ucode_key_table)) | 636 | if (test_and_set_bit(keyconf->keyidx, &priv->ucode_key_table)) |
636 | IWL_ERR(priv, "index %d already used in uCode key table.\n", | 637 | IWL_ERR(priv, "index %d already used in uCode key table.\n", |
637 | keyconf->keyidx); | 638 | keyconf->keyidx); |
638 | 639 | ||
639 | priv->wep_keys[keyconf->keyidx].key_size = keyconf->keylen; | 640 | priv->wep_keys[keyconf->keyidx].key_size = keyconf->keylen; |
640 | memcpy(&priv->wep_keys[keyconf->keyidx].key, &keyconf->key, | 641 | memcpy(&priv->wep_keys[keyconf->keyidx].key, &keyconf->key, |
@@ -643,7 +644,6 @@ int iwl_set_default_wep_key(struct iwl_priv *priv, | |||
643 | ret = iwl_send_static_wepkey_cmd(priv, 0); | 644 | ret = iwl_send_static_wepkey_cmd(priv, 0); |
644 | IWL_DEBUG_WEP(priv, "Set default WEP key: len=%d idx=%d ret=%d\n", | 645 | IWL_DEBUG_WEP(priv, "Set default WEP key: len=%d idx=%d ret=%d\n", |
645 | keyconf->keylen, keyconf->keyidx, ret); | 646 | keyconf->keylen, keyconf->keyidx, ret); |
646 | spin_unlock_irqrestore(&priv->sta_lock, flags); | ||
647 | 647 | ||
648 | return ret; | 648 | return ret; |
649 | } | 649 | } |
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index 2fd1b3d4949a..dd33251d6918 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -3344,7 +3344,6 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
3344 | 3344 | ||
3345 | mutex_lock(&priv->mutex); | 3345 | mutex_lock(&priv->mutex); |
3346 | iwl_scan_cancel_timeout(priv, 100); | 3346 | iwl_scan_cancel_timeout(priv, 100); |
3347 | mutex_unlock(&priv->mutex); | ||
3348 | 3347 | ||
3349 | switch (cmd) { | 3348 | switch (cmd) { |
3350 | case SET_KEY: | 3349 | case SET_KEY: |
@@ -3365,6 +3364,7 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
3365 | ret = -EINVAL; | 3364 | ret = -EINVAL; |
3366 | } | 3365 | } |
3367 | 3366 | ||
3367 | mutex_unlock(&priv->mutex); | ||
3368 | IWL_DEBUG_MAC80211(priv, "leave\n"); | 3368 | IWL_DEBUG_MAC80211(priv, "leave\n"); |
3369 | 3369 | ||
3370 | return ret; | 3370 | return ret; |