Преглед изворни кода

qcacmn: Acquire mlo lock before dispatching sync_comp

In MLO scenario where start response for partner ML AP vdevs are
processed simultaneously on different CPU cores, the order in which
the vdev sm lock is acquired may lead to deadlock.

To fix add change to dispatch the MLO_SYNC_COMPLETE under mlo_dev_ctx.

Change-Id: I86ef51fcc8d51277163fcc5a6afdee6d873f2e63
CRs-Fixed: 3368033
Santosh Anbu пре 2 година
родитељ
комит
0f5242e08a

+ 81 - 1
umac/mlo_mgr/inc/wlan_mlo_mgr_main.h

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -517,6 +517,62 @@ void tsf_recalculation_lock_release(struct wlan_mlo_dev_context *mldev)
 {
 	qdf_spin_unlock_bh(&mldev->tsf_recalculation_lock);
 }
+
+/**
+ * mlo_ap_lock_create - Create MLO AP mutex/spinlock
+ * @ap_ctx:  ML device AP context
+ *
+ * Creates mutex/spinlock
+ *
+ * Return: void
+ */
+static inline
+void mlo_ap_lock_create(struct wlan_mlo_ap *ap_ctx)
+{
+	qdf_spinlock_create(&ap_ctx->mlo_ap_lock);
+}
+
+/**
+ * mlo_ap_lock_destroy - Destroy MLO AP mutex/spinlock
+ * @ap_ctx:  ML device AP context
+ *
+ * Destroy mutex/spinlock
+ *
+ * Return: void
+ */
+static inline
+void mlo_ap_lock_destroy(struct wlan_mlo_ap *ap_ctx)
+{
+	qdf_spinlock_destroy(&ap_ctx->mlo_ap_lock);
+}
+
+/**
+ * mlo_ap_lock_acquire - Acquire MLO AP mutex/spinlock
+ * @ap_ctx:  ML device AP context
+ *
+ * acquire mutex/spinlock
+ *
+ * return: void
+ */
+static inline
+void mlo_ap_lock_acquire(struct wlan_mlo_ap *ap_ctx)
+{
+	qdf_spin_lock_bh(&ap_ctx->mlo_ap_lock);
+}
+
+/**
+ * mlo_ap_lock_release - Release MLO AP mutex/spinlock
+ * @ap_ctx:  ML device AP context
+ *
+ * release mutex/spinlock
+ *
+ * return: void
+ */
+static inline
+void mlo_ap_lock_release(struct wlan_mlo_ap *ap_ctx)
+{
+	qdf_spin_unlock_bh(&ap_ctx->mlo_ap_lock);
+}
 #else /* WLAN_MLO_USE_SPINLOCK */
 static inline
 void ml_link_lock_create(struct mlo_mgr_context *mlo_ctx)
@@ -739,6 +795,30 @@ void tsf_recalculation_lock_release(struct wlan_mlo_dev_context *mldev)
 {
 	qdf_mutex_release(&mldev->tsf_recalculation_lock);
 }
+
+static inline
+void mlo_ap_lock_create(struct wlan_mlo_ap *ap_ctx)
+{
+	qdf_mutex_create(&ap_ctx->mlo_ap_lock);
+}
+
+static inline
+void mlo_ap_lock_destroy(struct wlan_mlo_ap *ap_ctx)
+{
+	qdf_mutex_destroy(&ap_ctx->mlo_ap_lock);
+}
+
+static inline
+void mlo_ap_lock_acquire(struct wlan_mlo_ap *ap_ctx)
+{
+	qdf_mutex_acquire(&ap_ctx->mlo_ap_lock);
+}
+
+static inline
+void mlo_ap_lock_release(struct wlan_mlo_ap *ap_ctx)
+{
+	qdf_mutex_release(&ap_ctx->mlo_ap_lock);
+}
 #endif /* WLAN_MLO_USE_SPINLOCK */
 
 /**

+ 7 - 1
umac/mlo_mgr/inc/wlan_mlo_mgr_public_structs.h

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -283,11 +283,17 @@ struct wlan_mlo_sta {
  * struct wlan_mlo_ap - MLO AP related info
  * @num_ml_vdevs: number of vdevs to form MLD
  * @ml_aid_mgr: ML AID mgr
+ * @mlo_ap_lock: lock to sync VDEV SM event
  * @mlo_vdev_quiet_bmap: Bitmap of vdevs for which quiet ie needs to enabled
  */
 struct wlan_mlo_ap {
 	uint8_t num_ml_vdevs;
 	struct wlan_ml_vdev_aid_mgr *ml_aid_mgr;
+#ifdef WLAN_MLO_USE_SPINLOCK
+	qdf_spinlock_t mlo_ap_lock;
+#else
+	qdf_mutex_t mlo_ap_lock;
+#endif
 	qdf_bitmap(mlo_vdev_quiet_bmap, WLAN_UMAC_MLO_MAX_VDEVS);
 };
 

+ 3 - 1
umac/mlo_mgr/src/wlan_mlo_mgr_ap.c

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -344,6 +344,7 @@ static bool mlo_handle_link_ready(struct wlan_objmgr_vdev *vdev)
 		return false;
 	}
 
+	mlo_ap_lock_acquire(vdev->mlo_dev_ctx->ap_ctx);
 	for (i = 0; i < num_links; i++) {
 		if (mlo_pre_link_up(vdev_list[i])) {
 			if (vdev_list[i] != vdev)
@@ -355,6 +356,7 @@ static bool mlo_handle_link_ready(struct wlan_objmgr_vdev *vdev)
 		/* Release ref taken as part of mlo_ap_get_vdev_list */
 		mlo_release_vdev_ref(vdev_list[i]);
 	}
+	mlo_ap_lock_release(vdev->mlo_dev_ctx->ap_ctx);
 	return true;
 }
 

+ 2 - 0
umac/mlo_mgr/src/wlan_mlo_mgr_main.c

@@ -345,6 +345,7 @@ g_ml_ref:
 static QDF_STATUS mlo_ap_ctx_deinit(struct wlan_mlo_dev_context *ml_dev)
 {
 	wlan_mlo_vdev_aid_mgr_deinit(ml_dev);
+	mlo_ap_lock_destroy(ml_dev->ap_ctx);
 	qdf_mem_free(ml_dev->ap_ctx);
 	ml_dev->ap_ctx = NULL;
 
@@ -362,6 +363,7 @@ static QDF_STATUS mlo_ap_ctx_init(struct wlan_mlo_dev_context *ml_dev)
 	}
 
 	ml_dev->ap_ctx = ap_ctx;
+	mlo_ap_lock_create(ml_dev->ap_ctx);
 	if (wlan_mlo_vdev_aid_mgr_init(ml_dev) != QDF_STATUS_SUCCESS) {
 		mlo_ap_ctx_deinit(ml_dev);
 		return QDF_STATUS_E_NOMEM;