Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wifi: mac80211: remove sta_mtx

We now hold the wiphy mutex everywhere that we use or
needed the sta_mtx, so we don't need this mutex any
more. Remove it.

Most of this change was done automatically with spatch.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>

+112 -214
+36 -76
net/mac80211/cfg.c
··· 214 214 struct sta_info *sta; 215 215 int ret; 216 216 217 + lockdep_assert_wiphy(local->hw.wiphy); 218 + 217 219 ret = ieee80211_if_change_type(sdata, type); 218 220 if (ret) 219 221 return ret; ··· 237 235 if (!ifmgd->associated) 238 236 return 0; 239 237 240 - mutex_lock(&local->sta_mtx); 241 238 sta = sta_info_get(sdata, sdata->deflink.u.mgd.bssid); 242 239 if (sta) 243 240 drv_sta_set_4addr(local, sdata, &sta->sta, 244 241 params->use_4addr); 245 - mutex_unlock(&local->sta_mtx); 246 242 247 243 if (params->use_4addr) 248 244 ieee80211_send_4addr_nullfunc(local, sdata); ··· 472 472 struct ieee80211_local *local = sdata->local; 473 473 struct sta_info *sta = NULL; 474 474 struct ieee80211_key *key; 475 - int err; 475 + 476 + lockdep_assert_wiphy(local->hw.wiphy); 476 477 477 478 if (!ieee80211_sdata_running(sdata)) 478 479 return -ENETDOWN; ··· 511 510 if (params->mode == NL80211_KEY_NO_TX) 512 511 key->conf.flags |= IEEE80211_KEY_FLAG_NO_AUTO_TX; 513 512 514 - mutex_lock(&local->sta_mtx); 515 - 516 513 if (mac_addr) { 517 514 sta = sta_info_get_bss(sdata, mac_addr); 518 515 /* ··· 525 526 */ 526 527 if (!sta || !test_sta_flag(sta, WLAN_STA_ASSOC)) { 527 528 ieee80211_key_free_unused(key); 528 - err = -ENOENT; 529 - goto out_unlock; 529 + return -ENOENT; 530 530 } 531 531 } 532 532 ··· 563 565 break; 564 566 } 565 567 566 - err = ieee80211_key_link(key, link, sta); 567 - 568 - out_unlock: 569 - mutex_unlock(&local->sta_mtx); 570 - 571 - return err; 568 + return ieee80211_key_link(key, link, sta); 572 569 } 573 570 574 571 static struct ieee80211_key * ··· 591 598 592 599 if (link_id >= 0) { 593 600 link_sta = rcu_dereference_check(sta->link[link_id], 594 - lockdep_is_held(&local->sta_mtx)); 601 + lockdep_is_held(&local->hw.wiphy->mtx)); 595 602 if (!link_sta) 596 603 return NULL; 597 604 } else { ··· 636 643 struct ieee80211_key *key; 637 644 int ret; 638 645 639 - mutex_lock(&local->sta_mtx); 646 + lockdep_assert_wiphy(local->hw.wiphy); 647 + 640 648 mutex_lock(&local->key_mtx); 641 649 642 650 key = ieee80211_lookup_key(sdata, link_id, key_idx, pairwise, mac_addr); ··· 651 657 ret = 0; 652 658 out_unlock: 653 659 mutex_unlock(&local->key_mtx); 654 - mutex_unlock(&local->sta_mtx); 655 660 656 661 return ret; 657 662 } ··· 853 860 struct sta_info *sta; 854 861 int ret = -ENOENT; 855 862 856 - mutex_lock(&local->sta_mtx); 863 + lockdep_assert_wiphy(local->hw.wiphy); 857 864 858 865 sta = sta_info_get_by_idx(sdata, idx); 859 866 if (sta) { ··· 861 868 memcpy(mac, sta->sta.addr, ETH_ALEN); 862 869 sta_set_sinfo(sta, sinfo, true); 863 870 } 864 - 865 - mutex_unlock(&local->sta_mtx); 866 871 867 872 return ret; 868 873 } ··· 881 890 struct sta_info *sta; 882 891 int ret = -ENOENT; 883 892 884 - mutex_lock(&local->sta_mtx); 893 + lockdep_assert_wiphy(local->hw.wiphy); 885 894 886 895 sta = sta_info_get_bss(sdata, mac); 887 896 if (sta) { 888 897 ret = 0; 889 898 sta_set_sinfo(sta, sinfo, true); 890 899 } 891 - 892 - mutex_unlock(&local->sta_mtx); 893 900 894 901 return ret; 895 902 } ··· 1789 1800 sdata_dereference(sdata->link[link_id], sdata); 1790 1801 struct link_sta_info *link_sta = 1791 1802 rcu_dereference_protected(sta->link[link_id], 1792 - lockdep_is_held(&local->sta_mtx)); 1803 + lockdep_is_held(&local->hw.wiphy->mtx)); 1793 1804 1794 1805 /* 1795 1806 * If there are no changes, then accept a link that doesn't exist, ··· 2023 2034 struct ieee80211_sub_if_data *sdata; 2024 2035 int err; 2025 2036 2037 + lockdep_assert_wiphy(local->hw.wiphy); 2038 + 2026 2039 if (params->vlan) { 2027 2040 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); 2028 2041 ··· 2068 2077 * visible yet), sta_apply_parameters (and inner functions) require 2069 2078 * the mutex due to other paths. 2070 2079 */ 2071 - mutex_lock(&local->sta_mtx); 2072 2080 err = sta_apply_parameters(local, sta, params); 2073 - mutex_unlock(&local->sta_mtx); 2074 2081 if (err) { 2075 2082 sta_info_free(local, sta); 2076 2083 return err; ··· 2111 2122 enum cfg80211_station_type statype; 2112 2123 int err; 2113 2124 2114 - mutex_lock(&local->sta_mtx); 2125 + lockdep_assert_wiphy(local->hw.wiphy); 2115 2126 2116 2127 sta = sta_info_get_bss(sdata, mac); 2117 - if (!sta) { 2118 - err = -ENOENT; 2119 - goto out_err; 2120 - } 2128 + if (!sta) 2129 + return -ENOENT; 2121 2130 2122 2131 switch (sdata->vif.type) { 2123 2132 case NL80211_IFTYPE_MESH_POINT: ··· 2145 2158 statype = CFG80211_STA_AP_CLIENT_UNASSOC; 2146 2159 break; 2147 2160 default: 2148 - err = -EOPNOTSUPP; 2149 - goto out_err; 2161 + return -EOPNOTSUPP; 2150 2162 } 2151 2163 2152 2164 err = cfg80211_check_station_change(wiphy, params, statype); 2153 2165 if (err) 2154 - goto out_err; 2166 + return err; 2155 2167 2156 2168 if (params->vlan && params->vlan != sta->sdata->dev) { 2157 2169 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); 2158 2170 2159 2171 if (params->vlan->ieee80211_ptr->use_4addr) { 2160 - if (vlansdata->u.vlan.sta) { 2161 - err = -EBUSY; 2162 - goto out_err; 2163 - } 2172 + if (vlansdata->u.vlan.sta) 2173 + return -EBUSY; 2164 2174 2165 2175 rcu_assign_pointer(vlansdata->u.vlan.sta, sta); 2166 2176 __ieee80211_check_fast_rx_iface(vlansdata); ··· 2192 2208 err = sta_apply_parameters(local, sta, params); 2193 2209 } 2194 2210 if (err) 2195 - goto out_err; 2196 - 2197 - mutex_unlock(&local->sta_mtx); 2211 + return err; 2198 2212 2199 2213 if (sdata->vif.type == NL80211_IFTYPE_STATION && 2200 2214 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) { ··· 2201 2219 } 2202 2220 2203 2221 return 0; 2204 - out_err: 2205 - mutex_unlock(&local->sta_mtx); 2206 - return err; 2207 2222 } 2208 2223 2209 2224 #ifdef CONFIG_MAC80211_MESH ··· 4545 4566 { 4546 4567 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 4547 4568 struct sta_info *sta; 4548 - int ret; 4569 + 4570 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 4549 4571 4550 4572 if (!sdata->local->ops->set_tid_config) 4551 4573 return -EOPNOTSUPP; ··· 4554 4574 if (!tid_conf->peer) 4555 4575 return drv_set_tid_config(sdata->local, sdata, NULL, tid_conf); 4556 4576 4557 - mutex_lock(&sdata->local->sta_mtx); 4558 4577 sta = sta_info_get_bss(sdata, tid_conf->peer); 4559 - if (!sta) { 4560 - mutex_unlock(&sdata->local->sta_mtx); 4578 + if (!sta) 4561 4579 return -ENOENT; 4562 - } 4563 4580 4564 - ret = drv_set_tid_config(sdata->local, sdata, &sta->sta, tid_conf); 4565 - mutex_unlock(&sdata->local->sta_mtx); 4566 - 4567 - return ret; 4581 + return drv_set_tid_config(sdata->local, sdata, &sta->sta, tid_conf); 4568 4582 } 4569 4583 4570 4584 static int ieee80211_reset_tid_config(struct wiphy *wiphy, ··· 4567 4593 { 4568 4594 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 4569 4595 struct sta_info *sta; 4570 - int ret; 4596 + 4597 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 4571 4598 4572 4599 if (!sdata->local->ops->reset_tid_config) 4573 4600 return -EOPNOTSUPP; ··· 4576 4601 if (!peer) 4577 4602 return drv_reset_tid_config(sdata->local, sdata, NULL, tids); 4578 4603 4579 - mutex_lock(&sdata->local->sta_mtx); 4580 4604 sta = sta_info_get_bss(sdata, peer); 4581 - if (!sta) { 4582 - mutex_unlock(&sdata->local->sta_mtx); 4605 + if (!sta) 4583 4606 return -ENOENT; 4584 - } 4585 4607 4586 - ret = drv_reset_tid_config(sdata->local, sdata, &sta->sta, tids); 4587 - mutex_unlock(&sdata->local->sta_mtx); 4588 - 4589 - return ret; 4608 + return drv_reset_tid_config(sdata->local, sdata, &sta->sta, tids); 4590 4609 } 4591 4610 4592 4611 static int ieee80211_set_sar_specs(struct wiphy *wiphy, ··· 4906 4937 { 4907 4938 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 4908 4939 struct ieee80211_local *local = wiphy_priv(wiphy); 4909 - int ret; 4910 4940 4911 - mutex_lock(&sdata->local->sta_mtx); 4912 - ret = sta_add_link_station(local, sdata, params); 4913 - mutex_unlock(&sdata->local->sta_mtx); 4941 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 4914 4942 4915 - return ret; 4943 + return sta_add_link_station(local, sdata, params); 4916 4944 } 4917 4945 4918 4946 static int sta_mod_link_station(struct ieee80211_local *local, ··· 4934 4968 { 4935 4969 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 4936 4970 struct ieee80211_local *local = wiphy_priv(wiphy); 4937 - int ret; 4938 4971 4939 - mutex_lock(&sdata->local->sta_mtx); 4940 - ret = sta_mod_link_station(local, sdata, params); 4941 - mutex_unlock(&sdata->local->sta_mtx); 4972 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 4942 4973 4943 - return ret; 4974 + return sta_mod_link_station(local, sdata, params); 4944 4975 } 4945 4976 4946 4977 static int sta_del_link_station(struct ieee80211_sub_if_data *sdata, ··· 4966 5003 struct link_station_del_parameters *params) 4967 5004 { 4968 5005 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 4969 - int ret; 4970 5006 4971 - mutex_lock(&sdata->local->sta_mtx); 4972 - ret = sta_del_link_station(sdata, params); 4973 - mutex_unlock(&sdata->local->sta_mtx); 5007 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 4974 5008 4975 - return ret; 5009 + return sta_del_link_station(sdata, params); 4976 5010 } 4977 5011 4978 5012 static int ieee80211_set_hw_timestamp(struct wiphy *wiphy,
+3 -2
net/mac80211/debugfs.c
··· 288 288 q_limit_low_old = local->aql_txq_limit_low[ac]; 289 289 q_limit_high_old = local->aql_txq_limit_high[ac]; 290 290 291 + wiphy_lock(local->hw.wiphy); 291 292 local->aql_txq_limit_low[ac] = q_limit_low; 292 293 local->aql_txq_limit_high[ac] = q_limit_high; 293 294 294 - mutex_lock(&local->sta_mtx); 295 295 list_for_each_entry(sta, &local->sta_list, list) { 296 296 /* If a sta has customized queue limits, keep it */ 297 297 if (sta->airtime[ac].aql_limit_low == q_limit_low_old && ··· 300 300 sta->airtime[ac].aql_limit_high = q_limit_high; 301 301 } 302 302 } 303 - mutex_unlock(&local->sta_mtx); 303 + wiphy_unlock(local->hw.wiphy); 304 + 304 305 return count; 305 306 } 306 307
+2 -2
net/mac80211/driver-ops.c
··· 569 569 570 570 for_each_set_bit(link_id, &links_to_rem, IEEE80211_MLD_MAX_NUM_LINKS) { 571 571 link_sta = rcu_dereference_protected(info->link[link_id], 572 - lockdep_is_held(&local->sta_mtx)); 572 + lockdep_is_held(&local->hw.wiphy->mtx)); 573 573 574 574 ieee80211_link_sta_debugfs_drv_remove(link_sta); 575 575 } ··· 585 585 586 586 for_each_set_bit(link_id, &links_to_add, IEEE80211_MLD_MAX_NUM_LINKS) { 587 587 link_sta = rcu_dereference_protected(info->link[link_id], 588 - lockdep_is_held(&local->sta_mtx)); 588 + lockdep_is_held(&local->hw.wiphy->mtx)); 589 589 ieee80211_link_sta_debugfs_drv_add(link_sta); 590 590 } 591 591
-3
net/mac80211/ethtool.c
··· 103 103 */ 104 104 105 105 wiphy_lock(local->hw.wiphy); 106 - mutex_lock(&local->sta_mtx); 107 106 108 107 if (sdata->vif.type == NL80211_IFTYPE_STATION) { 109 108 sta = sta_info_get_bss(sdata, sdata->deflink.u.mgd.bssid); ··· 197 198 data[i++] = survey.time_tx; 198 199 else 199 200 data[i++] = -1LL; 200 - 201 - mutex_unlock(&local->sta_mtx); 202 201 203 202 if (WARN_ON(i != STA_STATS_LEN)) { 204 203 wiphy_unlock(local->hw.wiphy);
+1 -3
net/mac80211/ibss.c
··· 1257 1257 unsigned long exp_time = IEEE80211_IBSS_INACTIVITY_LIMIT; 1258 1258 unsigned long exp_rsn = IEEE80211_IBSS_RSN_INACTIVITY_LIMIT; 1259 1259 1260 - mutex_lock(&local->sta_mtx); 1260 + lockdep_assert_wiphy(local->hw.wiphy); 1261 1261 1262 1262 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { 1263 1263 unsigned long last_active = ieee80211_sta_last_active(sta); ··· 1282 1282 WARN_ON(__sta_info_destroy(sta)); 1283 1283 } 1284 1284 } 1285 - 1286 - mutex_unlock(&local->sta_mtx); 1287 1285 } 1288 1286 1289 1287 /*
+2 -3
net/mac80211/ieee80211_i.h
··· 1435 1435 1436 1436 /* Station data */ 1437 1437 /* 1438 - * The mutex only protects the list, hash table and 1439 - * counter, reads are done with RCU. 1438 + * The list, hash table and counter are protected 1439 + * by the wiphy mutex, reads are done with RCU. 1440 1440 */ 1441 - struct mutex sta_mtx; 1442 1441 spinlock_t tim_lock; 1443 1442 unsigned long num_sta; 1444 1443 struct list_head sta_list;
+2 -6
net/mac80211/iface.c
··· 1503 1503 { 1504 1504 struct ieee80211_mgmt *mgmt = (void *)skb->data; 1505 1505 1506 + lockdep_assert_wiphy(local->hw.wiphy); 1507 + 1506 1508 if (ieee80211_is_action(mgmt->frame_control) && 1507 1509 mgmt->u.action.category == WLAN_CATEGORY_BACK) { 1508 1510 struct sta_info *sta; 1509 1511 int len = skb->len; 1510 1512 1511 - mutex_lock(&local->sta_mtx); 1512 1513 sta = sta_info_get_bss(sdata, mgmt->sa); 1513 1514 if (sta) { 1514 1515 switch (mgmt->u.action.u.addba_req.action_code) { ··· 1530 1529 break; 1531 1530 } 1532 1531 } 1533 - mutex_unlock(&local->sta_mtx); 1534 1532 } else if (ieee80211_is_action(mgmt->frame_control) && 1535 1533 mgmt->u.action.category == WLAN_CATEGORY_VHT) { 1536 1534 switch (mgmt->u.action.u.vht_group_notif.action_code) { ··· 1543 1543 band = status->band; 1544 1544 opmode = mgmt->u.action.u.vht_opmode_notif.operating_mode; 1545 1545 1546 - mutex_lock(&local->sta_mtx); 1547 1546 sta = sta_info_get_bss(sdata, mgmt->sa); 1548 1547 1549 1548 if (sta) ··· 1550 1551 &sta->deflink, 1551 1552 opmode, band); 1552 1553 1553 - mutex_unlock(&local->sta_mtx); 1554 1554 break; 1555 1555 } 1556 1556 case WLAN_VHT_ACTION_GROUPID_MGMT: ··· 1596 1598 * a block-ack session was active. That cannot be 1597 1599 * right, so terminate the session. 1598 1600 */ 1599 - mutex_lock(&local->sta_mtx); 1600 1601 sta = sta_info_get_bss(sdata, mgmt->sa); 1601 1602 if (sta) { 1602 1603 u16 tid = ieee80211_get_tid(hdr); ··· 1605 1608 WLAN_REASON_QSTA_REQUIRE_SETUP, 1606 1609 true); 1607 1610 } 1608 - mutex_unlock(&local->sta_mtx); 1609 1611 } else switch (sdata->vif.type) { 1610 1612 case NL80211_IFTYPE_STATION: 1611 1613 ieee80211_sta_rx_queued_mgmt(sdata, skb);
+2 -2
net/mac80211/key.c
··· 482 482 483 483 if (sta) { 484 484 link_sta = rcu_dereference_protected(sta->link[link_id], 485 - lockdep_is_held(&sta->local->sta_mtx)); 485 + lockdep_is_held(&sta->local->hw.wiphy->mtx)); 486 486 if (!link_sta) 487 487 return -ENOLINK; 488 488 } ··· 877 877 878 878 if (link_id >= 0) { 879 879 link_sta = rcu_dereference_protected(sta->link[link_id], 880 - lockdep_is_held(&sta->local->sta_mtx)); 880 + lockdep_is_held(&sta->local->hw.wiphy->mtx)); 881 881 if (!link_sta) { 882 882 ret = -ENOLINK; 883 883 goto out;
+1 -2
net/mac80211/link.c
··· 455 455 int ret; 456 456 457 457 sdata_assert_lock(sdata); 458 - mutex_lock(&local->sta_mtx); 458 + lockdep_assert_wiphy(local->hw.wiphy); 459 459 mutex_lock(&local->mtx); 460 460 mutex_lock(&local->key_mtx); 461 461 old_active = sdata->vif.active_links; ··· 475 475 } 476 476 mutex_unlock(&local->key_mtx); 477 477 mutex_unlock(&local->mtx); 478 - mutex_unlock(&local->sta_mtx); 479 478 480 479 return ret; 481 480 }
+9 -22
net/mac80211/mlme.c
··· 3207 3207 ifmgd->probe_send_count++; 3208 3208 3209 3209 if (dst) { 3210 - mutex_lock(&sdata->local->sta_mtx); 3210 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 3211 3211 sta = sta_info_get(sdata, dst); 3212 3212 if (!WARN_ON(!sta)) 3213 3213 ieee80211_check_fast_rx(sta); 3214 - mutex_unlock(&sdata->local->sta_mtx); 3215 3214 } 3216 3215 3217 3216 if (ieee80211_hw_check(&sdata->local->hw, REPORTS_TX_ACK_STATUS)) { ··· 3628 3629 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 3629 3630 const u8 *ap_addr = ifmgd->auth_data->ap_addr; 3630 3631 struct sta_info *sta; 3631 - bool result = true; 3632 3632 3633 3633 sdata_info(sdata, "authenticated\n"); 3634 3634 ifmgd->auth_data->done = true; ··· 3636 3638 run_again(sdata, ifmgd->auth_data->timeout); 3637 3639 3638 3640 /* move station state to auth */ 3639 - mutex_lock(&sdata->local->sta_mtx); 3641 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 3640 3642 sta = sta_info_get(sdata, ap_addr); 3641 3643 if (!sta) { 3642 3644 WARN_ONCE(1, "%s: STA %pM not found", sdata->name, ap_addr); 3643 - result = false; 3644 - goto out; 3645 + return false; 3645 3646 } 3646 3647 if (sta_info_move_state(sta, IEEE80211_STA_AUTH)) { 3647 3648 sdata_info(sdata, "failed moving %pM to auth\n", ap_addr); 3648 - result = false; 3649 - goto out; 3649 + return false; 3650 3650 } 3651 3651 3652 - out: 3653 - mutex_unlock(&sdata->local->sta_mtx); 3654 - return result; 3652 + return true; 3655 3653 } 3656 3654 3657 3655 static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, ··· 5093 5099 u16 valid_links = 0, dormant_links = 0; 5094 5100 int err; 5095 5101 5096 - mutex_lock(&sdata->local->sta_mtx); 5102 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 5097 5103 /* 5098 5104 * station info was already allocated and inserted before 5099 5105 * the association and should be available to us ··· 5141 5147 " (assoc)" : ""); 5142 5148 5143 5149 link_sta = rcu_dereference_protected(sta->link[link_id], 5144 - lockdep_is_held(&local->sta_mtx)); 5150 + lockdep_is_held(&local->hw.wiphy->mtx)); 5145 5151 if (WARN_ON(!link_sta)) 5146 5152 goto out_err; 5147 5153 ··· 5228 5234 if (sdata->wdev.use_4addr) 5229 5235 drv_sta_set_4addr(local, sdata, &sta->sta, true); 5230 5236 5231 - mutex_unlock(&sdata->local->sta_mtx); 5232 - 5233 5237 ieee80211_set_associated(sdata, assoc_data, changed); 5234 5238 5235 5239 /* ··· 5247 5255 return true; 5248 5256 out_err: 5249 5257 eth_zero_addr(sdata->vif.cfg.ap_addr); 5250 - mutex_unlock(&sdata->local->sta_mtx); 5251 5258 return false; 5252 5259 } 5253 5260 ··· 6133 6142 le16_to_cpu(mgmt->u.beacon.capab_info), 6134 6143 erp_valid, erp_value); 6135 6144 6136 - mutex_lock(&local->sta_mtx); 6145 + lockdep_assert_wiphy(local->hw.wiphy); 6137 6146 sta = sta_info_get(sdata, sdata->vif.cfg.ap_addr); 6138 6147 if (WARN_ON(!sta)) { 6139 - mutex_unlock(&local->sta_mtx); 6140 6148 goto free; 6141 6149 } 6142 6150 link_sta = rcu_dereference_protected(sta->link[link->link_id], 6143 - lockdep_is_held(&local->sta_mtx)); 6151 + lockdep_is_held(&local->hw.wiphy->mtx)); 6144 6152 if (WARN_ON(!link_sta)) { 6145 - mutex_unlock(&local->sta_mtx); 6146 6153 goto free; 6147 6154 } 6148 6155 ··· 6156 6167 elems->vht_operation, elems->he_operation, 6157 6168 elems->eht_operation, 6158 6169 elems->s1g_oper, bssid, &changed)) { 6159 - mutex_unlock(&local->sta_mtx); 6160 6170 sdata_info(sdata, 6161 6171 "failed to follow AP %pM bandwidth change, disconnect\n", 6162 6172 bssid); ··· 6173 6185 ieee80211_vht_handle_opmode(sdata, link_sta, 6174 6186 *elems->opmode_notif, 6175 6187 rx_status->band); 6176 - mutex_unlock(&local->sta_mtx); 6177 6188 6178 6189 changed |= ieee80211_handle_pwr_constr(link, chan, mgmt, 6179 6190 elems->country_elem,
+2 -4
net/mac80211/pm.c
··· 40 40 41 41 if (ieee80211_hw_check(hw, AMPDU_AGGREGATION) && 42 42 !(wowlan && wowlan->any)) { 43 - mutex_lock(&local->sta_mtx); 43 + lockdep_assert_wiphy(local->hw.wiphy); 44 44 list_for_each_entry(sta, &local->sta_list, list) { 45 45 set_sta_flag(sta, WLAN_STA_BLOCK_BA); 46 46 ieee80211_sta_tear_down_BA_sessions( 47 47 sta, AGG_STOP_LOCAL_REQUEST); 48 48 } 49 - mutex_unlock(&local->sta_mtx); 50 49 } 51 50 52 51 /* keep sched_scan only in case of 'any' trigger */ ··· 118 119 local->quiescing = false; 119 120 local->wowlan = false; 120 121 if (ieee80211_hw_check(hw, AMPDU_AGGREGATION)) { 121 - mutex_lock(&local->sta_mtx); 122 + lockdep_assert_wiphy(local->hw.wiphy); 122 123 list_for_each_entry(sta, 123 124 &local->sta_list, list) { 124 125 clear_sta_flag(sta, WLAN_STA_BLOCK_BA); 125 126 } 126 - mutex_unlock(&local->sta_mtx); 127 127 } 128 128 ieee80211_wake_queues_by_reason(hw, 129 129 IEEE80211_MAX_QUEUE_MAP,
+3 -3
net/mac80211/rx.c
··· 4669 4669 struct ieee80211_local *local = sdata->local; 4670 4670 struct sta_info *sta; 4671 4671 4672 - lockdep_assert_held(&local->sta_mtx); 4672 + lockdep_assert_wiphy(local->hw.wiphy); 4673 4673 4674 4674 list_for_each_entry(sta, &local->sta_list, list) { 4675 4675 if (sdata != sta->sdata && ··· 4683 4683 { 4684 4684 struct ieee80211_local *local = sdata->local; 4685 4685 4686 - mutex_lock(&local->sta_mtx); 4686 + lockdep_assert_wiphy(local->hw.wiphy); 4687 + 4687 4688 __ieee80211_check_fast_rx_iface(sdata); 4688 - mutex_unlock(&local->sta_mtx); 4689 4689 } 4690 4690 4691 4691 static void ieee80211_rx_8023(struct ieee80211_rx_data *rx,
+5 -10
net/mac80211/s1g.c
··· 2 2 /* 3 3 * S1G handling 4 4 * Copyright(c) 2020 Adapt-IP 5 + * Copyright (C) 2023 Intel Corporation 5 6 */ 6 7 #include <linux/ieee80211.h> 7 8 #include <net/mac80211.h> ··· 154 153 struct ieee80211_local *local = sdata->local; 155 154 struct sta_info *sta; 156 155 157 - mutex_lock(&local->sta_mtx); 156 + lockdep_assert_wiphy(local->hw.wiphy); 158 157 159 158 sta = sta_info_get_bss(sdata, mgmt->sa); 160 159 if (!sta) 161 - goto out; 160 + return; 162 161 163 162 switch (mgmt->u.action.u.s1g.action_code) { 164 163 case WLAN_S1G_TWT_SETUP: ··· 170 169 default: 171 170 break; 172 171 } 173 - 174 - out: 175 - mutex_unlock(&local->sta_mtx); 176 172 } 177 173 178 174 void ieee80211_s1g_status_twt_action(struct ieee80211_sub_if_data *sdata, ··· 179 181 struct ieee80211_local *local = sdata->local; 180 182 struct sta_info *sta; 181 183 182 - mutex_lock(&local->sta_mtx); 184 + lockdep_assert_wiphy(local->hw.wiphy); 183 185 184 186 sta = sta_info_get_bss(sdata, mgmt->da); 185 187 if (!sta) 186 - goto out; 188 + return; 187 189 188 190 switch (mgmt->u.action.u.s1g.action_code) { 189 191 case WLAN_S1G_TWT_SETUP: ··· 193 195 default: 194 196 break; 195 197 } 196 - 197 - out: 198 - mutex_unlock(&local->sta_mtx); 199 198 }
+30 -51
net/mac80211/sta_info.c
··· 88 88 .max_size = CONFIG_MAC80211_STA_HASH_MAX_SIZE, 89 89 }; 90 90 91 - /* Caller must hold local->sta_mtx */ 92 91 static int sta_info_hash_del(struct ieee80211_local *local, 93 92 struct sta_info *sta) 94 93 { ··· 98 99 static int link_sta_info_hash_add(struct ieee80211_local *local, 99 100 struct link_sta_info *link_sta) 100 101 { 101 - lockdep_assert_held(&local->sta_mtx); 102 + lockdep_assert_wiphy(local->hw.wiphy); 103 + 102 104 return rhltable_insert(&local->link_sta_hash, 103 - &link_sta->link_hash_node, 104 - link_sta_rht_params); 105 + &link_sta->link_hash_node, link_sta_rht_params); 105 106 } 106 107 107 108 static int link_sta_info_hash_del(struct ieee80211_local *local, 108 109 struct link_sta_info *link_sta) 109 110 { 110 - lockdep_assert_held(&local->sta_mtx); 111 + lockdep_assert_wiphy(local->hw.wiphy); 112 + 111 113 return rhltable_remove(&local->link_sta_hash, 112 - &link_sta->link_hash_node, 113 - link_sta_rht_params); 114 + &link_sta->link_hash_node, link_sta_rht_params); 114 115 } 115 116 116 117 static void __cleanup_single_sta(struct sta_info *sta) ··· 330 331 int i = 0; 331 332 332 333 list_for_each_entry_rcu(sta, &local->sta_list, list, 333 - lockdep_is_held(&local->sta_mtx)) { 334 + lockdep_is_held(&local->hw.wiphy->mtx)) { 334 335 if (sdata != sta->sdata) 335 336 continue; 336 337 if (i < idx) { ··· 354 355 struct sta_link_alloc *alloc = NULL; 355 356 struct link_sta_info *link_sta; 356 357 357 - link_sta = rcu_access_pointer(sta->link[link_id]); 358 - if (link_sta != &sta->deflink) 359 - lockdep_assert_held(&sta->local->sta_mtx); 358 + lockdep_assert_wiphy(sta->local->hw.wiphy); 360 359 360 + link_sta = rcu_access_pointer(sta->link[link_id]); 361 361 if (WARN_ON(!link_sta)) 362 362 return; 363 363 ··· 435 437 kfree(sta); 436 438 } 437 439 438 - /* Caller must hold local->sta_mtx */ 439 440 static int sta_info_hash_add(struct ieee80211_local *local, 440 441 struct sta_info *sta) 441 442 { ··· 714 717 { 715 718 struct ieee80211_sub_if_data *sdata = sta->sdata; 716 719 720 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 721 + 717 722 /* 718 723 * Can't be a WARN_ON because it can be triggered through a race: 719 724 * something inserts a STA (on one CPU) without holding the RTNL ··· 733 734 * for correctness. 734 735 */ 735 736 rcu_read_lock(); 736 - lockdep_assert_held(&sdata->local->sta_mtx); 737 737 if (ieee80211_hw_check(&sdata->local->hw, NEEDS_UNIQUE_STA_ADDR) && 738 738 ieee80211_find_sta_by_ifaddr(&sdata->local->hw, sta->addr, NULL)) { 739 739 rcu_read_unlock(); ··· 806 808 } 807 809 } 808 810 809 - /* 810 - * should be called with sta_mtx locked 811 - * this function replaces the mutex lock 812 - * with a RCU lock 813 - */ 814 811 static int sta_info_insert_finish(struct sta_info *sta) __acquires(RCU) 815 812 { 816 813 struct ieee80211_local *local = sta->local; ··· 813 820 struct station_info *sinfo = NULL; 814 821 int err = 0; 815 822 816 - lockdep_assert_held(&local->sta_mtx); 823 + lockdep_assert_wiphy(local->hw.wiphy); 817 824 818 825 /* check if STA exists already */ 819 826 if (sta_info_get_bss(sdata, sta->sta.addr)) { ··· 877 884 struct link_sta_info *link_sta; 878 885 879 886 link_sta = rcu_dereference_protected(sta->link[i], 880 - lockdep_is_held(&local->sta_mtx)); 887 + lockdep_is_held(&local->hw.wiphy->mtx)); 881 888 882 889 if (!link_sta) 883 890 continue; ··· 899 906 900 907 /* move reference to rcu-protected */ 901 908 rcu_read_lock(); 902 - mutex_unlock(&local->sta_mtx); 903 909 904 910 if (ieee80211_vif_is_mesh(&sdata->vif)) 905 911 mesh_accept_plinks_update(sdata); ··· 914 922 synchronize_net(); 915 923 out_cleanup: 916 924 cleanup_single_sta(sta); 917 - mutex_unlock(&local->sta_mtx); 918 925 kfree(sinfo); 919 926 rcu_read_lock(); 920 927 return err; ··· 925 934 int err; 926 935 927 936 might_sleep(); 928 - 929 - mutex_lock(&local->sta_mtx); 937 + lockdep_assert_wiphy(local->hw.wiphy); 930 938 931 939 err = sta_info_insert_check(sta); 932 940 if (err) { 933 941 sta_info_free(local, sta); 934 - mutex_unlock(&local->sta_mtx); 935 942 rcu_read_lock(); 936 943 return err; 937 944 } ··· 1208 1219 local = sta->local; 1209 1220 sdata = sta->sdata; 1210 1221 1211 - lockdep_assert_held(&local->sta_mtx); 1222 + lockdep_assert_wiphy(local->hw.wiphy); 1212 1223 1213 1224 /* 1214 1225 * Before removing the station from the driver and ··· 1233 1244 continue; 1234 1245 1235 1246 link_sta = rcu_dereference_protected(sta->link[i], 1236 - lockdep_is_held(&local->sta_mtx)); 1247 + lockdep_is_held(&local->hw.wiphy->mtx)); 1237 1248 1238 1249 link_sta_info_hash_del(local, link_sta); 1239 1250 } ··· 1387 1398 */ 1388 1399 1389 1400 might_sleep(); 1390 - lockdep_assert_held(&local->sta_mtx); 1401 + lockdep_assert_wiphy(local->hw.wiphy); 1391 1402 1392 1403 if (sta->sta_state == IEEE80211_STA_AUTHORIZED) { 1393 1404 ret = _sta_info_move_state(sta, IEEE80211_STA_ASSOC, recalc); ··· 1463 1474 int sta_info_destroy_addr(struct ieee80211_sub_if_data *sdata, const u8 *addr) 1464 1475 { 1465 1476 struct sta_info *sta; 1466 - int ret; 1467 1477 1468 - mutex_lock(&sdata->local->sta_mtx); 1478 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 1479 + 1469 1480 sta = sta_info_get(sdata, addr); 1470 - ret = __sta_info_destroy(sta); 1471 - mutex_unlock(&sdata->local->sta_mtx); 1472 - 1473 - return ret; 1481 + return __sta_info_destroy(sta); 1474 1482 } 1475 1483 1476 1484 int sta_info_destroy_addr_bss(struct ieee80211_sub_if_data *sdata, 1477 1485 const u8 *addr) 1478 1486 { 1479 1487 struct sta_info *sta; 1480 - int ret; 1481 1488 1482 - mutex_lock(&sdata->local->sta_mtx); 1489 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 1490 + 1483 1491 sta = sta_info_get_bss(sdata, addr); 1484 - ret = __sta_info_destroy(sta); 1485 - mutex_unlock(&sdata->local->sta_mtx); 1486 - 1487 - return ret; 1492 + return __sta_info_destroy(sta); 1488 1493 } 1489 1494 1490 1495 static void sta_info_cleanup(struct timer_list *t) ··· 1518 1535 } 1519 1536 1520 1537 spin_lock_init(&local->tim_lock); 1521 - mutex_init(&local->sta_mtx); 1522 1538 INIT_LIST_HEAD(&local->sta_list); 1523 1539 1524 1540 timer_setup(&local->sta_cleanup, sta_info_cleanup, 0); ··· 1540 1558 int ret = 0; 1541 1559 1542 1560 might_sleep(); 1561 + lockdep_assert_wiphy(local->hw.wiphy); 1543 1562 1544 1563 WARN_ON(vlans && sdata->vif.type != NL80211_IFTYPE_AP); 1545 1564 WARN_ON(vlans && !sdata->bss); 1546 1565 1547 - mutex_lock(&local->sta_mtx); 1548 1566 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { 1549 1567 if (sdata == sta->sdata || 1550 1568 (vlans && sdata->bss == sta->sdata->bss)) { ··· 1568 1586 if (!support_p2p_ps) 1569 1587 ieee80211_recalc_p2p_go_ps_allowed(sdata); 1570 1588 } 1571 - mutex_unlock(&local->sta_mtx); 1572 1589 1573 1590 return ret; 1574 1591 } ··· 1578 1597 struct ieee80211_local *local = sdata->local; 1579 1598 struct sta_info *sta, *tmp; 1580 1599 1581 - mutex_lock(&local->sta_mtx); 1600 + lockdep_assert_wiphy(local->hw.wiphy); 1582 1601 1583 1602 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { 1584 1603 unsigned long last_active = ieee80211_sta_last_active(sta); ··· 1597 1616 WARN_ON(__sta_info_destroy(sta)); 1598 1617 } 1599 1618 } 1600 - 1601 - mutex_unlock(&local->sta_mtx); 1602 1619 } 1603 1620 1604 1621 struct ieee80211_sta *ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw, ··· 2851 2872 struct sta_link_alloc *alloc; 2852 2873 int ret; 2853 2874 2854 - lockdep_assert_held(&sdata->local->sta_mtx); 2875 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 2855 2876 2856 2877 /* must represent an MLD from the start */ 2857 2878 if (WARN_ON(!sta->sta.valid_links)) ··· 2880 2901 2881 2902 void ieee80211_sta_free_link(struct sta_info *sta, unsigned int link_id) 2882 2903 { 2883 - lockdep_assert_held(&sta->sdata->local->sta_mtx); 2904 + lockdep_assert_wiphy(sta->sdata->local->hw.wiphy); 2884 2905 2885 2906 sta_remove_link(sta, link_id, false); 2886 2907 } ··· 2894 2915 int ret; 2895 2916 2896 2917 link_sta = rcu_dereference_protected(sta->link[link_id], 2897 - lockdep_is_held(&sdata->local->sta_mtx)); 2918 + lockdep_is_held(&sdata->local->hw.wiphy->mtx)); 2898 2919 2899 2920 if (WARN_ON(old_links == new_links || !link_sta)) 2900 2921 return -EINVAL; ··· 2938 2959 struct ieee80211_sub_if_data *sdata = sta->sdata; 2939 2960 u16 old_links = sta->sta.valid_links; 2940 2961 2941 - lockdep_assert_held(&sdata->local->sta_mtx); 2962 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 2942 2963 2943 2964 sta->sta.valid_links &= ~BIT(link_id); 2944 2965 ··· 2977 2998 { 2978 2999 struct sta_info *sta = container_of(pubsta, struct sta_info, sta); 2979 3000 2980 - return lockdep_is_held(&sta->local->sta_mtx); 3001 + return lockdep_is_held(&sta->local->hw.wiphy->mtx); 2981 3002 } 2982 3003 EXPORT_SYMBOL(lockdep_sta_mutex_held); 2983 3004 #endif
+1 -1
net/mac80211/sta_info.h
··· 827 827 struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata, 828 828 const u8 *addr); 829 829 830 - /* user must hold sta_mtx or be in RCU critical section */ 830 + /* user must hold wiphy mutex or be in RCU critical section */ 831 831 struct sta_info *sta_info_get_by_addrs(struct ieee80211_local *local, 832 832 const u8 *sta_addr, const u8 *vif_addr); 833 833
+9 -17
net/mac80211/tdls.c
··· 1479 1479 break; 1480 1480 } 1481 1481 1482 - mutex_lock(&local->sta_mtx); 1482 + lockdep_assert_wiphy(local->hw.wiphy); 1483 1483 sta = sta_info_get(sdata, peer); 1484 1484 if (!sta) { 1485 - mutex_unlock(&local->sta_mtx); 1486 1485 ret = -ENOLINK; 1487 1486 break; 1488 1487 } ··· 1490 1491 iee80211_tdls_recalc_ht_protection(sdata, sta); 1491 1492 1492 1493 set_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH); 1493 - mutex_unlock(&local->sta_mtx); 1494 1494 1495 1495 WARN_ON_ONCE(is_zero_ether_addr(sdata->u.mgd.tdls_peer) || 1496 1496 !ether_addr_equal(sdata->u.mgd.tdls_peer, peer)); ··· 1512 1514 1513 1515 ret = sta_info_destroy_addr(sdata, peer); 1514 1516 1515 - mutex_lock(&local->sta_mtx); 1517 + lockdep_assert_wiphy(local->hw.wiphy); 1516 1518 iee80211_tdls_recalc_ht_protection(sdata, NULL); 1517 - mutex_unlock(&local->sta_mtx); 1518 1519 1519 1520 iee80211_tdls_recalc_chanctx(sdata, NULL); 1520 1521 break; ··· 1671 1674 /* this may work, but is untested */ 1672 1675 return -EOPNOTSUPP; 1673 1676 1674 - mutex_lock(&local->sta_mtx); 1677 + lockdep_assert_wiphy(local->hw.wiphy); 1675 1678 sta = sta_info_get(sdata, addr); 1676 1679 if (!sta) { 1677 1680 tdls_dbg(sdata, ··· 1701 1704 set_sta_flag(sta, WLAN_STA_TDLS_OFF_CHANNEL); 1702 1705 1703 1706 out: 1704 - mutex_unlock(&local->sta_mtx); 1705 1707 dev_kfree_skb_any(skb); 1706 1708 return ret; 1707 1709 } ··· 1714 1718 struct ieee80211_local *local = sdata->local; 1715 1719 struct sta_info *sta; 1716 1720 1717 - mutex_lock(&local->sta_mtx); 1721 + lockdep_assert_wiphy(local->hw.wiphy); 1722 + 1718 1723 sta = sta_info_get(sdata, addr); 1719 1724 if (!sta) { 1720 1725 tdls_dbg(sdata, 1721 1726 "Invalid TDLS peer %pM for channel switch cancel\n", 1722 1727 addr); 1723 - goto out; 1728 + return; 1724 1729 } 1725 1730 1726 1731 if (!test_sta_flag(sta, WLAN_STA_TDLS_OFF_CHANNEL)) { 1727 1732 tdls_dbg(sdata, "TDLS channel switch not initiated by %pM\n", 1728 1733 addr); 1729 - goto out; 1734 + return; 1730 1735 } 1731 1736 1732 1737 drv_tdls_cancel_channel_switch(local, sdata, &sta->sta); 1733 1738 clear_sta_flag(sta, WLAN_STA_TDLS_OFF_CHANNEL); 1734 - 1735 - out: 1736 - mutex_unlock(&local->sta_mtx); 1737 1739 } 1738 1740 1739 1741 static struct sk_buff * ··· 1802 1808 return -EINVAL; 1803 1809 } 1804 1810 1805 - mutex_lock(&local->sta_mtx); 1811 + lockdep_assert_wiphy(local->hw.wiphy); 1806 1812 sta = sta_info_get(sdata, tf->sa); 1807 1813 if (!sta || !test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH)) { 1808 1814 tdls_dbg(sdata, "TDLS chan switch from non-peer sta %pM\n", ··· 1865 1871 tf->sa, params.status); 1866 1872 1867 1873 out: 1868 - mutex_unlock(&local->sta_mtx); 1869 1874 dev_kfree_skb_any(params.tmpl_skb); 1870 1875 kfree(elems); 1871 1876 return ret; ··· 1978 1985 goto free; 1979 1986 } 1980 1987 1981 - mutex_lock(&local->sta_mtx); 1988 + lockdep_assert_wiphy(local->hw.wiphy); 1982 1989 sta = sta_info_get(sdata, tf->sa); 1983 1990 if (!sta || !test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH)) { 1984 1991 tdls_dbg(sdata, "TDLS chan switch from non-peer sta %pM\n", ··· 2025 2032 tf->sa, params.chandef->chan->center_freq, 2026 2033 params.chandef->width); 2027 2034 out: 2028 - mutex_unlock(&local->sta_mtx); 2029 2035 dev_kfree_skb_any(params.tmpl_skb); 2030 2036 free: 2031 2037 kfree(elems);
+2 -2
net/mac80211/tx.c
··· 5927 5927 int ret; 5928 5928 u32 queues; 5929 5929 5930 - lockdep_assert_held(&local->sta_mtx); 5930 + lockdep_assert_wiphy(local->hw.wiphy); 5931 5931 5932 5932 /* only some cases are supported right now */ 5933 5933 switch (sdata->vif.type) { ··· 5988 5988 struct sta_info *sta = container_of(pubsta, struct sta_info, sta); 5989 5989 struct ieee80211_sub_if_data *sdata = sta->sdata; 5990 5990 5991 - lockdep_assert_held(&sdata->local->sta_mtx); 5991 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 5992 5992 5993 5993 /* only some cases are supported right now */ 5994 5994 switch (sdata->vif.type) {
+2 -5
net/mac80211/util.c
··· 2411 2411 struct sta_info *sta; 2412 2412 2413 2413 /* add STAs back */ 2414 - mutex_lock(&local->sta_mtx); 2414 + lockdep_assert_wiphy(local->hw.wiphy); 2415 2415 list_for_each_entry(sta, &local->sta_list, list) { 2416 2416 enum ieee80211_sta_state state; 2417 2417 ··· 2423 2423 WARN_ON(drv_sta_state(local, sta->sdata, sta, state, 2424 2424 state + 1)); 2425 2425 } 2426 - mutex_unlock(&local->sta_mtx); 2427 2426 } 2428 2427 2429 2428 static int ieee80211_reconfig_nan(struct ieee80211_sub_if_data *sdata) ··· 2901 2902 * are active. This is really a workaround though. 2902 2903 */ 2903 2904 if (ieee80211_hw_check(hw, AMPDU_AGGREGATION)) { 2904 - mutex_lock(&local->sta_mtx); 2905 + lockdep_assert_wiphy(local->hw.wiphy); 2905 2906 2906 2907 list_for_each_entry(sta, &local->sta_list, list) { 2907 2908 if (!local->resuming) ··· 2909 2910 sta, AGG_STOP_LOCAL_REQUEST); 2910 2911 clear_sta_flag(sta, WLAN_STA_BLOCK_BA); 2911 2912 } 2912 - 2913 - mutex_unlock(&local->sta_mtx); 2914 2913 } 2915 2914 2916 2915 /*