Parcourir la source

qcacld-3.0: Mark rx/fisa history prealloc as non-critical

Mark rx and fisa history related allocations as non
critical for prealloc. This will ensure that prealloc
init can continue when memory alloc fails for the above
as these are only for debug purposes.

Change-Id: I94fc5c35a3a7a5dae3a4c97cf4ceca4eee7372ca
CRs-Fixed: 2936359
Yeshwanth Sriram Guntuka il y a 4 ans
Parent
commit
2b309943f4
1 fichiers modifiés avec 23 ajouts et 12 suppressions
  1. 23 12
      core/dp/txrx3.0/dp_txrx.c

+ 23 - 12
core/dp/txrx3.0/dp_txrx.c

@@ -272,37 +272,44 @@ struct dp_consistent_prealloc_unaligned {
  * @ctxt_type: DP context type
  * @size: size of pre-alloc memory
  * @in_use: check if element is being used
+ * @is_critical: critical prealloc failure would cause prealloc_init to fail
  * @addr: address of memory allocated
  */
 struct dp_prealloc_context {
 	enum dp_ctxt_type ctxt_type;
 	uint32_t size;
 	bool in_use;
+	bool is_critical;
 	void *addr;
 };
 
 static struct dp_prealloc_context g_dp_context_allocs[] = {
-	{DP_PDEV_TYPE, (sizeof(struct dp_pdev)), false,  NULL},
+	{DP_PDEV_TYPE, (sizeof(struct dp_pdev)), false,  true, NULL},
 #ifdef WLAN_FEATURE_DP_RX_RING_HISTORY
 	/* 4 Rx ring history */
-	{DP_RX_RING_HIST_TYPE, sizeof(struct dp_rx_history), false, NULL},
-	{DP_RX_RING_HIST_TYPE, sizeof(struct dp_rx_history), false, NULL},
-	{DP_RX_RING_HIST_TYPE, sizeof(struct dp_rx_history), false, NULL},
-	{DP_RX_RING_HIST_TYPE, sizeof(struct dp_rx_history), false, NULL},
+	{DP_RX_RING_HIST_TYPE, sizeof(struct dp_rx_history), false, false,
+	 NULL},
+	{DP_RX_RING_HIST_TYPE, sizeof(struct dp_rx_history), false, false,
+	 NULL},
+	{DP_RX_RING_HIST_TYPE, sizeof(struct dp_rx_history), false, false,
+	 NULL},
+	{DP_RX_RING_HIST_TYPE, sizeof(struct dp_rx_history), false, false,
+	 NULL},
 	/* 1 Rx error ring history */
 	{DP_RX_ERR_RING_HIST_TYPE, sizeof(struct dp_rx_err_history),
-	 false, NULL},
+	 false, false, NULL},
 #ifndef RX_DEFRAG_DO_NOT_REINJECT
 	/* 1 Rx reinject ring history */
 	{DP_RX_REINJECT_RING_HIST_TYPE, sizeof(struct dp_rx_reinject_history),
-	 false, NULL},
+	 false, false, NULL},
 #endif	/* RX_DEFRAG_DO_NOT_REINJECT */
 	/* 1 Rx refill ring history */
 	{DP_RX_REFILL_RING_HIST_TYPE, sizeof(struct dp_rx_refill_history),
-	false, NULL},
+	false, false, NULL},
 #endif	/* WLAN_FEATURE_DP_RX_RING_HISTORY */
 #ifdef WLAN_SUPPORT_RX_FISA
-	{DP_FISA_RX_FT_TYPE, sizeof(struct dp_fisa_rx_sw_ft) * FISA_RX_FT_SIZE, false, NULL},
+	{DP_FISA_RX_FT_TYPE, sizeof(struct dp_fisa_rx_sw_ft) * FISA_RX_FT_SIZE,
+	 false, true, NULL},
 #endif
 };
 
@@ -498,7 +505,7 @@ void dp_prealloc_deinit(void)
 
 	for (i = 0; i < QDF_ARRAY_SIZE(g_dp_context_allocs); i++) {
 		cp = &g_dp_context_allocs[i];
-		if (qdf_unlikely(up->in_use))
+		if (qdf_unlikely(cp->in_use))
 			dp_warn("i %d: context in use while free", i);
 
 		if (cp->addr) {
@@ -527,7 +534,7 @@ QDF_STATUS dp_prealloc_init(void)
 		cp = &g_dp_context_allocs[i];
 		cp->addr = qdf_mem_malloc(cp->size);
 
-		if (qdf_unlikely(!cp->addr)) {
+		if (qdf_unlikely(!cp->addr) && cp->is_critical) {
 			dp_warn("i %d: unable to preallocate %d bytes memory!",
 				i, cp->size);
 			break;
@@ -628,7 +635,8 @@ void *dp_prealloc_get_context_memory(uint32_t ctxt_type)
 	for (i = 0; i < QDF_ARRAY_SIZE(g_dp_context_allocs); i++) {
 		cp = &g_dp_context_allocs[i];
 
-		if ((ctxt_type == cp->ctxt_type) && !cp->in_use) {
+		if ((ctxt_type == cp->ctxt_type) && !cp->in_use &&
+		    cp->addr) {
 			cp->in_use = true;
 			return cp->addr;
 		}
@@ -642,6 +650,9 @@ QDF_STATUS dp_prealloc_put_context_memory(uint32_t ctxt_type, void *vaddr)
 	int i;
 	struct dp_prealloc_context *cp;
 
+	if (!vaddr)
+		return QDF_STATUS_E_FAILURE;
+
 	for (i = 0; i < QDF_ARRAY_SIZE(g_dp_context_allocs); i++) {
 		cp = &g_dp_context_allocs[i];