Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3131097ybi; Thu, 18 Jul 2019 21:38:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqyzj2rDo2K85V8tdaHof3h0xNB3k4ECkFOzIXK9yc+ztzX7InPkQQybfoS2T6mtvNDTedTc X-Received: by 2002:a63:e54:: with SMTP id 20mr50729972pgo.244.1563511090717; Thu, 18 Jul 2019 21:38:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563511090; cv=none; d=google.com; s=arc-20160816; b=k+vtbne/Ht4o/x2s3hwhU85Qet50t1guVKcfVNX7951LquGFVQaCDYYj7T0ytgGPA/ 7Z14tVaeIEenIIeD1TBurqPZY2cyqIHQzsTIUra1hxZsiZBzjFvL9DUxIJqAua8tucfl wgNwppSs77CJ/oLTUBwyiUXZCIjtz3JaLxdXrddJq7KaMqd71wJYYxtRZ79St+DjBF09 d1h6jCzGTyM0Lgnj1ZnAo+v85Rp7g+8PlGPHox9SB/6UUJqsUurP8/ofbmwY/z+mr3yb qGli5VSi7Q06zo8ImQeUXVM21e+WD25Zo86QI5tTakuPYl4JL74JoQ0Tf8daQZ+viEKl XFRw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=70iUtad02NTMmuRmk5Sg6s72KSycjqvs/vECVxvYjps=; b=UIFOXjV4jspe+uOhSJuzsYZH6tKP0qVKTOAX3hT6lrRFMh5ApEZsKiBtLB4i2/Qde3 OFAYi2O54koKHR18jHcXR/D75bIs5fIOiksRrqDHWAnhMGYauK4raQnM6BNx09oo6hZN jOJBJRdhX54WAb51/k9SnIXoe0i7b6vX0zrqxUS/w+eQLgM3NjrCn5zV6N2RrmYmsF5i /mauCrzCSdfcEmz6vdz885RPXKcS7hvylsUJG88reGrF2neSdmqjmWE1kUfh4U1WC9sS RhWXjR0JitdCns1QyXGXX3rzBtRXXLVtwwwh9+6e7TA5ad0QoIOu4jZ430HvQE6XYDL5 0UiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qzJ5t31w; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10si705426pla.135.2019.07.18.21.37.55; Thu, 18 Jul 2019 21:38:10 -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=qzJ5t31w; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731386AbfGSEhA (ORCPT + 99 others); Fri, 19 Jul 2019 00:37:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:60266 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728191AbfGSEAX (ORCPT ); Fri, 19 Jul 2019 00:00:23 -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 5DD70218B8; Fri, 19 Jul 2019 04:00:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508823; bh=XRfZBIvwwvJEotxUX79ZQHqiqmY7KdKnFRGsQhI4u9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qzJ5t31wSuOhes6pIgro4a1THCj/BBMYOrQEB9Pd1QR5O1tPefzc1pfo+/uh+nfVH 8QIBYFynMV27vDf35vLWF5Y41rTfGxXIWZduzhUGDllkfLSc1YGVbZvWTGpcruFWGU /nZQGoPqPZtDFLQjvkxjFDZr7UV7F+7pZCA5ljc4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Geert Uytterhoeven , Eugeniu Rosca , Greg Kroah-Hartman , Sasha Levin , linux-serial@vger.kernel.org Subject: [PATCH AUTOSEL 5.2 109/171] serial: sh-sci: Terminate TX DMA during buffer flushing Date: Thu, 18 Jul 2019 23:55:40 -0400 Message-Id: <20190719035643.14300-109-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Geert Uytterhoeven [ 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