Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3789653ybi; Mon, 29 Jul 2019 12:39:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4r94mFBvK02IeEwkwKP6Q9HIzu4dNTweCi59AVR+A66P11zEtgjsPl6DH/6ot1f4Bz1zG X-Received: by 2002:a63:5860:: with SMTP id i32mr77265130pgm.124.1564429185740; Mon, 29 Jul 2019 12:39:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429185; cv=none; d=google.com; s=arc-20160816; b=VHEHfKl+52OfbWOIAsUzTEe/UR+Cs11f734hq25UvGg0uztkIGvmtOWPzsH6Bu4VYf wBNIPJW+L2tYe0sW+o6SpG1tcoX9oagvq5kHFL7Tmu6Sx1Qt7kyA2dGLXVz5MW7qzc5Z ZLWsqz7sIwMPXaaRNjt4rQ+Td96Vk2624r3Ae3lvqdEhiXtDXm1wGY1nXFyBEzrWz4BE LeZEP9SpgxGbM6vx0ZUBF06QBCLNPGsTXO2qILkRpoHDpgPKE9ctOh3Rd/VmyyOyNPMf dqTilV9fApfEoYXHL+YA8jxkLTfFBkrrZ2jIwMQhydirJMxyzfU2SkmiOzxnHa/iPNFm AIww== 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=QrdVZFWhzS7KSQhxcOMKMbXGM6JrzCPLVGmCFuxhJt8=; b=q3PoqxC8G0VJ4AYwHFUPryp8svYVxhe/pxolVeqea172MVMKcm+tTMAWxYP60KSoWe wsOYBh3QJ6lab/e/WZpdkBkGahKt909+j2UqL9gXVMM112TjAn6iftU0wrMMrpC2pv4X 1paM/8Q/7Osrf67xcz37wm5qx2WDvzrMiKabYeL7+20IKb5RQnrQyqYrXHEw5oG1JYun Ewo07rWrrSh9mpD63ViZJFKevtIxm2+gD5i4OqR57+vFS6PxaPie58ovHcRYayVA/o9D T00jvsusSNxx5YgAscSQOX/Ih4waH3PzcuCgbCc3PaQOOYlJ3Xe04QuzQxQvbAKFChVZ C/4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dXyQk5ro; 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 d9si29665232pgv.577.2019.07.29.12.39.31; Mon, 29 Jul 2019 12:39:45 -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=dXyQk5ro; 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 S2388640AbfG2ThB (ORCPT + 99 others); Mon, 29 Jul 2019 15:37:01 -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