From patchwork Mon Oct 30 13:03:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 10032517 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 88F7660291 for ; Mon, 30 Oct 2017 13:05:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7131227F8E for ; Mon, 30 Oct 2017 13:05:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6074B28884; Mon, 30 Oct 2017 13:05:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1F12327F8E for ; Mon, 30 Oct 2017 13:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=8wX6Y6BgfWhrcxkkyWL5nO4YJxnbmV4Ui98sqeKtZ40=; b=cV3 IXiuqWrcks0gcx3qWC68Pr5X5nSQS1a3Wg+O0rMftyQLMfT3rVPoRgZ1Vcp0HS5TplzsKnkz9H6fQ ExFy1CIYsSQykX6//3SMPtXZH0eu9D5A2UvENTHW9xuBfHSH5muNMI5CA3oeuvuFMASjARRmJVesc gXWKB7aAsfMAuSAm4CdyDIEOoVq3NZwsXEwmf3n0qYJU63j8fiYJALnjBApsQozpmyclPHmHk7rPn RLQP1vYHLHyTS7+FdfwM/wMAnz1AKGcHYqKJa+K2pGgUgA9lFfuzzz+1Lwh2O5KAWC5wkc/preruQ 8Ojta2Pn7SL1J/L8NtpIrZh83Epeq3g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e99l6-0005VV-T3; Mon, 30 Oct 2017 13:05:41 +0000 Received: from mout.kundenserver.de ([217.72.192.73]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e99l1-0004dh-7W for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2017 13:05:37 +0000 Received: from localhost.localdomain ([95.90.209.135]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.183]) with ESMTPSA (Nemesis) id 0LpwXf-1dTn2l28Mp-00fhIa; Mon, 30 Oct 2017 14:04:00 +0100 From: Stefan Wahren To: Russell King , Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH] tty: amba-pl011: Report AUTOCTS capability to framework Date: Mon, 30 Oct 2017 14:03:06 +0100 Message-Id: <1509368586-26662-1-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 2.7.4 X-Provags-ID: V03:K0:jdpnbdFRehgcRGia7i1ZjVTGNKu/ql91NQTDs4NRFAH1brJgCra JqlZhYLk06V2Xyap61jHp88ict9eW3IZB9wY6N+sh8vRpmGzqhXKpXrVo+fz30GSYK90Mch rZpkj5KSQZIbrbFYU3kQ7j9yeYGngFJw9imwEU/rqITJHkE7ZNdAQEp/e0pJJMRaZJVVoFZ XatrKAooe8+2v5BB0pY7g== X-UI-Out-Filterresults: notjunk:1; V01:K0:Dku74enuj2w=:LaJJ/An8GPsNxygR1bNsgz VFeLurp94Vavr2kDHBVtCaJZNjH4MYltUg+ZUgVL+ML1mC2HOT/wTQeRy6JZimuJZfeUmb/Ns oFy5uKLCFCDkT6AYqjJPc7KhKdOUlh15eGSEYiWQGj+CPhwdbBnPpiRKDtb+toQZzyuXa4JcU gKd6JE7foNLIqSd+4iEr5fA3wfUF5EJCEQ0TfX09Yu11v9xlcc8Lbn/aHEhezVHIXCJnG1Ni7 avYSv9VwC0brAPx1DuBA60J/YQ40T+wVNntxE8KLUZWQcj3nnF6iVpgPXSbJE0vAaxGLSNack q3XYcnaD9soa5f+sD6HKgbJ06fepUs4BSMI89phf3OhdjJBphlq8w7d/3RDGFyFiR/buzah/j gp4Y0ejdz/4gvonBo0ZPLt7+efkeZt7LMdAZGGx9E7PY9BmauihBnMs5IAYS+4XsL9Jd9s8Nv XCU/Egj7GlWm3pARcRXy2q8UX1sfQ5gNh9OSP6CMHRBmlX0/qSXLNGF8U2FujJJTljr8EukgM lJ1ZmPXiRCiUy9PvNzBc3pUU5F3e2h9QUoJLEwyeB9Qy2DEUhHajo8MNBJnPJ1I/qa6K73Icw wvmwXb8x+lPIDAv2EClv3EifoLH7xAOoNpggHvP/cAivy+ONSQQnUswgNYr5h29Zl2GvXPgN5 YW5lDtJSdCyUDir9A69TuG2gV07ZgOd0WKItlTeuQa6uSqeF4Yza+cXtiZIHP5fbta+xyPYPc bgTCcqH5mv0eGMGNbi3HY8gPpf4VdRF86mMqwA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171030_060535_732300_DD06F869 X-CRM114-Status: GOOD ( 10.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: loic.poulain@gmail.com, Stefan Wahren , Phil Elwell , linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Phil Elwell The PL011 has full hardware RTS/CTS support which is enabled by the driver when flow control is requested. However, it doesn't notify the UART framework of the fact, causing the software CTS support to be enabled at the same time. Software CTS triggers the sending of another batch of characters when CTS becomes asserted. The pl011 interrupt handler processes the CTIS bit before TXIS, which can cause some characters to be sent between the time that the TXIS bit first becomes asserted and the time it is handled by a call to px011_tx_chars. This would be fine were it not for the optimisation in pl011_tx_char that assumes the FIFO is half-empty if called from the interrupt handler and skips the checking of the FIFO status register before sending each character, leading to data loss if the FIFO is more than half-full. Prevent the data loss and improve efficiency by indicating the AUTOCTS support. Signed-off-by: Phil Elwell Signed-off-by: Stefan Wahren --- drivers/tty/serial/amba-pl011.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 111e6a9..00019b8 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -2029,9 +2029,11 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios, old_cr |= UART011_CR_CTSEN; uap->autorts = true; + port->status |= UPSTAT_AUTOCTS; } else { old_cr &= ~(UART011_CR_CTSEN | UART011_CR_RTSEN); uap->autorts = false; + port->status &= ~UPSTAT_AUTOCTS; } if (uap->vendor->oversampling) {