From: Arnd Bergmann <arnd@arndb.de>
To: linux-arm-kernel@lists.infradead.org
Cc: "Li.Xiubo@freescale.com" <Li.Xiubo@freescale.com>,
"linux-pwm@vger.kernel.org" <linux-pwm@vger.kernel.org>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"thierry.reding@gmail.com" <thierry.reding@gmail.com>,
Jingchang Lu <jingchang.lu@freescale.com>,
"shawn.guo@linaro.org" <shawn.guo@linaro.org>,
Huan Wang <Huan.Wang@freescale.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
Subject: Re: [PATCHv8 1/4] pwm: Add Freescale FTM PWM driver support
Date: Fri, 3 Jan 2014 13:50:59 +0100 [thread overview]
Message-ID: <201401031350.59447.arnd@arndb.de> (raw)
In-Reply-To: <bb5e14370ddb4ce2921140d147244097@BY2PR03MB505.namprd03.prod.outlook.com>
On Friday 03 January 2014, Li.Xiubo@freescale.com wrote:
> > Subject: Re: [PATCHv8 1/4] pwm: Add Freescale FTM PWM driver support
> >
> > On Thursday 02 January 2014 17:57:01 Xiubo Li wrote:
> > > +static inline u32 ftm_readl(bool big_endian, const void __iomem *addr)
> > > +{
> > > + u32 val;
> > > +
> > > + val = __raw_readl(addr);
> > > +
> > > + if (likely(big_endian))
> > > + val = be32_to_cpu((__force __be32)val);
> > > + else
> > > + val = le32_to_cpu((__force __le32)val);
> > > + rmb();
> > > +
> > > + return val;
> > > +}
> > > +
> > > +static inline void ftm_writel(bool big_endian, u32 val, void __iomem *addr)
> > > +{
> > > + wmb();
> > > + if (likely(big_endian))
> > > + val = (__force u32)cpu_to_be32(val);
> > > + else
> > > + val = (__force u32)cpu_to_le32(val);
> > > +
> > > + __raw_writel(val, addr);
> >
> > These functions definitely need some comments regarding why this is necessary.
> > I assume that after 8 rounds of review (that I did not read) this has been
> > discussed already, so please explain above the functions why you don't just
> > use ioread32be/ioread32 and iowrite32be/iowrite32 here.
> >
>
> As Thierry has commonts in some days before:
> ----
> A few years ago GregKH commented in response to a patch that ioread*()
> weren't supposed to be used for memory-mapped only devices. The original
> purpose apparently was to allow drivers to work with both I/O and
> memory-mapped devices.
> ----
> I'm not very sure.
Adding Greg here to make sure we have a common understanding in the future.
ioread*() was indeed introduced for devices that can be both I/O and memory
space, and is a bit slowed than readl() on architectures that don't have
memory mapped I/O space (i.e. x86).
However, ioread32be is the only architecture-independent big-endian
accessor function (some architectures have in_be32, but that doesn't
work on ARM), and as mandated by Linus a couple of years ago when
we wanted to take some shortcuts on powerpc, ioread32 has to be
semantically the same as readl when used on pointers returned from
ioremap() rather than ioport_map, and ioread32be is just the
byte-swapped version of it.
We have a couple of drivers using ioread* because of the need for
big-endian data access, and I would continue recommending that unless
I hear a good argument against it.
> The big-endian supports is added at v7~v8 patch series.
Yes, that version looks fine and it avoids the above problem nicely,
but I'd still like to make sure we come to a conclusion on the problem
of big-endian I/O accessors.
Arnd
next prev parent reply other threads:[~2014-01-03 12:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-02 9:57 [PATCHv8 0/4] Add Freescale FTM PWM driver Xiubo Li
2014-01-02 9:57 ` [PATCHv8 1/4] pwm: Add Freescale FTM PWM driver support Xiubo Li
2014-01-02 11:12 ` Arnd Bergmann
2014-01-03 9:19 ` Li.Xiubo
2014-01-03 12:50 ` Arnd Bergmann [this message]
2014-01-06 7:39 ` Li.Xiubo
2014-01-02 9:57 ` [PATCHv8 2/4] ARM: dts: Add Freescale FTM PWM node for VF610 Xiubo Li
2014-01-02 9:57 ` [PATCHv8 3/4] ARM: dts: Enables FTM PWM device for Vybrid VF610 TOWER board Xiubo Li
2014-01-02 9:57 ` [PATCHv8 4/4] Documentation: Add device tree bindings for Freescale FTM PWM Xiubo Li
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=201401031350.59447.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=Huan.Wang@freescale.com \
--cc=Li.Xiubo@freescale.com \
--cc=gregkh@linuxfoundation.org \
--cc=jingchang.lu@freescale.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=shawn.guo@linaro.org \
--cc=thierry.reding@gmail.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
Powered by JetHome