Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: David Brownell <david-b@...>
Cc: Nick Piggin <nickpiggin@...>, Andrew Morton <akpm@...>, Ingo Molnar <mingo@...>, Linux Kernel list <linux-kernel@...>, Florian Fainelli <florian.fainelli@...>
Date: Wednesday, November 14, 2007 - 5:54 am

On Wed, 14 Nov 2007 00:37:57 -0800
David Brownell <david-b@pacbell.net> wrote:


But isn't there any way we can remove the lock from the fast path
altogether? What is it really protecting?

Since this is the code that runs under the lock (excluding the "extra
checks" case):

+static inline struct gpio_chip *gpio_to_chip(unsigned gpio)
+{
+	return chips[gpio / ARCH_GPIOS_PER_CHIP];
+}

I'd say it protects against chips being removed in the middle of the
operation. However, this comment says that chips cannot be removed
while any gpio on it is requested:

+/* gpio_lock protects the table of chips and to gpio_chip->requested.
+ * While any gpio is requested, its gpio_chip is not removable.  It's
+ * a raw spinlock to ensure safe access from hardirq contexts, and to
+ * shrink bitbang overhead:  per-bit preemption would be very wrong.
+ */

And since we drop the lock before calling the actual get/set bit
operation, we would be screwed anyway if the chip was removed during
the call to __gpio_set_value(). So what does the lock really buy us?

Håvard
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, David Brownell, (Fri Nov 9, 3:36 pm)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, Thomas Gleixner, (Wed Nov 14, 8:14 am)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, Thomas Gleixner, (Thu Nov 15, 3:35 am)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, Thomas Gleixner, (Thu Nov 15, 3:32 am)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, Haavard Skinnemoen, (Thu Nov 15, 4:51 am)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, Haavard Skinnemoen, (Wed Nov 14, 5:54 am)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, Haavard Skinnemoen, (Thu Nov 15, 4:43 am)