[v2] common/octeontx2: fix memory mapping API's usage
diff mbox series

Message ID 20200924103932.3834392-1-sarosh.arif@emumba.com
State Accepted
Delegated to: Jerin Jacob
Headers show
Series
  • [v2] common/octeontx2: fix memory mapping API's usage
Related show

Checks

Context Check Description
ci/travis-robot success Travis build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Sarosh Arif Sept. 24, 2020, 10:39 a.m. UTC
replace mmap() with rte_mem_map() 
and replace munmap() with rte_mem_unmap()

Fixes: e1d9a02ad8f0 ("common/octeontx2: introduce common device class")
Signed-off-by: Sarosh Arif <sarosh.arif@emumba.com>
---
v2:
update description and commit message
---
 drivers/common/octeontx2/otx2_dev.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Jerin Jacob Sept. 28, 2020, 6:08 a.m. UTC | #1
On Thu, Sep 24, 2020 at 4:10 PM Sarosh Arif <sarosh.arif@emumba.com> wrote:
>
> replace mmap() with rte_mem_map()
> and replace munmap() with rte_mem_unmap()
>
> Fixes: e1d9a02ad8f0 ("common/octeontx2: introduce common device class")
> Signed-off-by: Sarosh Arif <sarosh.arif@emumba.com>

Updated the commit message to:
<
    common/octeontx2: fix memory mapping API usage

    Replace mmap() and munmap() APIs with EAL abstraction for the same.

    Fixes: e1d9a02ad8f0 ("common/octeontx2: introduce common device class")
    Signed-off-by: Sarosh Arif <sarosh.arif@emumba.com>
>

Acked-by: Jerin Jacob <jerinj@marvell.com>
Applied to dpdk-next-net-mrvl/master. Thanks




> ---
> v2:
> update description and commit message
> ---
>  drivers/common/octeontx2/otx2_dev.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/common/octeontx2/otx2_dev.c b/drivers/common/octeontx2/otx2_dev.c
> index d61c712fa..6a84df234 100644
> --- a/drivers/common/octeontx2/otx2_dev.c
> +++ b/drivers/common/octeontx2/otx2_dev.c
> @@ -11,6 +11,7 @@
>  #include <rte_common.h>
>  #include <rte_eal.h>
>  #include <rte_memcpy.h>
> +#include <rte_eal_paging.h>
>
>  #include "otx2_dev.h"
>  #include "otx2_mbox.h"
> @@ -34,10 +35,11 @@ mbox_mem_map(off_t off, size_t size)
>         if (mem_fd < 0)
>                 goto error;
>
> -       va = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, mem_fd, off);
> +       va = rte_mem_map(NULL, size, RTE_PROT_READ | RTE_PROT_WRITE,
> +                       RTE_MAP_SHARED, mem_fd, off);
>         close(mem_fd);
>
> -       if (va == MAP_FAILED)
> +       if (va == NULL)
>                 otx2_err("Failed to mmap sz=0x%zx, fd=%d, off=%jd",
>                          size, mem_fd, (intmax_t)off);
>  error:
> @@ -48,7 +50,7 @@ static void
>  mbox_mem_unmap(void *va, size_t size)
>  {
>         if (va)
> -               munmap(va, size);
> +               rte_mem_unmap(va, size);
>  }
>
>  static int
> --
> 2.25.1
>

Patch
diff mbox series

diff --git a/drivers/common/octeontx2/otx2_dev.c b/drivers/common/octeontx2/otx2_dev.c
index d61c712fa..6a84df234 100644
--- a/drivers/common/octeontx2/otx2_dev.c
+++ b/drivers/common/octeontx2/otx2_dev.c
@@ -11,6 +11,7 @@ 
 #include <rte_common.h>
 #include <rte_eal.h>
 #include <rte_memcpy.h>
+#include <rte_eal_paging.h>
 
 #include "otx2_dev.h"
 #include "otx2_mbox.h"
@@ -34,10 +35,11 @@  mbox_mem_map(off_t off, size_t size)
 	if (mem_fd < 0)
 		goto error;
 
-	va = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, mem_fd, off);
+	va = rte_mem_map(NULL, size, RTE_PROT_READ | RTE_PROT_WRITE,
+			RTE_MAP_SHARED, mem_fd, off);
 	close(mem_fd);
 
-	if (va == MAP_FAILED)
+	if (va == NULL)
 		otx2_err("Failed to mmap sz=0x%zx, fd=%d, off=%jd",
 			 size, mem_fd, (intmax_t)off);
 error:
@@ -48,7 +50,7 @@  static void
 mbox_mem_unmap(void *va, size_t size)
 {
 	if (va)
-		munmap(va, size);
+		rte_mem_unmap(va, size);
 }
 
 static int