Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp477606imm; Wed, 4 Jul 2018 00:04:59 -0700 (PDT) X-Google-Smtp-Source: AAOMgpftfF1k3N9q+DR9gdAkAjlXQhlo4vNZ/UBychQEyQtYyfJJ/OsamNOcTMoq/K+W33wHcV3S X-Received: by 2002:a62:8d16:: with SMTP id z22-v6mr918704pfd.181.1530687899261; Wed, 04 Jul 2018 00:04:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530687899; cv=none; d=google.com; s=arc-20160816; b=d+G89t90f84F5c/5J2BAa3jj9bVPbBDsB3/Z8FkIIiP2zB0Jp3MQAOQnjY2JS25lvl JifrHsDw3NLrA6dfQc9u4TJHOK3L/anqPNhT9PVj4x6CvPQ+YiPTdlK442G17eMER46C rYSKhJG317nGjkecso+xBWLOSEk7d22ivY6IEknXZE+bWlG90Sv9gM5MzLAklc2GVJ5/ DbmdkG8G6RBjlpvmePcF4XbOigeaKki8S1CLLG/dQWYU4izf3JN67BR1c7pVJsLeYcQ5 2Wmrkkc/QddjB0ASias0PdD1QOkh8G+kuUdQSufwbG7usQEO63MDSOk0g4+13ciZTbSD /2nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=yPJhDYKsGPn5R3fSxOae0BcbSIzFiWIYptCdrS/N5DY=; b=lsx2xGamQfGbcYmovmzuWYXW37qeIHB7DRcnntI4Iy4x2H0ju09cuc1CQrRGCILeTg bIXHcZ3uzyoKUrJeZDyMkOxxzl93Ih6BtmNNrlnMQD8mOUiHy072k3DKNBWBZyycE+th hjAtXlxwT4rmDkV+rrFLBkTh3mMItcjEHii0Hr9RKSXrMKXQ2NuCIpxPPv+iN6fmn7Qc XNvYU6j5X5bdRMd8ePeI+ch1euoQ6LYbC/CrZpOGu0m2pxQKs4y8LIG6HleVJll6n7EJ L41NoxzABY7QLlxMuLkoOyF5aJW0INwb/7S4kCJS9YVErlI3eD65MiHDHu0kbgY4hBcD rghg== ARC-Authentication-Results: i=1; mx.google.com; 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 l21-v6si3064941pfk.321.2018.07.04.00.04.44; Wed, 04 Jul 2018 00:04:59 -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; 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 S932412AbeGDHEA (ORCPT + 99 others); Wed, 4 Jul 2018 03:04:00 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:34817 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753068AbeGDHD7 (ORCPT ); Wed, 4 Jul 2018 03:03:59 -0400 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fabpM-0005JL-OA; Wed, 04 Jul 2018 09:03:48 +0200 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1fabpH-0004tl-0o; Wed, 04 Jul 2018 09:03:43 +0200 Date: Wed, 4 Jul 2018 09:03:42 +0200 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Esben Haabendal Cc: linux-i2c@vger.kernel.org, Esben Haabendal , Wolfram Sang , Phil Reid , Philipp Zabel , Lucas Stach , Clemens Gruber , Michail Georgios Etairidis , linux-kernel@vger.kernel.org, Yuan Yao , linux-imx@nxp.com Subject: Re: [PATCH 1/4] i2c: imx: Fix reinit_completion() use Message-ID: <20180704070342.pgnjjffk34nkloob@pengutronix.de> References: <20180523095623.3347-1-esben.haabendal@gmail.com> <20180523095623.3347-2-esben.haabendal@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180523095623.3347-2-esben.haabendal@gmail.com> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Cc += Yuan Yao who authored DMA support and the NXP team. On Wed, May 23, 2018 at 11:56:20AM +0200, Esben Haabendal wrote: > From: Esben Haabendal > > Make sure to call reinit_completion() before dma is started to avoid race > condition where reinit_compleition() is called after complete() and before s/compleition/completion/ > wait_for_completion_timeout(). Is this a theoretical problem, or did it trigger on your side? > Signed-off-by: Esben Haabendal Fixes: ce1a78840ff7 ("i2c: imx: add DMA support for freescale i2c driver") Reviewed-by: Uwe Kleine-K?nig > --- > drivers/i2c/busses/i2c-imx.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c > index d7267dd9c7bf..6fca5e64cffb 100644 > --- a/drivers/i2c/busses/i2c-imx.c > +++ b/drivers/i2c/busses/i2c-imx.c > @@ -377,6 +377,7 @@ static int i2c_imx_dma_xfer(struct imx_i2c_struct *i2c_imx, > goto err_desc; > } > > + reinit_completion(&dma->cmd_complete); > txdesc->callback = i2c_imx_dma_callback; > txdesc->callback_param = i2c_imx; > if (dma_submit_error(dmaengine_submit(txdesc))) { > @@ -631,7 +632,6 @@ static int i2c_imx_dma_write(struct imx_i2c_struct *i2c_imx, > * The first byte must be transmitted by the CPU. > */ > imx_i2c_write_reg(msgs->addr << 1, i2c_imx, IMX_I2C_I2DR); > - reinit_completion(&i2c_imx->dma->cmd_complete); > time_left = wait_for_completion_timeout( > &i2c_imx->dma->cmd_complete, > msecs_to_jiffies(DMA_TIMEOUT)); > @@ -690,7 +690,6 @@ static int i2c_imx_dma_read(struct imx_i2c_struct *i2c_imx, > if (result) > return result; > > - reinit_completion(&i2c_imx->dma->cmd_complete); > time_left = wait_for_completion_timeout( > &i2c_imx->dma->cmd_complete, > msecs_to_jiffies(DMA_TIMEOUT)); Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |