public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: Linux UIO driver cache problem in PowerPC (fix)
       [not found] <169c03cb0803121222h5fca9cdal5af873cd2a700f4d@mail.gmail.com>
@ 2008-03-13  7:19 ` Hans-Jürgen Koch
  2008-03-13 21:53   ` Grant Likely
  2008-03-14 10:33   ` Hans J. Koch
  0 siblings, 2 replies; 6+ messages in thread
From: Hans-Jürgen Koch @ 2008-03-13  7:19 UTC (permalink / raw)
  To: Jean-Samuel Chenard; +Cc: Thomas Gleixner, LKML, Greg KH, grant.likely

Am Wed, 12 Mar 2008 15:22:59 -0400
schrieb "Jean-Samuel Chenard" <jsamch@gmail.com>:

> Hi,

Hi Jean-Samuel,
thanks for your report. Please CC LKML if you find bugs like this. I
also added Grant Likely (PPC Xilinx Virtex maintainer), as it seems to
be a platform specific problem.

> 
> Experimenting with your userspace I/O driver on a Xilinx FPGA (PowerPC
> 405), I was having problems when reading hardware device registers
> mapped on my platform using the user-space mmap() call.
> 
> After some investigation (looking at the driver/char/mspec.c file), I
> found that preventing caching of the page in uio_mmap_physical fixed
> my issues with userspace mmap() reading messed-up values.

Hm, we already mark the page with VM_IO. That's sufficient on x86 and
arm. I'm not sure whether this is a bug in PPC memory handling. Why do
they cache VM_IO pages? 

> 
> This patch is against your initial commit of the UIO driver in the
> mainline kernel tree.
> 
> ====
> diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
> index 865f32b..36e1123 100644
> --- a/drivers/uio/uio.c
> +++ b/drivers/uio/uio.c
> @@ -22,6 +22,7 @@
>  #include <linux/string.h>
>  #include <linux/kobject.h>
>  #include <linux/uio_driver.h>
> +#include <asm/pgtable.h>
> 
>  #define UIO_MAX_DEVICES 255
> 
> @@ -447,6 +448,8 @@ 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);
> +
>         return remap_pfn_range(vma,
>                                vma->vm_start,
>                                idev->info->mem[mi].addr >> PAGE_SHIFT,
> ====
> 
> I am a bit unsure if this will break something in any of your uses of
> the UIO driver (on other platforms than ppc), but it really fixes
> things for me.  

It should be OK, but unneccesary on other platforms. I have no
objections, but I fear in 6 months we'll see a patch removing that
line again because it's not needed... 

> Let me know if you need more details on what was
> happening on my platform before I added this statement.

I'd like to hear the opinion of people really involved in PPC memory
handling.

> 
> Thanks for the great driver for user-space I/O, it will save me lots
> of time in my research.
> 
> Regards,
> 
> Jean-Samuel

Thanks,
Hans


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

* Re: Linux UIO driver cache problem in PowerPC (fix)
  2008-03-13  7:19 ` Linux UIO driver cache problem in PowerPC (fix) Hans-Jürgen Koch
@ 2008-03-13 21:53   ` Grant Likely
  2008-03-14  7:41     ` Juergen Beisert
  2008-03-14 10:33   ` Hans J. Koch
  1 sibling, 1 reply; 6+ messages in thread
From: Grant Likely @ 2008-03-13 21:53 UTC (permalink / raw)
  To: Hans-Jürgen Koch, Josh Boyer, linuxppc-embedded
  Cc: Jean-Samuel Chenard, Thomas Gleixner, LKML, Greg KH

On Thu, Mar 13, 2008 at 1:19 AM, Hans-Jürgen Koch <hjk@linutronix.de> wrote:
> Am Wed, 12 Mar 2008 15:22:59 -0400
>  schrieb "Jean-Samuel Chenard" <jsamch@gmail.com>:
>
>  > Hi,
>
>  Hi Jean-Samuel,
>  thanks for your report. Please CC LKML if you find bugs like this. I
>  also added Grant Likely (PPC Xilinx Virtex maintainer), as it seems to
>  be a platform specific problem.

Hmmm.  I'm not a memory handling expert so I don't know what's going
on here.  Josh, does this look like anything that would be ppc405
related?

g.

>
>  >
>  > Experimenting with your userspace I/O driver on a Xilinx FPGA (PowerPC
>  > 405), I was having problems when reading hardware device registers
>  > mapped on my platform using the user-space mmap() call.
>  >
>  > After some investigation (looking at the driver/char/mspec.c file), I
>  > found that preventing caching of the page in uio_mmap_physical fixed
>  > my issues with userspace mmap() reading messed-up values.
>
>  Hm, we already mark the page with VM_IO. That's sufficient on x86 and
>  arm. I'm not sure whether this is a bug in PPC memory handling. Why do
>  they cache VM_IO pages?
>
>  >
>  > This patch is against your initial commit of the UIO driver in the
>  > mainline kernel tree.
>  >
>  > ====
>  > diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
>  > index 865f32b..36e1123 100644
>  > --- a/drivers/uio/uio.c
>  > +++ b/drivers/uio/uio.c
>  > @@ -22,6 +22,7 @@
>  >  #include <linux/string.h>
>  >  #include <linux/kobject.h>
>  >  #include <linux/uio_driver.h>
>  > +#include <asm/pgtable.h>
>  >
>  >  #define UIO_MAX_DEVICES 255
>  >
>  > @@ -447,6 +448,8 @@ 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);
>  > +
>  >         return remap_pfn_range(vma,
>  >                                vma->vm_start,
>  >                                idev->info->mem[mi].addr >> PAGE_SHIFT,
>  > ====
>  >
>  > I am a bit unsure if this will break something in any of your uses of
>  > the UIO driver (on other platforms than ppc), but it really fixes
>  > things for me.
>
>  It should be OK, but unneccesary on other platforms. I have no
>  objections, but I fear in 6 months we'll see a patch removing that
>  line again because it's not needed...
>
>  > Let me know if you need more details on what was
>  > happening on my platform before I added this statement.
>
>  I'd like to hear the opinion of people really involved in PPC memory
>  handling.
>
>  >
>  > Thanks for the great driver for user-space I/O, it will save me lots
>  > of time in my research.
>  >
>  > Regards,
>  >
>  > Jean-Samuel
>
>  Thanks,
>  Hans
>
>



-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: Linux UIO driver cache problem in PowerPC (fix)
  2008-03-13 21:53   ` Grant Likely
@ 2008-03-14  7:41     ` Juergen Beisert
  0 siblings, 0 replies; 6+ messages in thread
From: Juergen Beisert @ 2008-03-14  7:41 UTC (permalink / raw)
  To: linux-kernel

On Thursday 13 March 2008 22:53, Grant Likely wrote:
> On Thu, Mar 13, 2008 at 1:19 AM, Hans-Jürgen Koch <hjk@linutronix.de> wrote:
> > Am Wed, 12 Mar 2008 15:22:59 -0400
> >
> >  schrieb "Jean-Samuel Chenard" <jsamch@gmail.com>:
> >  > Hi,
> >
> >  Hi Jean-Samuel,
> >  thanks for your report. Please CC LKML if you find bugs like this. I
> >  also added Grant Likely (PPC Xilinx Virtex maintainer), as it seems to
> >  be a platform specific problem.
>
> Hmmm.  I'm not a memory handling expert so I don't know what's going
> on here.  Josh, does this look like anything that would be ppc405
> related?

The UIO also doesn't work on a MPC5200 CPU. With the additional 
pgprot_noncached() call now it works as expected.

Juergen

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

* Re: Linux UIO driver cache problem in PowerPC (fix)
  2008-03-13  7:19 ` Linux UIO driver cache problem in PowerPC (fix) Hans-Jürgen Koch
  2008-03-13 21:53   ` Grant Likely
@ 2008-03-14 10:33   ` Hans J. Koch
  2008-03-16  2:51     ` Leon Woestenberg
  1 sibling, 1 reply; 6+ messages in thread
From: Hans J. Koch @ 2008-03-14 10:33 UTC (permalink / raw)
  To: Hans-Jürgen Koch
  Cc: Jean-Samuel Chenard, Thomas Gleixner, LKML, Greg KH, grant.likely,
	Juergen Beisert

Am Thu, 13 Mar 2008 08:19:32 +0100
schrieb Hans-Jürgen Koch <hjk@linutronix.de>:

> Am Wed, 12 Mar 2008 15:22:59 -0400
> schrieb "Jean-Samuel Chenard" <jsamch@gmail.com>:
> 
> > Hi,

Hi Jean-Samuel,
I investigated a bit and found your patch to be correct. I cleaned it
up a bit and sent it to Greg and LKML. I added you as author and also
took the freedom to add your Signed-off-by.

Juergen, Thomas, Grant, if you can confirm this, please add your
signature as well.

Thanks,
Hans

> 
> Hi Jean-Samuel,
> thanks for your report. Please CC LKML if you find bugs like this. I
> also added Grant Likely (PPC Xilinx Virtex maintainer), as it seems to
> be a platform specific problem.
> 
> > 
> > Experimenting with your userspace I/O driver on a Xilinx FPGA
> > (PowerPC 405), I was having problems when reading hardware device
> > registers mapped on my platform using the user-space mmap() call.
> > 
> > After some investigation (looking at the driver/char/mspec.c file),
> > I found that preventing caching of the page in uio_mmap_physical
> > fixed my issues with userspace mmap() reading messed-up values.
> 
> Hm, we already mark the page with VM_IO. That's sufficient on x86 and
> arm. I'm not sure whether this is a bug in PPC memory handling. Why do
> they cache VM_IO pages? 
> 
> > 
> > This patch is against your initial commit of the UIO driver in the
> > mainline kernel tree.
> > 
> > ====
> > diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
> > index 865f32b..36e1123 100644
> > --- a/drivers/uio/uio.c
> > +++ b/drivers/uio/uio.c
> > @@ -22,6 +22,7 @@
> >  #include <linux/string.h>
> >  #include <linux/kobject.h>
> >  #include <linux/uio_driver.h>
> > +#include <asm/pgtable.h>
> > 
> >  #define UIO_MAX_DEVICES 255
> > 
> > @@ -447,6 +448,8 @@ 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);
> > +
> >         return remap_pfn_range(vma,
> >                                vma->vm_start,
> >                                idev->info->mem[mi].addr >>
> > PAGE_SHIFT, ====
> > 
> > I am a bit unsure if this will break something in any of your uses
> > of the UIO driver (on other platforms than ppc), but it really fixes
> > things for me.  
> 
> It should be OK, but unneccesary on other platforms. I have no
> objections, but I fear in 6 months we'll see a patch removing that
> line again because it's not needed... 
> 
> > Let me know if you need more details on what was
> > happening on my platform before I added this statement.
> 
> I'd like to hear the opinion of people really involved in PPC memory
> handling.
> 
> > 
> > Thanks for the great driver for user-space I/O, it will save me lots
> > of time in my research.
> > 
> > Regards,
> > 
> > Jean-Samuel
> 
> Thanks,
> Hans
> 
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-kernel" in the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: Linux UIO driver cache problem in PowerPC (fix)
  2008-03-14 10:33   ` Hans J. Koch
@ 2008-03-16  2:51     ` Leon Woestenberg
  2008-03-16 12:20       ` Hans J. Koch
  0 siblings, 1 reply; 6+ messages in thread
From: Leon Woestenberg @ 2008-03-16  2:51 UTC (permalink / raw)
  To: Hans J. Koch
  Cc: Jean-Samuel Chenard, Thomas Gleixner, LKML, Greg KH, grant.likely,
	Juergen Beisert

Hello,

On Fri, Mar 14, 2008 at 11:33 AM, Hans J. Koch <hjk@linutronix.de> wrote:
>  I investigated a bit and found your patch to be correct. I cleaned it
>  up a bit and sent it to Greg and LKML. I added you as author and also
>  took the freedom to add your Signed-off-by.
>
Could you elaborate why exactly this is needed, maybe even as a
comment in the patch?

It seemed non-trivial enough to rectify adding a comment.

Thanks,
-- 
Leon

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

* Re: Linux UIO driver cache problem in PowerPC (fix)
  2008-03-16  2:51     ` Leon Woestenberg
@ 2008-03-16 12:20       ` Hans J. Koch
  0 siblings, 0 replies; 6+ messages in thread
From: Hans J. Koch @ 2008-03-16 12:20 UTC (permalink / raw)
  To: Leon Woestenberg
  Cc: Jean-Samuel Chenard, Thomas Gleixner, LKML, Greg KH, grant.likely,
	Juergen Beisert

Am Sun, 16 Mar 2008 03:51:10 +0100
schrieb "Leon Woestenberg" <leon.woestenberg@gmail.com>:

> Hello,
> 
> On Fri, Mar 14, 2008 at 11:33 AM, Hans J. Koch <hjk@linutronix.de>
> wrote:
> >  I investigated a bit and found your patch to be correct. I cleaned
> > it up a bit and sent it to Greg and LKML. I added you as author
> > and also took the freedom to add your Signed-off-by.
> >
> Could you elaborate why exactly this is needed, maybe even as a
> comment in the patch?

As far as I understood, the VM_IO flag simply means that the page is
used for IO. On some architectures this automatically means that the
page is not cached, but this is not guaranteed. That's why
pgprot_noncached() exists.

If I misunderstood something or somebody can explain it better, please
let me know.

> 
> It seemed non-trivial enough to rectify adding a comment.

It _is_ trivial. It's just something you don't need every day, and
therefore it's not known to everybody (including me) or not obvious.
But if you look at it:

VM_IO means IO
pgprot_noncached means noncached

What could be more trivial?

Thanks,
Hans

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

end of thread, other threads:[~2008-03-16 12:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <169c03cb0803121222h5fca9cdal5af873cd2a700f4d@mail.gmail.com>
2008-03-13  7:19 ` Linux UIO driver cache problem in PowerPC (fix) Hans-Jürgen Koch
2008-03-13 21:53   ` Grant Likely
2008-03-14  7:41     ` Juergen Beisert
2008-03-14 10:33   ` Hans J. Koch
2008-03-16  2:51     ` Leon Woestenberg
2008-03-16 12: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