Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp628434imm; Wed, 23 May 2018 02:57:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqj+eb+3ZVLxKulUVRt1lNLD4IV02chk8/rVi5+hBR1SqK1/Y3SBUCOh+4pbxD54jHgxF4+ X-Received: by 2002:a62:c0dc:: with SMTP id g89-v6mr2195469pfk.223.1527069440916; Wed, 23 May 2018 02:57:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527069440; cv=none; d=google.com; s=arc-20160816; b=qVXgXWXn6pXOJFao1WdVsnQXBsN0biCBaV24Twe114H9D3dy6Cd48z8Wkv4VVScb1A jfayVLtvCBD/HLxM6PODTSLC/aRGGvyiCMJV09z3qHIUMJv5asD7mSv7F7+nAA99pBgf vDENxuJ/Md1QQQPhlZ/2c6ClTLlBR2OGNVD3gJ0lJefSjLkOX7KjbQLkTxC/SxSnJw5o uQDuNpHi9bOtuXynkU0mJf6UOSb45frDKz9q+H2BvHnE3KMdPGzB7x8vGG7IPE+XoLWb BPiu2ZpjJwcb+S86H+0BYarlOU36uZAvAjKd34mr/blo+TXBzhzebqSuVrTF//F3+0id q5WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=15mYISuX5dOSefC6jChGApaI0uyBbxBWCwb15ZuQDLE=; b=JmY+xZXKKyDPk4J6HCIH4/iV8D0KubVe1R12uQElQqq0Edk0mcZ7+VS/e4WtiGsDo7 6RKaCQaFIl3yqN6sSm3RKM3nfgu15NqBrZNdQZRZE3CVBMsX2sC4mVLzg13CJ8iZNEE1 3C3u4aOuMXbH5h1p8ua6enfjGonp9sbFAYP/qupV5rwDP2+X324ooJ323cMU/cAoESbS hb7T7Twg88ClmwPgx7w2sNAPsKb5JcBTiR88kZFfnmHdhe41STO+XS43+rd0cK3VJPCs 6pM4p86kKAiknVIErR2840lYkdDS1AIamlf22ZcwIXKPKVdj2WklP6e03wK5bpXuRK/7 dYlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ZEBNru2s; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r63-v6si18004441plb.366.2018.05.23.02.57.06; Wed, 23 May 2018 02:57:20 -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=fail header.i=@gmail.com header.s=20161025 header.b=ZEBNru2s; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932306AbeEWJ4e (ORCPT + 99 others); Wed, 23 May 2018 05:56:34 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:35735 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932180AbeEWJ43 (ORCPT ); Wed, 23 May 2018 05:56:29 -0400 Received: by mail-wr0-f193.google.com with SMTP id i14-v6so25337104wre.2; Wed, 23 May 2018 02:56:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=15mYISuX5dOSefC6jChGApaI0uyBbxBWCwb15ZuQDLE=; b=ZEBNru2sFjNhXzAIUkvZyDaEyhT1HYr/oGNMq9SGAjq9Qr/ikTZjURwKurz7ajLpbQ zWmF8GHGFn7GPG6GA5qIvBBkVGQh9VDO2Rvimd30kb+AtLhHACe3s5FYTSJrUKOBhCrq nut4DqejzC8w3W1XxyH+2h3kN23CWSBEHWtXxMpDe/KQWSlLiuMuK9bLl+l7XdoQ/Qvs +BvZLWfPgx8BhPhgC7TMe7RwusF+C9isENRSlmtaCwD1YuqkehwCNjrt/7/tW7Hd11KQ Bd+BOZYDIEV38gJT9bVoyHyV5kRK0N/xwywwBn6UOf8IIf7kjnDbAcbzqInLXis8AdHt LaBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=15mYISuX5dOSefC6jChGApaI0uyBbxBWCwb15ZuQDLE=; b=bvQR5rnTCU7uSmKzw82L6M/CZZO/6fgrgJ7AlgIvgHo3S66UJ52D+FpT3GmQdlrlm0 /lUE5V5DYBoN5OMyv7WW2aQ7RCzKZt46G6eFaVqiAaszRYi5q6z+6lWdzj3GZBW2CfQR 21qZzlQVoKu6zqhS6+tW4TjoxiEAgTOqcgKiquWx+NlOgSy3NYeQju4oC6x9UO/a4TvC CZJgDlth/Li+GdCGueK4P12AKCd/kBHiEFFzzO/tyOT/060d4ASMas6AzJVieGdezUyc OO04TXcoJ23Co0sj6uoFvsJj/8S3oe9/T3xgV4pS4B9q0z7gkXrPX59ss4xxTc3w/WGJ 7tHw== X-Gm-Message-State: ALKqPwfObeuhG7gTkufHbW8Fku0KO8yogULUTLQYYBjn3qAOAmq3n686 NyFPBY5NpX9qFNXfeIcsD/x/dSCLhN0= X-Received: by 2002:a19:a692:: with SMTP id p140-v6mr1240749lfe.121.1527069388188; Wed, 23 May 2018 02:56:28 -0700 (PDT) Received: from localhost ([87.54.42.112]) by smtp.gmail.com with ESMTPSA id i9-v6sm3326204ljb.87.2018.05.23.02.56.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 May 2018 02:56:27 -0700 (PDT) From: Esben Haabendal To: linux-i2c@vger.kernel.org Cc: Esben Haabendal , Wolfram Sang , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Phil Reid , Philipp Zabel , Lucas Stach , Clemens Gruber , Michail Georgios Etairidis , linux-kernel@vger.kernel.org Subject: [PATCH 1/4] i2c: imx: Fix reinit_completion() use Date: Wed, 23 May 2018 11:56:20 +0200 Message-Id: <20180523095623.3347-2-esben.haabendal@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180523095623.3347-1-esben.haabendal@gmail.com> References: <20180523095623.3347-1-esben.haabendal@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 wait_for_completion_timeout(). Signed-off-by: Esben Haabendal --- 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)); -- 2.17.0