Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp830824ybl; Wed, 11 Dec 2019 08:09:17 -0800 (PST) X-Google-Smtp-Source: APXvYqzB+n2W2BbiJgjciyHF6uwzU/R1mWehN2obupVQE9aJo4yfaFh5W7ja3L4rvmXw06kpG/FA X-Received: by 2002:a05:6830:15a:: with SMTP id j26mr2718728otp.137.1576080557604; Wed, 11 Dec 2019 08:09:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576080557; cv=none; d=google.com; s=arc-20160816; b=cjqH605ufuwDMhQQNWdlfvU/81arguRvaNqYICQxUMq5t0cju8t25r0go4MxhRJE0Q oj/4kr87Ios/6IvW0j1ArgoZiCUoRilWFaJ390qeKp/bXziEMSEzD3EgG+P4qGZsh43n yTp5Nvf2E3ASwQhNAvcAQcH4isO6pmj1uC8rWmnKUHUPpqNTxhBd35sjHJMN4jwiRDLu P0L+g4qA5f01V4yPfquPsDNuXLtkThpvTLfLBLQn7bODDvQ0l4Il7EV1zcKMh6Yo78iE +X7RI7TllB3qjjqrAAIyg5RDFtpxbJaV4sERApXWUFsSWsns4Yzb/IPywdW8tJHkf6oa VaLQ== 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=p5Cf4QiwOHTCLyrJdmJREpX5vt+eh9F9D7RD/+KJGdk=; b=qFvMspYuXtDiFdDvAraJ2t+G7yoV8Nk10RdY4lkxhOTJ9ZtRBvq7oDtT4BWBeYXCJI iEZVSVd7AAVfg3BSFzLWM56moYglJKSnNOBIhGaQ6WzRF4cL3T9xkZwrvtweCkxeJPl0 522oCIUduQ3LD1AcIxfsUvPk324EcjaiE/vq2owfACOFNyXXdQoMZWmyeXbPTUMpXn7v WWjUWSXMx2zJkHxb9KOaO8MNPIdNYHuHaeHXDuzpyLNRmx8jlcUZnA+8TVrCpQESmD51 EHJX4KOAfTyEXuNXn0fW6u0xnMygvWUpnVaa/QIDYTUDoekNiXWDGPCpen5TecvZaU2f J0gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ifXSSH1u; 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 o3si1273603oie.9.2019.12.11.08.09.05; Wed, 11 Dec 2019 08:09:17 -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=ifXSSH1u; 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 S2387829AbfLKQGy (ORCPT + 99 others); Wed, 11 Dec 2019 11:06:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:34372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731083AbfLKPMe (ORCPT ); Wed, 11 Dec 2019 10:12:34 -0500 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 9BC8E208C3; Wed, 11 Dec 2019 15:12:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576077153; bh=b9/T+4wPcyLPyVncmvBzEbAy3vXyz2XW65TL7H7amlY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ifXSSH1uvM8a0lpEZ+3s0vs/gwbyCz6cZRykY+E88TsLuPRTnAKmj7vOdbC07fA8e at0lNlnC+uHJfwgEwQZp8aS676uIfkY12Iyq23KhjJvRn8eS4RgTnOGGetnGYXcsEI PdIm2OYxA0xUQzypYssqBsfvmuR2vOjHYwZ3j3Mc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeffrey Hugo , Bjorn Andersson , Andy Gross Subject: [PATCH 5.3 009/105] tty: serial: msm_serial: Fix flow control Date: Wed, 11 Dec 2019 16:04:58 +0100 Message-Id: <20191211150223.451692465@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191211150221.153659747@linuxfoundation.org> References: <20191211150221.153659747@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Jeffrey Hugo commit b027ce258369cbfa88401a691c23dad01deb9f9b upstream. hci_qca interfaces to the wcn3990 via a uart_dm on the msm8998 mtp and Lenovo Miix 630 laptop. As part of initializing the wcn3990, hci_qca disables flow, configures the uart baudrate, and then reenables flow - at which point an event is expected to be received over the uart from the wcn3990. It is observed that this event comes after the baudrate change but before hci_qca re-enables flow. This is unexpected, and is a result of msm_reset() being broken. According to the uart_dm hardware documentation, it is recommended that automatic hardware flow control be enabled by setting RX_RDY_CTL. Auto hw flow control will manage RFR based on the configured watermark. When there is space to receive data, the hw will assert RFR. When the watermark is hit, the hw will de-assert RFR. The hardware documentation indicates that RFR can me manually managed via CR when RX_RDY_CTL is not set. SET_RFR asserts RFR, and RESET_RFR de-asserts RFR. msm_reset() is broken because after resetting the hardware, it unconditionally asserts RFR via SET_RFR. This enables flow regardless of the current configuration, and would undo a previous flow disable operation. It should instead de-assert RFR via RESET_RFR to block flow until the hardware is reconfigured. msm_serial should rely on the client to specify that flow should be enabled, either via mctrl() or the termios structure, and only assert RFR in response to those triggers. Fixes: 04896a77a97b ("msm_serial: serial driver for MSM7K onboard serial peripheral.") Signed-off-by: Jeffrey Hugo Reviewed-by: Bjorn Andersson Cc: stable Reviewed-by: Andy Gross Link: https://lore.kernel.org/r/20191021154616.25457-1-jeffrey.l.hugo@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/msm_serial.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/tty/serial/msm_serial.c +++ b/drivers/tty/serial/msm_serial.c @@ -980,6 +980,7 @@ static unsigned int msm_get_mctrl(struct static void msm_reset(struct uart_port *port) { struct msm_port *msm_port = UART_TO_MSM(port); + unsigned int mr; /* reset everything */ msm_write(port, UART_CR_CMD_RESET_RX, UART_CR); @@ -987,7 +988,10 @@ static void msm_reset(struct uart_port * msm_write(port, UART_CR_CMD_RESET_ERR, UART_CR); msm_write(port, UART_CR_CMD_RESET_BREAK_INT, UART_CR); msm_write(port, UART_CR_CMD_RESET_CTS, UART_CR); - msm_write(port, UART_CR_CMD_SET_RFR, UART_CR); + msm_write(port, UART_CR_CMD_RESET_RFR, UART_CR); + mr = msm_read(port, UART_MR1); + mr &= ~UART_MR1_RX_RDY_CTL; + msm_write(port, mr, UART_MR1); /* Disable DM modes */ if (msm_port->is_uartdm)