linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Eddie Dawydiuk <eddie@embeddedarm.com>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: PPC PCI bus registers
Date: Thu, 03 Sep 2009 20:00:32 +1000	[thread overview]
Message-ID: <1251972032.15089.30.camel@pasglop> (raw)
In-Reply-To: <4A9F0377.1070606@embeddedarm.com>

On Wed, 2009-09-02 at 16:44 -0700, Eddie Dawydiuk wrote:
> Hello,
> 
> I have a question regarding reading PCI bus registers from a user space 
> application running on a PPC SBC. Seeing as though the PCI bus is little endian 
> and PPC is big endian is it typical that one must perform a byte swap on all 16 
> and 32 bit register reads?
> 
> I've found this is true on a custom board I am working on(with an FPGA connected 
> via the PCI bus) and as a result I've added a byte swap command in busybox to 
> accommodate this feature...

Note that powerpc has efficient load/store reverse instructions that
perform the byteswap for you. We use them for IOs in the kernel for
example.

Also, if you're going to access a PCI device directly, beware of other
issues such as ordering. PPC is an out of order architecture, you need
to ensure you add the appropriate memory barriers if you want to ensure
you accesses are done in the order you write them in your program.

For "standard" stuff that doesn't involve DMA or locks, an eieio after
both MMIO loads and stores should do the trick.

If you need to order vs. DMA and/or locks, you may want to look at what
the kernel does in io.h

Cheers,
Ben.

  parent reply	other threads:[~2009-09-03 10:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-02 23:44 PPC PCI bus registers Eddie Dawydiuk
2009-09-02 23:56 ` Grant Likely
2009-09-03 10:00 ` Benjamin Herrenschmidt [this message]
2009-09-16 18:58   ` Eddie Dawydiuk
2009-09-16 21:54     ` Benjamin Herrenschmidt
2009-09-16 22:11       ` Eddie Dawydiuk
2009-09-17  1:24         ` Benjamin Herrenschmidt
2009-09-17 16:11           ` Eddie Dawydiuk

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=1251972032.15089.30.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=eddie@embeddedarm.com \
    --cc=linuxppc-dev@ozlabs.org \
    /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).