linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: catalin.marinas@arm.com (Catalin Marinas)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 2/4] ARM: Add atomic_io_modify optimized routines
Date: Wed, 28 Aug 2013 09:53:40 +0100	[thread overview]
Message-ID: <20130828085340.GB58219@MacBook-Pro.local> (raw)
In-Reply-To: <1377358532-23802-3-git-send-email-ezequiel.garcia@free-electrons.com>

On Sat, Aug 24, 2013 at 04:35:30PM +0100, Ezequiel Garcia wrote:
> Implement arch-specific atomic_io_modify and atomic_io_modify_relaxed,
> which are based on writel/readl_relaxed and writel_relaxed/readl_relaxed,
> respectively.
> In both cases, by relaxing the readl, perfomance can be improved.
> 
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> ---
>  arch/arm/include/asm/io.h |  4 ++++
>  arch/arm/kernel/io.c      | 29 +++++++++++++++++++++++++++++
>  2 files changed, 33 insertions(+)
> 
> diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
> index d070741..53637b6 100644
> --- a/arch/arm/include/asm/io.h
> +++ b/arch/arm/include/asm/io.h
> @@ -397,5 +397,9 @@ extern int devmem_is_allowed(unsigned long pfn);
>  extern void register_isa_ports(unsigned int mmio, unsigned int io,
>  			       unsigned int io_shift);
>  
> +#define __HAVE_ARCH_ATOMIC_IO_MODIFY
> +extern void atomic_io_modify(void __iomem *reg, u32 mask, u32 set);
> +extern void atomic_io_modify_relaxed(void __iomem *reg, u32 mask, u32 set);
> +
>  #endif	/* __KERNEL__ */
>  #endif	/* __ASM_ARM_IO_H */
> diff --git a/arch/arm/kernel/io.c b/arch/arm/kernel/io.c
> index dcd5b4d..a8c9c9b 100644
> --- a/arch/arm/kernel/io.c
> +++ b/arch/arm/kernel/io.c
> @@ -1,6 +1,35 @@
>  #include <linux/export.h>
>  #include <linux/types.h>
>  #include <linux/io.h>
> +#include <linux/spinlock.h>
> +
> +static DEFINE_RAW_SPINLOCK(__io_lock);
> +
> +void atomic_io_modify_relaxed(void __iomem *reg, u32 mask, u32 set)
> +{
> +	unsigned long flags;
> +	u32 value;
> +
> +	raw_spin_lock_irqsave(&__io_lock, flags);
> +	value = readl_relaxed(reg) & ~mask;
> +	value |= (set & mask);
> +	writel_relaxed(value, reg);
> +	raw_spin_unlock_irqrestore(&__io_lock, flags);
> +}
> +EXPORT_SYMBOL(atomic_io_modify_relaxed);
> +
> +void atomic_io_modify(void __iomem *reg, u32 mask, u32 set)
> +{
> +	unsigned long flags;
> +	u32 value;
> +
> +	raw_spin_lock_irqsave(&__io_lock, flags);
> +	value = readl_relaxed(reg) & ~mask;
> +	value |= (set & mask);
> +	writel(value, reg);
> +	raw_spin_unlock_irqrestore(&__io_lock, flags);
> +}
> +EXPORT_SYMBOL(atomic_io_modify);

Is this any different from the generic one introduced in patch 1/4? I
would rather just use the generic definition. Similarly, a generic
atomic_io_modify_relaxed() but guarded with something like
__HAVE_ARCH_RELAXED_IO.

-- 
Catalin

  reply	other threads:[~2013-08-28  8:53 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-24 15:35 [PATCH v4 0/4] Introduce atomic MMIO modify Ezequiel Garcia
2013-08-24 15:35 ` [PATCH v4 1/4] lib: " Ezequiel Garcia
2013-08-24 18:27   ` richard -rw- weinberger
2013-08-24 19:58     ` Ezequiel Garcia
2013-08-24 20:35       ` Richard Weinberger
2013-08-24 20:49         ` Ezequiel Garcia
2013-08-24 20:53           ` Richard Weinberger
2013-08-24 23:15       ` Russell King - ARM Linux
2013-08-27 14:37   ` Ezequiel Garcia
2013-08-27 20:37   ` Andrew Morton
2013-08-28 10:24     ` Ezequiel Garcia
2013-08-28 19:33       ` Andrew Morton
2013-08-29  8:03         ` Thomas Petazzoni
2013-08-28 10:37   ` Ezequiel Garcia
2013-08-28 16:16     ` Linus Torvalds
2013-08-24 15:35 ` [PATCH v4 2/4] ARM: Add atomic_io_modify optimized routines Ezequiel Garcia
2013-08-28  8:53   ` Catalin Marinas [this message]
2013-08-28  9:49     ` Ezequiel Garcia
2013-08-28 10:01       ` Thomas Petazzoni
2013-08-28 11:39         ` Catalin Marinas
2013-08-24 15:35 ` [PATCH v4 3/4] clocksource: orion: Use atomic access for shared registers Ezequiel Garcia
2013-08-24 15:35 ` [PATCH v4 4/4] 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=20130828085340.GB58219@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).