Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 872cac88 authored by Rakesh Pillai's avatar Rakesh Pillai Committed by Gerrit - the friendly Code Review server
Browse files

qcacmn: Pre-alloc rx rings history when feature is enabled

Currently the rx rings history is allocated dynamically
on load time. The memory requirement for saving these
history are more than a page (order 5 to 6 allocations).
Such big memory allocation can fail due to various
reasons, one of them being memory fragmentation.

Fix this by pre-allocating the rx ring history memory.
Also allocate the rx reinject history memory when the
HW accelerated path is used.

Change-Id: Id957cd5df91a2ca7f182dea691a0557b4e386f55
CRs-Fixed: 2844388
parent 6f322437
Loading
Loading
Loading
Loading
+40 −10
Original line number Diff line number Diff line
@@ -1373,7 +1373,7 @@ void dp_context_free_mem(struct dp_soc *soc, enum dp_ctxt_type ctxt_type,

	if (soc->cdp_soc.ol_ops->dp_prealloc_put_context) {
		status = soc->cdp_soc.ol_ops->dp_prealloc_put_context(
								DP_PDEV_TYPE,
								ctxt_type,
								vaddr);
	} else {
		dp_warn("dp_prealloc_get_context null!");
@@ -3799,6 +3799,28 @@ static QDF_STATUS dp_htt_ppdu_stats_attach(struct dp_pdev *pdev)
}

#ifdef WLAN_FEATURE_DP_RX_RING_HISTORY
#ifndef RX_DEFRAG_DO_NOT_REINJECT
/**
 * dp_soc_rx_reinject_ring_history_attach - Attach the reo reinject ring
 *					    history.
 * @soc: DP soc handle
 *
 * Return: None
 */
static void dp_soc_rx_reinject_ring_history_attach(struct dp_soc *soc)
{
	soc->rx_reinject_ring_history = dp_context_alloc_mem(
			soc, DP_RX_REINJECT_RING_HIST_TYPE, rx_ring_hist_size);
	if (soc->rx_reinject_ring_history)
		qdf_atomic_init(&soc->rx_reinject_ring_history->index);
}
#else /* RX_DEFRAG_DO_NOT_REINJECT */
static inline void
dp_soc_rx_reinject_ring_history_attach(struct dp_soc *soc)
{
}
#endif /* RX_DEFRAG_DO_NOT_REINJECT */

/**
 * dp_soc_rx_history_attach() - Attach the ring history record buffers
 * @soc: DP soc structure
@@ -3818,23 +3840,23 @@ static void dp_soc_rx_history_attach(struct dp_soc *soc)
	uint32_t rx_err_ring_hist_size;
	uint32_t rx_reinject_hist_size;

	rx_ring_hist_size = sizeof(*soc->rx_ring_history[i]);
	rx_ring_hist_size = sizeof(*soc->rx_ring_history[0]);
	rx_err_ring_hist_size = sizeof(*soc->rx_err_ring_history);
	rx_reinject_hist_size = sizeof(*soc->rx_reinject_ring_history);

	for (i = 0; i < MAX_REO_DEST_RINGS; i++) {
		soc->rx_ring_history[i] = qdf_mem_malloc(rx_ring_hist_size);
		soc->rx_ring_history[i] = dp_context_alloc_mem(
				soc, DP_RX_RING_HIST_TYPE, rx_ring_hist_size);
		if (soc->rx_ring_history[i])
			qdf_atomic_init(&soc->rx_ring_history[i]->index);
	}

	soc->rx_err_ring_history = qdf_mem_malloc(rx_err_ring_hist_size);
	soc->rx_err_ring_history = dp_context_alloc_mem(
			soc, DP_RX_ERR_RING_HIST_TYPE, rx_ring_hist_size);
	if (soc->rx_err_ring_history)
		qdf_atomic_init(&soc->rx_err_ring_history->index);

	soc->rx_reinject_ring_history = qdf_mem_malloc(rx_reinject_hist_size);
	if (soc->rx_reinject_ring_history)
		qdf_atomic_init(&soc->rx_reinject_ring_history->index);
	dp_soc_rx_reinject_ring_history_attach(soc);
}

static void dp_soc_rx_history_detach(struct dp_soc *soc)
@@ -3842,10 +3864,18 @@ static void dp_soc_rx_history_detach(struct dp_soc *soc)
	int i;

	for (i = 0; i < MAX_REO_DEST_RINGS; i++)
		qdf_mem_free(soc->rx_ring_history[i]);
		dp_context_free_mem(soc, DP_RX_RING_HIST_TYPE,
				    soc->rx_ring_history[i]);

	dp_context_free_mem(soc, DP_RX_ERR_RING_HIST_TYPE,
			    soc->rx_err_ring_history);

	qdf_mem_free(soc->rx_err_ring_history);
	qdf_mem_free(soc->rx_reinject_ring_history);
	/*
	 * No need for a featurized detach since qdf_mem_free takes
	 * care of NULL pointer.
	 */
	dp_context_free_mem(soc, DP_RX_REINJECT_RING_HIST_TYPE,
			    soc->rx_reinject_ring_history);
}

#else
+7 −1
Original line number Diff line number Diff line
@@ -284,9 +284,15 @@ enum dp_cpu_ring_map_types {
/**
 * enum dp_ctxt - context type
 * @DP_PDEV_TYPE: PDEV context
 * @DP_RX_RING_HIST_TYPE: Datapath rx ring history
 * @DP_RX_ERR_RING_HIST_TYPE: Datapath rx error ring history
 * @DP_RX_REINJECT_RING_HIST_TYPE: Datapath reinject ring history
 */
enum dp_ctxt_type {
	DP_PDEV_TYPE
	DP_PDEV_TYPE,
	DP_RX_RING_HIST_TYPE,
	DP_RX_ERR_RING_HIST_TYPE,
	DP_RX_REINJECT_RING_HIST_TYPE,
};

/**