Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3756517pxk; Tue, 29 Sep 2020 05:38:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjpC/9cqNnixqARE3WmiYD9zSkhR58MOC50jbexsWqiTFUDjVE1jioQVChBElyYS1+IURk X-Received: by 2002:aa7:d382:: with SMTP id x2mr3046192edq.108.1601383086163; Tue, 29 Sep 2020 05:38:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601383086; cv=none; d=google.com; s=arc-20160816; b=rCrKuINu0XWTYnQnc6tSUcGAScRVXmbpraWKSasxt6zLGDi+LmFBgKLCfLyE69qEcw 5fEzy+ZSWFJ9gCGt37p/hlgchpxONLGarkP7tYGKm8xwZPE2O18NbvAu5n6ja1OrC/V5 iHfK2vv5i6/tGFmsa1q/BdhouzJA81c6DESAmW2ICk4LRsigX+IX+E39IJSgc5XM2iLv ivKfj3+ChPHF+GZWo7CpxR2cjpwqxvFblFKe7GpPXmEtft0MtnlgOKj81KKedHvYuEU1 3wCC2FBDwPaFArp/HHkn5LLMG4fet3CbujMDVjlzeSKZ74QJS8dZp71+/ylIybfIrTUl Qc7w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2qz5kMiRGt/h0uGobPIavPbmBVMZCYihM74F9yHv+f4=; b=iGhwC4fzOGK5TVHxbpR9gcXBA86PPZIq/TOlDpeBIo4T4ZiFomv3y/eyOzy0SUv+vm qtYoZ3EjE8AZhzge5lxTRx/Lnc2Cem1jKsUVm4J5nw8Kd3ZJEX758JCuhp3Mz+3PyTNt ixccDtdNHbpl0LNB1fOdNhWm8W67K2QoogoborjMnMvJCPkKApP/t+NOB69/Dr7A0Irw aS/o9sX+7aK9IWhHTsKPpAFXVYYzfTiD7a2W6CJTzc5rGiyn1O0f5rpEaGii5rUMvfwa KoBIMIieWWDunMj8Ni+h+VAV0cpflT5wAcx0Zzs9Q5KeHZHXMZsLGG+rY44xyyQrNku2 CWPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=w2clj4Si; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a20si3349934edj.252.2020.09.29.05.37.42; Tue, 29 Sep 2020 05:38:06 -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=w2clj4Si; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729478AbgI2LW4 (ORCPT + 99 others); Tue, 29 Sep 2020 07:22:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:34428 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729634AbgI2LRf (ORCPT ); Tue, 29 Sep 2020 07:17:35 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 0B8F9206DB; Tue, 29 Sep 2020 11:17:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601378254; bh=u0gIlx+26lPy9i8hc8Z2XqPWMlpcGLOnbaDcSsjvkrE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w2clj4SizrnxKoqqKE2Ck0PY7IysA3ll2ejXvEE83RrwH5u/HhP6j+5EPGhv0rvyB 4vSgbBn0dzTugWE3woXbXSbXrAjZJGjoykuSjfFVf7U1RRp1BpvZwdDEv+KiIvHuJp kyGdabqOhyvCuFjPvE2JUboT/V6Wkk4ZTVpEZA70= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vignesh Raghavendra , Sasha Levin Subject: [PATCH 4.14 088/166] serial: 8250: 8250_omap: Terminate DMA before pushing data on RX timeout Date: Tue, 29 Sep 2020 13:00:00 +0200 Message-Id: <20200929105939.608685288@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929105935.184737111@linuxfoundation.org> References: <20200929105935.184737111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 33df33a9e646a..726852ebef855 100644 --- a/drivers/tty/serial/8250/8250_omap.c +++ b/drivers/tty/serial/8250/8250_omap.c @@ -773,7 +773,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; @@ -833,7 +836,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