linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tty: serial: jsm: hold port lock when reporting modem line changes
@ 2021-07-10 14:05 Zheyu Ma
  2021-07-12  6:16 ` Jiri Slaby
  0 siblings, 1 reply; 2+ messages in thread
From: Zheyu Ma @ 2021-07-10 14:05 UTC (permalink / raw)
  To: gregkh, jirislaby, rclemsmith; +Cc: zheyuma97, linux-serial, linux-kernel

uart_handle_dcd_change() requires a port lock to be held and will emit a
warning when lockdep is enabled.

Held corresponding lock to fix warnings.

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
---
 drivers/tty/serial/jsm/jsm_neo.c | 2 ++
 drivers/tty/serial/jsm/jsm_tty.c | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/drivers/tty/serial/jsm/jsm_neo.c b/drivers/tty/serial/jsm/jsm_neo.c
index bf0e2a4cb0ce..c6f927a76c3b 100644
--- a/drivers/tty/serial/jsm/jsm_neo.c
+++ b/drivers/tty/serial/jsm/jsm_neo.c
@@ -815,7 +815,9 @@ static void neo_parse_isr(struct jsm_board *brd, u32 port)
 		/* Parse any modem signal changes */
 		jsm_dbg(INTR, &ch->ch_bd->pci_dev,
 			"MOD_STAT: sending to parse_modem_sigs\n");
+		spin_lock_irqsave(&ch->uart_port.lock, lock_flags);
 		neo_parse_modem(ch, readb(&ch->ch_neo_uart->msr));
+		spin_unlock_irqrestore(&ch->uart_port.lock, lock_flags);
 	}
 }
 
diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c
index 8e42a7682c63..d74cbbbf33c6 100644
--- a/drivers/tty/serial/jsm/jsm_tty.c
+++ b/drivers/tty/serial/jsm/jsm_tty.c
@@ -187,6 +187,7 @@ static void jsm_tty_break(struct uart_port *port, int break_state)
 
 static int jsm_tty_open(struct uart_port *port)
 {
+	unsigned long lock_flags;
 	struct jsm_board *brd;
 	struct jsm_channel *channel =
 		container_of(port, struct jsm_channel, uart_port);
@@ -240,6 +241,7 @@ static int jsm_tty_open(struct uart_port *port)
 	channel->ch_cached_lsr = 0;
 	channel->ch_stops_sent = 0;
 
+	spin_lock_irqsave(&port->lock, lock_flags);
 	termios = &port->state->port.tty->termios;
 	channel->ch_c_cflag	= termios->c_cflag;
 	channel->ch_c_iflag	= termios->c_iflag;
@@ -259,6 +261,7 @@ static int jsm_tty_open(struct uart_port *port)
 	jsm_carrier(channel);
 
 	channel->ch_open_count++;
+	spin_unlock_irqrestore(&port->lock, lock_flags);
 
 	jsm_dbg(OPEN, &channel->ch_bd->pci_dev, "finish\n");
 	return 0;
-- 
2.17.6


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tty: serial: jsm: hold port lock when reporting modem line changes
  2021-07-10 14:05 [PATCH] tty: serial: jsm: hold port lock when reporting modem line changes Zheyu Ma
@ 2021-07-12  6:16 ` Jiri Slaby
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Slaby @ 2021-07-12  6:16 UTC (permalink / raw)
  To: Zheyu Ma, gregkh, rclemsmith; +Cc: linux-serial, linux-kernel

On 10. 07. 21, 16:05, Zheyu Ma wrote:
> uart_handle_dcd_change() requires a port lock to be held and will emit a
> warning when lockdep is enabled.

Please attach an excerpt from the warning to the commit log.

> Held corresponding lock to fix warnings.
> 
> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
> ---
>   drivers/tty/serial/jsm/jsm_neo.c | 2 ++
>   drivers/tty/serial/jsm/jsm_tty.c | 3 +++
>   2 files changed, 5 insertions(+)
> 
> diff --git a/drivers/tty/serial/jsm/jsm_neo.c b/drivers/tty/serial/jsm/jsm_neo.c
> index bf0e2a4cb0ce..c6f927a76c3b 100644
> --- a/drivers/tty/serial/jsm/jsm_neo.c
> +++ b/drivers/tty/serial/jsm/jsm_neo.c
> @@ -815,7 +815,9 @@ static void neo_parse_isr(struct jsm_board *brd, u32 port)
>   		/* Parse any modem signal changes */
>   		jsm_dbg(INTR, &ch->ch_bd->pci_dev,
>   			"MOD_STAT: sending to parse_modem_sigs\n");
> +		spin_lock_irqsave(&ch->uart_port.lock, lock_flags);
>   		neo_parse_modem(ch, readb(&ch->ch_neo_uart->msr));
> +		spin_unlock_irqrestore(&ch->uart_port.lock, lock_flags);
>   	}
>   }
>   
> diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c
> index 8e42a7682c63..d74cbbbf33c6 100644
> --- a/drivers/tty/serial/jsm/jsm_tty.c
> +++ b/drivers/tty/serial/jsm/jsm_tty.c
> @@ -187,6 +187,7 @@ static void jsm_tty_break(struct uart_port *port, int break_state)
>   
>   static int jsm_tty_open(struct uart_port *port)
>   {
> +	unsigned long lock_flags;
>   	struct jsm_board *brd;
>   	struct jsm_channel *channel =
>   		container_of(port, struct jsm_channel, uart_port);
> @@ -240,6 +241,7 @@ static int jsm_tty_open(struct uart_port *port)
>   	channel->ch_cached_lsr = 0;
>   	channel->ch_stops_sent = 0;
>   
> +	spin_lock_irqsave(&port->lock, lock_flags);
>   	termios = &port->state->port.tty->termios;
>   	channel->ch_c_cflag	= termios->c_cflag;
>   	channel->ch_c_iflag	= termios->c_iflag;
> @@ -259,6 +261,7 @@ static int jsm_tty_open(struct uart_port *port)
>   	jsm_carrier(channel);
>   
>   	channel->ch_open_count++;
> +	spin_unlock_irqrestore(&port->lock, lock_flags);
>   
>   	jsm_dbg(OPEN, &channel->ch_bd->pci_dev, "finish\n");
>   	return 0;
> 


-- 
js
suse labs

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-12  6:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-10 14:05 [PATCH] tty: serial: jsm: hold port lock when reporting modem line changes Zheyu Ma
2021-07-12  6:16 ` Jiri Slaby

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).