From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6429CC76186 for ; Mon, 29 Jul 2019 19:37:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2F4B12054F for ; Mon, 29 Jul 2019 19:37:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429024; bh=60McAhv8Kg4CbgA2H2vIEpXVsWmyswfPhAqeofhlX3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=mnm8SnzLsfY84ApmKHxcRdB3uFL0LDugTLvF7RRwCvnlVppcHu8Ha+oRnOPJRgVGD 6OhjA47xL8TbEmtkbLSRwQlahBJejD5l7M2h0VxesOwKoRNLMdg692bOxAdQUMfQrF xGwynCt2pNxFGOZa2uiySE224lDaYL7kIe7uF1vQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727594AbfG2ThD (ORCPT ); Mon, 29 Jul 2019 15:37:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:51450 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388459AbfG2Tg5 (ORCPT ); Mon, 29 Jul 2019 15:36:57 -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 00A90217D7; Mon, 29 Jul 2019 19:36:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429016; bh=60McAhv8Kg4CbgA2H2vIEpXVsWmyswfPhAqeofhlX3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dXyQk5roqyyg2TPqnZbnC6yB544l+MiaUixNCLYevETVd0EvUB4VkTbpB+WPYxOlQ tE3pUEeek4MIImTupT8jV6Ofx7/Q8e9GZTbPPtNua+KdbQOXbMA1PxDzqoBkgQBXKU tK2GqZ9fy4pgFtyz3WTQzQEayHCRBFhtmV6x/kOA= 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 4.14 257/293] serial: sh-sci: Terminate TX DMA during buffer flushing Date: Mon, 29 Jul 2019 21:22:28 +0200 Message-Id: <20190729190844.117512130@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 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 66c8bbea06c4..dc0b36ab999a 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1571,11 +1571,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