* [PATCH] gpio: core: Do not call get_direction in atomic context for sleeping gpio
@ 2016-05-24 13:18 Laxman Dewangan
2016-05-30 15:15 ` Linus Walleij
0 siblings, 1 reply; 2+ messages in thread
From: Laxman Dewangan @ 2016-05-24 13:18 UTC (permalink / raw)
To: linus.walleij, gnurou; +Cc: linux-gpio, linux-kernel, Laxman Dewangan
When adding the gpiochip, the GPIO HW drivers' callback get_direction()
get called in atomic context. Some of the GPIO HW drivers can sleep when
accessing the register and hence it can create the sleeping call in
atomic context.
Call get_direction() in non-atomic context from gpiochip_add() if GPIO
HW driver is having sleepable callback i.e. chip->can_sleep = 1.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
This is found when implementing the get_direction() of max77620 on 20160520
linux-next.
drivers/gpio/gpiolib.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index d407f904..4d04171 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -636,7 +636,15 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data)
* If we have .get_direction, set up the initial
* direction flag from the hardware.
*/
- int dir = chip->get_direction(chip, i);
+ int dir;
+
+ if (chip->can_sleep)
+ spin_unlock_irqrestore(&gpio_lock, flags);
+
+ dir = chip->get_direction(chip, i);
+
+ if (chip->can_sleep)
+ spin_lock_irqsave(&gpio_lock, flags);
if (!dir)
set_bit(FLAG_IS_OUT, &desc->flags);
--
2.1.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] gpio: core: Do not call get_direction in atomic context for sleeping gpio
2016-05-24 13:18 [PATCH] gpio: core: Do not call get_direction in atomic context for sleeping gpio Laxman Dewangan
@ 2016-05-30 15:15 ` Linus Walleij
0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2016-05-30 15:15 UTC (permalink / raw)
To: Laxman Dewangan; +Cc: Alexandre Courbot, linux-gpio, linux-kernel
On Tue, May 24, 2016 at 3:18 PM, Laxman Dewangan <ldewangan@nvidia.com> wrote:
> When adding the gpiochip, the GPIO HW drivers' callback get_direction()
> get called in atomic context. Some of the GPIO HW drivers can sleep when
> accessing the register and hence it can create the sleeping call in
> atomic context.
>
> Call get_direction() in non-atomic context from gpiochip_add() if GPIO
> HW driver is having sleepable callback i.e. chip->can_sleep = 1.
>
> Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
>
> ---
> This is found when implementing the get_direction() of max77620 on 20160520
> linux-next.
I chose to send a new patch just moving the lock release before the
direction check. I just sent it with you as Reported-by.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-05-30 15:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-24 13:18 [PATCH] gpio: core: Do not call get_direction in atomic context for sleeping gpio Laxman Dewangan
2016-05-30 15:15 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®