From patchwork Tue Jun 2 14:00:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 213944 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AF7BC433E2 for ; Tue, 2 Jun 2020 14:01:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C76F2074B for ; Tue, 2 Jun 2020 14:01:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591106490; bh=SFnZGfuUZh9BGwo8gb4PEuJJ3RLFPSIYhTnGuCGCLD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=FfmLgX0PEciN7cismUNeSpl/YijDul09ElMrPGNOLwJFZ9UFOo6pOtU5V8RI/axim NDYOdp15spxVohc/P4CgJCrk10vSYFZtjikHlgHZldM4rfjVYVH16yoGsR1m35Q3tc DWSBgeZhEzUaXx6dMJzOYxsg9VBKYAGG9If+Zcjg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727070AbgFBOB3 (ORCPT ); Tue, 2 Jun 2020 10:01:29 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:41445 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726000AbgFBOB3 (ORCPT ); Tue, 2 Jun 2020 10:01:29 -0400 Received: by mail-lf1-f67.google.com with SMTP id u16so6239239lfl.8; Tue, 02 Jun 2020 07:01:27 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=7TsTVRy6VoIywIRL97JtwPjdmIS2xffzmjhoZrIa1AA=; b=eOsGiqaPePBg9gD9SVka1Kwq1CpL2OBOyyPJrYxi5m2hYmtOJ/v7bu83HfKBdkLZWc oj6mSbMP9vdotQC3eXB6t3hrE0VFnA6P//g1hV3p+uiWHy0Y3KoeFX1aITko7+eUlgWq sQSVqU0B/DSxw4QSn1mGUFCRGBHKzxIW0xaUfpnvH7rx3eTMO1tIqDOHi2BYVPlI19jT cr9C4gqu2gWSyPjibVvqIXrXbKzhM5rBDrGTp2Pc1Y8YnlMR444FUbSgmiaDK66jVtka ImfiBBofIpz4ws2gLKmOnyMvXmKMeIkPV6lMH97mLwdUU6XESQ2ycJX2VteAEFV0qvhc s7Og== X-Gm-Message-State: AOAM5332KyAMv1YJFYfNqibUZfQUJ+OvZbEoFt+fRMNExqTNZe05uzKh 1vB1yivc31atZcVGCGxU0TM= X-Google-Smtp-Source: ABdhPJyua9OTdM+nCysSu614tZnmPjAqAmTU6yC4euXIi+HEamZNG2cLy12oe+as8rRKEabuEdEN8g== X-Received: by 2002:ac2:485a:: with SMTP id 26mr13899122lfy.57.1591106486401; Tue, 02 Jun 2020 07:01:26 -0700 (PDT) Received: from xi.terra (c-beaee455.07-184-6d6c6d4.bbcust.telenor.se. [85.228.174.190]) by smtp.gmail.com with ESMTPSA id s13sm825849lfp.81.2020.06.02.07.01.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 07:01:25 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1jg7Ti-0000xz-RD; Tue, 02 Jun 2020 16:01:18 +0200 From: Johan Hovold To: Greg Kroah-Hartman Cc: Jiri Slaby , Dmitry Safonov <0x7f454c46@gmail.com>, Andy Shevchenko , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable Subject: [PATCH 2/4] serial: core: fix broken sysrq port unlock Date: Tue, 2 Jun 2020 16:00:56 +0200 Message-Id: <20200602140058.3656-3-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200602140058.3656-1-johan@kernel.org> References: <20200602140058.3656-1-johan@kernel.org> MIME-Version: 1.0 Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Commit d6e1935819db ("serial: core: Allow processing sysrq at port unlock time") worked around a circular locking dependency by adding helpers used to defer sysrq processing to when the port lock was released. A later commit unfortunately converted these inline helpers to exported functions despite the fact that the unlock helper was restoring irq flags, something which needs to be done in the same function that saved them (e.g. on SPARC). Fixes: 8e20fc391711 ("serial_core: Move sysrq functions from header file") Cc: stable # 5.6 Cc: Dmitry Safonov <0x7f454c46@gmail.com> Signed-off-by: Johan Hovold --- drivers/tty/serial/serial_core.c | 19 ------------------- include/linux/serial_core.h | 21 +++++++++++++++++++-- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index edfb7bc14bbf..f6cf9cc4ce69 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3239,25 +3239,6 @@ int uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch) } EXPORT_SYMBOL_GPL(uart_prepare_sysrq_char); -void uart_unlock_and_check_sysrq(struct uart_port *port, unsigned long irqflags) -{ - int sysrq_ch; - - if (!port->has_sysrq) { - spin_unlock_irqrestore(&port->lock, irqflags); - return; - } - - sysrq_ch = port->sysrq_ch; - port->sysrq_ch = 0; - - spin_unlock_irqrestore(&port->lock, irqflags); - - if (sysrq_ch) - handle_sysrq(sysrq_ch); -} -EXPORT_SYMBOL_GPL(uart_unlock_and_check_sysrq); - /* * We do the SysRQ and SAK checking like this... */ diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 1f4443db5474..858c5dd926ad 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -462,8 +462,25 @@ extern void uart_insert_char(struct uart_port *port, unsigned int status, extern int uart_handle_sysrq_char(struct uart_port *port, unsigned int ch); extern int uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch); -extern void uart_unlock_and_check_sysrq(struct uart_port *port, - unsigned long irqflags); + +static inline void uart_unlock_and_check_sysrq(struct uart_port *port, unsigned long irqflags) +{ + int sysrq_ch; + + if (!port->has_sysrq) { + spin_unlock_irqrestore(&port->lock, irqflags); + return; + } + + sysrq_ch = port->sysrq_ch; + port->sysrq_ch = 0; + + spin_unlock_irqrestore(&port->lock, irqflags); + + if (sysrq_ch) + handle_sysrq(sysrq_ch); +} + extern int uart_handle_break(struct uart_port *port); /* From patchwork Tue Jun 2 14:00:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 213943 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF335C433E2 for ; Tue, 2 Jun 2020 14:01:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A3A562074B for ; Tue, 2 Jun 2020 14:01:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591106499; bh=fZH11i5Q7gqU/qRbrKlZ6oMTCERUJw6ZUawYVDPcU8A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=igUAIdxIqO+HozNHP/unCdytdpAquMLjIt+bJtE/u4u+70CddElWdnInx3YqoKLoz Yv3DJFafRJD2A4J5KAQDy0i3M/ekhySP4L33/WOLBajMSTlpNR6MX/pKkkJyxkRtwL ADlAurX8n5U0ETXWNCMb99xzZ6q6FT5b9TFepepI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726019AbgFBOBi (ORCPT ); Tue, 2 Jun 2020 10:01:38 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:36056 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726037AbgFBOBa (ORCPT ); Tue, 2 Jun 2020 10:01:30 -0400 Received: by mail-lf1-f66.google.com with SMTP id c21so6241392lfb.3; Tue, 02 Jun 2020 07:01:28 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=TA2VrMpQcKxxkV/93dofpkZjb0FySJYHvfRazp8UvOQ=; b=uMb1/Xd7MhJVJoHZvqjm0Fk/cLlOBI+8tuScKSqiIqxHS/0CPfeBsW7IVF06vjklPn ETRn6zOQ/LfZaXL2EUJ044YzBlSpwGJvrVHhmVpS/JTSe5O4vwmquwmhPgRnQyQ2Kb1t cPuMy2jjpMZdCOqsG1h06iWFIb1q7feMRm3K7PPikczWdSUo5PYSW2bgw0+ZkelhHIyM PEPZZkeOlbValw5QGjUzZNoliRnRVkyvj2OYtLZwKvo4lu2aHHVR7XfMsb4qAbnox8eb s9ONn0SMONRaxIzf8jdJTWxo600Ry6Grnx/n2TZW3xenDlCP4iVqE+f7UXmdwtxHfReh 3xqA== X-Gm-Message-State: AOAM533CMdIG+L4ewNJHbLrahetdWe//FScd/99V4cEpK6vwtikoiE+y kTGW31o56TyCl6H/ITZKB8A= X-Google-Smtp-Source: ABdhPJw4qHQUsMq3CqXI9gPXpNZdAlvrVo30lnIjen10Igua9LsXpcqp8e72gU7Hknt1mvWKupwi5Q== X-Received: by 2002:ac2:58fb:: with SMTP id v27mr14410052lfo.116.1591106488045; Tue, 02 Jun 2020 07:01:28 -0700 (PDT) Received: from xi.terra (c-beaee455.07-184-6d6c6d4.bbcust.telenor.se. [85.228.174.190]) by smtp.gmail.com with ESMTPSA id t22sm430077lji.90.2020.06.02.07.01.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 07:01:26 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1jg7Tj-0000y8-0g; Tue, 02 Jun 2020 16:01:19 +0200 From: Johan Hovold To: Greg Kroah-Hartman Cc: Jiri Slaby , Dmitry Safonov <0x7f454c46@gmail.com>, Andy Shevchenko , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 4/4] serial: core: drop redundant sysrq checks Date: Tue, 2 Jun 2020 16:00:58 +0200 Message-Id: <20200602140058.3656-5-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200602140058.3656-1-johan@kernel.org> References: <20200602140058.3656-1-johan@kernel.org> MIME-Version: 1.0 Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org The sysrq timestamp will never be set unless port->has_sysrq so drop the redundant checks that where added by commit 1997e9dfdc84 ("serial_core: Un-ifdef sysrq SUPPORT_SYSRQ"). Signed-off-by: Johan Hovold --- include/linux/serial_core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index a8a213b71553..2f6c3cfe2ae7 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -468,7 +468,7 @@ bool uart_try_toggle_sysrq(struct uart_port *port, unsigned int ch); static inline int uart_handle_sysrq_char(struct uart_port *port, unsigned int ch) { - if (!port->has_sysrq || !port->sysrq) + if (!port->sysrq) return 0; if (ch && time_before(jiffies, port->sysrq)) { @@ -487,7 +487,7 @@ static inline int uart_handle_sysrq_char(struct uart_port *port, unsigned int ch static inline int uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch) { - if (!port->has_sysrq || !port->sysrq) + if (!port->sysrq) return 0; if (ch && time_before(jiffies, port->sysrq)) {