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

Commit e3bb9993 authored by Ananya Gupta's avatar Ananya Gupta Committed by Gerrit - the friendly Code Review server
Browse files

qcacmn: Pre allocate pdev during attach

Pre-allocate pdev context as size exceeds dynamic allocation
threshold (4KB).

Change-Id: Ida866275ed1ddea5a9b6aa1cf114ccd226ed0f22
CRs-Fixed: 2825110
parent 7fc80fba
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1102,6 +1102,9 @@ struct ol_if_ops {
				   uint8_t *peer_mac_addr);
#endif
#ifdef DP_MEM_PRE_ALLOC
	void *(*dp_prealloc_get_context)(uint32_t ctxt_type);

	QDF_STATUS(*dp_prealloc_put_context)(uint32_t ctxt_type, void *vaddr);
	void *(*dp_prealloc_get_consistent)(uint32_t *size,
					    void **base_vaddr_unaligned,
					    qdf_dma_addr_t *paddr_unaligned,
+36 −0
Original line number Diff line number Diff line
@@ -2127,6 +2127,28 @@ static inline uint32_t dp_history_get_next_index(qdf_atomic_t *curr_idx,
}

#ifdef DP_MEM_PRE_ALLOC
/**
 * dp_context_alloc_mem() - allocate memory for DP context
 * @soc: datapath soc handle
 * @ctxt_type: DP context type
 * @ctxt_size: DP context size
 *
 * Return: DP context address
 */
void *dp_context_alloc_mem(struct dp_soc *soc, enum dp_ctxt_type ctxt_type,
			   size_t ctxt_size);

/**
 * dp_context_free_mem() - Free memory of DP context
 * @soc: datapath soc handle
 * @ctxt_type: DP context type
 * @vaddr: Address of context memory
 *
 * Return: None
 */
void dp_context_free_mem(struct dp_soc *soc, enum dp_ctxt_type ctxt_type,
			 void *vaddr);

/**
 * dp_desc_multi_pages_mem_alloc() - alloc memory over multiple pages
 * @soc: datapath soc handle
@@ -2173,6 +2195,20 @@ void dp_desc_multi_pages_mem_free(struct dp_soc *soc,
				  bool cacheable);

#else
static inline
void *dp_context_alloc_mem(struct dp_soc *soc, enum dp_ctxt_type ctxt_type,
			   size_t ctxt_size)
{
	return qdf_mem_malloc(ctxt_size);
}

static inline
void dp_context_free_mem(struct dp_soc *soc, enum dp_ctxt_type ctxt_type,
			 void *vaddr)
{
	qdf_mem_free(vaddr);
}

static inline
void dp_desc_multi_pages_mem_alloc(struct dp_soc *soc,
				   enum dp_desc_type desc_type,
+44 −2
Original line number Diff line number Diff line
@@ -1344,6 +1344,48 @@ dp_srng_configure_interrupt_thresholds(struct dp_soc *soc,


#ifdef DP_MEM_PRE_ALLOC
void *dp_context_alloc_mem(struct dp_soc *soc, enum dp_ctxt_type ctxt_type,
			   size_t ctxt_size)
{
	void *ctxt_mem;

	if (!soc->cdp_soc.ol_ops->dp_prealloc_get_context) {
		dp_warn("dp_prealloc_get_context null!");
		goto dynamic_alloc;
	}

	ctxt_mem = soc->cdp_soc.ol_ops->dp_prealloc_get_context(ctxt_type);

	if (ctxt_mem)
		goto end;

dynamic_alloc:
	dp_info("Pre-alloc of ctxt failed. Dynamic allocation");
	ctxt_mem = qdf_mem_malloc(ctxt_size);
end:
	return ctxt_mem;
}

void dp_context_free_mem(struct dp_soc *soc, enum dp_ctxt_type ctxt_type,
			 void *vaddr)
{
	QDF_STATUS status;

	if (soc->cdp_soc.ol_ops->dp_prealloc_put_context) {
		status = soc->cdp_soc.ol_ops->dp_prealloc_put_context(
								DP_PDEV_TYPE,
								vaddr);
	} else {
		dp_warn("dp_prealloc_get_context null!");
		status = QDF_STATUS_E_NOSUPPORT;
	}

	if (QDF_IS_STATUS_ERROR(status)) {
		dp_info("Context not pre-allocated");
		qdf_mem_free(vaddr);
	}
}

static inline
void *dp_srng_aligned_mem_alloc_consistent(struct dp_soc *soc,
					   struct dp_srng *srng,
@@ -3842,7 +3884,7 @@ static inline QDF_STATUS dp_pdev_attach_wifi3(struct cdp_soc_t *txrx_soc,
	if (dp_is_soc_reinit(soc)) {
		pdev = soc->pdev_list[pdev_id];
	} else {
		pdev = qdf_mem_malloc(sizeof(*pdev));
		pdev = dp_context_alloc_mem(soc, DP_PDEV_TYPE, sizeof(*pdev));
		qdf_minidump_log(pdev, sizeof(*pdev), "dp_pdev");
	}

@@ -4529,7 +4571,7 @@ static void dp_pdev_detach(struct cdp_pdev *txrx_pdev, int force)

	soc->pdev_list[pdev->pdev_id] = NULL;
	qdf_minidump_remove(pdev);
	qdf_mem_free(pdev);
	dp_context_free_mem(soc, DP_PDEV_TYPE, pdev);
}

/*
+8 −0
Original line number Diff line number Diff line
@@ -281,6 +281,14 @@ enum dp_cpu_ring_map_types {
	DP_NSS_CPU_RING_MAP_MAX
};

/**
 * enum dp_ctxt - context type
 * @DP_PDEV_TYPE: PDEV context
 */
enum dp_ctxt_type {
	DP_PDEV_TYPE
};

/**
 * enum dp_desc_type - source type for multiple pages allocation
 * @DP_TX_DESC_TYPE: DP SW TX descriptor