From: Linus Walleij <linus.walleij@linaro.org>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: "linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Björn Andersson" <bjorn.andersson@linaro.org>,
Linux-Renesas <linux-renesas-soc@vger.kernel.org>
Subject: Re: [PATCH v2] gpio: convince line to become input in irq helper
Date: Tue, 5 Jul 2016 16:52:41 +0200 [thread overview]
Message-ID: <CACRpkdZpRSrt4u_h11ROavVFZDh6OYJ49gJ6eD0y4gGuOxzMYg@mail.gmail.com> (raw)
In-Reply-To: <CAMuHMdXVEjyctU88-u=FJcY0AwLKvFxdizkPTTjt_X=xM_H6UQ@mail.gmail.com>
I sent a patch for the direction setter to be more careful, but
it's no silver bullet for strange semantics.
On Tue, Jul 5, 2016 at 12:07 PM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> [1] gpio_rcar e6052000.gpio: sense irq = 11, type = 8
> ravb e6800000.ethernet eth0: Base address at 0xe6800000,
> 2e:09:0a:00:83:1e, IRQ 131.
> ...
> [2] gpiochip_irq_reqres: gpiochip e6052000.gpio
> [3] gpio_rcar e6052000.gpio: gpio_rcar_direction_input: 11
> [4] gpiochip_irq_reqres: desc->flags = 0x0
(...)
> This configures the GPIO for plain input mode, cfr. [3] above, basically
> undoing the configuration from [1]. Hence interrupts no longer come through,
> and Ethernet fails.
The driver is a bit fragile in that it relies on a certain call semantic,
I guess it is not a widespread problem so we should be able to make
a local fix if necessary.
The .set_direction() call should
set the direction. Why is it turning off interrupts as a side effect?
What happens if you apply this, making the .request() function handle
the pin setup and .set_direction() really just setting the
direction?
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index 681c93fb9e70..68fb0147caf4 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -221,7 +221,20 @@ static void
gpio_rcar_config_general_input_output_mode(struct gpio_chip *chip,
struct gpio_rcar_priv *p = gpiochip_get_data(chip);
unsigned long flags;
- /* follow steps in the GPIO documentation for
+ spin_lock_irqsave(&p->lock, flags);
+
+ /* Select Input Mode or Output Mode in INOUTSEL */
+ gpio_rcar_modify_bit(p, INOUTSEL, gpio, output);
+
+ spin_unlock_irqrestore(&p->lock, flags);
+}
+
+static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset)
+{
+ struct gpio_rcar_priv *p = gpiochip_get_data(chip);
+
+ /*
+ * follow steps in the GPIO documentation for
* "Setting General Output Mode" and
* "Setting General Input Mode"
*/
@@ -234,14 +247,8 @@ static void
gpio_rcar_config_general_input_output_mode(struct gpio_chip *chip,
/* Select "General Input/Output Mode" in IOINTSEL */
gpio_rcar_modify_bit(p, IOINTSEL, gpio, false);
- /* Select Input Mode or Output Mode in INOUTSEL */
- gpio_rcar_modify_bit(p, INOUTSEL, gpio, output);
-
spin_unlock_irqrestore(&p->lock, flags);
-}
-static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset)
-{
return pinctrl_request_gpio(chip->base + offset);
}
.request() is always called before .set_direction() when issuing
gpiod_get() anyways, so the order required according to the comment
will be satisfied when the GPIO is first requested, but if we're just
using the interrupt, we still will be able to set the direction right.
Yours,
Linus Walleij
next prev parent reply other threads:[~2016-07-05 14:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-22 21:25 [PATCH v2] gpio: convince line to become input in irq helper Linus Walleij
2016-06-22 21:51 ` Bjorn Andersson
2016-06-29 5:17 ` Alexandre Courbot
2016-07-05 10:07 ` Geert Uytterhoeven
2016-07-05 14:52 ` Linus Walleij [this message]
2016-07-06 9:07 ` Grygorii Strashko
2016-07-06 12:38 ` Linus Walleij
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=CACRpkdZpRSrt4u_h11ROavVFZDh6OYJ49gJ6eD0y4gGuOxzMYg@mail.gmail.com \
--to=linus.walleij@linaro.org \
--cc=acourbot@nvidia.com \
--cc=bjorn.andersson@linaro.org \
--cc=geert@linux-m68k.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.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).