From: Ryan Mallon <ryan@bluewatersys.com>
To: David Brownell <david-b@pacbell.net>
Cc: "David Brownell" <dbrownell@users.sourceforge.net>,
gregkh@suse.de, "linux kernel" <linux-kernel@vger.kernel.org>,
ext-jani.1.nikula@nokia.com,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Andrew Morton" <akpm@linux-foundation.org>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>
Subject: Re: gpiolib and sleeping gpios
Date: Mon, 21 Jun 2010 09:31:26 +1200 [thread overview]
Message-ID: <4C1E88AE.5070808@bluewatersys.com> (raw)
In-Reply-To: <386783.17931.qm@web180310.mail.gq1.yahoo.com>
On 06/19/2010 06:21 PM, David Brownell wrote:
>
>>
>> The runtime warnings will only show instances where the
>> non-sleeping
>> versions where called instead of the sleeping versions.
>
> ... *AND* the GPIO requires the cansleep() version...
>
> Right; such calls are errors. We issue
> warnings since fault returns are inapplicable.
A driver which only uses the non-sleeping versions, but _could_ use the
cansleep variants (ie all calls to gpio_(set/get)_value are made from
contexts where it is possible to sleep) is not so easy to spot. Passing
a sleeping to gpio to such a driver will result in spurious warnings.
>> There is no
>> warning to say that we are calling the spinlock safe
>> version, where it is possible to sleep.
>
> The call context isn't what controls whether
> gpio_get_value() or gpio_get_value_cansleep()
> is appropriate ... it's the GPIO itself, and
> how its implementation works.
No, a driver should not know anything about a gpio which is passed to
it. If a driver is able to call the cansleep variants, then it should,
and it will allow any gpio, sleeping or non-sleeping, to be used with
that driver.
If a driver uses a gpio in such a way that it cannot sleep, ie the
gpio_(get/set)_value calls are made from spinlock context, then only
gpios which do not sleep may be used with that driver.
Thats why I think specifying whether the gpio is able to sleep when it
is requested is a good idea. A driver which cannot use a sleeping gpio
> "possible to sleep" is a GPIO attribute,
> exposed by a predicate. If spinlock-safe
> calls are used on GPIOs with that attribute,
> a warning *IS* issued.
Possible to sleep is also an attribute of how a driver _uses_ a gpio.
>>
>> The point I was trying to make is that there are lots of
>> drivers which
>> will not work with gpios on sleeping io expanders because
>> they call the
>> spinlock safe gpio calls.
>
> And they will trigger runtime warnings, and
> thus eventually get fixed. The way to do that
> is to check if the GPIO needs the cansleep()
> call
Hmm, maybe this then for drivers which cannot accept sleeping gpios:
if (gpio_cansleep(some_gpio)) {
dev_err(&dev, "This driver only supports non-sleeping gpios");
return -EINVAL;
}
err = gpio_request(some_gpio, "some_gpio");
I think ideally, gpio_request should specify this via a flags argument, ie:
#define GPIOF_NO_SLEEP 0x0
#define GPIOF_CANSLEEP 0x1
err = gpio_request(some_gpio, "some_gpio", GPIOF_NO_SLEEP);
~Ryan
--
Bluewater Systems Ltd - ARM Technology Solution Centre
Ryan Mallon 5 Amuri Park, 404 Barbadoes St
ryan@bluewatersys.com PO Box 13 889, Christchurch 8013
http://www.bluewatersys.com New Zealand
Phone: +64 3 3779127 Freecall: Australia 1800 148 751
Fax: +64 3 3779135 USA 1800 261 2934
next prev parent reply other threads:[~2010-06-20 21:31 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-17 21:47 gpiolib and sleeping gpios Ryan Mallon
2010-06-18 5:27 ` Uwe Kleine-König
2010-06-18 6:16 ` David Brownell
2010-06-18 22:01 ` Ryan Mallon
2010-06-19 6:21 ` David Brownell
2010-06-20 21:31 ` Ryan Mallon [this message]
2010-06-21 2:40 ` David Brownell
2010-06-21 5:09 ` Uwe Kleine-König
2010-06-23 1:59 ` [RFC PATCH] Rework gpio cansleep (was Re: gpiolib and sleeping gpios) Ryan Mallon
2010-06-23 4:37 ` David Brownell
2010-06-23 4:58 ` Eric Miao
2010-06-23 9:51 ` David Brownell
2010-06-23 5:02 ` Ryan Mallon
2010-06-23 5:26 ` Eric Miao
2010-06-23 9:39 ` David Brownell
2010-06-23 19:12 ` Ryan Mallon
2010-06-24 4:46 ` [RFC PATCH] Rework gpio cansleep (was Re: gpiolib and sleepinggpios) Jon Povey
2010-06-24 8:20 ` Lars-Peter Clausen
2010-06-24 8:29 ` Jani Nikula
2010-06-24 10:31 ` Lars-Peter Clausen
2010-06-24 6:41 ` [RFC PATCH] Rework gpio cansleep (was Re: gpiolib and sleeping gpios) Uwe Kleine-König
2010-06-23 22:53 ` Jamie Lokier
2010-06-23 23:06 ` Ryan Mallon
2010-06-24 0:04 ` Jamie Lokier
2010-06-24 0:10 ` Ryan Mallon
2010-06-25 7:19 ` David Brownell
2010-06-24 4:33 ` [RFC PATCH] Rework gpio cansleep (was Re: gpiolib and sleepinggpios) Jon Povey
2010-06-29 8:29 ` gpiolib and sleeping gpios CoffBeta
2010-06-23 11:53 ` Jani Nikula
2010-06-23 12:40 ` David Brownell
2010-06-23 13:22 ` Jani Nikula
2010-06-23 13:39 ` David Brownell
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=4C1E88AE.5070808@bluewatersys.com \
--to=ryan@bluewatersys.com \
--cc=akpm@linux-foundation.org \
--cc=david-b@pacbell.net \
--cc=dbrownell@users.sourceforge.net \
--cc=ext-jani.1.nikula@nokia.com \
--cc=gregkh@suse.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=u.kleine-koenig@pengutronix.de \
/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