RE: Accessing flash directly from User Space [SOLVED]

2009-10-28 Thread Jonathan Haws
> > On Tue, Oct 27, 2009 at 04:24:53PM -0600, Jonathan Haws wrote: > > >> >>> How can I get that pointer? Unfortunately I cannot simply > > use > > >> the > > >> >>> > > >> >> address of the flash. Is there some magical function call > > that > > >> >> gives me access to that portion of the memor

RE: Accessing flash directly from User Space [SOLVED]

2009-10-29 Thread Joakim Tjernlund
> > > > On Tue, Oct 27, 2009 at 04:24:53PM -0600, Jonathan Haws wrote: > > > >> >>> How can I get that pointer? Unfortunately I cannot simply > > > use > > > >> the > > > >> >>> > > > >> >> address of the flash. Is there some magical function call > > > that > > > >> >> gives me access to that po

RE: Accessing flash directly from User Space [SOLVED]

2009-10-29 Thread Joakim Tjernlund
> > > > > > > On Tue, Oct 27, 2009 at 04:24:53PM -0600, Jonathan Haws wrote: > > > > >> >>> How can I get that pointer? Unfortunately I cannot simply > > > > use > > > > >> the > > > > >> >>> > > > > >> >> address of the flash. Is there some magical function call > > > > that > > > > >> >> gives

RE: Accessing flash directly from User Space [SOLVED]

2009-10-29 Thread Kenneth Johansson
On Thu, 2009-10-29 at 10:00 +0100, Joakim Tjernlund wrote: > > > > > > On Tue, Oct 27, 2009 at 04:24:53PM -0600, Jonathan Haws wrote: > > > > >> >>> How can I get that pointer? Unfortunately I cannot simply > > > > use > > > > >> the > > > > >> >>> > > > > >> >> address of the flash. Is there som

RE: Accessing flash directly from User Space [SOLVED]

2009-10-29 Thread Jonathan Haws
> Does O_DIRECT help? (you may need to define _GNU_SOURCE before > #include) Nope, O_DIRECT did not help - in fact it caused the application to crash. Why that is I am not sure, but it crashed. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.o

RE: Accessing flash directly from User Space [SOLVED]

2009-10-29 Thread Jonathan Haws
> > > Anyway, to make a long story short, I inserted an msync() after > each > > > assignment to the flash. This resolved my problem and I can now > program my flash. > > > > Ouch, this was news to me too. Calling msync() after every write > kills performance. > > We use mmap(/dev/mem) to access H

Re: Accessing flash directly from User Space [SOLVED]

2009-10-29 Thread Scott Wood
On Thu, Oct 29, 2009 at 10:00:28AM +0100, Joakim Tjernlund wrote: > > I have found the problem. It occurred to me in the shower (okay not really, > > but most good ideas happen there). > > > > What was happening is that I was in fact able to write to the correct > > registers. However, I would tr

RE: Accessing flash directly from User Space [SOLVED]

2009-10-30 Thread Jonathan Haws
> On Thu, Oct 29, 2009 at 10:00:28AM +0100, Joakim Tjernlund wrote: > > > I have found the problem. It occurred to me in the shower (okay > not really, > > > but most good ideas happen there). > > > > > > What was happening is that I was in fact able to write to the > correct > > > registers. How

Re: Accessing flash directly from User Space [SOLVED]

2009-10-30 Thread Michael Buesch
On Friday 30 October 2009 15:50:22 Jonathan Haws wrote: > > I suspect that the msync() was merely serving as a very heavyweight > > memory barrier. > > I did try hacking the mb() calls from the kernel source to use them in user > space, but they had no effect. I still had to include the calls to

RE: Accessing flash directly from User Space [SOLVED]

2009-10-30 Thread Jonathan Haws
> On Friday 30 October 2009 15:50:22 Jonathan Haws wrote: > > > I suspect that the msync() was merely serving as a very > heavyweight > > > memory barrier. > > > > I did try hacking the mb() calls from the kernel source to use > them in user space, but they had no effect. I still had to include >

Re: Accessing flash directly from User Space [SOLVED]

2009-10-30 Thread Alessandro Rubini
> asm("eieio; sync"); Hmm... : : : "memory" And, doesn't ";" start a comment in assembly? (no, not on powerpc it seems) Just to make sure, if you replace msync() with another system call, like "kill(1, 0);" you can verify wether it's really useful or if it's only acting as a barrier. /a

Re: Accessing flash directly from User Space [SOLVED]

2009-10-30 Thread Michael Buesch
On Friday 30 October 2009 16:08:55 Alessandro Rubini wrote: > > asm("eieio; sync"); > > Hmm... > : : : "memory" > > And, doesn't ";" start a comment in assembly? (no, not on powerpc it seems) Yes, I think the barrier is wrong. Please try with #define mb()__asm__ __volatile__("eieio\n

RE: Accessing flash directly from User Space [SOLVED]

2009-10-30 Thread Jonathan Haws
> On Friday 30 October 2009 16:08:55 Alessandro Rubini wrote: > > > asm("eieio; sync"); > > > > Hmm... > > : : : "memory" > > > > And, doesn't ";" start a comment in assembly? (no, not on powerpc > it seems) > > Yes, I think the barrier is wrong. > Please try with > > #define mb() __asm__ __

Re: Accessing flash directly from User Space [SOLVED]

2009-10-30 Thread Micha Nelissen
Michael Buesch wrote: Yes, I think the barrier is wrong. Please try with #define mb()__asm__ __volatile__("eieio\n sync\n" : : : "memory") For uncached memory, eieio should be enough. Micha ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlab

Re: Accessing flash directly from User Space [SOLVED]

2009-10-30 Thread Scott Wood
On Fri, Oct 30, 2009 at 04:08:55PM +0100, Alessandro Rubini wrote: > > asm("eieio; sync"); > > Hmm... > : : : "memory" > > And, doesn't ";" start a comment in assembly? (no, not on powerpc it seems) ';' is an instruction separator on all GNU as targets that I'm familiar with (though a quic

RE: Accessing flash directly from User Space [SOLVED]

2009-10-30 Thread Jonathan Haws
> Michael Buesch wrote: > > Yes, I think the barrier is wrong. > > Please try with > > > > #define mb()__asm__ __volatile__("eieio\n sync\n" : : : > "memory") > > > For uncached memory, eieio should be enough. I tried eieio alone and it did not work. It needed the above command to take

Re: Accessing flash directly from User Space [SOLVED]

2009-10-30 Thread Gabriel Paubert
On Fri, Oct 30, 2009 at 10:46:46AM -0600, Jonathan Haws wrote: > > Michael Buesch wrote: > > > Yes, I think the barrier is wrong. > > > Please try with > > > > > > #define mb() __asm__ __volatile__("eieio\n sync\n" : : : > > "memory") > > > > > > For uncached memory, eieio should be enough.

RE: Accessing flash directly from User Space [SOLVED]

2009-10-31 Thread Joakim Tjernlund
> > > On Friday 30 October 2009 16:08:55 Alessandro Rubini wrote: > > > > asm("eieio; sync"); > > > > > > Hmm... > > >: : : "memory" > > > > > > And, doesn't ";" start a comment in assembly? (no, not on powerpc > > it seems) > > > > Yes, I think the barrier is wrong. > > Please try with > > > >

Re: Accessing flash directly from User Space [SOLVED]

2009-10-31 Thread Michael Buesch
On Saturday 31 October 2009 14:26:48 Joakim Tjernlund wrote: > > > > > On Friday 30 October 2009 16:08:55 Alessandro Rubini wrote: > > > > > asm("eieio; sync"); > > > > > > > > Hmm... > > > >: : : "memory" > > > > > > > > And, doesn't ";" start a comment in assembly? (no, not on powerpc > > > i

Re: Accessing flash directly from User Space [SOLVED]

2009-10-31 Thread Joakim Tjernlund
Michael Buesch wrote on 31/10/2009 17:42:54: > > On Saturday 31 October 2009 14:26:48 Joakim Tjernlund wrote: > > > > > > > On Friday 30 October 2009 16:08:55 Alessandro Rubini wrote: > > > > > > asm("eieio; sync"); > > > > > > > > > > Hmm... > > > > >: : : "memory" > > > > > > > > > > And, do

Re: Accessing flash directly from User Space [SOLVED]

2009-10-31 Thread Michael Buesch
On Saturday 31 October 2009 21:14:07 Joakim Tjernlund wrote: > Michael Buesch wrote on 31/10/2009 17:42:54: > > > > On Saturday 31 October 2009 14:26:48 Joakim Tjernlund wrote: > > > > > > > > > On Friday 30 October 2009 16:08:55 Alessandro Rubini wrote: > > > > > > > asm("eieio; sync"); > > > > >

Re: Accessing flash directly from User Space [SOLVED]

2009-10-31 Thread Joakim Tjernlund
Michael Buesch wrote on 31/10/2009 21:35:31: > > On Saturday 31 October 2009 21:14:07 Joakim Tjernlund wrote: > > Michael Buesch wrote on 31/10/2009 17:42:54: > > > > > > On Saturday 31 October 2009 14:26:48 Joakim Tjernlund wrote: > > > > > > > > > > > On Friday 30 October 2009 16:08:55 Alessand

Re: Accessing flash directly from User Space [SOLVED]

2009-11-01 Thread Segher Boessenkool
mmio[0] = address; mmio[1] = data; mb(); eieio is enough here. mmio[3] |= 0x01; /* This triggers an operation -> address=data */ /* probably also need an mb() here, if the following code * depends on the operation to be triggered. */ No, a sync does not guarantee the device has seen the sto