summaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2016-11-12 09:01:09 -0500
committerLinus Walleij <linus.walleij@linaro.org>2016-11-15 04:26:34 -0500
commit60f8339eb388df8a46f8eb4282ff0e15f08f218c (patch)
treeb6945de6817572f75673024744bd19aeda41c184 /drivers/gpio
parent386377b5473043c09b2de40bfe5abfb0fc87e1b4 (diff)
gpio: do not double-check direction on sleeping chips
When locking a GPIO line as IRQ, we go to lengths to double-check that the line is really set as input before marking it as used for IRQ. This is not good on GPIO chips that can sleep, because this function is called in IRQ-safe context. Just skip this if it can't be checked quickly. Currently this happens on sleeping expanders such as STMPE or TC3589x: BUG: scheduling while atomic: swapper/1/0x00000002 Modules linked in: CPU: 0 PID: 1 Comm: swapper Not tainted 4.9.0-rc1+ #38 Hardware name: Nomadik STn8815 [<c000f2e0>] (unwind_backtrace) from [<c000d244>] (show_stack+0x10/0x14) [<c000d244>] (show_stack) from [<c0037b78>] (__schedule_bug+0x54/0x80) [<c0037b78>] (__schedule_bug) from [<c042df14>] (__schedule+0x3a0/0x460) [<c042df14>] (__schedule) from [<c042e028>] (schedule+0x54/0xb8) (...) This patch fixes that problem and relies on the direction read from the chip when it was added. Cc: stable@vger.kernel.org Fixes: 9c10280d85c1 ("gpio: flush direction status in gpiochip_lock_as_irq()") Cc: Patrice Chotard <patrice.chotard@st.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpiolib.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 93ed0e00c578..868128a676ba 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2737,8 +2737,11 @@ int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset)
2737 if (IS_ERR(desc)) 2737 if (IS_ERR(desc))
2738 return PTR_ERR(desc); 2738 return PTR_ERR(desc);
2739 2739
2740 /* Flush direction if something changed behind our back */ 2740 /*
2741 if (chip->get_direction) { 2741 * If it's fast: flush the direction setting if something changed
2742 * behind our back
2743 */
2744 if (!chip->can_sleep && chip->get_direction) {
2742 int dir = chip->get_direction(chip, offset); 2745 int dir = chip->get_direction(chip, offset);
2743 2746
2744 if (dir) 2747 if (dir)