From mboxrd@z Thu Jan 1 00:00:00 1970 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=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 04DD8C76186 for ; Mon, 29 Jul 2019 19:40:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C545B21773 for ; Mon, 29 Jul 2019 19:40:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429212; bh=w1ZoQS4VWdOENadtlvaDwrnQwkMIUhSybf3HlpTUJkk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=OpRFVbnTAk2M2it+ZhP6NJHsyfjY/pSpB5H0etsFnhHCeAj241YCFmKkbdkbr4Dap sy4HGlt3VObK2JQ7iwTiK9WrXxOpBi5Gtnufd9BEHEY8mJL8ScO5XEgRqsrlwKXp1b 5RCZlWGdFzVxWi0um9BNlgkyKdixUUx4VxwNZCjU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389119AbfG2TkL (ORCPT ); Mon, 29 Jul 2019 15:40:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:55420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389108AbfG2TkI (ORCPT ); Mon, 29 Jul 2019 15:40:08 -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 9DE242054F; Mon, 29 Jul 2019 19:40:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429208; bh=w1ZoQS4VWdOENadtlvaDwrnQwkMIUhSybf3HlpTUJkk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UnohOnWIMcgKq4FmCyeuswEvtOWEnrWPXnsX4f5FAmUFpdU6YDUWi8gh78iVFGjM2 PcpKT1hWqvlQCpJzBQP7QlYOupXxKi94G3fgxdxY+T8t9Z4fhyi9iGuLdjZzyB5yjs IGQHffRhqJU843pzdiy+bnlouGJCA2jlFbbxiSaU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kimmo Rautkoski , Sasha Levin Subject: [PATCH 4.19 025/113] serial: 8250: Fix TX interrupt handling condition Date: Mon, 29 Jul 2019 21:21:52 +0200 Message-Id: <20190729190701.894601031@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190655.455345569@linuxfoundation.org> References: <20190729190655.455345569@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 [ Upstream commit db1b5bc047b3cadaedab3826bba82c3d9e023c4b ] Interrupt handler checked THRE bit (transmitter holding register empty) in LSR to detect if TX fifo is empty. In case when there is only receive interrupts the TX handling got called because THRE bit in LSR is set when there is no transmission (FIFO empty). TX handling caused TX stop, which in RS-485 half-duplex mode actually resets receiver FIFO. This is not desired during reception because of possible data loss. The fix is to check if THRI is set in IER in addition of the TX fifo status. THRI in IER is set when TX is started and cleared when TX is stopped. This ensures that TX handling is only called when there is really transmission on going and an interrupt for THRE and not when there are only RX interrupts. Signed-off-by: Kimmo Rautkoski Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/8250/8250_port.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index e26d87b6ffc5..aa4de6907f77 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -1874,7 +1874,8 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) status = serial8250_rx_chars(up, status); } serial8250_modem_status(up); - if ((!up->dma || up->dma->tx_err) && (status & UART_LSR_THRE)) + if ((!up->dma || up->dma->tx_err) && (status & UART_LSR_THRE) && + (up->ier & UART_IER_THRI)) serial8250_tx_chars(up); spin_unlock_irqrestore(&port->lock, flags); -- 2.20.1