Skip to content

Commit 813f303

Browse files
ZheyuMagregkh
authored andcommitted
tty: serial: jsm: hold port lock when reporting modem line changes
[ Upstream commit 240e126 ] 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 the following warnings. [ 132.528648] WARNING: CPU: 5 PID: 11600 at drivers/tty/serial/serial_core.c:3046 uart_handle_dcd_change+0xf4/0x120 [ 132.530482] Modules linked in: [ 132.531050] CPU: 5 PID: 11600 Comm: jsm Not tainted 5.14.0-rc1-00003-g7fef2edf7cc7-dirty #31 [ 132.535268] RIP: 0010:uart_handle_dcd_change+0xf4/0x120 [ 132.557100] Call Trace: [ 132.557562] ? __free_pages+0x83/0xb0 [ 132.558213] neo_parse_modem+0x156/0x220 [ 132.558897] neo_param+0x399/0x840 [ 132.559495] jsm_tty_open+0x12f/0x2d0 [ 132.560131] uart_startup.part.18+0x153/0x340 [ 132.560888] ? lock_is_held_type+0xe9/0x140 [ 132.561660] uart_port_activate+0x7f/0xe0 [ 132.562351] ? uart_startup.part.18+0x340/0x340 [ 132.563003] tty_port_open+0x8d/0xf0 [ 132.563523] ? uart_set_options+0x1e0/0x1e0 [ 132.564125] uart_open+0x24/0x40 [ 132.564604] tty_open+0x15c/0x630 Signed-off-by: Zheyu Ma <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 2525484 commit 813f303

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

drivers/tty/serial/jsm/jsm_neo.c

+2
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,9 @@ static void neo_parse_isr(struct jsm_board *brd, u32 port)
827827
/* Parse any modem signal changes */
828828
jsm_dbg(INTR, &ch->ch_bd->pci_dev,
829829
"MOD_STAT: sending to parse_modem_sigs\n");
830+
spin_lock_irqsave(&ch->uart_port.lock, lock_flags);
830831
neo_parse_modem(ch, readb(&ch->ch_neo_uart->msr));
832+
spin_unlock_irqrestore(&ch->uart_port.lock, lock_flags);
831833
}
832834
}
833835

drivers/tty/serial/jsm/jsm_tty.c

+3
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ static void jsm_tty_break(struct uart_port *port, int break_state)
195195

196196
static int jsm_tty_open(struct uart_port *port)
197197
{
198+
unsigned long lock_flags;
198199
struct jsm_board *brd;
199200
struct jsm_channel *channel =
200201
container_of(port, struct jsm_channel, uart_port);
@@ -248,6 +249,7 @@ static int jsm_tty_open(struct uart_port *port)
248249
channel->ch_cached_lsr = 0;
249250
channel->ch_stops_sent = 0;
250251

252+
spin_lock_irqsave(&port->lock, lock_flags);
251253
termios = &port->state->port.tty->termios;
252254
channel->ch_c_cflag = termios->c_cflag;
253255
channel->ch_c_iflag = termios->c_iflag;
@@ -267,6 +269,7 @@ static int jsm_tty_open(struct uart_port *port)
267269
jsm_carrier(channel);
268270

269271
channel->ch_open_count++;
272+
spin_unlock_irqrestore(&port->lock, lock_flags);
270273

271274
jsm_dbg(OPEN, &channel->ch_bd->pci_dev, "finish\n");
272275
return 0;

0 commit comments

Comments
 (0)