Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp877685pxk; Thu, 17 Sep 2020 20:05:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiTcedp2/y6Shz++Vjj5Gjx5C4flfXsfyATdRalwJ8goPEHWy5aVbLvKv6x/tDR9SAue2V X-Received: by 2002:a17:906:4c89:: with SMTP id q9mr35266005eju.290.1600398352257; Thu, 17 Sep 2020 20:05:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398352; cv=none; d=google.com; s=arc-20160816; b=NIGwxdnwI3VLR2FxrYqBereaRK5TXM+OAHUx+VGaP46c/CDeSNDesL6hW3DyLGX1eo Y4E3Co2wJKKFe0tpbew3piEr9DsCdCgimbHKtVyqhFR4BtConMqemoOHqnB71cYmqVHW aZNWmkJiLziIFktw8CNhtIi7IHR/a/XSSCdNvppe/rsyYpqzPKPMR1xFuXDajcuOAjoh dI2C/IllmocFZQSdKF3hpYm4VWoHP0FrQ5CzwlwGWed/b+YgSkmVkgNzviaqa3Wx0ED0 GSZcY87N9A20lr/HOjHvrqclrCqun+nbosooShAv7CSl5msn7CzPaJhoGkzYzGOmwJkf 6bzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=INNuHg673uWubH8uwseinBDX/3qmsV6po4FZaY3CroE=; b=BsWa9jkK7ePrKxiyJDk0RyixPa4JMUEqNxiZ1RNxvvQw+la29nFqWtMQSkYr5t19Et rohARF9NYuACjF5PTl+7sfxwUOGNPhjapX9fvO0a20DToBQy8sBcgV1E4jS3JOtArwLT 9y27iYJQfkKNgyhJmdWgBRKx9//yeePW2mZY1pfXj0ItGm5pO3L6PDqJ0VFlUnpDtaLe Zg2rqsorr0FHuSR701UsKJYOhddDOzyRQwjTM2hXCz2kHjXgz4rdf/9I9N3U3uwGtgYN wr0BLJ/i3PvlZ46nvlB/Ggd5a1QA48c50mBYFAd3ME9sUs+BuobPNFdIF4MzN622gS6T Ws7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gcu7oyvZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d26si1051154edx.497.2020.09.17.20.05.29; Thu, 17 Sep 2020 20:05:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gcu7oyvZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727453AbgIRCFJ (ORCPT + 99 others); Thu, 17 Sep 2020 22:05:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:53094 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727449AbgIRCFH (ORCPT ); Thu, 17 Sep 2020 22:05:07 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B320323718; Fri, 18 Sep 2020 02:05:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394706; bh=JrV5sVkueBazySqufptnzl7LsYTayQ3slafpTrUBHkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gcu7oyvZjKUl9HhBGWcYCu+PF3X0YqIexU37jylZ/0LTrzsRG0xhezr/577JG/aSZ q5yNt1bAjyZQgK81SRwXSqbafeq5Wt7yGiX3c+Bsf9CW/AjrWVt34H9L30QZouzzBb gWsc1n7vGfbJ8SabsHU6lNzZeOWL5KMnwxcjOBRg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Vignesh Raghavendra , Greg Kroah-Hartman , Sasha Levin , linux-serial@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 192/330] serial: 8250: 8250_omap: Terminate DMA before pushing data on RX timeout Date: Thu, 17 Sep 2020 21:58:52 -0400 Message-Id: <20200918020110.2063155-192-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vignesh Raghavendra [ Upstream commit 7cf4df30a98175033e9849f7f16c46e96ba47f41 ] Terminate and flush DMA internal buffers, before pushing RX data to higher layer. Otherwise, this will lead to data corruption, as driver would end up pushing stale buffer data to higher layer while actual data is still stuck inside DMA hardware and has yet not arrived at the memory. While at that, replace deprecated dmaengine_terminate_all() with dmaengine_terminate_async(). Signed-off-by: Vignesh Raghavendra Link: https://lore.kernel.org/r/20200319110344.21348-2-vigneshr@ti.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/8250/8250_omap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c index 2624b5d083366..f2c6d9d3bb28f 100644 --- a/drivers/tty/serial/8250/8250_omap.c +++ b/drivers/tty/serial/8250/8250_omap.c @@ -790,7 +790,10 @@ static void __dma_rx_do_complete(struct uart_8250_port *p) dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state); count = dma->rx_size - state.residue; - + if (count < dma->rx_size) + dmaengine_terminate_async(dma->rxchan); + if (!count) + goto unlock; ret = tty_insert_flip_string(tty_port, dma->rx_buf, count); p->port.icount.rx += ret; @@ -852,7 +855,6 @@ static void omap_8250_rx_dma_flush(struct uart_8250_port *p) spin_unlock_irqrestore(&priv->rx_dma_lock, flags); __dma_rx_do_complete(p); - dmaengine_terminate_all(dma->rxchan); } static int omap_8250_rx_dma(struct uart_8250_port *p) -- 2.25.1