From: ezequiel.garcia@free-electrons.com (Ezequiel Garcia)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/3] ARM: Introduce atomic MMIO clear/set
Date: Wed, 21 Aug 2013 11:36:55 -0300 [thread overview]
Message-ID: <20130821143654.GB2459@localhost> (raw)
In-Reply-To: <20130820210839.GE17845@n2100.arm.linux.org.uk>
Russell,
On Tue, Aug 20, 2013 at 10:08:39PM +0100, Russell King - ARM Linux wrote:
> On Tue, Aug 20, 2013 at 01:48:25PM -0300, Ezequiel Garcia wrote:
> > Based on a similar approach suggested by Russel King:
>
> Russell please.
>
> We Russells get upset when our names are incorrectly spelt, just like
> others get upset if they end up with extra letters in their names, or
> you confuse Steven vs Stephen. Or even dare call a Deborah "Debs"
> (I did that once and the result was not particularly nice!)
>
Ouch... sorry about that!
> > +void atomic_io_clear_set(u32 clear, u32 set, void __iomem *reg)
> > +{
> > + spin_lock(&__io_lock);
> > + writel((readl(reg) & ~clear) | set, reg);
> > + /* ensure the write get done before unlocking */
> > + __iowmb();
> > + spin_unlock(&__io_lock);
> > +}
> > +EXPORT_SYMBOL(atomic_io_clear_set);
>
> Some comments - neither of them you _have_ to act on:
>
> 1. writel((readl(reg) & ~mask) | (set & mask), reg) could be deemed
> to give better semantics - consider that if you don't look at the
> implementation, how do you know what the result of setting a bit
> in both the set & clear masks would be?
>
> 2. A historical note, that back in the 1980s with things like the BBC
> micro, this kind of operation was defined:
>
> new_value = (old_value & mask) ^ value
>
> which has the flexibility of being able to set, clear or toggle any
> bit. I'm not saying that's a good interface, I'm merely pointing
> out that the problem of being able to set and clear bits is nothing
> new and other solutions are available. :)
>
> 3. Would it be better to separate these by having atomic_io_clear() and
> atomic_io_set() functions?
>
> Just some things to think about; I have no overall preference here.
Indeed, I don't have any strong opinions on any of the above.
However, I'm a bit inclined to your proposal in (1), which coincides with:
int regmap_update_bits(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val)
This looks a lot less intuitive to me, but more flexible.
Any other thoughts?
--
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
next prev parent reply other threads:[~2013-08-21 14:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-20 16:48 [PATCH v2 0/3] Introduce atomic MMIO register clear-set Ezequiel Garcia
2013-08-20 16:48 ` [PATCH v2 1/3] ARM: Introduce atomic MMIO clear/set Ezequiel Garcia
2013-08-20 16:55 ` Ezequiel Garcia
2013-08-20 21:08 ` Russell King - ARM Linux
2013-08-21 14:36 ` Ezequiel Garcia [this message]
2013-08-21 12:24 ` Will Deacon
2013-08-21 14:22 ` Ezequiel Garcia
2013-08-21 16:28 ` Will Deacon
2013-08-20 16:48 ` [PATCH v2 2/3] clocksource: orion: Use atomic access for shared registers Ezequiel Garcia
2013-08-20 16:48 ` [PATCH v2 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=20130821143654.GB2459@localhost \
--to=ezequiel.garcia@free-electrons.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.