Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp93486pxv; Tue, 13 Jul 2021 22:54:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhU5KxJgsVh3k8lcGPxBi3Uf5SN34/Sxyq5G/J7pTWZQZ4FGDBojEF4fAIsW5Od5PLVjDp X-Received: by 2002:a02:c496:: with SMTP id t22mr7437358jam.80.1626242090944; Tue, 13 Jul 2021 22:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626242090; cv=none; d=google.com; s=arc-20160816; b=RVqR8VuqcaeG+FNfjVzsDHzOYnFWFtIIXU+gIOpTvWEUVtj33XcfhL/fOTcJ4cPmaA eJ7aGOgjh68y8ZPMD/cLbHHqG/6RvirlFfkEaXjP8rtIHYpqhL1SBD4ulL0smgcG5PSD 0hG2LPfB1hetQYfw5xDOCDucrYXQVFYMwct430LPaQ3QTMmfscZDcZussEUWNDVZ1Pg1 VvLsGP4nRxtDgxRFHpOJ5us+YVLlVD7FFpTy3BIhFLP0INl1TVfAL4P2/MQU4PZ0iNmF T2cRnsnLG7ELa9158bM1EREapwrkkhsHnBhKngQUMWudhPbYu/+yjVT9jYr0hfkRkKa9 Qh+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=FcWz93B3TY2NaEB6A00DYMs3rnSUlD4JI48Qjj+1dto=; b=wEVqFFlyzuN3+EO0aurr/EYixlZHT+fKHiNeGLvuP/G4daG7pLHurHNMEXpZJX0YNP sCiuI6+/UjXSS6Dv1yn7MjpJwZB65me4Z8zhKHFTzW5KHCu1ZsRVgJcJhY/7tfbISxmw gjMuFwt2wz4ef1jZaRarPfiiYmLAqlEu4wRztTNhmovtSoSY1Ss+IyvI0SWmMWZ+xnLE UE9l10YAdBK8k0E+LzHo7i5TXdYJKWzO/3aM0emjHNGshXJYw9JmVrcSiThpk+8gi3sc fscbK8HDLXdq9qyJYGMsknPS2mrRgMVPUkvgjMoaEsjs1Uk1ojIB7yBbNoVU0oVLhnnS QWvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=I6dUFLht; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y9si1399078ilv.11.2021.07.13.22.54.39; Tue, 13 Jul 2021 22:54:50 -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=@gmail.com header.s=20161025 header.b=I6dUFLht; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238001AbhGNF40 (ORCPT + 99 others); Wed, 14 Jul 2021 01:56:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237971AbhGNF40 (ORCPT ); Wed, 14 Jul 2021 01:56:26 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73DF2C0613DD; Tue, 13 Jul 2021 22:53:35 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id g6-20020a17090adac6b029015d1a9a6f1aso3014081pjx.1; Tue, 13 Jul 2021 22:53:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=FcWz93B3TY2NaEB6A00DYMs3rnSUlD4JI48Qjj+1dto=; b=I6dUFLht6XEJWdXKzQSNpt8coqO8492xaA25/5tMPw5iCpQnwB4fWPN5qNIi6+TsWC 4Yx/Nx4YAvxsa6jEcXtzipX1qDevkNk56obKp/XH2BiIgp9achR1cuKPZSgXbo0cRs+M P6R35psBXBseb34/aTufJH1uUccG9KLwuCvwPV6OdB/psTLtJBbLSS9+u9eR4K7TZ6K1 ze76dsl/bjZXoD2t4oGNx99sp9GzELsovZeB+CSelTPOeJ2ZcW2s6LVvHVbJm02adi/r USf13g11MyOKMdHUB/cAT9Z2g+2KwbXqd+UTP2Fvlblh0kmnrpJcAlpPzYfjLcJE0b7q 56sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=FcWz93B3TY2NaEB6A00DYMs3rnSUlD4JI48Qjj+1dto=; b=jaLivzZ1yli5t9BcJxY8cONcm+gxDT9HSOgQCOT7mEVWPjhvTMgP8kYehK7169IA6r VlFWJpul9+LyvEhtxdcXp07qcW64HlCpVWTLHAjekEhBYyu3oDA5+KWB27Q+I3eSgyxW rcubYK9mJKCI4HrG18KE165TU9t23ObLqK0icezI0z/1AOPydUEJKI0F0tNF80wgP9mf tuRCPMKuDq6BjPwamSifKOiZVCmQuph2lH4USBWLoflQeqZx+DJj1keqT0H15gU2TLXR oPFB81CuyaRYeQk+LaGXKD+aD7tLyIopwHW8n3FkHWSVBsrpdcTDucgC/03BTa676oPa k45g== X-Gm-Message-State: AOAM531mKOfCyOoXtT6/ZXhALgpNV6CqCaVp4PSML2kw2pJyUIOuVP2M 5F5KIc5Pjh5SZtu9fq70sQ== X-Received: by 2002:a17:90a:b284:: with SMTP id c4mr8180136pjr.213.1626242014991; Tue, 13 Jul 2021 22:53:34 -0700 (PDT) Received: from vultr.guest ([107.191.53.97]) by smtp.gmail.com with ESMTPSA id c11sm1143812pfp.0.2021.07.13.22.53.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jul 2021 22:53:34 -0700 (PDT) From: Zheyu Ma To: gregkh@linuxfoundation.org, jirislaby@kernel.org, rclemsmith@gmail.com Cc: zheyuma97@gmail.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] tty: serial: jsm: hold port lock when reporting modem line changes Date: Wed, 14 Jul 2021 05:53:23 +0000 Message-Id: <1626242003-3809-1-git-send-email-zheyuma97@gmail.com> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Changes in v2: - Attach an excerpt from the warning --- 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