Explorar el Código

qcacmn: Move peer ref id debug support under compile flag

ref id debug support adds an array of atomic_t to peer object which
significantly increases peer object size. Move this debug support
under compile time flag WLAN_OBJMGR_REF_ID_DEBUG to save memory.

Change-Id: I9c14e23078a702419a15ad79eb384cc6727a5ef3
CRs-Fixed: 2293170
Om Prakash Tripathi hace 6 años
padre
commit
bf3428b207

+ 23 - 0
umac/cmn_services/obj_mgr/inc/wlan_objmgr_peer_obj.h

@@ -147,7 +147,9 @@ struct wlan_objmgr_peer_mlme {
 struct wlan_objmgr_peer_objmgr {
 	struct wlan_objmgr_vdev *vdev;
 	qdf_atomic_t ref_cnt;
+#ifdef WLAN_OBJMGR_REF_ID_DEBUG
 	qdf_atomic_t ref_id_dbg[WLAN_REF_ID_MAX];
+#endif
 	uint8_t print_cnt;
 };
 
@@ -1036,4 +1038,25 @@ static inline void wlan_peer_set_pdev_id(struct wlan_objmgr_peer *peer,
 	peer->pdev_id = pdev_id;
 }
 
+/**
+ * wlan_objmgr_print_peer_ref_ids() - print peer object refs
+ * @peer: peer object pointer
+ * @log_level: log level
+ *
+ * Return: void
+ */
+void wlan_objmgr_print_peer_ref_ids(struct wlan_objmgr_peer *peer,
+				    QDF_TRACE_LEVEL log_level);
+
+/**
+ * wlan_objmgr_peer_get_comp_ref_cnt() - get component ref count for a peer
+ * @peer: peer object pointer
+ * @id: component id
+ *
+ * Return: uint32_t
+ */
+uint32_t
+wlan_objmgr_peer_get_comp_ref_cnt(struct wlan_objmgr_peer *peer,
+				  enum wlan_umac_comp_id id);
+
 #endif /* _WLAN_OBJMGR_PEER_OBJ_H_*/

+ 90 - 17
umac/cmn_services/obj_mgr/src/wlan_objmgr_peer_obj.c

@@ -132,6 +132,20 @@ static QDF_STATUS wlan_objmgr_peer_obj_free(struct wlan_objmgr_peer *peer)
 
 }
 
+#ifdef WLAN_OBJMGR_REF_ID_DEBUG
+static void
+wlan_objmgr_peer_init_ref_id_debug(struct wlan_objmgr_peer *peer)
+{
+	uint8_t id;
+
+	for (id = 0; id < WLAN_REF_ID_MAX; id++)
+		qdf_atomic_init(&peer->peer_objmgr.ref_id_dbg[id]);
+}
+#else
+static inline void
+wlan_objmgr_peer_init_ref_id_debug(struct wlan_objmgr_peer *peer) {}
+#endif
+
 struct wlan_objmgr_peer *wlan_objmgr_peer_obj_create(
 			struct wlan_objmgr_vdev *vdev,
 			enum wlan_peer_type type,
@@ -172,8 +186,7 @@ struct wlan_objmgr_peer *wlan_objmgr_peer_obj_create(
 	}
 	peer->obj_state = WLAN_OBJ_STATE_ALLOCATED;
 	qdf_atomic_init(&peer->peer_objmgr.ref_cnt);
-	for (id = 0; id < WLAN_REF_ID_MAX; id++)
-		qdf_atomic_init(&peer->peer_objmgr.ref_id_dbg[id]);
+	wlan_objmgr_peer_init_ref_id_debug(peer);
 	wlan_objmgr_peer_get_ref(peer, WLAN_OBJMGR_ID);
 	/* set vdev to peer */
 	wlan_peer_set_vdev(peer, vdev);
@@ -330,8 +343,7 @@ QDF_STATUS wlan_objmgr_peer_obj_delete(struct wlan_objmgr_peer *peer)
 		      QDF_MAC_ADDR_ARRAY(macaddr));
 
 	print_idx = qdf_get_pidx();
-	wlan_objmgr_print_ref_ids(peer->peer_objmgr.ref_id_dbg,
-				  QDF_TRACE_LEVEL_DEBUG);
+	wlan_objmgr_print_peer_ref_ids(peer, QDF_TRACE_LEVEL_DEBUG);
 	/**
 	 * Update VDEV object state to LOGICALLY DELETED
 	 * It prevents further access of this object
@@ -574,8 +586,21 @@ void *wlan_objmgr_peer_get_comp_private_obj(
 }
 qdf_export_symbol(wlan_objmgr_peer_get_comp_private_obj);
 
+#ifdef WLAN_OBJMGR_REF_ID_DEBUG
+static inline void
+wlan_objmgr_peer_get_debug_id_ref(struct wlan_objmgr_peer *peer,
+				  wlan_objmgr_ref_dbgid id)
+{
+	qdf_atomic_inc(&peer->peer_objmgr.ref_id_dbg[id]);
+}
+#else
+static inline void
+wlan_objmgr_peer_get_debug_id_ref(struct wlan_objmgr_peer *peer,
+				  wlan_objmgr_ref_dbgid id) {}
+#endif
+
 void wlan_objmgr_peer_get_ref(struct wlan_objmgr_peer *peer,
-					wlan_objmgr_ref_dbgid id)
+			      wlan_objmgr_ref_dbgid id)
 {
 	if (peer == NULL) {
 		obj_mgr_err("peer obj is NULL for %d", id);
@@ -584,7 +609,7 @@ void wlan_objmgr_peer_get_ref(struct wlan_objmgr_peer *peer,
 	}
 	/* Increment ref count */
 	qdf_atomic_inc(&peer->peer_objmgr.ref_cnt);
-	qdf_atomic_inc(&peer->peer_objmgr.ref_id_dbg[id]);
+	wlan_objmgr_peer_get_debug_id_ref(peer, id);
 
 	return;
 }
@@ -622,20 +647,14 @@ QDF_STATUS wlan_objmgr_peer_try_get_ref(struct wlan_objmgr_peer *peer,
 }
 qdf_export_symbol(wlan_objmgr_peer_try_get_ref);
 
-void wlan_objmgr_peer_release_ref(struct wlan_objmgr_peer *peer,
-						 wlan_objmgr_ref_dbgid id)
+#ifdef WLAN_OBJMGR_REF_ID_DEBUG
+static void
+wlan_objmgr_peer_release_debug_id_ref(struct wlan_objmgr_peer *peer,
+				      wlan_objmgr_ref_dbgid id)
 {
-
 	uint8_t *macaddr;
 
-	if (peer == NULL) {
-		obj_mgr_err("peer obj is NULL for %d", id);
-		QDF_ASSERT(0);
-		return;
-	}
-
 	macaddr = wlan_peer_get_macaddr(peer);
-
 	if (!qdf_atomic_read(&peer->peer_objmgr.ref_id_dbg[id])) {
 		obj_mgr_err(
 		"peer(%02x:%02x:%02x:%02x:%02x:%02x) ref was not taken by %d",
@@ -646,6 +665,27 @@ void wlan_objmgr_peer_release_ref(struct wlan_objmgr_peer *peer,
 		WLAN_OBJMGR_BUG(0);
 	}
 
+	qdf_atomic_dec(&peer->peer_objmgr.ref_id_dbg[id]);
+}
+#else
+static inline void
+wlan_objmgr_peer_release_debug_id_ref(struct wlan_objmgr_peer *peer,
+				      wlan_objmgr_ref_dbgid id) {}
+#endif
+
+void wlan_objmgr_peer_release_ref(struct wlan_objmgr_peer *peer,
+				  wlan_objmgr_ref_dbgid id)
+{
+	uint8_t *macaddr;
+
+	if (!peer) {
+		obj_mgr_err("peer obj is NULL for %d", id);
+		QDF_ASSERT(0);
+		return;
+	}
+
+	macaddr = wlan_peer_get_macaddr(peer);
+
 	if (!qdf_atomic_read(&peer->peer_objmgr.ref_cnt)) {
 		obj_mgr_err("peer(%02x:%02x:%02x:%02x:%02x:%02x) ref cnt is 0",
 				macaddr[0], macaddr[1], macaddr[2],
@@ -653,7 +693,7 @@ void wlan_objmgr_peer_release_ref(struct wlan_objmgr_peer *peer,
 		WLAN_OBJMGR_BUG(0);
 		return;
 	}
-	qdf_atomic_dec(&peer->peer_objmgr.ref_id_dbg[id]);
+	wlan_objmgr_peer_release_debug_id_ref(peer, id);
 
 	/* Provide synchronization from the access to add peer
 	 * to logically deleted peer list.
@@ -860,3 +900,36 @@ struct wlan_objmgr_peer *wlan_peer_get_next_peer_of_psoc_ref(
 
 	return peer_next;
 }
+
+#ifdef WLAN_OBJMGR_REF_ID_DEBUG
+void
+wlan_objmgr_print_peer_ref_ids(struct wlan_objmgr_peer *peer,
+			       QDF_TRACE_LEVEL log_level)
+{
+	wlan_objmgr_print_ref_ids(peer->peer_objmgr.ref_id_dbg, log_level);
+}
+
+uint32_t
+wlan_objmgr_peer_get_comp_ref_cnt(struct wlan_objmgr_peer *peer,
+				  enum wlan_umac_comp_id id)
+{
+	return qdf_atomic_read(&peer->peer_objmgr.ref_id_dbg[id]);
+}
+#else
+void
+wlan_objmgr_print_peer_ref_ids(struct wlan_objmgr_peer *peer,
+			       QDF_TRACE_LEVEL log_level)
+{
+	uint32_t pending_ref;
+
+	pending_ref = qdf_atomic_read(&peer->peer_objmgr.ref_cnt);
+	obj_mgr_log_level(log_level, "Pending refs -- %d", pending_ref);
+}
+
+uint32_t
+wlan_objmgr_peer_get_comp_ref_cnt(struct wlan_objmgr_peer *peer,
+				  enum wlan_umac_comp_id id)
+{
+	return 0;
+}
+#endif

+ 32 - 15
umac/cmn_services/obj_mgr/src/wlan_objmgr_psoc_obj.c

@@ -1935,8 +1935,7 @@ static void wlan_objmgr_psoc_peer_ref_print(struct wlan_objmgr_psoc *psoc,
 	obj_mgr_alert("Peer MAC:%02x:%02x:%02x:%02x:%02x:%02x state:%d vdev_id:%d",
 		  macaddr[0], macaddr[1], macaddr[2], macaddr[3],
 		  macaddr[4], macaddr[5], obj_state, vdev_id);
-	wlan_objmgr_print_ref_ids(peer->peer_objmgr.ref_id_dbg,
-				  QDF_TRACE_LEVEL_FATAL);
+	wlan_objmgr_print_peer_ref_ids(peer, QDF_TRACE_LEVEL_FATAL);
 }
 
 static void wlan_objmgr_psoc_vdev_ref_print(struct wlan_objmgr_psoc *psoc,
@@ -2098,6 +2097,35 @@ void wlan_objmgr_psoc_check_for_vdev_leaks(struct wlan_objmgr_psoc *psoc)
 }
 qdf_export_symbol(wlan_objmgr_psoc_check_for_vdev_leaks);
 
+#ifdef WLAN_OBJMGR_REF_ID_DEBUG
+static void
+wlan_objmgr_print_peer_ref_leaks(struct wlan_objmgr_peer *peer, int vdev_id)
+{
+	qdf_atomic_t *ref_id_dbg;
+	int32_t refs;
+	int ref_id;
+
+	ref_id_dbg = peer->peer_objmgr.ref_id_dbg;
+	wlan_objmgr_for_each_refs(ref_id_dbg, ref_id, refs) {
+		obj_mgr_err(QDF_MAC_ADDR_STR " %7u   %4u   %s",
+			    QDF_MAC_ADDR_ARRAY(peer->macaddr),
+			    vdev_id,
+			    refs,
+			    string_from_dbgid(ref_id));
+	}
+}
+#else
+static inline void
+wlan_objmgr_print_peer_ref_leaks(struct wlan_objmgr_peer *peer, int vdev_id)
+{
+	obj_mgr_err(QDF_MAC_ADDR_STR " %7u   %4u   %s",
+		    QDF_MAC_ADDR_ARRAY(peer->macaddr),
+		    vdev_id,
+		    qdf_atomic_read(&peer->peer_objmgr.ref_cnt),
+		    "TOTAL_REF_COUNT");
+}
+#endif
+
 void wlan_objmgr_psoc_check_for_peer_leaks(struct wlan_objmgr_psoc *psoc)
 {
 	struct wlan_objmgr_psoc_objmgr *_psoc;
@@ -2126,20 +2154,9 @@ void wlan_objmgr_psoc_check_for_peer_leaks(struct wlan_objmgr_psoc *psoc)
 
 		wlan_vdev_obj_lock(vdev);
 		wlan_objmgr_for_each_vdev_peer(vdev, peer) {
-			qdf_atomic_t *ref_id_dbg;
-			int ref_id;
-			int32_t refs;
-
 			wlan_peer_obj_lock(peer);
-			ref_id_dbg = peer->peer_objmgr.ref_id_dbg;
-			wlan_objmgr_for_each_refs(ref_id_dbg, ref_id, refs) {
-				leaks++;
-				obj_mgr_err(QDF_MAC_ADDR_STR " %7u   %4u   %s",
-					    QDF_MAC_ADDR_ARRAY(peer->macaddr),
-					    vdev_id,
-					    refs,
-					    string_from_dbgid(ref_id));
-			}
+			leaks += qdf_atomic_read(&peer->peer_objmgr.ref_cnt);
+			wlan_objmgr_print_peer_ref_leaks(peer, vdev_id);
 			wlan_peer_obj_unlock(peer);
 		}
 		wlan_vdev_obj_unlock(vdev);