Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3800430ybi; Mon, 29 Jul 2019 12:53:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6veGARhGWuVw8DckORKi+BY7XAY5NXDQ42ok24E+fPqtWmXdQ+BSMjFfTCYuW0T5B+pEF X-Received: by 2002:a17:90a:d58c:: with SMTP id v12mr111728306pju.7.1564430000476; Mon, 29 Jul 2019 12:53:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564430000; cv=none; d=google.com; s=arc-20160816; b=HnEGsHJxOI2fERBOSUpwsoY7rOvNfM1cryoxWOW6jXhC7tMQ9UMeT11cY3bv16tdZd xrZcJgn3FtrF2i749wejqMkw1xtWkLM1WtUv/EaRIdTYrBp8tWdsAfGyGsOImo6txiWo EtLJ4CaQ2BsRRMo0Miw2zrl5RajGO5/FVNn/TPHOopf21BKqrbmqapiuNIwfTudVLGFF IkannqTTQNQpGA4n1ayGpFMGcYaxVMtwJNcrsSkSBIXSDy+2bJI24H9aXa8ujpkja43n GAewX9xAan2ITG+7tlTorWgczaEiryMcC7sFGlCqquu3Po4lnsmmJKunZUzlGzqGfls1 t47w== 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=Px7up0dSmBry+hA6LvxXu87lm4Mm6/Rif2Bvb48LT64=; b=a6iZ9gmAJlrXxGlM7ncdcypVVojCYZSDXSrRfnJpQXlSZ1JSHrBg04tj3SzZqUsprm rPz+xJ3/2NNIeZ+Sf5obxL1NtgtzSXev3rP/qO8qx7gY9aFOH8170P+5yB1ECaaXwfYE Z4XJ6qxrPB5YxIucRAAvARhu8zLhQWNBjH7lgPWnW4pM6Q8Yzm3ddcNHEBwGVOX+I/F1 WsCup366bUXT+GCLalXo+GIzzmdq4Np4/U+qpiLxubRD5ke2AIG5oteNhXk+mRqcA3Om VNfjwz2V1eLqmuJH0g254Nt10/R+IIRtTWoIAU6FZlRX3L9PVvin8sLGq3LA4Z7m6UCC zydQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WqbRxA8n; 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 g127si18160182pgc.128.2019.07.29.12.53.04; Mon, 29 Jul 2019 12:53:20 -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=WqbRxA8n; 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 S2403789AbfG2Tua (ORCPT + 99 others); Mon, 29 Jul 2019 15:50:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:41418 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389932AbfG2Tu1 (ORCPT ); Mon, 29 Jul 2019 15:50:27 -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 AC28F205F4; Mon, 29 Jul 2019 19:50:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429827; bh=TBtsDAYMGhKlZN8o03Cd0shvIVqlR+qnP83xIDMBDiY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WqbRxA8nORfzYPwDsa2dar6pSlLAWreuBLkz0OgRdkUFqKy5JnA/b8//yzX2/KUQO UT+IcX8zMPulDcSl9THyzcTu5pSroF3CWpWYgvrHqzZvebRQRg7NR2lOKobBdlp7yg R7pwynq6OS9mXUIQErlGEKGJYJBgG/wMubI15PnE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geert Uytterhoeven , Eugeniu Rosca , Sasha Levin Subject: [PATCH 5.2 107/215] serial: sh-sci: Terminate TX DMA during buffer flushing Date: Mon, 29 Jul 2019 21:21:43 +0200 Message-Id: <20190729190757.481787934@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@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 775b7ffd7d6d5db320d99b0a485c51e04dfcf9f1 ] While the .flush_buffer() callback clears sci_port.tx_dma_len since commit 1cf4a7efdc71cab8 ("serial: sh-sci: Fix race condition causing garbage during shutdown"), it does not terminate a transmit DMA operation that may be in progress. Fix this by terminating any pending DMA operations, and resetting the corresponding cookie. Signed-off-by: Geert Uytterhoeven Reviewed-by: Eugeniu Rosca Tested-by: Eugeniu Rosca Link: https://lore.kernel.org/r/20190624123540.20629-3-geert+renesas@glider.be Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/sh-sci.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index abc705716aa0..1d25c4e2d0d2 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1648,11 +1648,18 @@ static void sci_free_dma(struct uart_port *port) static void sci_flush_buffer(struct uart_port *port) { + struct sci_port *s = to_sci_port(port); + /* * In uart_flush_buffer(), the xmit circular buffer has just been - * cleared, so we have to reset tx_dma_len accordingly. + * cleared, so we have to reset tx_dma_len accordingly, and stop any + * pending transfers */ - to_sci_port(port)->tx_dma_len = 0; + s->tx_dma_len = 0; + if (s->chan_tx) { + dmaengine_terminate_async(s->chan_tx); + s->cookie_tx = -EINVAL; + } } #else /* !CONFIG_SERIAL_SH_SCI_DMA */ static inline void sci_request_dma(struct uart_port *port) -- 2.20.1