diff mbox

[v3] serial: mctrl_gpio: add IRQ locking

Message ID 1461918193-7121-1-git-send-email-yegorslists@googlemail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yegor Yefremov April 29, 2016, 8:23 a.m. UTC
From: Yegor Yefremov <yegorslists@googlemail.com>

uart_handle_cts_change should be called with port->lock held. And for
this to be save you must also disable irqs.

CC: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
---
Changes:
	v3: send this patch separately from the 8259 mctrl_gpio series
	    and improve commit wording (Uwe Kleine-König)

 drivers/tty/serial/serial_mctrl_gpio.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Uwe Kleine-König April 29, 2016, 8:32 a.m. UTC | #1
On Fri, Apr 29, 2016 at 10:23:13AM +0200, yegorslists@googlemail.com wrote:
> From: Yegor Yefremov <yegorslists@googlemail.com>
> 
> uart_handle_cts_change should be called with port->lock held. And for
> this to be save you must also disable irqs.
> 
> CC: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> ---
> Changes:
> 	v3: send this patch separately from the 8259 mctrl_gpio series
> 	    and improve commit wording (Uwe Kleine-König)
> 
>  drivers/tty/serial/serial_mctrl_gpio.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/tty/serial/serial_mctrl_gpio.c b/drivers/tty/serial/serial_mctrl_gpio.c
> index bb5e4f9..85b77ba 100644
> --- a/drivers/tty/serial/serial_mctrl_gpio.c
> +++ b/drivers/tty/serial/serial_mctrl_gpio.c
> @@ -143,6 +143,9 @@ static irqreturn_t mctrl_gpio_irq_handle(int irq, void *context)
>  	struct uart_port *port = gpios->port;
>  	u32 mctrl = gpios->mctrl_prev;
>  	u32 mctrl_diff;
> +	unsigned long flags;
> +
> +	spin_lock_irqsave(&port->lock, flags);
>  
>  	mctrl_gpio_get(gpios, &mctrl);
>  

mctrl_gpio_get might sleep, right? So better move the lock to after
mctrl_gpio_get.

If you change this you can add my Ack. Sorry that I didn't notice during
v2.

Best regards
Uwe
Yegor Yefremov April 29, 2016, 8:52 a.m. UTC | #2
On Fri, Apr 29, 2016 at 10:32 AM, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
> On Fri, Apr 29, 2016 at 10:23:13AM +0200, yegorslists@googlemail.com wrote:
>> From: Yegor Yefremov <yegorslists@googlemail.com>
>>
>> uart_handle_cts_change should be called with port->lock held. And for
>> this to be save you must also disable irqs.
>>
>> CC: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
>> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
>> ---
>> Changes:
>>       v3: send this patch separately from the 8259 mctrl_gpio series
>>           and improve commit wording (Uwe Kleine-König)
>>
>>  drivers/tty/serial/serial_mctrl_gpio.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/tty/serial/serial_mctrl_gpio.c b/drivers/tty/serial/serial_mctrl_gpio.c
>> index bb5e4f9..85b77ba 100644
>> --- a/drivers/tty/serial/serial_mctrl_gpio.c
>> +++ b/drivers/tty/serial/serial_mctrl_gpio.c
>> @@ -143,6 +143,9 @@ static irqreturn_t mctrl_gpio_irq_handle(int irq, void *context)
>>       struct uart_port *port = gpios->port;
>>       u32 mctrl = gpios->mctrl_prev;
>>       u32 mctrl_diff;
>> +     unsigned long flags;
>> +
>> +     spin_lock_irqsave(&port->lock, flags);
>>
>>       mctrl_gpio_get(gpios, &mctrl);
>>
>
> mctrl_gpio_get might sleep, right? So better move the lock to after
> mctrl_gpio_get.
>
> If you change this you can add my Ack. Sorry that I didn't notice during
> v2.

No problem. v4 is out. Thanks for reviewing.

Yegor
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/tty/serial/serial_mctrl_gpio.c b/drivers/tty/serial/serial_mctrl_gpio.c
index bb5e4f9..85b77ba 100644
--- a/drivers/tty/serial/serial_mctrl_gpio.c
+++ b/drivers/tty/serial/serial_mctrl_gpio.c
@@ -143,6 +143,9 @@  static irqreturn_t mctrl_gpio_irq_handle(int irq, void *context)
 	struct uart_port *port = gpios->port;
 	u32 mctrl = gpios->mctrl_prev;
 	u32 mctrl_diff;
+	unsigned long flags;
+
+	spin_lock_irqsave(&port->lock, flags);
 
 	mctrl_gpio_get(gpios, &mctrl);
 
@@ -165,6 +168,8 @@  static irqreturn_t mctrl_gpio_irq_handle(int irq, void *context)
 		wake_up_interruptible(&port->state->port.delta_msr_wait);
 	}
 
+	spin_unlock_irqrestore(&port->lock, flags);
+
 	return IRQ_HANDLED;
 }