Re: [patch/rfc 1/4] GPIO implementation framework

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: eric miao <eric.y.miao@...>
Cc: Linux Kernel list <linux-kernel@...>, Felipe Balbi <felipebalbi@...>, Bill Gatliff <bgat@...>, Haavard Skinnemoen <hskinnemoen@...>, Andrew Victor <andrew@...>, Tony Lindgren <tony@...>, Jean Delvare <khali@...>, Kevin Hilman <khilman@...>, Paul Mundt <lethal@...>, Ben Dooks <ben@...>
Date: Tuesday, November 13, 2007 - 3:06 pm

On Monday 12 November 2007, eric miao wrote:

We "can" do most anything.  What would that improve though?

Each irq_chip handles multiple IRQs ... just like this patch
has each gpio_chip handling multiple GPIOs.  (Not that I think
GPIO code should closely model IRQ code; they need to address
very different problems.)

I can't tell what you intend to suggest as a "per-GPIO" data
structure; since I can think of at least three different ways
to do such a thing, you should be more concrete.  I'd think it
should be in *addition* to a gpio_chip structure though.



The can_sleep value is a per-controller thing.  The other bits are
indeed per-GPIO.

So do you mean a structure with two bits, plus a pointer to a
gpio_chip, plus likely other stuff (what?) to make it work?
What would the hot-path costs be (for getting/setting values of
an on-chip GPIO)?



Why should holes (in the GPIO number sequence) be a problem?  In
this code, they don't cost much space at all.  They'd cost more
if there were a per-GPIO structure though...

The only downside of GPIOS_PER_CHIP that I know of right now
is that it complicates mixing gpio bank sizes; it's a ceiling,
some controllers would allocate more than they need.  The
upside of that is efficiency, and a closer match to how
underlying hardware works.

Of course, GPIOS_PER_CHIP *could* be decoupled from how the
table of gpio_chip pointers is managed.  If the table were to
group GPIOs in units of 8, a gpio_chip with 32 GPIOs could
take four adjacent entries while an 8-bit GPIO expander could
take just one.  That'd be a very easy patch, supporting a more
dense allocation of GPIO numbers... although it would increase
static memory consumption by typically NR_GPIOS/4 pointers.



I'd say "return chips[gpio / ARCH_GPIOS_PER_CHIP]" already meets
both criteria!

There's also "efficient" to consider; this way doesn't cost much
memory or add levels of indirection (compared to most platforms,
which already use a similar array).



Why would per-GPIO locking be needed though?  Look again...

The locking is there fundamentally because gpio_chip structures
may need to be unregistered; that's not a per-gpio issue.
Even when a gpio is marked in chip->requested under that lock,
that's part of ensuring that the unregistration is prevented so
long as the GPIO is in active use.

Plus, fine grained locking is rarely a good idea; it normally
increases locking overhead by involving multiple locks.  Only
add extra locks if a single lock sees too much contention; and
even then, only if that contention can't be removed by using a
smarter design.

- Dave



-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch/rfc 1/4] GPIO implementation framework, David Brownell, (Mon Oct 29, 9:51 pm)
Re: [patch/rfc 1/4] GPIO implementation framework, David Brownell, (Mon Nov 5, 5:05 pm)
Re: [patch/rfc 1/4] GPIO implementation framework, eric miao, (Mon Nov 12, 10:28 pm)
Re: [patch/rfc 1/4] GPIO implementation framework, David Brownell, (Tue Nov 13, 3:06 pm)
Re: [patch/rfc 1/4] GPIO implementation framework, eric miao, (Tue Nov 13, 8:57 pm)
Re: [patch/rfc 1/4] GPIO implementation framework, David Brownell, (Tue Nov 13, 11:30 pm)
Re: [patch/rfc 1/4] GPIO implementation framework, eric miao, (Wed Nov 14, 2:40 am)
Re: [patch/rfc 1/4] GPIO implementation framework, David Brownell, (Wed Nov 14, 3:08 am)
Re: [patch/rfc 1/4] GPIO implementation framework, David Brownell, (Mon Nov 26, 9:46 pm)
Re: [patch/rfc 1/4] GPIO implementation framework, eric miao, (Tue Nov 27, 6:58 am)
[patch/rfc 2.6.24-rc3-mm] gpiolib grows a gpio_desc, David Brownell, (Tue Nov 27, 11:15 pm)
Re: [patch/rfc 2.6.24-rc3-mm] gpiolib grows a gpio_desc, David Brownell, (Wed Nov 28, 5:53 am)
Re: [patch/rfc 1/4] GPIO implementation framework, David Brownell, (Tue Nov 27, 3:29 pm)
Re: [patch/rfc 1/4] GPIO implementation framework, eric miao, (Wed Nov 28, 1:11 am)
Re: [patch/rfc 1/4] GPIO implementation framework, David Brownell, (Tue Nov 27, 3:03 pm)
Re: [patch/rfc 1/4] GPIO implementation framework, David Brownell, (Tue Nov 27, 1:26 pm)
Re: [patch/rfc 1/4] GPIO implementation framework, eric miao, (Tue Nov 13, 9:00 pm)
Re: [patch/rfc 1/4] GPIO implementation framework, David Brownell, (Tue Nov 13, 11:25 pm)
Re: [patch/rfc 1/4] GPIO implementation framework, eric miao, (Wed Nov 14, 2:37 am)
Re: [patch/rfc 1/4] GPIO implementation framework, David Brownell, (Tue Nov 13, 11:53 pm)
Re: [patch/rfc 1/4] GPIO implementation framework, eric miao, (Tue Nov 13, 9:02 pm)
Re: [patch/rfc 1/4] GPIO implementation framework, David Brownell, (Tue Nov 13, 11:28 pm)
Re: [patch/rfc 1/4] GPIO implementation framework, eric miao, (Tue Nov 13, 9:03 pm)
Re: [patch/rfc 1/4] GPIO implementation framework, David Brownell, (Wed Nov 14, 12:18 am)
Re: [patch/rfc 1/4] GPIO implementation framework, eric miao, (Wed Nov 14, 2:46 am)
Re: [patch/rfc 1/4] GPIO implementation framework, eric miao, (Tue Nov 13, 9:04 pm)
Re: [patch/rfc 1/4] GPIO implementation framework, eric miao, (Tue Nov 13, 9:04 pm)
Re: [patch/rfc 1/4] GPIO implementation framework, David Brownell, (Wed Nov 14, 12:36 am)
Re: [patch/rfc 1/4] GPIO implementation framework, Jean Delvare, (Sat Nov 17, 6:38 am)
Re: [patch/rfc 1/4] GPIO implementation framework, David Brownell, (Sat Nov 17, 1:36 pm)
Re: [patch/rfc 1/4] GPIO implementation framework, Jean Delvare, (Tue Nov 20, 11:20 am)
Re: [patch/rfc 1/4] GPIO implementation framework, eric miao, (Wed Nov 14, 2:51 am)
Re: [patch/rfc 1/4] GPIO implementation framework, David Brownell, (Wed Nov 14, 3:19 am)
Re: [patch/rfc 1/4] GPIO implementation framework, eric miao, (Wed Nov 14, 3:36 am)