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=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 615CFC48BD1 for ; Thu, 10 Jun 2021 07:02:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3EE5161374 for ; Thu, 10 Jun 2021 07:02:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229792AbhFJHEG (ORCPT ); Thu, 10 Jun 2021 03:04:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:56406 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229778AbhFJHEE (ORCPT ); Thu, 10 Jun 2021 03:04:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E1E6961374; Thu, 10 Jun 2021 07:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623308514; bh=kH4pnvJ0MpZOy3As+Jz/LPNcbVZsxfO3CyyE6Knr5Vc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GSDwBMIza/j1wufCVzOT+v6HFmmoDgj/KPuTWQ8QCWxjiIPxBUbjWb8tzOiSraTh5 Eqh1K/JiPsIdxQ5jm+Is+PIqZSCDGy2XQlQGDWfQVxF4qpZCHoWhDI7QmNK29niNAh VP6OBNd7UDRc5p+iAWwr5ezIvJBcpY9NMdk5FYP0= Date: Thu, 10 Jun 2021 09:01:52 +0200 From: Greg KH To: Geert Uytterhoeven Cc: Yoshihiro Shimoda , Sergei Shtylyov , Jiri Slaby , "open list:SERIAL DRIVERS" , Linux-Renesas Subject: Re: [PATCH v3] serial: sh-sci: Stop dmaengine transfer in sci_stop_tx() Message-ID: References: <20210609014902.271237-1-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org On Thu, Jun 10, 2021 at 08:58:04AM +0200, Geert Uytterhoeven wrote: > Hi Shimoda-san, > > On Thu, Jun 10, 2021 at 2:50 AM Yoshihiro Shimoda > wrote: > > > From: Geert Uytterhoeven, Sent: Thursday, June 10, 2021 12:30 AM > > > On Wed, Jun 9, 2021 at 5:09 PM Sergei Shtylyov > > > wrote: > > > > On 6/9/21 4:49 AM, Yoshihiro Shimoda wrote: > > > > > Stop dmaengine transfer in sci_stop_tx(). Otherwise, the following > > > > > message is possible output when system enters suspend and while > > > > > transferring data, because clearing TIE bit in SCSCR is not able to > > > > > stop any dmaengine transfer. > > > > > > > > > > sh-sci e6550000.serial: ttySC1: Unable to drain transmitter > > > > > > > > > > Note that this patch uses dmaengine_terminate_async() so that > > > > > we can apply this patch into longterm kernel v4.9.x or later. > > > > > > > > > > Fixes: 73a19e4c0301 ("serial: sh-sci: Add DMA support.") > > > > > Signed-off-by: Yoshihiro Shimoda > > > > > --- > > > > > > > > > > drivers/tty/serial/sh-sci.c | 8 ++++++++ > > > > > 1 file changed, 8 insertions(+) > > > > > > > > > > diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c > > > > > index 4baf1316ea72..2d5487bf6855 100644 > > > > > --- a/drivers/tty/serial/sh-sci.c > > > > > +++ b/drivers/tty/serial/sh-sci.c > > > > > @@ -610,6 +610,14 @@ static void sci_stop_tx(struct uart_port *port) > > > > > ctrl &= ~SCSCR_TIE; > > > > > > > > > > serial_port_out(port, SCSCR, ctrl); > > > > > + > > > > > +#ifdef CONFIG_SERIAL_SH_SCI_DMA > > > > > > > > Why not use IS_ENABLED() instead? Gets rid of #ifdef. :-) > > > > > > > > > + if (to_sci_port(port)->chan_tx && > > > > > + !dma_submit_error(to_sci_port(port)->cookie_tx)) { > > > > > + dmaengine_terminate_async(to_sci_port(port)->chan_tx); > > > > > + to_sci_port(port)->cookie_tx = -EINVAL; > > > > > > Because chan_tx and cookie_tx do not exist if CONFIG_SERIAL_SH_SCI_DMA > > > is disabled. > > > > This is a nit though, chan_tx always exists. > > I stand corrected, only cookie_tx depends on CONFIG_SERIAL_SH_SCI_DMA. > > > > Yes, that's why all the DMA code in this driver (.c file) is protected by > > > #ifdef CONFIG_SERIAL_SH_SCI_DMA. > > > > I'm thinking we have to remove #ifdef from sh-sci.c file at first... > > While I don't disagree that would be worthwhile, do we really need > to refactor a driver first, before a fix that follows the existing > driver style can be applied (and backported)? No we do not. Sorry if this usage is already in the driver, might as well keep it there, I thought this was an exception and was being added for the first time here. thanks, greg k-h