Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4515454pxj; Wed, 12 May 2021 07:17:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5I6lDpBrUM0Q/cFcF7eLVmTRGesfKwdvjZJeJuxd26F+5tWFh+W0L/mPLTrYXCxccvLKr X-Received: by 2002:a19:f506:: with SMTP id j6mr26441685lfb.454.1620829056050; Wed, 12 May 2021 07:17:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620829056; cv=none; d=google.com; s=arc-20160816; b=z+CG68UJ70NnTk9Xkf3qAxv3gYT/9hJJVsmto2NUe2ZV/YJVRiSiD7EjNldp+v61g0 PZL+8+JiwmWA0fg7vH+cEgiojDQjYYblsdN+n3/rHSI8A6nlF5EfUHlAj2pl7fYwuxkS ED6NrzwGQmDVObh0DfOc6QYhp4ZjysAXadsmJICLWCS7SmG69zQmtQRTZWIMvV2rduvY jItUNlrEiMqWBXSEg3riHWrq903vJCs3NL+c5Wk9xQM39q6OyZmf+lWs6jVUJXCY0+3P reRYz79KyCXwfTFnouWLSwGD8/CFSYI96Jag7P+px2d7PfZT9X/lqWB2MCUQj3c9aADc Mv8w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QxeVxBSNPd9X+FwB7w/uW8Ipt1KaSSCH/Y0I4/zPuaY=; b=SbIMQMxKLrJW9AJ4PNj4LvGLAB5D5BKyMoGwbpEz6lZAbsfuoS/XxxO8LffsNLJ3uS xNMD9Vj3U9AXn13F0RR9B9znrDZ4i2FjGCPr8bv+oCu2Cr1mjz/qLpw/1xZuPQH34HWL Tp7LK/mn5EAHx2JKCiT88/Ss9N/3SbQFECICkgvXGBX6L75JagWQpmSnT7O1q1aKRkZu K+1lQs7ttX2UW9f1nbjMvuoXJFrIOjKw44MLgrPNjdbAesF8k2ewNidSMU7ZeT/p/vp8 IvAw4iOWDfETWsUK874bkgXl274d0zxDkh5tz8Dj0bXR2CyobyGUQfc3Q2JcssusX+Hw cTSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=fhp7HGPH; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v7si17995lfg.336.2021.05.12.07.17.06; Wed, 12 May 2021 07:17:36 -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=@walle.cc header.s=mail2016061301 header.b=fhp7HGPH; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231325AbhELOOr (ORCPT + 99 others); Wed, 12 May 2021 10:14:47 -0400 Received: from ssl.serverraum.org ([176.9.125.105]:43327 "EHLO ssl.serverraum.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231397AbhELOOQ (ORCPT ); Wed, 12 May 2021 10:14:16 -0400 Received: from mwalle01.fritz.box (unknown [IPv6:2a02:810c:c200:2e91:fa59:71ff:fe9b:b851]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 833BE22268; Wed, 12 May 2021 16:13:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1620828787; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QxeVxBSNPd9X+FwB7w/uW8Ipt1KaSSCH/Y0I4/zPuaY=; b=fhp7HGPHKnK9gZ4PIM3+TNWwi70Qu3mg0W7BSJCbbjNRSuh8YCoA7YledPdHBX/iPhI5T5 NiN3Eox1DdGdYsxLDDfBDZB+9Ve5yfuNISqacV8ce4og6YGpsd8kSlRjT1OKU5dJ3ka0Hm /V77A37kN/SD7AnEF+InRyZJbsUYBrs= From: Michael Walle To: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby , Angelo Dureghello , Johan Hovold , Philippe Schenker , Michael Walle Subject: [PATCH v2 5/9] serial: fsl_lpuart: handle break and make sysrq work Date: Wed, 12 May 2021 16:12:51 +0200 Message-Id: <20210512141255.18277-6-michael@walle.cc> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210512141255.18277-1-michael@walle.cc> References: <20210512141255.18277-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Although there is already sysrq characters handling, a break condition was never detected. Add support for it. The LPUART can't distinguish between a framing error and a break condition. We assume it is a break if the received data is all zero. Signed-off-by: Michael Walle --- drivers/tty/serial/fsl_lpuart.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 63a1dac7c3aa..c76bdb855ba9 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -910,6 +910,7 @@ static void lpuart32_rxint(struct lpuart_port *sport) unsigned int flg, ignored = 0; struct tty_port *port = &sport->port.state->port; unsigned long rx, sr; + bool is_break; spin_lock(&sport->port.lock); @@ -924,14 +925,27 @@ static void lpuart32_rxint(struct lpuart_port *sport) rx = lpuart32_read(&sport->port, UARTDATA); rx &= UARTDATA_MASK; + /* + * The LPUART can't distinguish between a break and a framing error, + * thus we assume it is a break if the received data is zero. + */ + is_break = (sr & UARTSTAT_FE) && !rx; + + if (is_break && uart_handle_break(&sport->port)) + continue; + if (uart_prepare_sysrq_char(&sport->port, rx)) continue; if (sr & (UARTSTAT_PE | UARTSTAT_OR | UARTSTAT_FE)) { - if (sr & UARTSTAT_PE) - sport->port.icount.parity++; - else if (sr & UARTSTAT_FE) + if (sr & UARTSTAT_PE) { + if (is_break) + sport->port.icount.brk++; + else + sport->port.icount.parity++; + } else if (sr & UARTSTAT_FE) { sport->port.icount.frame++; + } if (sr & UARTSTAT_OR) sport->port.icount.overrun++; @@ -944,15 +958,17 @@ static void lpuart32_rxint(struct lpuart_port *sport) sr &= sport->port.read_status_mask; - if (sr & UARTSTAT_PE) - flg = TTY_PARITY; - else if (sr & UARTSTAT_FE) + if (sr & UARTSTAT_PE) { + if (is_break) + flg = TTY_BREAK; + else + flg = TTY_PARITY; + } else if (sr & UARTSTAT_FE) { flg = TTY_FRAME; + } if (sr & UARTSTAT_OR) flg = TTY_OVERRUN; - - sport->port.sysrq = 0; } tty_insert_flip_char(port, rx, flg); -- 2.20.1