All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] crypto/ccp: use contiguous allocation for DMA memory
@ 2018-04-17 10:32 Ravi Kumar
  2018-04-17 10:35 ` Burakov, Anatoly
  2018-04-17 13:02 ` De Lara Guarch, Pablo
  0 siblings, 2 replies; 3+ messages in thread
From: Ravi Kumar @ 2018-04-17 10:32 UTC (permalink / raw)
  To: dev; +Cc: pablo.de.lara.guarch, hemant.agrawal

rte_eal_get_physmem_layout() is obsolete now.
This patch fix the broken API usage and allocates
DMA memory with RTE_MEMZONE_IOVA_CONTIG memzone flag.

Signed-off-by: Ravi Kumar <Ravi1.kumar@amd.com>
---
 drivers/crypto/ccp/ccp_dev.c | 45 +++++++++++++++++++-------------------------
 1 file changed, 19 insertions(+), 26 deletions(-)

diff --git a/drivers/crypto/ccp/ccp_dev.c b/drivers/crypto/ccp/ccp_dev.c
index 55cfcdd..80fe6a4 100644
--- a/drivers/crypto/ccp/ccp_dev.c
+++ b/drivers/crypto/ccp/ccp_dev.c
@@ -88,36 +88,29 @@ ccp_queue_dma_zone_reserve(const char *queue_name,
 			   int socket_id)
 {
 	const struct rte_memzone *mz;
-	unsigned int memzone_flags = 0;
-	const struct rte_memseg *ms;
 
 	mz = rte_memzone_lookup(queue_name);
-	if (mz != 0)
-		return mz;
-
-	ms = rte_eal_get_physmem_layout();
-	switch (ms[0].hugepage_sz) {
-	case(RTE_PGSIZE_2M):
-		memzone_flags = RTE_MEMZONE_2MB;
-		break;
-	case(RTE_PGSIZE_1G):
-		memzone_flags = RTE_MEMZONE_1GB;
-		break;
-	case(RTE_PGSIZE_16M):
-		memzone_flags = RTE_MEMZONE_16MB;
-		break;
-	case(RTE_PGSIZE_16G):
-		memzone_flags = RTE_MEMZONE_16GB;
-		break;
-	default:
-		memzone_flags = RTE_MEMZONE_SIZE_HINT_ONLY;
+	if (mz != 0) {
+		if (((size_t)queue_size <= mz->len) &&
+		    ((socket_id == SOCKET_ID_ANY) ||
+		     (socket_id == mz->socket_id))) {
+			CCP_LOG_INFO("re-use memzone already "
+				     "allocated for %s", queue_name);
+			return mz;
+		}
+		CCP_LOG_ERR("Incompatible memzone already "
+			    "allocated %s, size %u, socket %d. "
+			    "Requested size %u, socket %u",
+			    queue_name, (uint32_t)mz->len,
+			    mz->socket_id, queue_size, socket_id);
+		return NULL;
 	}
 
-	return rte_memzone_reserve_aligned(queue_name,
-					   queue_size,
-					   socket_id,
-					   memzone_flags,
-					   queue_size);
+	CCP_LOG_INFO("Allocate memzone for %s, size %u on socket %u",
+		     queue_name, queue_size, socket_id);
+
+	return rte_memzone_reserve_aligned(queue_name, queue_size,
+			socket_id, RTE_MEMZONE_IOVA_CONTIG, queue_size);
 }
 
 /* bitmap support apis */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] crypto/ccp: use contiguous allocation for DMA memory
  2018-04-17 10:32 [PATCH v1] crypto/ccp: use contiguous allocation for DMA memory Ravi Kumar
@ 2018-04-17 10:35 ` Burakov, Anatoly
  2018-04-17 13:02 ` De Lara Guarch, Pablo
  1 sibling, 0 replies; 3+ messages in thread
From: Burakov, Anatoly @ 2018-04-17 10:35 UTC (permalink / raw)
  To: Ravi Kumar, dev; +Cc: pablo.de.lara.guarch, hemant.agrawal

On 17-Apr-18 11:32 AM, Ravi Kumar wrote:
> rte_eal_get_physmem_layout() is obsolete now.
> This patch fix the broken API usage and allocates
> DMA memory with RTE_MEMZONE_IOVA_CONTIG memzone flag.
> 
> Signed-off-by: Ravi Kumar <Ravi1.kumar@amd.com>
> ---

FWIW,

Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] crypto/ccp: use contiguous allocation for DMA memory
  2018-04-17 10:32 [PATCH v1] crypto/ccp: use contiguous allocation for DMA memory Ravi Kumar
  2018-04-17 10:35 ` Burakov, Anatoly
@ 2018-04-17 13:02 ` De Lara Guarch, Pablo
  1 sibling, 0 replies; 3+ messages in thread
From: De Lara Guarch, Pablo @ 2018-04-17 13:02 UTC (permalink / raw)
  To: Ravi Kumar, dev; +Cc: hemant.agrawal



> -----Original Message-----
> From: Ravi Kumar [mailto:Ravi1.kumar@amd.com]
> Sent: Tuesday, April 17, 2018 11:32 AM
> To: dev@dpdk.org
> Cc: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>;
> hemant.agrawal@nxp.com
> Subject: [PATCH v1] crypto/ccp: use contiguous allocation for DMA memory
> 
> rte_eal_get_physmem_layout() is obsolete now.
> This patch fix the broken API usage and allocates DMA memory with
> RTE_MEMZONE_IOVA_CONTIG memzone flag.
> 
> Signed-off-by: Ravi Kumar <Ravi1.kumar@amd.com>

Squashed into second commit of the AMD CCP patchset and applied to dpdk-next-crypto.

Thanks for the quick patch!
Pablo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-04-17 13:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-17 10:32 [PATCH v1] crypto/ccp: use contiguous allocation for DMA memory Ravi Kumar
2018-04-17 10:35 ` Burakov, Anatoly
2018-04-17 13:02 ` De Lara Guarch, Pablo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.