From: Arnd Bergmann <arnd@arndb.de>
To: Jonas Bonn <jonas@southpole.se>
Cc: Jiri Slaby <jirislaby@gmail.com>, linux-kernel@vger.kernel.org
Subject: Re: ioremap definition in generic io.h
Date: Thu, 30 Sep 2010 14:04:36 +0200 [thread overview]
Message-ID: <201009301404.36551.arnd@arndb.de> (raw)
In-Reply-To: <1285847579.2639.3.camel@needafix>
On Thursday 30 September 2010, Jonas Bonn wrote:
> On Thu, 2010-09-30 at 13:45 +0200, Arnd Bergmann wrote:
> > On Wednesday 29 September 2010, Jonas Bonn wrote:
> > > On another note, looking at the definitions of ioread32/iowrite32, they
> > > imply a little-endian bus. Some architectures (e.g. Microblaze) define
> > > these to use host-native byte ordering instead. Is there a correct
> > > way these functions should be defined?
> >
> > ioread32/iowrite32 are accessor functions for PCI byte order which is
> > little endian. If microblaze does this differently, that is a microblaze
> > bug. Any code that needs big-endian I/O should use ioread32be/iowrite32be.
> >
>
> So what's the correct way to do host-native access? For example, big
> endian access on a big endian processor. I think I'm missing something
> fundamental here...
The I/O accessors in Linux are written under the assumption that the I/O
device is fixed endian and may be used on both kinds of CPUs.
I assume that microblaze is a special case here because you synthesize
the I/O devices together with the CPU core and choose a common endianess
for both, right?
We have the __raw_readl()/__raw_writel() functions which are defined as
host-endian, but I would not recommend using them in general because they
also mean slightly different things depending on the architecture.
It's probably best to define your own functions for microblaze. Obviously
the drivers are not portable to other architectures anyway because those
might be cross-endian.
It's probably best to name the accessors by the bus that the devices
are attached to, and then define them in a a per-bus header file, like
#ifdef CONFIG_PLB_BIG_ENDIAN
#define plb_ioread32(p) ioread32be(p)
#define plb_iowrite32(p) iowrite32be(p)
#else
#define plb_ioread32(p) ioread32(p)
#define plb_iowrite32(p) iowrite32(p)
#endif
Arnd
next prev parent reply other threads:[~2010-09-30 12:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-29 7:59 ioremap definition in generic io.h Jonas Bonn
2010-09-29 10:53 ` Jiri Slaby
2010-09-29 11:07 ` Jonas Bonn
2010-09-30 11:45 ` Arnd Bergmann
2010-09-30 11:52 ` Jonas Bonn
2010-09-30 12:04 ` Arnd Bergmann [this message]
2010-10-01 8:35 ` Jonas Bonn
2010-10-01 8:43 ` Arnd Bergmann
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=201009301404.36551.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=jirislaby@gmail.com \
--cc=jonas@southpole.se \
--cc=linux-kernel@vger.kernel.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