Commit 4d3acf43 authored by Johannes Berg's avatar Johannes Berg
Browse files

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: default avatarJohannes Berg <johannes.berg@intel.com>
parent a26787aa
Loading
Loading
Loading
Loading
+36 −76
Original line number Diff line number Diff line
@@ -214,6 +214,8 @@ static int ieee80211_change_iface(struct wiphy *wiphy,
	struct sta_info *sta;
	int ret;

	lockdep_assert_wiphy(local->hw.wiphy);

	ret = ieee80211_if_change_type(sdata, type);
	if (ret)
		return ret;
@@ -235,12 +237,10 @@ static int ieee80211_change_iface(struct wiphy *wiphy,
		if (!ifmgd->associated)
			return 0;

		mutex_lock(&local->sta_mtx);
		sta = sta_info_get(sdata, sdata->deflink.u.mgd.bssid);
		if (sta)
			drv_sta_set_4addr(local, sdata, &sta->sta,
					  params->use_4addr);
		mutex_unlock(&local->sta_mtx);

		if (params->use_4addr)
			ieee80211_send_4addr_nullfunc(local, sdata);
@@ -472,7 +472,8 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
	struct ieee80211_local *local = sdata->local;
	struct sta_info *sta = NULL;
	struct ieee80211_key *key;
	int err;

	lockdep_assert_wiphy(local->hw.wiphy);

	if (!ieee80211_sdata_running(sdata))
		return -ENETDOWN;
@@ -510,8 +511,6 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
	if (params->mode == NL80211_KEY_NO_TX)
		key->conf.flags |= IEEE80211_KEY_FLAG_NO_AUTO_TX;

	mutex_lock(&local->sta_mtx);

	if (mac_addr) {
		sta = sta_info_get_bss(sdata, mac_addr);
		/*
@@ -526,8 +525,7 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
		 */
		if (!sta || !test_sta_flag(sta, WLAN_STA_ASSOC)) {
			ieee80211_key_free_unused(key);
			err = -ENOENT;
			goto out_unlock;
			return -ENOENT;
		}
	}

@@ -565,12 +563,7 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
		break;
	}

	err = ieee80211_key_link(key, link, sta);

 out_unlock:
	mutex_unlock(&local->sta_mtx);

	return err;
	return ieee80211_key_link(key, link, sta);
}

static struct ieee80211_key *
@@ -598,7 +591,7 @@ ieee80211_lookup_key(struct ieee80211_sub_if_data *sdata, int link_id,

		if (link_id >= 0) {
			link_sta = rcu_dereference_check(sta->link[link_id],
							 lockdep_is_held(&local->sta_mtx));
							 lockdep_is_held(&local->hw.wiphy->mtx));
			if (!link_sta)
				return NULL;
		} else {
@@ -643,7 +636,8 @@ static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
	struct ieee80211_key *key;
	int ret;

	mutex_lock(&local->sta_mtx);
	lockdep_assert_wiphy(local->hw.wiphy);

	mutex_lock(&local->key_mtx);

	key = ieee80211_lookup_key(sdata, link_id, key_idx, pairwise, mac_addr);
@@ -657,7 +651,6 @@ static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
	ret = 0;
 out_unlock:
	mutex_unlock(&local->key_mtx);
	mutex_unlock(&local->sta_mtx);

	return ret;
}
@@ -860,7 +853,7 @@ static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
	struct sta_info *sta;
	int ret = -ENOENT;

	mutex_lock(&local->sta_mtx);
	lockdep_assert_wiphy(local->hw.wiphy);

	sta = sta_info_get_by_idx(sdata, idx);
	if (sta) {
@@ -869,8 +862,6 @@ static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
		sta_set_sinfo(sta, sinfo, true);
	}

	mutex_unlock(&local->sta_mtx);

	return ret;
}

@@ -890,7 +881,7 @@ static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
	struct sta_info *sta;
	int ret = -ENOENT;

	mutex_lock(&local->sta_mtx);
	lockdep_assert_wiphy(local->hw.wiphy);

	sta = sta_info_get_bss(sdata, mac);
	if (sta) {
@@ -898,8 +889,6 @@ static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
		sta_set_sinfo(sta, sinfo, true);
	}

	mutex_unlock(&local->sta_mtx);

	return ret;
}

@@ -1800,7 +1789,7 @@ static int sta_link_apply_parameters(struct ieee80211_local *local,
		sdata_dereference(sdata->link[link_id], sdata);
	struct link_sta_info *link_sta =
		rcu_dereference_protected(sta->link[link_id],
					  lockdep_is_held(&local->sta_mtx));
					  lockdep_is_held(&local->hw.wiphy->mtx));

	/*
	 * If there are no changes, then accept a link that doesn't exist,
@@ -2034,6 +2023,8 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
	struct ieee80211_sub_if_data *sdata;
	int err;

	lockdep_assert_wiphy(local->hw.wiphy);

	if (params->vlan) {
		sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);

@@ -2077,9 +2068,7 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
	 * visible yet), sta_apply_parameters (and inner functions) require
	 * the mutex due to other paths.
	 */
	mutex_lock(&local->sta_mtx);
	err = sta_apply_parameters(local, sta, params);
	mutex_unlock(&local->sta_mtx);
	if (err) {
		sta_info_free(local, sta);
		return err;
@@ -2122,13 +2111,11 @@ static int ieee80211_change_station(struct wiphy *wiphy,
	enum cfg80211_station_type statype;
	int err;

	mutex_lock(&local->sta_mtx);
	lockdep_assert_wiphy(local->hw.wiphy);

	sta = sta_info_get_bss(sdata, mac);
	if (!sta) {
		err = -ENOENT;
		goto out_err;
	}
	if (!sta)
		return -ENOENT;

	switch (sdata->vif.type) {
	case NL80211_IFTYPE_MESH_POINT:
@@ -2158,22 +2145,19 @@ static int ieee80211_change_station(struct wiphy *wiphy,
			statype = CFG80211_STA_AP_CLIENT_UNASSOC;
		break;
	default:
		err = -EOPNOTSUPP;
		goto out_err;
		return -EOPNOTSUPP;
	}

	err = cfg80211_check_station_change(wiphy, params, statype);
	if (err)
		goto out_err;
		return err;

	if (params->vlan && params->vlan != sta->sdata->dev) {
		vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);

		if (params->vlan->ieee80211_ptr->use_4addr) {
			if (vlansdata->u.vlan.sta) {
				err = -EBUSY;
				goto out_err;
			}
			if (vlansdata->u.vlan.sta)
				return -EBUSY;

			rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
			__ieee80211_check_fast_rx_iface(vlansdata);
@@ -2208,9 +2192,7 @@ static int ieee80211_change_station(struct wiphy *wiphy,
		err = sta_apply_parameters(local, sta, params);
	}
	if (err)
		goto out_err;

	mutex_unlock(&local->sta_mtx);
		return err;

	if (sdata->vif.type == NL80211_IFTYPE_STATION &&
	    params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
@@ -2219,9 +2201,6 @@ static int ieee80211_change_station(struct wiphy *wiphy,
	}

	return 0;
out_err:
	mutex_unlock(&local->sta_mtx);
	return err;
}

#ifdef CONFIG_MAC80211_MESH
@@ -4566,7 +4545,8 @@ static int ieee80211_set_tid_config(struct wiphy *wiphy,
{
	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
	struct sta_info *sta;
	int ret;

	lockdep_assert_wiphy(sdata->local->hw.wiphy);

	if (!sdata->local->ops->set_tid_config)
		return -EOPNOTSUPP;
@@ -4574,17 +4554,11 @@ static int ieee80211_set_tid_config(struct wiphy *wiphy,
	if (!tid_conf->peer)
		return drv_set_tid_config(sdata->local, sdata, NULL, tid_conf);

	mutex_lock(&sdata->local->sta_mtx);
	sta = sta_info_get_bss(sdata, tid_conf->peer);
	if (!sta) {
		mutex_unlock(&sdata->local->sta_mtx);
	if (!sta)
		return -ENOENT;
	}

	ret = drv_set_tid_config(sdata->local, sdata, &sta->sta, tid_conf);
	mutex_unlock(&sdata->local->sta_mtx);

	return ret;
	return drv_set_tid_config(sdata->local, sdata, &sta->sta, tid_conf);
}

static int ieee80211_reset_tid_config(struct wiphy *wiphy,
@@ -4593,7 +4567,8 @@ static int ieee80211_reset_tid_config(struct wiphy *wiphy,
{
	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
	struct sta_info *sta;
	int ret;

	lockdep_assert_wiphy(sdata->local->hw.wiphy);

	if (!sdata->local->ops->reset_tid_config)
		return -EOPNOTSUPP;
@@ -4601,17 +4576,11 @@ static int ieee80211_reset_tid_config(struct wiphy *wiphy,
	if (!peer)
		return drv_reset_tid_config(sdata->local, sdata, NULL, tids);

	mutex_lock(&sdata->local->sta_mtx);
	sta = sta_info_get_bss(sdata, peer);
	if (!sta) {
		mutex_unlock(&sdata->local->sta_mtx);
	if (!sta)
		return -ENOENT;
	}

	ret = drv_reset_tid_config(sdata->local, sdata, &sta->sta, tids);
	mutex_unlock(&sdata->local->sta_mtx);

	return ret;
	return drv_reset_tid_config(sdata->local, sdata, &sta->sta, tids);
}

static int ieee80211_set_sar_specs(struct wiphy *wiphy,
@@ -4937,13 +4906,10 @@ ieee80211_add_link_station(struct wiphy *wiphy, struct net_device *dev,
{
	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
	struct ieee80211_local *local = wiphy_priv(wiphy);
	int ret;

	mutex_lock(&sdata->local->sta_mtx);
	ret = sta_add_link_station(local, sdata, params);
	mutex_unlock(&sdata->local->sta_mtx);
	lockdep_assert_wiphy(sdata->local->hw.wiphy);

	return ret;
	return sta_add_link_station(local, sdata, params);
}

static int sta_mod_link_station(struct ieee80211_local *local,
@@ -4968,13 +4934,10 @@ ieee80211_mod_link_station(struct wiphy *wiphy, struct net_device *dev,
{
	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
	struct ieee80211_local *local = wiphy_priv(wiphy);
	int ret;

	mutex_lock(&sdata->local->sta_mtx);
	ret = sta_mod_link_station(local, sdata, params);
	mutex_unlock(&sdata->local->sta_mtx);
	lockdep_assert_wiphy(sdata->local->hw.wiphy);

	return ret;
	return sta_mod_link_station(local, sdata, params);
}

static int sta_del_link_station(struct ieee80211_sub_if_data *sdata,
@@ -5003,13 +4966,10 @@ ieee80211_del_link_station(struct wiphy *wiphy, struct net_device *dev,
			   struct link_station_del_parameters *params)
{
	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
	int ret;

	mutex_lock(&sdata->local->sta_mtx);
	ret = sta_del_link_station(sdata, params);
	mutex_unlock(&sdata->local->sta_mtx);
	lockdep_assert_wiphy(sdata->local->hw.wiphy);

	return ret;
	return sta_del_link_station(sdata, params);
}

static int ieee80211_set_hw_timestamp(struct wiphy *wiphy,
+3 −2
Original line number Diff line number Diff line
@@ -288,10 +288,10 @@ static ssize_t aql_txq_limit_write(struct file *file,
	q_limit_low_old = local->aql_txq_limit_low[ac];
	q_limit_high_old = local->aql_txq_limit_high[ac];

	wiphy_lock(local->hw.wiphy);
	local->aql_txq_limit_low[ac] = q_limit_low;
	local->aql_txq_limit_high[ac] = q_limit_high;

	mutex_lock(&local->sta_mtx);
	list_for_each_entry(sta, &local->sta_list, list) {
		/* If a sta has customized queue limits, keep it */
		if (sta->airtime[ac].aql_limit_low == q_limit_low_old &&
@@ -300,7 +300,8 @@ static ssize_t aql_txq_limit_write(struct file *file,
			sta->airtime[ac].aql_limit_high = q_limit_high;
		}
	}
	mutex_unlock(&local->sta_mtx);
	wiphy_unlock(local->hw.wiphy);

	return count;
}

+2 −2
Original line number Diff line number Diff line
@@ -569,7 +569,7 @@ int drv_change_sta_links(struct ieee80211_local *local,

	for_each_set_bit(link_id, &links_to_rem, IEEE80211_MLD_MAX_NUM_LINKS) {
		link_sta = rcu_dereference_protected(info->link[link_id],
						     lockdep_is_held(&local->sta_mtx));
						     lockdep_is_held(&local->hw.wiphy->mtx));

		ieee80211_link_sta_debugfs_drv_remove(link_sta);
	}
@@ -585,7 +585,7 @@ int drv_change_sta_links(struct ieee80211_local *local,

	for_each_set_bit(link_id, &links_to_add, IEEE80211_MLD_MAX_NUM_LINKS) {
		link_sta = rcu_dereference_protected(info->link[link_id],
						     lockdep_is_held(&local->sta_mtx));
						     lockdep_is_held(&local->hw.wiphy->mtx));
		ieee80211_link_sta_debugfs_drv_add(link_sta);
	}

+0 −3
Original line number Diff line number Diff line
@@ -103,7 +103,6 @@ static void ieee80211_get_stats(struct net_device *dev,
	 */

	wiphy_lock(local->hw.wiphy);
	mutex_lock(&local->sta_mtx);

	if (sdata->vif.type == NL80211_IFTYPE_STATION) {
		sta = sta_info_get_bss(sdata, sdata->deflink.u.mgd.bssid);
@@ -199,8 +198,6 @@ static void ieee80211_get_stats(struct net_device *dev,
	else
		data[i++] = -1LL;

	mutex_unlock(&local->sta_mtx);

	if (WARN_ON(i != STA_STATS_LEN)) {
		wiphy_unlock(local->hw.wiphy);
		return;
+1 −3
Original line number Diff line number Diff line
@@ -1257,7 +1257,7 @@ static void ieee80211_ibss_sta_expire(struct ieee80211_sub_if_data *sdata)
	unsigned long exp_time = IEEE80211_IBSS_INACTIVITY_LIMIT;
	unsigned long exp_rsn = IEEE80211_IBSS_RSN_INACTIVITY_LIMIT;

	mutex_lock(&local->sta_mtx);
	lockdep_assert_wiphy(local->hw.wiphy);

	list_for_each_entry_safe(sta, tmp, &local->sta_list, list) {
		unsigned long last_active = ieee80211_sta_last_active(sta);
@@ -1282,8 +1282,6 @@ static void ieee80211_ibss_sta_expire(struct ieee80211_sub_if_data *sdata)
			WARN_ON(__sta_info_destroy(sta));
		}
	}

	mutex_unlock(&local->sta_mtx);
}

/*
Loading