linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Matt Sealey <matt@genesi-usa.com>
Cc: PowerPC dev list <linuxppc-dev@ozlabs.org>
Subject: Re: PCI reading without endian conversion
Date: Sat, 21 Feb 2009 09:37:30 +1100	[thread overview]
Message-ID: <1235169450.8805.193.camel@pasglop> (raw)
In-Reply-To: <b5e2fc790902201057of113946yea9ccc7405e31926@mail.gmail.com>

On Fri, 2009-02-20 at 12:57 -0600, Matt Sealey wrote:
> Hi guys,
> 
> What's the correct way to read from PCI address space (basically it's
> guaranteed to be non-coherent memory bar) without flipping bits like
> ioread32() does?

ioread32be() ? :-) But from what you say below, it seems the wrong
approach.

> I need to be able to copy a bank of registers from PCI address space
> into a temporary buffer so I can compare them in userspace through
> UIO. Because of the flipping and the difference between the original
> kernel driver (which used ioread32() and therefore "saw" big endian)
> and the userspace app (which has a direct view of the PCI space, and
> therefore "sees" little endian) I decided to give userspace an
> absolutely consistent little-endian view seeing as this may get ported
> to ARM in the coming months.

Your sentence above doesn't seem to make much sense to me ... Why don't
you just have your userspace use lwbrx and "see" the same thing as the
kernel ? Which would also happen to be the same thing as an ARM in LE
mode would see...

> I want to put as little code in there as possible and not laboriously
> manually flip from my ioread32() big endian values to little endian
> again (waste of time and code) if I can help it. Being able to read
> the raw value would help a lot, and if I need to do calculations on a
> small portion of the data then I can do the flips manually then (using
> le32_to_cpu and cpu_to_le32 which will be a noop on ARM), reducing the
> amount of porting I need to do in both kernel and userspace alike.
>
> So, is there something like a direct ioread32le() or so, which will
> not change behaviour across architectures, is present on ARM and PPC,
> and will handle both PCI address space, and "normal" "ioremapped"
> memory?

Little of what you say above make sense, you mix unrelated concepts and
all other weirdness mangled with purely false assumptions but from what
I can tell, what you should do is something along the line of:

 - kernel uses normal ioread32 on all platforms
 - userspace use lwbrx on powerpc and normal loads on LE platforms via
   some kind of macro you define for that

That will give you a consistent view accross the board.

Cheers,
Ben.

      parent reply	other threads:[~2009-02-20 22:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-20 18:57 PCI reading without endian conversion Matt Sealey
2009-02-20 19:11 ` Ira Snyder
2009-02-20 20:05   ` Matt Sealey
2009-02-20 21:07     ` Ira Snyder
2009-02-20 21:56       ` Matt Sealey
2009-02-20 23:50         ` Ira Snyder
2009-02-21  4:33           ` Benjamin Herrenschmidt
2009-02-23 10:37           ` Geert Uytterhoeven
2009-02-20 22:37 ` Benjamin Herrenschmidt [this message]

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=1235169450.8805.193.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=matt@genesi-usa.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).