Received: by 10.192.165.148 with SMTP id m20csp215528imm; Fri, 20 Apr 2018 05:45:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx48HNS3ZoVoQKpw5LavpIqi08zy0E0Pa0clW2/a0P78vPYlIxZDVDFWU8niXNdpANkYxWj6s X-Received: by 2002:a17:902:42a5:: with SMTP id h34-v6mr10084729pld.65.1524228336406; Fri, 20 Apr 2018 05:45:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524228336; cv=none; d=google.com; s=arc-20160816; b=B4SMEZwoYrfQiWJ4iYovVtG5UgTlunxmc+6yw/XR+qaaX7qBnI786/siQFf8SMLGdP vGVKTA4hEMH+EPekxyZ5hrfCB/1eE+rjrSRKn7SR5P4ERWVYTeieCrgCF1dcrKQn1wK5 pe5OUC8M9NbEsC0jbMN1A8oOzuj2FZ3MuuMm47+IFR6xFsD7GzmwnDvVzQTZJCYGLtKk Qr1PKxFs+IGCumvjwqvJHIC1ipruw4ZuZETCrQ1cZfUxulLxQO7QuTvgM6nkoVa0bRe6 OSb/DAXWHdSuEThnydem8zOentEvjLwTf+AfljLBhiJhdYa8qWbZCoJhjsvPnGzKTDX0 nvFQ== 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 :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=ztZS1Wcs5rBIO/dGP6yxE3QgHSG3bcMc47Bu+rWpThU=; b=RekC5GdcwgheXNptN+ZhbokvAQaSpZlCrSrWDJTmZ1/RSCk9sChYeSh2MYgr6Zkkf5 WRlirrDCyPLKIkwa8bCkPyae+Z/tzJmBo81lmpM8OWTelyAEbudShWkk/UVUCIiUnPiP 7QBcFbktgJAj+x0o+3JxIzBNvblPJAYacQLHq+fjaBECfGYA8H94Gx3P66oURQXT0TPZ ZDFMHcEZGILqzCTxQIWOEmr8YSdbZ5deXBf664JzjpyYNN6FUylov5utm/YxVxJFDVjo t+dNEiJ9pGBLNsaNCUpMuCHCoKxniYuTnBhfoQ7YllLmXPC3ZWQf0maoxWWzuy34+Skb C2BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=vKui75vg; 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 p8si4869650pgn.406.2018.04.20.05.45.21; Fri, 20 Apr 2018 05:45:36 -0700 (PDT) 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=@agner.ch header.s=dkim header.b=vKui75vg; 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 S1754811AbeDTMoQ (ORCPT + 99 others); Fri, 20 Apr 2018 08:44:16 -0400 Received: from mail.kmu-office.ch ([178.209.48.109]:60670 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754712AbeDTMoM (ORCPT ); Fri, 20 Apr 2018 08:44:12 -0400 Received: from trochilidae.toradex.int (unknown [IPv6:2001:1620:c6e:10::3]) by mail.kmu-office.ch (Postfix) with ESMTPSA id CD3DC5C1422; Fri, 20 Apr 2018 14:44:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1524228251; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=ztZS1Wcs5rBIO/dGP6yxE3QgHSG3bcMc47Bu+rWpThU=; b=vKui75vg28t71v28P+R88J1cANM0ztSk9SEQtQxQ/0WM8JG72oyrA3Emu8SZtsiFy15rNT Ph+TFBG7nnD2XazIT9CZJLXEIWbgwDz2P3tEa8G6Oc5G26owypt7C7EuX9ep69A12A7pyY WcFoLbxDWJ8McdEIhxT5Soxz+MJ/p0w= From: Stefan Agner To: gregkh@linuxfoundation.org Cc: u.kleine-koenig@pengutronix.de, festevam@gmail.com, jslaby@suse.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Agner Subject: [PATCH v2] serial: imx: fix cached UCR2 read on software reset Date: Fri, 20 Apr 2018 14:44:07 +0200 Message-Id: <20180420124407.12892-1-stefan@agner.ch> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-2.10 / 15.00]; RCVD_TLS_ALL(0.00)[]; ASN(0.00)[asn:13030, ipnet:2001:1620::/32, country:CH]; RCVD_COUNT_ZERO(0.00)[0]; FROM_HAS_DN(0.00)[]; MID_CONTAINS_FROM(1.00)[]; TO_DN_SOME(0.00)[]; MIME_GOOD(-0.10)[text/plain]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To reset the UART the SRST needs be cleared (low active). According to the documentation the bit will remain active for 4 module clocks until it is cleared (set to 1). Hence the real register need to be read in case the cached register indicates that the SRST bit is zero. This bug lead to wrong baudrate because the baud rate register got restored before reset completed in imx_flush_buffer. Fixes: 3a0ab62f43de ("serial: imx: implement shadow registers for UCRx and UFCR") Signed-off-by: Stefan Agner Reviewed-by: Fabio Estevam Reviewed-by: Uwe Kleine-König --- Hi Greg, Since this fixes a regression it should go into v4.17... -- Stefan drivers/tty/serial/imx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 91f3a1a5cb7f..4ff6bd6eb9ab 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -316,7 +316,7 @@ static u32 imx_uart_readl(struct imx_port *sport, u32 offset) * differ from the value that was last written. As it only * clears after being set, reread conditionally. */ - if (sport->ucr2 & UCR2_SRST) + if (!(sport->ucr2 & UCR2_SRST)) sport->ucr2 = readl(sport->port.membase + offset); return sport->ucr2; break; -- 2.17.0