Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3790258ybi; Mon, 29 Jul 2019 12:40:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqGLSmeUJW8tSUh0v6Iditt//3r+UwkbkaGDDU+9FO1LhPtEVx0xH9cgC7RH2W1iHoTgnL X-Received: by 2002:a62:1ccd:: with SMTP id c196mr38533398pfc.102.1564429232390; Mon, 29 Jul 2019 12:40:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429232; cv=none; d=google.com; s=arc-20160816; b=Qe/cnwZA1e6qY0vGOvMORFF1Ur2Uuan5LlkU7AWyUL8dZsvktNLquNZZa/n5YYxO4G q2Bis+ufxf9wrP19wt5RPGewVdUQJYLkHjQpw8BTC728sCaVJZVQCdfQv18oqA0j3RQ+ AzfuJAZpkFRBlIeCkjcRYXbgQmPXKVJ+nN2NN83fo8Pv0DZCt0dHfuyOuSUzjKLyQ3Ht 7H3+MdIiBJINGZH8qeCpHrUoXpbykhU3ROB/9CwJ0YHsr6rNtEPKmuDpOhzWa1JUjXWf d4uxoPzYdC+nQTW9cuWqSu98K6+2Pl/+JEiGILRDCeyzHvjm5I+mQNjRuQ9ThIhUZdsg U/ig== 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=eT3a+6hZxA24lZqTcU54rfT+DyqGhFQF8E0K1dyb17o=; b=oRvPdEEKdwbYTYFIi+6LiL178LLN+sIkROdaW416TOEqP6ve/40b0V3uD8Rn5SYa7d Cc1STK8tuHzfKZp/k2z2y9Th70WuWUa0vVlcf5gzphwN6h4T0b24T1BRAGtWSnraDbKt QoXCsoEidDitpqks/BwoieuR1jHwIw3XRpiav8oEudqZfPWizR5t8jj8NTm+hxAlwLwA ZeI15TZgMT/u87vO1ZFPRoVoCmWYj+EV6JDR8PRLqHXJJ3+cBo1Dh3uTjLqcgNs57y7c 4CfaX9v76sr9PgB1LdnnKwSkrzcnCqi6bbBHlmdnZ52eNuegk/fHF0J2e3e9heUJB8rn nJWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EN1wyJCb; 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 u18si24536579plq.311.2019.07.29.12.40.17; Mon, 29 Jul 2019 12:40:32 -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=@kernel.org header.s=default header.b=EN1wyJCb; 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 S2388779AbfG2Thr (ORCPT + 99 others); Mon, 29 Jul 2019 15:37:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:52638 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388750AbfG2Thq (ORCPT ); Mon, 29 Jul 2019 15:37:46 -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 2615020C01; Mon, 29 Jul 2019 19:37:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429065; bh=bDfhRMuXP5B3GwHpV1Bk3DWSkybPAdwcpwijME229TQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EN1wyJCbiBJF0S9Noh0wOBDi+6nTgxYZ4yrF6dyKgzwZWSRgDIX01HDqIXmu91CIN cXnIfebgNUE+bg1ow+q73VOKdD2DLsr4+4R6eWPDXcuNXc8BNDwQZLnVASMuOezP0z Z8VDc7+5F5DV9rM5mecGeFm5NKmSVy/49eong5xQ= 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.14 235/293] serial: 8250: Fix TX interrupt handling condition Date: Mon, 29 Jul 2019 21:22:06 +0200 Message-Id: <20190729190842.470737156@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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 ab0796d14ac1..a73d2bc4b685 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -1878,7 +1878,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