From: catalin.marinas@arm.com (Catalin Marinas)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 1/3] ARM: Introduce atomic MMIO modify
Date: Fri, 30 Aug 2013 10:15:36 +0100 [thread overview]
Message-ID: <20130830091534.GA62188@MacBook-Pro.local> (raw)
In-Reply-To: <20130830090807.GB25628@mudshark.cambridge.arm.com>
On Fri, Aug 30, 2013 at 10:08:07AM +0100, Will Deacon wrote:
> On Fri, Aug 23, 2013 at 12:48:05PM +0100, Catalin Marinas wrote:
> > On Fri, Aug 23, 2013 at 12:32:26PM +0100, Ezequiel Garcia wrote:
> > > On Fri, Aug 23, 2013 at 08:07:50AM -0300, Ezequiel Garcia wrote:
> > > > On Fri, Aug 23, 2013 at 01:38:02PM +0300, Baruch Siach wrote:
> > > > > On Fri, Aug 23, 2013 at 07:24:03AM -0300, Ezequiel Garcia wrote:
> > > > > > Some SoC have MMIO regions that are shared across orthogonal
> > > > > > subsystems. This commit implements a possible solution for the
> > > > > > thread-safe access of such regions through a spinlock-protected API.
> > > > > >
> > > > > > Concurrent access is protected with a single spinlock for the
> > > > > > entire MMIO address space. While this protects shared-registers,
> > > > > > it also serializes access to unrelated/unshared registers.
> > > > > >
> > > > > > We add relaxed and non-relaxed variants, by using writel_relaxed and writel,
> > > > > > respectively. The rationale for this is that some users may not require
> > > > > > register write completion but only thread-safe access to a register.
> > > > > >
> > > > > > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > > > >
> > > > > Is there a reason why this should be limited to ARM? I haven't found anything
> > > > > ARM specific in the code.
> > > >
> > > > I guess not.
> > >
> > > ... or maybe yes. I'm not seeing {readl,writel}_relaxed as guaranteed
> > > to exist in every architecture. So, indeed, this seems to be ARM-dependent.
> >
> > There was a discussion couple of years ago to make these part of the IO
> > specification since many architectures define them:
> >
> > http://thread.gmane.org/gmane.linux.ports.arm.kernel/117626
> >
> > (and some older threads on linux-arch which I haven't searched)
> >
> > We could have some default implementation pointing to readl/writel while
> > letting the arch code to define more optimised variants.
>
> The main thing I dislike about that is the back-to-back dsbs that you will
> get from the read-(modify)-write. It really makes the non-optimised version
> needlessly expensive.
Yes, it's pretty bad. But we don't have relaxed (write) accessors on
other architectures and I'm not sure about their semantics either. I
guess here it's a data dependency so you cannot write the value before
reading it, especially since sane architectures should speculate reads
or writes to device memory.
What about making it always use *_relaxed() accessors if the
architecture provides them? No need for atomic_io_modify_relaxed().
--
Catalin
next prev parent reply other threads:[~2013-08-30 9:15 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-23 10:24 [PATCH v3 0/3] Introduce atomic MMIO register modify Ezequiel Garcia
2013-08-23 10:24 ` [PATCH v3 1/3] ARM: Introduce atomic MMIO modify Ezequiel Garcia
2013-08-23 10:38 ` Baruch Siach
2013-08-23 11:07 ` Ezequiel Garcia
2013-08-23 11:32 ` Ezequiel Garcia
2013-08-23 11:48 ` Catalin Marinas
2013-08-30 9:08 ` Will Deacon
2013-08-30 9:15 ` Catalin Marinas [this message]
2013-08-30 9:20 ` Will Deacon
2013-08-30 10:03 ` Catalin Marinas
2013-08-30 20:08 ` Jason Gunthorpe
2013-08-30 22:18 ` Russell King - ARM Linux
2013-09-05 8:59 ` Gregory CLEMENT
2013-09-05 9:08 ` Will Deacon
2013-09-05 9:20 ` Gregory CLEMENT
2013-09-06 16:48 ` Jason Gunthorpe
2013-08-23 11:28 ` Ezequiel Garcia
2013-08-23 10:24 ` [PATCH v3 2/3] clocksource: orion: Use atomic access for shared registers Ezequiel Garcia
2013-08-23 10:38 ` Baruch Siach
2013-08-23 10:49 ` Ezequiel Garcia
2013-08-23 10:24 ` [PATCH v3 3/3] watchdog: " Ezequiel Garcia
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=20130830091534.GA62188@MacBook-Pro.local \
--to=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.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).