* [PATCH] UIO: Allow a UIO driver to override the default pgprot when we mmap
@ 2011-10-12 14:43 Kumar Gala
2011-10-12 15:35 ` Hans J. Koch
0 siblings, 1 reply; 4+ messages in thread
From: Kumar Gala @ 2011-10-12 14:43 UTC (permalink / raw)
To: hjk; +Cc: linuxppc-dev, gregkh, linux-kernel
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.
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
drivers/uio/uio.c | 6 +++++-
include/linux/uio_driver.h | 2 ++
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index d2efe82..88f4444 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -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,
diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
index 665517c..4c618cd 100644
--- a/include/linux/uio_driver.h
+++ b/include/linux/uio_driver.h
@@ -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
--
1.7.3.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] UIO: Allow a UIO driver to override the default pgprot when we mmap
2011-10-12 14:43 [PATCH] UIO: Allow a UIO driver to override the default pgprot when we mmap Kumar Gala
@ 2011-10-12 15:35 ` Hans J. Koch
2011-10-12 16:08 ` Kumar Gala
0 siblings, 1 reply; 4+ messages in thread
From: Hans J. Koch @ 2011-10-12 15:35 UTC (permalink / raw)
To: Kumar Gala; +Cc: linuxppc-dev, hjk, gregkh, linux-kernel
On Wed, Oct 12, 2011 at 09:43:36AM -0500, Kumar Gala wrote:
> For some devices the default behavior of pgprot_noncached is not
> the correct flags for the address space.
For what devices? Can you give a real world usecase where this is needed?
Thanks,
Hans
> 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 <galak@kernel.crashing.org>
> ---
> drivers/uio/uio.c | 6 +++++-
> include/linux/uio_driver.h | 2 ++
> 2 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
> index d2efe82..88f4444 100644
> --- a/drivers/uio/uio.c
> +++ b/drivers/uio/uio.c
> @@ -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,
> diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
> index 665517c..4c618cd 100644
> --- a/include/linux/uio_driver.h
> +++ b/include/linux/uio_driver.h
> @@ -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
> --
> 1.7.3.4
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] UIO: Allow a UIO driver to override the default pgprot when we mmap
2011-10-12 15:35 ` Hans J. Koch
@ 2011-10-12 16:08 ` Kumar Gala
2011-10-12 16:20 ` Hans J. Koch
0 siblings, 1 reply; 4+ messages in thread
From: Kumar Gala @ 2011-10-12 16:08 UTC (permalink / raw)
To: Hans J. Koch; +Cc: linuxppc-dev, gregkh, linux-kernel
On Oct 12, 2011, at 10:35 AM, Hans J. Koch wrote:
> On Wed, Oct 12, 2011 at 09:43:36AM -0500, Kumar Gala wrote:
>> For some devices the default behavior of pgprot_noncached is not
>> the correct flags for the address space.
>=20
> For what devices? Can you give a real world usecase where this is =
needed?
>=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
>=20
>> Provide a means for the
>> kernel side UIO driver to override the flags without having to
>> implement its own full mmap callback.
>>=20
>> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
>> ---
>> drivers/uio/uio.c | 6 +++++-
>> include/linux/uio_driver.h | 2 ++
>> 2 files changed, 7 insertions(+), 1 deletions(-)
>>=20
>> diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
>> index d2efe82..88f4444 100644
>> --- a/drivers/uio/uio.c
>> +++ b/drivers/uio/uio.c
>> @@ -656,7 +656,11 @@ static int uio_mmap_physical(struct =
vm_area_struct *vma)
>>=20
>> vma->vm_flags |=3D VM_IO | VM_RESERVED;
>>=20
>> - 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);
>> + else
>> + vma->vm_page_prot =3D =
pgprot_noncached(vma->vm_page_prot);
>>=20
>> return remap_pfn_range(vma,
>> vma->vm_start,
>> diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
>> index 665517c..4c618cd 100644
>> --- a/include/linux/uio_driver.h
>> +++ b/include/linux/uio_driver.h
>> @@ -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);
>> };
>>=20
>> #define MAX_UIO_MAPS 5
>> --=20
>> 1.7.3.4
>>=20
>>=20
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] UIO: Allow a UIO driver to override the default pgprot when we mmap
2011-10-12 16:08 ` Kumar Gala
@ 2011-10-12 16:20 ` Hans J. Koch
0 siblings, 0 replies; 4+ messages in thread
From: Hans J. Koch @ 2011-10-12 16:20 UTC (permalink / raw)
To: Kumar Gala; +Cc: linuxppc-dev, Hans J. Koch, gregkh, linux-kernel
On Wed, Oct 12, 2011 at 11:08:20AM -0500, Kumar Gala wrote:
>
> On Oct 12, 2011, at 10:35 AM, Hans J. Koch wrote:
>
> > On Wed, Oct 12, 2011 at 09:43:36AM -0500, Kumar Gala wrote:
> >> For some devices the default behavior of pgprot_noncached is not
> >> the correct flags for the address space.
> >
> > For what devices? Can you give a real world usecase where this is needed?
> >
> > 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.
Could you please post the kernel part of that driver?
Thanks,
Hans
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-10-12 16:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-12 14:43 [PATCH] UIO: Allow a UIO driver to override the default pgprot when we mmap Kumar Gala
2011-10-12 15:35 ` Hans J. Koch
2011-10-12 16:08 ` Kumar Gala
2011-10-12 16:20 ` Hans J. Koch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).