[RFC PATCH] arm/imx/gpio: add spinlock protection

Sascha Hauer s.hauer at pengutronix.de
Tue Jul 6 03:17:02 EDT 2010


On Tue, Jul 06, 2010 at 08:00:34AM +0300, Baruch Siach wrote:
> Hi Sascha,
> 
> On Mon, Jul 05, 2010 at 09:52:18AM +0200, Sascha Hauer wrote:
> > On Sun, Jul 04, 2010 at 10:15:13AM +0300, Baruch Siach wrote:
> > > The GPIO and IRQ/GPIO registers need protection from concurrent access for
> > > operations that are not atomic.
> > 
> > I don't think we need locking here. mxc_gpio_irq_handler is called with
> > desc->lock held (from the parent interrupt, not the chained interrupts).
> > Other functions like enable_irq/disable_irq which result in mask/unmask
> > operations run with interrupts disabled.
> 
> What about the .set_type method?

Is only called with interrupts disabled.

> 
> Adding David Brownell to CC.
> 
> > Apart from this other architectures do not use locking here aswell.
> 
> The Nomadic gpio driver does use a spinlock for mask/unmask operations.
> 
> What about the _set_gpio_direction, and mxc_gpio_set? These functions may be 
> called from a process context (e.g., via sysfs). A context switch between 
> __raw_readl and __raw_writel will cause corruption.

The gpio_chip functions are protected by a single spinlock in
gpiolib. The gpio related registers and the irq related regsiters are
totally orthogonal, so we need no locking between these registers.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the linux-arm-kernel mailing list