Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4108021ybi; Mon, 29 Jul 2019 19:25:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxd6g3jn3zTfa74sh2GJ8Q4ZQtLKUhzDr9mqndSJwDsMtd4HU9iQ2x3T/DXRUVVD1nriWTv X-Received: by 2002:a17:902:654f:: with SMTP id d15mr106182725pln.253.1564453552798; Mon, 29 Jul 2019 19:25:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564453552; cv=none; d=google.com; s=arc-20160816; b=Hgal1eU8AWKJYyF6cN529gUagR+1bXsufaIibZjlY0Egu5TuLxjJ8pT6XkDA0n6HDV 5i66PvsKUeZtkr06lz8ySN6au7bqEDeD17WNeXvuWD+Dkyqx2m0NJ08DSqfR9/vCeVj6 QuDA9ywjwPuSIiVrQgPzXaXoi6HE8szDwmiL3M1297f8THZc7aTvk6tt4Oo4hXmodBSJ WUDj2caEn0QGZT5yZLlIllpbkMs6y02ZHgHGjFRYDJc2rpcmeZGrCtVseiGoFJfn2yMq 38TMviLeVsCaM0xkkmcp79eSNTZlgPusYHQlFhd6ZCYVdDtQoJyztoKBVs+sCewcLnmS NP3g== 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=izN6TFMM6DK5cJvwwpzkfO83Y4B3IhCdGm40S/xU54o=; b=dlU7iAnbsyplzEk7czBxYMcwieFq8VacvOaQNsH7dHgnhzw7CWDzEblS6Ke1Bn5RHy tcrX72fxsOVeUTzBKq3zo+61XceFx002lCCsqEixWxhmm3MEN4wWxnQzf1NbjZXjstcW Wq78myv7kINMF+FbhhgpUZhptMLlsg3X1d91ai7NqL1QyvO4E/BVPThl6GWz/i48WNB3 j7bcj+wSI/0aawmR4ASpd+VgDJ/wGfAIkzn/P6jfGit5NGp8xa3iDspzfV0oZfoLrcWO MUAogQ7hNM14DiNNq1BvF0E/GZqjzrP/zkgRrvfBxoXOeOPXlGMvtk4ddQZcglWG0wOK /U4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=up7FV0me; 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 l63si27781455pge.264.2019.07.29.19.25.37; Mon, 29 Jul 2019 19:25:52 -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=up7FV0me; 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 S2389415AbfG2Tlt (ORCPT + 99 others); Mon, 29 Jul 2019 15:41:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:57350 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388871AbfG2Tls (ORCPT ); Mon, 29 Jul 2019 15:41:48 -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 D71002054F; Mon, 29 Jul 2019 19:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429307; bh=Ui8DeQETYyUnZJcoGyKgdLlTuU6tjrgcZVP1NDiSPco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=up7FV0meLZuLo7RG2ibpoCSYSKjsgrEsdYEIytP598Y8Di0ih8/hV9+K0FoBR3d8t TOxzgsw8t2flnWrr7sEdsw9vd5Q8bYLxE8frL9YoqORn021/R9MO29gUySnkkJXHGJ OuVwDNjypcbKTbboupQSDoZ0x4ZNPbKQKDhn1ffw= 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.19 056/113] serial: sh-sci: Terminate TX DMA during buffer flushing Date: Mon, 29 Jul 2019 21:22:23 +0200 Message-Id: <20190729190708.903184110@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190655.455345569@linuxfoundation.org> References: <20190729190655.455345569@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 040832635a64..71f12601e693 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1633,11 +1633,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