Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp612704img; Fri, 22 Mar 2019 05:09:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwuHUUOfUOtfFu7XgO0HRR5I7+GN45QI+jvZX4Q8ujQ8xQstODRHAKnVoDu3zNaPA+j5HzA X-Received: by 2002:a65:41ca:: with SMTP id b10mr8618445pgq.146.1553256575117; Fri, 22 Mar 2019 05:09:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553256575; cv=none; d=google.com; s=arc-20160816; b=rHnPwvh+ltxQTQETQJfFhkBu1gMLRWM+kmSwXDCNinrO/HJvV2F88XXY0BY/ZmZhCg aeoa0Mbty61gTdJd3C5ZfsMWkDscz0V23EzxwOdZ1gm9cfDDFUwY0q/zSifnttw4BT7R hGGsEIx/KL1XGM2rjDTyPwFE8lUEH5zQ8lEU5YBUisMr5R0+pZ1MZ7GXaQVsz5gfJYu0 TPFp3Vil0H5bJHetz2iZ3aBbom45bETQqcRE9dG5XoY7huG8izSZ0CXRAEIxu3krxkt2 4gHJKkxW3vDSpmh+9t8RT+wkW5vZ/8825AR4LP7DNRNsRXUgWkH1aVQTvLeL/Wa2wx8E e1fQ== 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=MDxO8IaKJE3iwxDrOu8REHbfcIIf9mD51UC8Uuant7M=; b=R7zoLdOcXbwsvxP93TdT/vejk+XGj8EXAIMS9Bcyc+8fgtNP+on/y2YRIyLl5dkZ+F HgwbjCK0C115jKYyu0gzLRRg6pf6abVfcW8w+vJfK/HsBlkkAipdhYdezx46bdvgijBR /HwNbDxZHbSKnWpnJ6lCdIqxpc7ihMfrxCCrBfTUReT+AbZr1FSBTOSmz2qDwaVxG7iC TqF31G7t5asoi7bdNwWBK36F5u/SMhkqkhT6uLH9bNDh4kbWJ2O5fXHO44RCMTuifcO8 IoebiybjsCLkqvNROX/vzNVHUzAQ8jRXGQrBuIe5seqv7XpTbcoMJIP4QDqe0Ev1tXVP Sfxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cBnJR4pH; 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 w9si6996744pll.389.2019.03.22.05.09.20; Fri, 22 Mar 2019 05:09:35 -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=cBnJR4pH; 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 S2388793AbfCVMIl (ORCPT + 99 others); Fri, 22 Mar 2019 08:08:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:47042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388314AbfCVMIj (ORCPT ); Fri, 22 Mar 2019 08:08:39 -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 5E68821916; Fri, 22 Mar 2019 12:08:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553256518; bh=AQqpYqdxLMQw/vqH56cUslHi8pQ+V6BoMJLbFPlFIQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cBnJR4pHbPd7WNE/Maz0wWzBy8Xbo1ukgUEQRM4rtCMfMPmExbnA+nQHPRGHUz3Nt 8J/shouiyXiQMDrJC61Hr6/v58G2/vr2XESa+ridUeM5LTj3j9SB0MFmXt8aIQ72nZ LkxQ7oCI+Qd4thplBsJSyctaa7VkuAxe8Jv6Ii+8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anssi Hannula Subject: [PATCH 4.19 213/280] serial: uartps: Fix stuck ISR if RX disabled with non-empty FIFO Date: Fri, 22 Mar 2019 12:16:06 +0100 Message-Id: <20190322111333.329917441@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111306.356185024@linuxfoundation.org> References: <20190322111306.356185024@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Anssi Hannula commit 7abab1605139bc41442864c18f9573440f7ca105 upstream. If RX is disabled while there are still unprocessed bytes in RX FIFO, cdns_uart_handle_rx() called from interrupt handler will get stuck in the receive loop as read bytes will not get removed from the RX FIFO and CDNS_UART_SR_RXEMPTY bit will never get set. Avoid the stuck handler by checking first if RX is disabled. port->lock protects against race with RX-disabling functions. This HW behavior was mentioned by Nathan Rossi in 43e98facc4a3 ("tty: xuartps: Fix RX hang, and TX corruption in termios call") which fixed a similar issue in cdns_uart_set_termios(). The behavior can also be easily verified by e.g. setting CDNS_UART_CR_RX_DIS at the beginning of cdns_uart_handle_rx() - the following loop will then get stuck. Resetting the FIFO using RXRST would not set RXEMPTY either so simply issuing a reset after RX-disable would not work. I observe this frequently on a ZynqMP board during heavy RX load at 1M baudrate when the reader process exits and thus RX gets disabled. Fixes: 61ec9016988f ("tty/serial: add support for Xilinx PS UART") Signed-off-by: Anssi Hannula Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/xilinx_uartps.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -362,7 +362,13 @@ static irqreturn_t cdns_uart_isr(int irq cdns_uart_handle_tx(dev_id); isrstatus &= ~CDNS_UART_IXR_TXEMPTY; } - if (isrstatus & CDNS_UART_IXR_RXMASK) + + /* + * Skip RX processing if RX is disabled as RXEMPTY will never be set + * as read bytes will not be removed from the FIFO. + */ + if (isrstatus & CDNS_UART_IXR_RXMASK && + !(readl(port->membase + CDNS_UART_CR) & CDNS_UART_CR_RX_DIS)) cdns_uart_handle_rx(dev_id, isrstatus); spin_unlock(&port->lock);