diff mbox series

[x/azure,08/17] uio: introduce UIO_MEM_IOVA

Message ID 20190607193851.21914-9-marcelo.cerri@canonical.com
State New
Headers show
Series LP: #1812123 - Upstream Commits Needed for DPDK on Azure | expand

Commit Message

Marcelo Henrique Cerri June 7, 2019, 7:38 p.m. UTC
From: Stephen Hemminger <stephen@networkplumber.org>

BugLink: http://bugs.launchpad.net/bugs/1812123

Introduce the concept of mapping physical memory locations that
are normal memory. The new type UIO_MEM_IOVA are similar to
existing UIO_MEM_PHYS but the backing memory is not marked as uncached.

Also, indent related switch to the currently used style.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(backported from commit bfddabfa230452cea32aae82f9cd85ab22601acf)
[marcelo.cerri@canonical.com: fixed context in uio_mmap()]
Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
---
 drivers/uio/uio.c          | 18 ++++++++++--------
 include/linux/uio_driver.h |  1 +
 2 files changed, 11 insertions(+), 8 deletions(-)

Comments

Seth Forshee June 7, 2019, 8:05 p.m. UTC | #1
On Fri, Jun 07, 2019 at 04:38:42PM -0300, Marcelo Henrique Cerri wrote:
> @@ -703,13 +704,14 @@ static int uio_mmap(struct file *filep, struct vm_area_struct *vma)
>  	}
>  
>  	switch (idev->info->mem[mi].memtype) {
> -		case UIO_MEM_PHYS:
> -			return uio_mmap_physical(vma);
> -		case UIO_MEM_LOGICAL:
> -		case UIO_MEM_VIRTUAL:
> -			return uio_mmap_logical(vma);
> -		default:
> -			return -EINVAL;
> +	case UIO_MEM_IOVA:
> +	    case UIO_MEM_PHYS:
> +		    return uio_mmap_physical(vma);
> +	    case UIO_MEM_LOGICAL:
> +	    case UIO_MEM_VIRTUAL:
> +		    return uio_mmap_logical(vma);
> +	    default:
> +		    return -EINVAL;

Something funky is going on with the indentation here.
diff mbox series

Patch

diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index ff04b7f8549f..ff695bdee0a7 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -656,7 +656,8 @@  static int uio_mmap_physical(struct vm_area_struct *vma)
 		return -EINVAL;
 
 	vma->vm_ops = &uio_physical_vm_ops;
-	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+	if (idev->info->mem[mi].memtype == UIO_MEM_PHYS)
+		vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 
 	/*
 	 * We cannot use the vm_iomap_memory() helper here,
@@ -703,13 +704,14 @@  static int uio_mmap(struct file *filep, struct vm_area_struct *vma)
 	}
 
 	switch (idev->info->mem[mi].memtype) {
-		case UIO_MEM_PHYS:
-			return uio_mmap_physical(vma);
-		case UIO_MEM_LOGICAL:
-		case UIO_MEM_VIRTUAL:
-			return uio_mmap_logical(vma);
-		default:
-			return -EINVAL;
+	case UIO_MEM_IOVA:
+	    case UIO_MEM_PHYS:
+		    return uio_mmap_physical(vma);
+	    case UIO_MEM_LOGICAL:
+	    case UIO_MEM_VIRTUAL:
+		    return uio_mmap_logical(vma);
+	    default:
+		    return -EINVAL;
 	}
 }
 
diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
index 3c85c81b0027..afa0bed36650 100644
--- a/include/linux/uio_driver.h
+++ b/include/linux/uio_driver.h
@@ -131,6 +131,7 @@  extern void uio_event_notify(struct uio_info *info);
 #define UIO_MEM_PHYS	1
 #define UIO_MEM_LOGICAL	2
 #define UIO_MEM_VIRTUAL 3
+#define UIO_MEM_IOVA	4
 
 /* defines for uio_port->porttype */
 #define UIO_PORT_NONE	0