فهرست منبع

qcacmn: Add a flag to use the right locking scheme

When the flag is enabled, use spinlock else use mutex in TWT code.

Change-Id: I2504a86569e1341ac0e75c24b0c98bd7d949aac0
CRs-Fixed: 3136148
Manoj Ekbote 3 سال پیش
والد
کامیت
27181a9d1e
3فایلهای تغییر یافته به همراه89 افزوده شده و 7 حذف شده
  1. 4 4
      umac/twt/core/src/wlan_twt_common.c
  2. 3 3
      umac/twt/core/src/wlan_twt_objmgr.c
  3. 82 0
      umac/twt/core/src/wlan_twt_priv.h

+ 4 - 4
umac/twt/core/src/wlan_twt_common.c

@@ -420,9 +420,9 @@ wlan_twt_set_peer_capabilities(struct wlan_objmgr_psoc *psoc,
 		return QDF_STATUS_E_FAILURE;
 	}
 
-	qdf_mutex_acquire(&peer_priv->twt_peer_lock);
+	twt_lock_acquire(&peer_priv->twt_peer_lock);
 	peer_priv->peer_capability = peer_cap;
-	qdf_mutex_release(&peer_priv->twt_peer_lock);
+	twt_lock_release(&peer_priv->twt_peer_lock);
 
 	twt_debug("set peer cap: 0x%x", peer_cap);
 	wlan_objmgr_peer_release_ref(peer, WLAN_TWT_ID);
@@ -454,9 +454,9 @@ wlan_twt_get_peer_capabilities(struct wlan_objmgr_psoc *psoc,
 		return QDF_STATUS_E_FAILURE;
 	}
 
-	qdf_mutex_acquire(&peer_priv->twt_peer_lock);
+	twt_lock_acquire(&peer_priv->twt_peer_lock);
 	*peer_cap = peer_priv->peer_capability;
-	qdf_mutex_release(&peer_priv->twt_peer_lock);
+	twt_lock_release(&peer_priv->twt_peer_lock);
 
 	twt_debug("get peer cap: 0x%x", *peer_cap);
 	wlan_objmgr_peer_release_ref(peer, WLAN_TWT_ID);

+ 3 - 3
umac/twt/core/src/wlan_twt_objmgr.c

@@ -144,7 +144,7 @@ wlan_twt_peer_obj_create_handler(struct wlan_objmgr_peer *peer, void *arg)
 	if (!twt_peer_obj)
 		return QDF_STATUS_E_NOMEM;
 
-	qdf_mutex_create(&twt_peer_obj->twt_peer_lock);
+	twt_lock_create(&twt_peer_obj->twt_peer_lock);
 
 	status = wlan_objmgr_peer_component_obj_attach(peer,
 						       WLAN_UMAC_COMP_TWT,
@@ -152,7 +152,7 @@ wlan_twt_peer_obj_create_handler(struct wlan_objmgr_peer *peer, void *arg)
 						       QDF_STATUS_SUCCESS);
 
 	if (QDF_IS_STATUS_ERROR(status)) {
-		qdf_mutex_destroy(&twt_peer_obj->twt_peer_lock);
+		twt_lock_destroy(&twt_peer_obj->twt_peer_lock);
 		qdf_mem_free(twt_peer_obj);
 		twt_err("peer twt object attach failed");
 		return QDF_STATUS_E_FAILURE;
@@ -180,7 +180,7 @@ wlan_twt_peer_obj_destroy_handler(struct wlan_objmgr_peer *peer, void *arg)
 		return QDF_STATUS_E_INVAL;
 	}
 
-	qdf_mutex_destroy(&twt_peer_obj->twt_peer_lock);
+	twt_lock_destroy(&twt_peer_obj->twt_peer_lock);
 
 	status = wlan_objmgr_peer_component_obj_detach(peer, WLAN_UMAC_COMP_TWT,
 						       twt_peer_obj);

+ 82 - 0
umac/twt/core/src/wlan_twt_priv.h

@@ -100,12 +100,94 @@ struct twt_session {
  * @session_info: session info
  */
 struct twt_peer_priv_obj {
+#ifdef WLAN_TWT_SPINLOCK
+	qdf_spinlock_t twt_peer_lock;
+#else
 	qdf_mutex_t twt_peer_lock;
+#endif
 	uint8_t peer_capability;
 	uint8_t num_twt_sessions;
 	struct twt_session session_info
 		[WLAN_MAX_TWT_SESSIONS_PER_PEER];
 };
 
+#ifdef WLAN_TWT_SPINLOCK
+/**
+ * twt_lock_create - Create TWT peer mutex/spinlock
+ * @twt_lock: lock object
+ *
+ * Creates TWT peer mutex/spinlock
+ *
+ * Return: void
+ */
+static inline void
+twt_lock_create(qdf_spinlock_t *twt_lock)
+{
+	qdf_spinlock_create(twt_lock);
+}
+
+/**
+ * twt_lock_destroy - Destroy TWT mutex/spinlock
+ * @twt_lock: lock object
+ *
+ * Destroy TWT peer mutex/spinlock
+ *
+ * Return: void
+ */
+static inline void
+twt_lock_destroy(qdf_spinlock_t *twt_lock)
+{
+	qdf_spinlock_destroy(twt_lock);
+}
+
+/**
+ * twt_lock_acquire - acquire TWT mutex/spinlock
+ * @twt_lock: lock object
+ *
+ * acquire TWT mutex/spinlock
+ *
+ * return: void
+ */
+static inline void twt_lock_acquire(qdf_spinlock_t *twt_lock)
+{
+	qdf_spin_lock_bh(twt_lock);
+}
+
+/**
+ * twt_lock_release - release TWT mutex/spinlock
+ * @twt_lock: lock object
+ *
+ * release TWT mutex/spinlock
+ *
+ * return: void
+ */
+static inline void twt_lock_release(qdf_spinlock_t *twt_lock)
+{
+	qdf_spin_unlock_bh(twt_lock);
+}
+#else
+static inline void
+twt_lock_create(qdf_mutex_t *twt_lock)
+{
+	qdf_mutex_create(twt_lock);
+}
+
+static inline void
+twt_lock_destroy(qdf_mutex_t *twt_lock)
+{
+	qdf_mutex_destroy(twt_lock);
+}
+
+static inline void twt_lock_acquire(qdf_mutex_t *twt_lock)
+{
+	qdf_mutex_acquire(twt_lock);
+}
+
+static inline void twt_lock_release(qdf_mutex_t *twt_lock)
+{
+	qdf_mutex_release(twt_lock);
+}
+#endif /* WLAN_TWT_SPINLOCK */
+
 #endif /* End  of _WLAN_TWT_PRIV_H_ */