linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Michael Buesch <mb@bu3sch.de>
To: Joakim Tjernlund <joakim.tjernlund@transmode.se>
Cc: "scottwood@freescale.com" <scottwood@freescale.com>,
	Alessandro Rubini <rubini@gnudd.com>,
	"bgat@billgatliff.com" <bgat@billgatliff.com>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
	Jonathan Haws <Jonathan.Haws@sdl.usu.edu>
Subject: Re: Accessing flash directly from User Space [SOLVED]
Date: Sat, 31 Oct 2009 21:35:31 +0100	[thread overview]
Message-ID: <200910312135.34196.mb@bu3sch.de> (raw)
In-Reply-To: <OF7FB0F99B.2962ECBA-ONC1257660.006EDDB5-C1257660.006F2808@transmode.se>

On Saturday 31 October 2009 21:14:07 Joakim Tjernlund wrote:
> Michael Buesch <mb@bu3sch.de> 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, 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 sync\n" : : :
> > > > > "memory")
> > > >
> > > > That definition worked great.  I must have missed the : : : "memory" bit when
> > > > I was digging through code.
> > > >
> > > > Thanks, that gives me about a 2x speedup over the msync() calls.
> > >
> > > Exactly when should you use the barrier? At every access,
> > > every read or when changing from write to read?
> >
> > Well, it depends on the device you are accessing. I'll give you a small pseudo example.
> >
> > mmio[0] = address;
> > mmio[1] = data;
> > mb();
> > 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. */
> 
> So anything that depends on the previous accesses needs a mb()

No, not really. I would always put an mb() where the comment is.
Imagine you have two instances of the above (probably in a loop):

mmio[0] = address;
mmio[1] = data;
mb();
mmio[3] |= 0x01; /* This triggers an operation -> address=data */
mb();

mmio[0] = address;
mmio[1] = data;
mb();
mmio[3] |= 0x01; /* This triggers an operation -> address=data */
mb();

> hmm, the mmio[0] and mmio[1] are written in order I hope?

We do not care in this example, as the write to [3] does trigger
the device operation. We do only care that [0] and [1] are set
when [3] is written. We do not care in what order [0] and [1] are written.

This is just an artificial example, but I think you get my point.
My point just being is that an mb() does only belong where it matters.
And what matters is defined by your device specifications.

-- 
Greetings, Michael.

  reply	other threads:[~2009-10-31 20:36 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-27 19:59 Accessing flash directly from User Space Jonathan Haws
2009-10-27 20:13 ` Bill Gatliff
2009-10-27 20:15   ` Jonathan Haws
2009-10-27 20:30     ` Bill Gatliff
2009-10-27 20:31       ` Jonathan Haws
2009-10-27 22:24       ` Jonathan Haws
2009-10-27 22:32         ` Scott Wood
2009-10-27 22:35           ` Jonathan Haws
2009-10-27 22:42             ` Scott Wood
2009-10-27 22:52               ` Jonathan Haws
2009-10-28  9:56                 ` Kenneth Johansson
2009-10-28 14:45                   ` Jonathan Haws
2009-10-29 21:36                     ` Joerg Albert
2009-10-29 21:39                       ` Jonathan Haws
2009-10-29 16:33                 ` Scott Wood
2009-10-29 16:48                   ` Jonathan Haws
     [not found]           ` <BB99A6BA28709744BF22A68E6D7EB51F0330D368AA@midas.usurf.usu.edu >
2009-10-27 22:42             ` Alessandro Rubini
2009-10-28 11:24         ` Josh Boyer
2009-10-28 14:38           ` Jonathan Haws
2009-10-28 17:44             ` Accessing flash directly from User Space [SOLVED] Jonathan Haws
2009-10-29  9:00               ` Joakim Tjernlund
2009-10-29  9:15                 ` Joakim Tjernlund
2009-10-29 17:01                   ` Jonathan Haws
2009-10-29 11:08                 ` Kenneth Johansson
2009-10-29 17:02                   ` Jonathan Haws
2009-10-29 23:30                 ` Scott Wood
2009-10-30 14:50                   ` Jonathan Haws
2009-10-30 14:56                     ` Michael Buesch
2009-10-30 14:57                       ` Jonathan Haws
     [not found]                       ` <BB99A6BA28709744BF22A68E6D7EB51F0330E23124@midas.usurf.usu.edu >
2009-10-30 15:08                         ` Alessandro Rubini
2009-10-30 15:24                           ` Michael Buesch
2009-10-30 15:33                             ` Jonathan Haws
2009-10-31 13:26                               ` Joakim Tjernlund
2009-10-31 16:42                                 ` Michael Buesch
2009-10-31 20:14                                   ` Joakim Tjernlund
2009-10-31 20:35                                     ` Michael Buesch [this message]
2009-10-31 22:31                                       ` Joakim Tjernlund
2009-11-01 10:07                                         ` Segher Boessenkool
2009-10-30 15:48                             ` Micha Nelissen
2009-10-30 16:46                               ` Jonathan Haws
2009-10-30 17:49                                 ` Gabriel Paubert
2009-10-30 15:57                           ` Scott Wood
     [not found]       ` <BB99A6BA28709744BF22A68E6D7EB51F0330D3688B@midas.usurf.usu.edu >
2009-10-27 22:32         ` Accessing flash directly from User Space Alessandro Rubini
2009-10-27 22:33           ` Jonathan Haws

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200910312135.34196.mb@bu3sch.de \
    --to=mb@bu3sch.de \
    --cc=Jonathan.Haws@sdl.usu.edu \
    --cc=bgat@billgatliff.com \
    --cc=joakim.tjernlund@transmode.se \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=rubini@gnudd.com \
    --cc=scottwood@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).