Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2320138pxb; Mon, 20 Sep 2021 18:43:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJ4clhzjnONwXZWxEVn1NnjCKQddQ6dvepqmycYLzMAgszdRVy5kP6wBaqk3AAsBxznt05 X-Received: by 2002:a6b:7842:: with SMTP id h2mr3097419iop.157.1632188625016; Mon, 20 Sep 2021 18:43:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188625; cv=none; d=google.com; s=arc-20160816; b=BXP6UHLFwtLXlHjK1+GI1h7bfzAzvQhrAPjk/rhVBrkchzHsO5XJY2dD6YxDncpwp2 DoRDeKbkorpdWIaroeYKUX9m1T1pRcR9QD6X1WhK/c8Ci+r9hORpvWZmXdgfAc8VosDn p1GZZNE7g69sn+/7e+gpbFH2QecJUj0iSzYukR4R3Dz/CcJFLbHRI/UW0+6k9vsE1nkl 5doGXL9Ag8wNhtVjSkuHnW8hq2TZqprwCpSjqCbr43cZThJPN63FbuT2nDIG0SzVVCtN tTFSFCqGYSS2Nma9K5qJ0aa0MIr+cvGf9eSxHL8UTpU1+ORnrh80/l1eWCkXDq8gRnml XFiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dYPXMETAEtxgAx58kAVwvDffm2oRcixnOug23rUFpYo=; b=rvP36ApJ/fXN2LdqGfrQ+3vdXZp/cAD1ndxK+oVj5N6sXv6E/gQeQqkM100Vet0VKX tsW3+d3KH3Y6/id+0eUHcAgxxOn5osTA6+0eHdyxF041o+QwrPTeMJTFEaEfvsxqLJW8 +iVKb1AAN61xDzPE72AQv54DT27HHaXBIiR7jY0A+czf3PQQlI5lWo+OLNORhpz2qb5q j72tJiSRJo0w1vGPPOtC9MredOnVoW8TITFe7YZpf/kCs5TQ/D40Vm6+cH1Dfm1iexVl kOEr389Zze+IaofPF6MfV3IO1rT6v9/+hUFbnLNCdA/K6w/gudq2pvoYmDzWjmwvjpeC Q8bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sLKuf2uw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h5si14118970jaa.119.2021.09.20.18.43.34; Mon, 20 Sep 2021 18:43:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sLKuf2uw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237445AbhITQ4E (ORCPT + 99 others); Mon, 20 Sep 2021 12:56:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:38784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245056AbhITQwX (ORCPT ); Mon, 20 Sep 2021 12:52:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6575E6135F; Mon, 20 Sep 2021 16:49:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632156584; bh=tpsUBxbwHyahRTHJl8F6xAiSAZHaGuLkki7aXRR/kiE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sLKuf2uwz0TIxtIBB0pMTSUg695+Y8pCuvoV+HK+/e+PUPouzRxrcBFFROQkdA5K1 0M7rfpWg2nhYJpavdJt5O+pwImAgjrG4kxjOtJJ64ttZJAYEyPlHcrhqLbps0BCWXN Y+N09pIaRg0jC4+zhYlmJ2O/v7pkzBTTEgWXP6Ck= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zheyu Ma , Sasha Levin Subject: [PATCH 4.4 093/133] tty: serial: jsm: hold port lock when reporting modem line changes Date: Mon, 20 Sep 2021 18:42:51 +0200 Message-Id: <20210920163915.682147187@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163912.603434365@linuxfoundation.org> References: <20210920163912.603434365@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zheyu Ma [ Upstream commit 240e126c28df084222f0b661321e8e3ecb0d232e ] 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 Link: https://lore.kernel.org/r/1626242003-3809-1-git-send-email-zheyuma97@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- 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 932b2accd06f..4ed0c099c757 100644 --- a/drivers/tty/serial/jsm/jsm_neo.c +++ b/drivers/tty/serial/jsm/jsm_neo.c @@ -827,7 +827,9 @@ static inline 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 524e86ab3cae..dad3abab8280 100644 --- a/drivers/tty/serial/jsm/jsm_tty.c +++ b/drivers/tty/serial/jsm/jsm_tty.c @@ -195,6 +195,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); @@ -248,6 +249,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; @@ -267,6 +269,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.30.2