From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: Mason <slash.tmp@free.fr>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>,
Rich Felker <dalias@libc.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
linux-pci <linux-pci@vger.kernel.org>
Subject: Re: [PATCH 1/8] arch/sh: add sh7786_mm_sel() function
Date: Mon, 8 Jan 2018 13:55:15 +0100 [thread overview]
Message-ID: <20180108135515.166da07c@windsurf> (raw)
In-Reply-To: <a306b914-e95a-4199-60de-39e88782ac05@free.fr>
Hello,
On Mon, 8 Jan 2018 13:28:42 +0100, Mason wrote:
> > +static inline u32 sh7786_mm_sel(void)
> > +{
> > + return __raw_readl(0xFC400020) & 0x7;
>
> I thought we were never supposed to use __raw_readl(), rather use readl_relaxed() instead?
>
> The difference is that readl_relaxed() takes care of endianness, which would seem relevant
> since you have both endianness. Am I missing something?
Yes. That I/O accessors in Linux are a mess.
On ARM for example, when the CPU runs big-endian, the devices are still
little-endian, so we use readl/writel (or their relaxed variants) to do
the endianness conversion.
However, on SH, platform devices have an endianness that follow the
CPU one. So if you run little-endian, your devices are little endian,
if you run big-endian, your devices are big endian. Hence the use of
__raw_readl().
So you could ask me: but if SH behaves like this, why is readl/writel
doing an endianness conversion on this architecture? Well because
readl/writel were originally introduced for PCI devices, and PCI
devices are always little-endian, even when your SH core runs
big-endian.
Basically, I think the I/O accessors are just a mess, and the only way
to solve this mess properly would be to have a "struct device *" as
argument to those accessors, that tells the accessor how the device
behaves in terms of endianness.
Best regards,
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
next prev parent reply other threads:[~2018-01-08 12:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-04 15:08 [PATCH 0/8] SH7786 PCIe support fixes Thomas Petazzoni
2017-12-04 15:09 ` [PATCH 1/8] arch/sh: add sh7786_mm_sel() function Thomas Petazzoni
2018-01-08 12:28 ` Mason
2018-01-08 12:55 ` Thomas Petazzoni [this message]
2017-12-04 15:09 ` [PATCH 2/8] arch/sh: make the DMA mapping operations observe dev->dma_pfn_offset Thomas Petazzoni
2017-12-04 15:09 ` [PATCH 3/8] arch/sh: pci: don't use disabled resources Thomas Petazzoni
2017-12-04 15:09 ` [PATCH 4/8] arch/sh: pcie-sh7786: mark unavailable PCI resource as disabled Thomas Petazzoni
2017-12-04 15:09 ` [PATCH 5/8] arch/sh: pcie-sh7786: exclude unusable PCI MEM areas Thomas Petazzoni
2017-12-04 15:09 ` [PATCH 6/8] arch/sh: pcie-sh7786: adjust PCI MEM and IO regions Thomas Petazzoni
2017-12-04 15:09 ` [PATCH 7/8] arch/sh: pcie-sh7786: adjust the memory mapping Thomas Petazzoni
2017-12-04 15:09 ` [PATCH 8/8] arch/sh: pcie-sh7786: handle non-zero DMA offset Thomas Petazzoni
2018-01-07 15:06 ` [PATCH 0/8] SH7786 PCIe support fixes Thomas Petazzoni
2018-01-08 22:12 ` Bjorn Helgaas
2018-01-08 22:27 ` Thomas Petazzoni
2018-02-26 13:32 ` Thomas Petazzoni
2018-02-19 16:22 ` Thomas Petazzoni
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=20180108135515.166da07c@windsurf \
--to=thomas.petazzoni@free-electrons.com \
--cc=bhelgaas@google.com \
--cc=dalias@libc.org \
--cc=geert@linux-m68k.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=slash.tmp@free.fr \
--cc=ysato@users.sourceforge.jp \
/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