Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752627AbdGEL6w (ORCPT ); Wed, 5 Jul 2017 07:58:52 -0400 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:46333 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751966AbdGEL6u (ORCPT ); Wed, 5 Jul 2017 07:58:50 -0400 Date: Wed, 5 Jul 2017 13:58:47 +0200 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Romain Perier Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Nandor Han , linux-arm-kernel@lists.infradead.org, Lothar =?iso-8859-1?Q?Wa=DFmann?= Subject: Re: [PATCH 3/7] serial: imx: init dma_is_{rx|tx}ing variables Message-ID: <20170705115847.nxgznbv5xacnbjqg@pengutronix.de> References: <20170630120446.13994-1-romain.perier@collabora.com> <20170630120446.13994-4-romain.perier@collabora.com> <20170630141329.6144cddd@karo-electronics.de> <20170703065221.imbpbybsrd3of4ec@pengutronix.de> <91cc9a48-58e9-98a9-58aa-1a949b9b5552@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <91cc9a48-58e9-98a9-58aa-1a949b9b5552@collabora.com> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:5054:ff:fe2a:3aa X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2241 Lines: 64 Hello Romain, On Wed, Jul 05, 2017 at 12:14:57PM +0200, Romain Perier wrote: > Le 03/07/2017 ? 08:52, Uwe Kleine-K?nig a ?crit : > > On Fri, Jun 30, 2017 at 02:13:29PM +0200, Lothar Wa?mann wrote: > >> On Fri, 30 Jun 2017 14:04:42 +0200 Romain Perier wrote: > >>> From: Nandor Han > >>> > >>> Initialize both dma_is_{rx|tx}ing variables when DMA is enabled to avoid > >>> checking uninitialized variables if port shutdown is requested before > >>> DMA channels get a chance to start. > >>> > >>> Signed-off-by: Nandor Han > >>> Signed-off-by: Romain Perier > >>> --- > >>> drivers/tty/serial/imx.c | 3 +++ > >>> 1 file changed, 3 insertions(+) > >>> > >>> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c > >>> index 188063d..81fb413 100644 > >>> --- a/drivers/tty/serial/imx.c > >>> +++ b/drivers/tty/serial/imx.c > >>> @@ -1225,6 +1225,9 @@ static void imx_enable_dma(struct imx_port *sport) > >>> > >>> imx_setup_ufcr(sport, TXTL_DMA, RXTL_DMA); > >>> > >>> + sport->dma_is_rxing = 0; > >>> + sport->dma_is_txing = 0; > >>> + > >>> sport->dma_is_enabled = 1; > >>> } > >>> > >> sport is devm_kzalloc()ed, so the variables are initialized to 0 anyway. > > I'd agree to Lothar's statement. Did you find this issue by inspection, > > or does it fix a compiler warning? Do you think there is an actual > > problem? > > > > Best regards > > Uwe > > > What does happen if the UART port is shutdown and then re-enabled ? I > don't think that kzalloc will work in this case imx_shutdown has: if (sport->dma_is_enabled) { sport->dma_is_rxing = 0; sport->dma_is_txing = 0; which might be good enough. Can dma_is_[rt]xing be != 0 if dma_is_enabled is false? It seems it cannot, the only place where dma_is_enabled is set to 0 (apart from the kzalloc where dma_is_[rt]xing is set to zero) is imx_disable_dma(). The only caller sets both dma_is_[rt]xing to zero before. So this patch should be dropped or its commit log improved to point out the actual problem. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |