From: u.kleine-koenig@pengutronix.de (Uwe Kleine-König)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] arm/imx/gpio: add spinlock protection
Date: Thu, 29 Jul 2010 08:42:41 +0200 [thread overview]
Message-ID: <20100729064241.GB11268@pengutronix.de> (raw)
In-Reply-To: <a1d5b20ff1b6e39355fcad2e882489df55c7bf2a.1278413731.git.baruch@tkos.co.il>
Hey Sascha,
On Tue, Jul 06, 2010 at 02:03:22PM +0300, Baruch Siach wrote:
> The GPIO registers need protection from concurrent access for operations that
> are not atomic.
>
> Cc: stable at kernel.org
> Cc: Juergen Beisert <j.beisert@pengutronix.de>
> Cc: Daniel Mack <daniel@caiaq.de>
> Reported-by: rpkamiak at rockwellcollins.com
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
> Changes v1 -> v2
>
> Remove redundant protection of GPIO/IRQ registers
>
> arch/arm/plat-mxc/gpio.c | 8 ++++++++
> arch/arm/plat-mxc/include/mach/gpio.h | 1 +
> 2 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/plat-mxc/gpio.c b/arch/arm/plat-mxc/gpio.c
> index 71437c6..9ebbd31 100644
> --- a/arch/arm/plat-mxc/gpio.c
> +++ b/arch/arm/plat-mxc/gpio.c
> @@ -214,13 +214,16 @@ static void _set_gpio_direction(struct gpio_chip *chip, unsigned offset,
> struct mxc_gpio_port *port =
> container_of(chip, struct mxc_gpio_port, chip);
> u32 l;
> + unsigned long flags;
>
> + spin_lock_irqsave(&port->lock, flags);
> l = __raw_readl(port->base + GPIO_GDIR);
> if (dir)
> l |= 1 << offset;
> else
> l &= ~(1 << offset);
> __raw_writel(l, port->base + GPIO_GDIR);
> + spin_unlock_irqrestore(&port->lock, flags);
> }
>
> static void mxc_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
> @@ -229,9 +232,12 @@ static void mxc_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
> container_of(chip, struct mxc_gpio_port, chip);
> void __iomem *reg = port->base + GPIO_DR;
> u32 l;
> + unsigned long flags;
>
> + spin_lock_irqsave(&port->lock, flags);
> l = (__raw_readl(reg) & (~(1 << offset))) | (value << offset);
> __raw_writel(l, reg);
> + spin_unlock_irqrestore(&port->lock, flags);
> }
>
> static int mxc_gpio_get(struct gpio_chip *chip, unsigned offset)
> @@ -285,6 +291,8 @@ int __init mxc_gpio_init(struct mxc_gpio_port *port, int cnt)
> port[i].chip.base = i * 32;
> port[i].chip.ngpio = 32;
>
> + spin_lock_init(&port[i].lock);
> +
> /* its a serious configuration bug when it fails */
> BUG_ON( gpiochip_add(&port[i].chip) < 0 );
>
> diff --git a/arch/arm/plat-mxc/include/mach/gpio.h b/arch/arm/plat-mxc/include/mach/gpio.h
> index 894d2f8..6bd932c 100644
> --- a/arch/arm/plat-mxc/include/mach/gpio.h
> +++ b/arch/arm/plat-mxc/include/mach/gpio.h
> @@ -36,6 +36,7 @@ struct mxc_gpio_port {
> int virtual_irq_start;
> struct gpio_chip chip;
> u32 both_edges;
> + spinlock_t lock;
> };
>
> int mxc_gpio_init(struct mxc_gpio_port*, int);
can you please fold this into Baruch's patch:
diff --git a/arch/arm/plat-mxc/include/mach/gpio.h b/arch/arm/plat-mxc/include/mach/gpio.h
index 661fbc6..af33b74 100644
--- a/arch/arm/plat-mxc/include/mach/gpio.h
+++ b/arch/arm/plat-mxc/include/mach/gpio.h
@@ -19,6 +19,7 @@
#ifndef __ASM_ARCH_MXC_GPIO_H__
#define __ASM_ARCH_MXC_GPIO_H__
+#include <linux/spinlock.h>
#include <mach/hardware.h>
#include <asm-generic/gpio.h>
This fixes a build failure with mx27_defconfig.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
next prev parent reply other threads:[~2010-07-29 6:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-04 7:15 [RFC PATCH] arm/imx/gpio: add spinlock protection Baruch Siach
2010-07-05 7:02 ` Uwe Kleine-König
2010-07-05 7:52 ` Sascha Hauer
2010-07-06 5:00 ` Baruch Siach
2010-07-06 7:17 ` Sascha Hauer
2010-07-06 7:40 ` Baruch Siach
2010-07-06 10:07 ` Sascha Hauer
2010-07-06 10:37 ` Baruch Siach
2010-07-06 11:03 ` [PATCH v2] " Baruch Siach
2010-07-21 5:10 ` Baruch Siach
2010-07-29 6:42 ` Uwe Kleine-König [this message]
2010-08-02 7:29 ` [PATCH] ARM: imx: Fix build failure when including <mach/gpio.h> without <linux/spinlock.h> Uwe Kleine-König
2010-08-02 7:46 ` Baruch Siach
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=20100729064241.GB11268@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--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).