From patchwork Tue Apr 28 18:25:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 226809 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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 D97DEC83000 for ; Tue, 28 Apr 2020 18:50:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B75A7206A1 for ; Tue, 28 Apr 2020 18:50:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588099827; bh=0lPXiegyr/iApzt/uCz1N5w1u3DCYeQHzxUA3HwEud8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=MYNlNqiEIN4xUkLnUWcczkX8Ncki9m+T3fjFCPuPwDBI6IETXJAmHIRnimovEANiZ y4Qfj/wJWjS4lGsNJEnh7M9cyfM+Aluxrs1Qdb2YKljhOn1qIeJjV9AhATju898wV3 R1uioe5woefLu/3QfuKX5M0R5/VFfd5Rd09ZBPTc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730634AbgD1Sia (ORCPT ); Tue, 28 Apr 2020 14:38:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:56966 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730632AbgD1Sia (ORCPT ); Tue, 28 Apr 2020 14:38:30 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 027B72076A; Tue, 28 Apr 2020 18:38:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588099109; bh=0lPXiegyr/iApzt/uCz1N5w1u3DCYeQHzxUA3HwEud8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PRNNCXH4sf8cap2bxy4EAeNG7R1HN7k54rsi41GLcUpj0FNFNtmMe5dFbzRdL5Uj9 GDaEr8yrBHr8ddY4nh8vNAjDiXYigyKIzTmPYIztjT1Qx/u5OuI7QwydHZLMhp7rjB jgGoptR+WuVRXXHjTwaLAuUCqNfkHs8BC2r2mJfo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kazuhiro Fujita , Hao Bui , KAZUMI HARADA , Lad Prabhakar , Geert Uytterhoeven Subject: [PATCH 5.6 156/167] serial: sh-sci: Make sure status register SCxSR is read in correct sequence Date: Tue, 28 Apr 2020 20:25:32 +0200 Message-Id: <20200428182245.315652758@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200428182225.451225420@linuxfoundation.org> References: <20200428182225.451225420@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Kazuhiro Fujita commit 3dc4db3662366306e54ddcbda4804acb1258e4ba upstream. For SCIF and HSCIF interfaces the SCxSR register holds the status of data that is to be read next from SCxRDR register, But where as for SCIFA and SCIFB interfaces SCxSR register holds status of data that is previously read from SCxRDR register. This patch makes sure the status register is read depending on the port types so that errors are caught accordingly. Cc: Signed-off-by: Kazuhiro Fujita Signed-off-by: Hao Bui Signed-off-by: KAZUMI HARADA Signed-off-by: Lad Prabhakar Tested-by: Geert Uytterhoeven Link: https://lore.kernel.org/r/1585333048-31828-1-git-send-email-kazuhiro.fujita.jg@renesas.com Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/sh-sci.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -870,9 +870,16 @@ static void sci_receive_chars(struct uar tty_insert_flip_char(tport, c, TTY_NORMAL); } else { for (i = 0; i < count; i++) { - char c = serial_port_in(port, SCxRDR); + char c; - status = serial_port_in(port, SCxSR); + if (port->type == PORT_SCIF || + port->type == PORT_HSCIF) { + status = serial_port_in(port, SCxSR); + c = serial_port_in(port, SCxRDR); + } else { + c = serial_port_in(port, SCxRDR); + status = serial_port_in(port, SCxSR); + } if (uart_handle_sysrq_char(port, c)) { count--; i--; continue;