Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp55956imu; Thu, 8 Nov 2018 14:42:34 -0800 (PST) X-Google-Smtp-Source: AJdET5faHrPN5PHAVHRK2gP+1GASeSurJ7Axkin1KYelWBBrxX/DvsjjUV8f8Gwz9AdKI/8oUPef X-Received: by 2002:a62:5d49:: with SMTP id r70-v6mr6509793pfb.123.1541716954205; Thu, 08 Nov 2018 14:42:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541716954; cv=none; d=google.com; s=arc-20160816; b=lrdFh5fFJ8pujuMMK+swJmlUAoOk1FoEcp4yWTQXJcXM8sg9NfFWjr0TV5j1Jr/prp 3EB13FjKz31mZAlNjwDInmNGVPnBuRlwg+1MUWJdWNy6aVQCEdC7HIbo/n7yCtVfdgq/ 2eBB6sqvlppPWqBd0zDmahJsi+3SXV61PvdK6R/7slavcktvQKknfnGN0BbSFDpSgv4K 3PsfpOgHaPkhWH7DTwwm9XCqPYAwf+aGFwil1tVtFB12sBiYkTQyDWsgz/JgouQJOq9c ghwTXQetOlSLbAAYeGxD8TjbfEL5XbpGvB2/KXVb23ZReB3c7QhqJe/AKcYIezdzRdGd VkIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lpRtI8MgOZd29nxB2+Wk1AxyLibl/MZwJGWYSMNgwFk=; b=zcAmAcYTh60+Vc7+ya4o1QPUx4Mb7mblMJ2jkM2hhh5r56evpX/5o8sta83Zyrw0S0 TV23lmkHvfPj/uF+FfVflWQp++1QvxCJCnfmSQ1MpWbQlfxXjBdBo80yuBlpqBvd3EmA KJn7o6YEJHq0mcr9aU3R4BRi0MsMCnhNl329oYSJI5s4WjWw6Vo8LtWRwecuqNkK9fhV xXXVtJ/WDNAl36p8tH/vkYzIH3N8buPJustRc1AV7/+RAzi5RxBcyWrg4pKXfP0v7GfR iL0w5oxFRHd8UvLyBeTJRhNeO88NcUQ9RdxpjSJLt28/03XrDLXg1H9NJRrlsJjz23uQ l/sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wQ6QE70M; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h65-v6si5922757pfc.62.2018.11.08.14.42.18; Thu, 08 Nov 2018 14:42:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wQ6QE70M; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728972AbeKIHdi (ORCPT + 99 others); Fri, 9 Nov 2018 02:33:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:49456 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728951AbeKIHdi (ORCPT ); Fri, 9 Nov 2018 02:33:38 -0500 Received: from localhost (unknown [208.72.13.198]) (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 C31D220892; Thu, 8 Nov 2018 21:56:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714170; bh=YLmCx82ocb9RuUFgAsuHuhj8YE/KYq8DRgy4fJa4RQU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wQ6QE70MomBCDQbB5DZUNxYz9eEkBc19K+Iuya6d3cLpjjB9mu0F1J2Id8LhUoI9E po4Sj7ElgCh2XNnUjKZ8yI2WEHy4c27A3Ti0HiNo1j3npx50CH9SXbsuxz6+kBeFHJ IP8RZBi2VImQV6Lk9v3ziUO2Ps8JcRMZceZWOp8U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefan Agner , Bhuvanchandra DV , Sasha Levin Subject: [PATCH 3.18 093/144] tty: serial: fsl_lpuart: fix clearing of receive flag Date: Thu, 8 Nov 2018 13:51:04 -0800 Message-Id: <20181108215103.075842925@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215054.826084593@linuxfoundation.org> References: <20181108215054.826084593@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit d68827c62a105eec547945daedf4d1d3e283717d ] Commit 8e4934c6d6c6 ("tty: serial: fsl_lpuart: clear receive flag on FIFO flush") implemented clearing of the receive flag by reading the status register only. It turned out that even though we flush the FIFO afterwards, a explicit read of the data register is still required. This leads to a FIFO underrun. To avoid this, follow the advice in the overrun "Operation section": Unconditionally clear RXUF after using RXFLUSH. Signed-off-by: Stefan Agner Signed-off-by: Bhuvanchandra DV Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/fsl_lpuart.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index af3047d8322a..92b7a5bf7c4d 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -910,13 +910,16 @@ static void lpuart_setup_watermark(struct lpuart_port *sport) writeb(val | UARTPFIFO_TXFE | UARTPFIFO_RXFE, sport->port.membase + UARTPFIFO); - /* explicitly clear RDRF */ - readb(sport->port.membase + UARTSR1); - /* flush Tx and Rx FIFO */ writeb(UARTCFIFO_TXFLUSH | UARTCFIFO_RXFLUSH, sport->port.membase + UARTCFIFO); + /* explicitly clear RDRF */ + if (readb(sport->port.membase + UARTSR1) & UARTSR1_RDRF) { + readb(sport->port.membase + UARTDR); + writeb(UARTSFIFO_RXUF, sport->port.membase + UARTSFIFO); + } + writeb(0, sport->port.membase + UARTTWFIFO); writeb(1, sport->port.membase + UARTRWFIFO); -- 2.17.1