UIO: Allow a UIO driver to override the default pgprot when we mmap
PATCH 1/1 UIO: Allow a UIO driver to override the default pgprot when we mmap
For some devices the default behavior of pgprot_noncached is not the correct flags for the address space. Provide a means for the kernel side UIO driver to override the flags without having to implement its own full mmap callback.
--- drivers/uio/uio.c | 6 +++++- include/linux/uio_driver.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletions(-)
drivers/uio/uio.c +5 -1
@@ -656,7 +656,11 @@ static int uio_mmap_physical(struct vm_area_struct *vma) vma->vm_flags |=VM_IO |VM_RESERVED ; - vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); +if (idev->info->mem[mi].set_pgprot) + vma->vm_page_prot = + idev->info->mem[mi].set_pgprot (vma->vm_page_prot); +else + vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); return remap_pfn_range(vma, vma->vm_start,
include/linux/uio_driver.h +2 -0
@@ -28,6 +28,7 @@ struct uio_map;* @memtype: type of memory addr points to * @internal_addr: ioremap-ped version of addr, for driver internal use * @map: for use by the UIO core only. +* @set_pgprot: allow driver to override default(noncached) pgprot */ struct uio_mem {const char *name;
@@ -36,6 +37,7 @@ struct uio_mem {int memtype;void __iomem *internal_addr;struct uio_map *map; +pgprot_t (*set_pgprot)(pgprot_t prot); };#define MAX_UIO_MAPS 5
Signature · 1 line
1.7.3.4
Quoted 2 lines · Kumar Gala
For some devices the default behavior of
pgprot_noncachedis not the correct flags for the address space.
For what devices? Can you give a real world usecase where this is needed?
Thanks,
Hans
Quoted 51 lines
Provide a means for the
kernel side UIO driver to override the flags without having to implement its own full mmap callback.Signed-off-by Kumar Gala <[email protected]>--- drivers/uio/uio.c | 6 +++++- include/linux/uio_driver.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletions(-)drivers/uio/uio.c +5
-1@@ -656,7 +656,11 @@ static int uio_mmap_physical(struct vm_area_struct *vma) vma->vm_flags |=VM_IO |VM_RESERVED ; - vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); +if (idev->info->mem[mi].set_pgprot) + vma->vm_page_prot = + idev->info->mem[mi].set_pgprot (vma->vm_page_prot); +else + vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); return remap_pfn_range(vma, vma->vm_start,include/linux/uio_driver.h +2
-0@@ -28,6 +28,7 @@ struct uio_map;* @memtype: type of memory addr points to * @internal_addr: ioremap-ped version of addr, for driver internal use * @map: for use by the UIO core only. +* @set_pgprot: allow driver to override default(noncached) pgprot */ struct uio_mem {const char *name;@@ -36,6 +37,7 @@ struct uio_mem {int memtype;void __iomem *internal_addr;struct uio_map *map; +pgprot_t (*set_pgprot)(pgprot_t prot); };#define MAX_UIO_MAPS 5Signature · 1 line
1.7.3.4
Quoted 5 lines · Hans J. Koch
Quoted 2 lines · Kumar Gala
For some devices the default behavior of
pgprot_noncachedis not the correct flags for the address space.=20
For what devices? Can you give a real world usecase where this is =
needed?
Quoted 3 lines
=20
Thanks,
Hans
In the Freescale Networking devices we have a coherent memory interface = to our HW queuing system. In that case we want to change the pgprot() = to be cache-able instead of non-cached.
- k
Quoted 16 lines
=20
drivers/uio/uio.c static int uio_mmap_physical(struct =
Quoted 15 lines
Provide a means for the
kernel side UIO driver to override the flags without having to implement its own full mmap callback.
=20Signed-off-by Kumar Gala <[email protected]>---
drivers/uio/uio.c | 6 +++++- include/linux/uio_driver.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletions(-)=20
drivers/uio/uio.c +0
-0@@ -656,7 +656,11 @@ static int uio_mmap_physical(struct =
vm_area_struct *vma)
Quoted 7 lines
drivers/uio/uio.c
Quoted 7 lines
=20
vma->vm_flags |=3D VM_IO | VM_RESERVED;=20
drivers/uio/uio.c +3
-1- vma->vm_page_prot =3D pgprot_noncached(vma->vm_page_prot); +if (idev->info->mem[mi].set_pgprot) + vma->vm_page_prot =3D + =
idev->info->mem[mi].set_pgprot(vma->vm_page_prot);
Quoted 2 lines
drivers/uio/uio.c
Quoted 2 lines
drivers/uio/uio.c +2
-0+else + vma->vm_page_prot =3D =
pgprot_noncached(vma->vm_page_prot);
Quoted 10 lines
include/linux/uio_driver.h struct uio_map; · line 29
Quoted 10 lines
=20
return remap_pfn_range(vma, vma->vm_start,include/linux/uio_driver.h +0
-0@@ -28,6 +28,7 @@ struct uio_map;* @memtype: type of memory addr points to * @internal_addr: ioremap-ped version of addr, for driver internal =
use
Quoted 2 lines
include/linux/uio_driver.h struct uio_map; · line 31
Quoted 2 lines
include/linux/uio_driver.h +1
-0* @map: for use by the UIO core only. +* @set_pgprot: allow driver to override =
default(noncached) pgprot
Quoted 15 lines
Quoted 15 lines
include/linux/uio_driver.h +1
-0*/ struct uio_mem {const char *name;@@ -36,6 +37,7 @@ struct uio_mem {int memtype;void __iomem *internal_addr;struct uio_map *map; +pgprot_t (*set_pgprot)(pgprot_t prot); };=20
#defineMAX_UIO_MAPS5
--=20
1.7.3.4
=20
=20
Quoted 7 lines · Kumar Gala
Quoted 4 lines · Hans J. Koch
Quoted 2 lines · Kumar Gala
For some devices the default behavior of
pgprot_noncachedis not the correct flags for the address space.
Quoted 6 lines
Quoted 4 lines
For what devices? Can you give a real world usecase where this is needed?
Thanks,
HansIn the Freescale Networking devices we have a coherent memory interface to our HW queuing system. In that case we want to change the
pgprot()to be cache-able instead of non-cached.
Could you please post the kernel part of that driver?
Thanks,
Hans