]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: iwlwifi: mvm: fix P2P-Device binding handling
authorJohannes Berg <johannes.berg@intel.com>
Wed, 27 May 2026 20:05:11 +0000 (23:05 +0300)
committerMiri Korenblit <miriam.rachel.korenblit@intel.com>
Wed, 3 Jun 2026 14:02:55 +0000 (17:02 +0300)
Our binding handling for P2P-Device can run into the following
scenario, as observed by our testing:

 - a station interface is connected on some channel
 - the P2P-Device does a remain-on-channel (ROC) on that channel
 - the ROC ends, and the P2P-Device is removed from the binding,
   but the phy_ctxt pointer is left around as a PHY cache so we
   don't need to recalibrate to the channel again and again in
   case it's not shared
 - a binding update by the station interface, even a removal,
   will re-add the P2P-Device to the binding
 - the P2P-Device is removed, which removes the PHY context, but
   it's still in the binding so the firmware crashes

Since the P2P device is removed from the binding and only re-
added by unrelated code, but we want to keep the phy_ctxt around
as a cache for future ROC usage, fix it by adding a boolean that
indicates whether or not the P2P-Device should be added to the
binding, and handle that in the binding iterator. That way, the
station interface cannot re-add the P2P-Device to the binding
when that isn't active.

Assisted-by: Github Copilot:claude-opus-4-6
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Link: https://patch.msgid.link/20260527230313.07f94335ae06.I384238b0859343c4a9a9dda20682be1aad89cc9d@changeid
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/binding.c
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
drivers/net/wireless/intel/iwlwifi/mvm/time-event.c

index 58e9a940024db7a84fe2aaff2b44c9ac5e898bd0..0812522edea0de809d9001583b72cfde25e740b2 100644 (file)
@@ -2,7 +2,7 @@
 /*
  * Copyright (C) 2012-2014, 2020 Intel Corporation
  * Copyright (C) 2016 Intel Deutschland GmbH
- * Copyright (C) 2022, 2024 Intel Corporation
+ * Copyright (C) 2022, 2024, 2026 Intel Corporation
  */
 #include <net/mac80211.h>
 #include "fw-api.h"
@@ -76,6 +76,9 @@ static void iwl_mvm_iface_iterator(void *_data, u8 *mac,
        if (vif == data->ignore_vif)
                return;
 
+       if (vif->type == NL80211_IFTYPE_P2P_DEVICE && !mvmvif->p2p_in_binding)
+               return;
+
        if (mvmvif->deflink.phy_ctxt != data->phyctxt)
                return;
 
index c256cbc6602e2b128f0b20763dad85881ec2a5eb..74bd4038fd5601458dda710c669adea67db0b3a1 100644 (file)
@@ -1104,6 +1104,7 @@ static void iwl_mvm_cleanup_iterator(void *data, u8 *mac,
        spin_unlock_bh(&mvm->time_event_lock);
 
        mvmvif->roc_activity = ROC_NUM_ACTIVITIES;
+       mvmvif->p2p_in_binding = false;
 
        mvmvif->bf_enabled = false;
        mvmvif->ba_enabled = false;
@@ -4634,6 +4635,7 @@ static int iwl_mvm_add_aux_sta_for_hs20(struct iwl_mvm *mvm, u32 lmac_id)
 
 static int iwl_mvm_roc_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
 {
+       struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
        int ret;
 
        lockdep_assert_held(&mvm->mutex);
@@ -4642,10 +4644,18 @@ static int iwl_mvm_roc_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
        if (WARN(ret, "Failed binding P2P_DEVICE\n"))
                return ret;
 
+       mvmvif->p2p_in_binding = true;
+
        /* The station and queue allocation must be done only after the binding
         * is done, as otherwise the FW might incorrectly configure its state.
         */
-       return iwl_mvm_add_p2p_bcast_sta(mvm, vif);
+       ret = iwl_mvm_add_p2p_bcast_sta(mvm, vif);
+       if (ret) {
+               iwl_mvm_binding_remove_vif(mvm, vif);
+               mvmvif->p2p_in_binding = false;
+       }
+
+       return ret;
 }
 
 static int iwl_mvm_roc(struct ieee80211_hw *hw,
index e09b63516230993f8ea181071780e77bd0d425ef..6bf71092faa1595d928f6f5a34b6b6b3ecd80adb 100644 (file)
@@ -383,6 +383,8 @@ struct iwl_mvm_vif_link_info {
  * @pm_enabled: indicates powersave is enabled
  * @roc_activity: currently running ROC activity for this vif (or
  *     ROC_NUM_ACTIVITIES if no activity is running).
+ * @p2p_in_binding: indicates that this P2P-Device interface should be
+ *     added to the binding, i.e. is running ROC right now
  * @session_prot_connection_loss: the connection was lost due to session
  *     protection ending without receiving a beacon, so we need to now
  *     protect the deauth separately
@@ -492,6 +494,7 @@ struct iwl_mvm_vif {
        struct iwl_mvm_time_event_data time_event_data;
        struct iwl_mvm_time_event_data hs_time_event_data;
        enum iwl_roc_activity roc_activity;
+       bool p2p_in_binding;
 
        /* TCP Checksum Offload */
        netdev_features_t features;
index 2b52a4f3bff983f22682d2e843eec254ee071d05..1692b6e75f579d68201ad22ff7bb87cd93a86b2b 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
- * Copyright (C) 2012-2014, 2018-2025 Intel Corporation
+ * Copyright (C) 2012-2014, 2018-2026 Intel Corporation
  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
  * Copyright (C) 2017 Intel Deutschland GmbH
  */
@@ -88,6 +88,7 @@ static void iwl_mvm_cleanup_roc(struct iwl_mvm *mvm)
                        } else {
                                iwl_mvm_rm_p2p_bcast_sta(mvm, vif);
                                iwl_mvm_binding_remove_vif(mvm, vif);
+                               mvmvif->p2p_in_binding = false;
                        }
 
                        /* Do not remove the PHY context as removing and adding