Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp339025imm; Mon, 9 Jul 2018 02:45:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfTNlFqbTaifLGe2hJ4urNwboclSy+ZwSLceHViSDoAmJfWS2LnZZvn35qTf2s0zfCU4i4L X-Received: by 2002:a63:d10c:: with SMTP id k12-v6mr4021882pgg.49.1531129519442; Mon, 09 Jul 2018 02:45:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531129519; cv=none; d=google.com; s=arc-20160816; b=klF4241aOy+u3LzswzSGV9IPYAXcaTyI4jEMhyI460Szjc19ueHaQuNhrDZnKdLeV/ WEL0o0DGP+JnEXo3pTAlm51on91ZHn0kz0qhZRsC/M1cgNAj3PlNvgdPFoADjwRpUZfY Ew676KXXkDGNczwEpr9K2a1woSup/0AqmqiKCRzw7FCADw5PGdRDP5ylkIzPeCI7FRaB 0tQZHjuEo47c+y9DV4E1D/SnydOzGiExhkj5FxhNYnji2PZ2mI6mp8BaHh04MCxP39an lBiL+CbHVuQvlQaYGk7Ehd9/GZtE6ir7fHJp5hrOSGdltsr5FE2CIPXQ35uPYNPeVYNn HLWw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=85O4D3Im7ZGdIr6UyDQTi5ey/7Ka1XJWMpnpdcRleeQ=; b=jFRk9t4K9iMJVVwfZodPL+JWt1JMOB8xc1YnzpFFnIcRzB2nohAvFePSizznBbGgtJ gu6wG/Tob0nCDTBGI/IXESv5O1QSt61+Rjqq/1CnDawQk8isUv3k9sfFHkkcobhvYTmH 63ZAvON1+qL+awuWd6cfWxymTSyV6C3BhqgqMBIerBw3n6KUaA7VmSU3xyhD6ABBVOSE vn0fSAzXO88i2vKeXcwAFC4hUMErgO94JcRWM/YFuQ58Z9bQvFkuMz31WfKtc3JPVLDK tW6bzOZCQ61UcogQVaijExNdMgF9oRj0hK43kgBIReq7Y7EeNgVQaSf4FnKohVHzbTQO 1J5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=cY6DjtOo; 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 i28-v6si2114622pfi.105.2018.07.09.02.45.04; Mon, 09 Jul 2018 02:45:19 -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=cY6DjtOo; 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 S932574AbeGIJnO (ORCPT + 99 others); Mon, 9 Jul 2018 05:43:14 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:34201 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754405AbeGIJnM (ORCPT ); Mon, 9 Jul 2018 05:43:12 -0400 Received: by mail-lj1-f196.google.com with SMTP id c12-v6so13601664ljj.1; Mon, 09 Jul 2018 02:43:11 -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 :mime-version:content-transfer-encoding; bh=85O4D3Im7ZGdIr6UyDQTi5ey/7Ka1XJWMpnpdcRleeQ=; b=cY6DjtOo43BxOe6+0TtGpzDe9c9duXo70ONW9OGgfDGJWfNpH0iYBhsKEv1fAIdkzL 7nskHhRiJiwcrajlQ6Ryd7vFHMKjoQYV1b/t+hSvl6QCiHLnS1jMmET9tbAHN96C9ISW S3CzVch52IRUs++qXcBtuNZNgt7i1AaDzhroBjhqrY2jyiCn+ysPu0K3EsBu9fhDfKj6 pLIJEsTxod/pzxaxqrFzbF6n1L1JWrljfrwvCiLcPlYNLsf5klAAz30hkzdW0gjQHvV9 gQWP1Zbw6Mw8DEfO8+okeDXGtk0YxEaAzmV5pyPRR73iOLS0+b+MXseOdMaB5d2lWIeF 6ghw== 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:mime-version:content-transfer-encoding; bh=85O4D3Im7ZGdIr6UyDQTi5ey/7Ka1XJWMpnpdcRleeQ=; b=JFeAI6NuhWBkjFls8I0FkASKntO9BqQrvyBa7K5AgYYuErIINpR10kY3k6XebdCjHo +qOZaf9kmm222StPo3O6AKgI7N67DhrnKzk7cNCfJJoQVONoYI8Y1KIh9IUUFYyUzRhO eoKLswHHCgdJJgzvL17WAIEzFCXhB+7ww0ipi9QGVAZKIPvF5jfLtnWM6JRthuPbzmhY NhMyGv07vofLmn5YfbLubvrijL683SRWih7Nun/SDBeE60qiKsPPyaAQohpBGq/y4+AA y+uZBoIfKmZQQU9L+qjAokjs90MMUnPgpt8Cu1aFSqr43sN9JupZke0TR4WDPNX2upGw FI7A== X-Gm-Message-State: APt69E167x1B8e3fI2IAT6zZeNFbvLRzOqMYv3Y5gkyqzLhqwd8lfZOh FHxjnfLiFLEHEWj3HFTtzYeTtIDlj6M= X-Received: by 2002:a2e:1d50:: with SMTP id d77-v6mr12189910ljd.104.1531129390376; Mon, 09 Jul 2018 02:43:10 -0700 (PDT) Received: from localhost (87-57-30-174-static.dk.customer.tdc.net. [87.57.30.174]) by smtp.gmail.com with ESMTPSA id k65-v6sm839279lje.3.2018.07.09.02.43.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jul 2018 02:43:09 -0700 (PDT) From: Esben Haabendal To: linux-i2c@vger.kernel.org Cc: Wolfram Sang , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Rob Herring , Mark Rutland , Yuan Yao , Esben Haabendal , Phil Reid , Lucas Stach , Linus Walleij , Peter Rosin , Fabio Estevam , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/4] i2c: imx: Fix reinit_completion() use Date: Mon, 9 Jul 2018 11:43:01 +0200 Message-Id: <20180709094304.8814-2-esben.haabendal@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180709094304.8814-1-esben.haabendal@gmail.com> References: <20180709094304.8814-1-esben.haabendal@gmail.com> 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 From: Esben Haabendal Make sure to call reinit_completion() before dma is started to avoid race condition where reinit_completion() is called after complete() and before wait_for_completion_timeout(). 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 0207e194f84b..39cfd98c7b23 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -368,6 +368,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))) { @@ -622,7 +623,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(i2c_8bit_addr_from_msg(msgs), 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)); @@ -681,7 +681,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.18.0