Skip to content

Commit a32a849

Browse files
egrumbachjmberg-intel
authored andcommitted
wifi: iwlwifi: mvm: fold the ref++ into iwl_mvm_phy_ctxt_add
When we want to add a phy_ctxt, we need to increase the ref. Note that all the WARN_ONs are already in place: * We check that we don't add a context with ref != 0 * We check that we don't modify a context with ref = 0 Signed-off-by: Emmanuel Grumbach <[email protected]> Signed-off-by: Gregory Greenman <[email protected]> Link: https://lore.kernel.org/r/20231011130030.c19c07746b26.I5b0cbe0760811631a320218a10b88870b5bf0897@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent f3276ff commit a32a849

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4716,7 +4716,6 @@ int iwl_mvm_roc_common(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
47164716
goto out_unlock;
47174717
}
47184718

4719-
iwl_mvm_phy_ctxt_ref(mvm, mvmvif->deflink.phy_ctxt);
47204719
goto link_and_start_p2p_roc;
47214720
}
47224721

@@ -4812,7 +4811,6 @@ static int __iwl_mvm_add_chanctx(struct iwl_mvm *mvm,
48124811
goto out;
48134812
}
48144813

4815-
iwl_mvm_phy_ctxt_ref(mvm, phy_ctxt);
48164814
*phy_ctxt_id = phy_ctxt->id;
48174815
out:
48184816
return ret;

drivers/net/wireless/intel/iwlwifi/mvm/phy-ctxt.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ int iwl_mvm_phy_ctxt_add(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
265265
struct cfg80211_chan_def *chandef,
266266
u8 chains_static, u8 chains_dynamic)
267267
{
268+
int ret;
269+
268270
WARN_ON(!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
269271
ctxt->ref);
270272
lockdep_assert_held(&mvm->mutex);
@@ -273,9 +275,16 @@ int iwl_mvm_phy_ctxt_add(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
273275
ctxt->width = chandef->width;
274276
ctxt->center_freq1 = chandef->center_freq1;
275277

276-
return iwl_mvm_phy_ctxt_apply(mvm, ctxt, chandef,
277-
chains_static, chains_dynamic,
278-
FW_CTXT_ACTION_ADD);
278+
ret = iwl_mvm_phy_ctxt_apply(mvm, ctxt, chandef,
279+
chains_static, chains_dynamic,
280+
FW_CTXT_ACTION_ADD);
281+
282+
if (ret)
283+
return ret;
284+
285+
ctxt->ref++;
286+
287+
return 0;
279288
}
280289

281290
/*
@@ -285,6 +294,11 @@ int iwl_mvm_phy_ctxt_add(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
285294
void iwl_mvm_phy_ctxt_ref(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt)
286295
{
287296
lockdep_assert_held(&mvm->mutex);
297+
298+
/* If we were taking the first ref, we should have
299+
* called iwl_mvm_phy_ctxt_add.
300+
*/
301+
WARN_ON(!ctxt->ref);
288302
ctxt->ref++;
289303
}
290304

0 commit comments

Comments
 (0)