Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3082594ybl; Sun, 12 Jan 2020 09:19:14 -0800 (PST) X-Google-Smtp-Source: APXvYqzNjcAZSOL6Z1I33dqA/gzQw55Ap1OPk2C2sWbVMRuEHNealWWOqeVTD8BjGrCEmtt9+zVY X-Received: by 2002:aca:c646:: with SMTP id w67mr9608143oif.171.1578849554360; Sun, 12 Jan 2020 09:19:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578849554; cv=none; d=google.com; s=arc-20160816; b=PVrwJfQ1sEwey1voyf08FRlSKyGWg4LP1SKiTlUxeldKXQwDDNAcH0Wa/QDVz0UcLq 98EYiNVoXRSsesrU444IUlXyhofZefgSAHqUee7fq73c/Zf56iD7Xi2LCEyq7J4WH85I Ua77yI62BkgLYqFHJseh0vUpB4BX5cmqL3axqdCS2AFKj9L4PD6Vzpbz0d8hifezWu7d obauZemDGJwJzuh4SekMsyMahk0zVvv/lc49j2GKtGUaTAqw8oIELsN/RRa4XGtDIEPo NJ41DGXWkUaGGZYr/MazbuO1lxtEPZVlxkYZN/KL0XQ5xrq0Py2/53u8hFoX+gFc200L UgFA== 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; bh=Tl7vtSi+PnhU8zv8cy8MKZTZZyU72nU5B2eEjZlckoM=; b=nx2yOE0hlZ5LJTgBbl778KT3BJ7J9kCuXrCD6qMc6G804F3RySnhI6l49174GwBcgx EffBFiz46bQU0h2/XkDpHEx1hYAcADiBlzj0PHw0J3HkfgEn/UMDZdATTLjOav52masr J51WWn8ae/Q8BueVpp4Gwf9Ciixl7GvSBTNKwgw+e8ShFn7Yi44xnn//zb7tY+B0agQW F1JjI2E0X6b+u2okJiAcZRT09aMd+XErJlhbmoxDG7ztLIFXBYTE0nRPqEg73jES+cpv Ho7Wzb5T/MmyeN9Oh/TtjwaDC+16RJblh/5LgH5zAj4OiyO0b1Ozn5EB9sSOETQTY59z Zl9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Yn/tXtmm"; 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=pass (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 14si4489964oij.200.2020.01.12.09.19.03; Sun, 12 Jan 2020 09:19:14 -0800 (PST) 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=pass header.i=@gmail.com header.s=20161025 header.b="Yn/tXtmm"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733206AbgALRSA (ORCPT + 99 others); Sun, 12 Jan 2020 12:18:00 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:33296 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728512AbgALRRs (ORCPT ); Sun, 12 Jan 2020 12:17:48 -0500 Received: by mail-lj1-f195.google.com with SMTP id y6so7464778lji.0; Sun, 12 Jan 2020 09:17:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Tl7vtSi+PnhU8zv8cy8MKZTZZyU72nU5B2eEjZlckoM=; b=Yn/tXtmmMJTK8+Rxd6IEgmXiuq4E9u7oY1tTnOaWi/kSD798c6lxhXjzhs82AS7TkY TBI6kWeNGAVhW779G/ThurMif0Uej6T4V2OaQywiQG7UGTiqCfZh5Kfhq+RZf1KnLNu4 jsNxdjH7U4ZwvWFPTfuGNBIXU2P1OfyNOIbH9LhZwumKzVNBr4dIEsyQihnEC0i5JIdH AVkIraHPW9fEj1aaJcLzTgmK6PhnTzgZHVfazYlHAiJ9j0s7KZKO+ZTjzWj3PrTzMcCt xmHYKZzvYFZ93ipnTfRkUKxaYR0KEBW8/iyI4i7dLb/8vk2HO9hRj813NQdkWSEh5LIR NWrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Tl7vtSi+PnhU8zv8cy8MKZTZZyU72nU5B2eEjZlckoM=; b=c6LC6pl2LhJYpUN4WV1KNvu8CWm0Xd5SNzoQ35VSbqkBEgwrMe64gebFz6hviGMGuy cQgxbMu0Uf7kuZmO9d7xHiq2XT01Xew0tE6K42Iu3m5QnQFhJ4AKVGEQvjl0f4hsjADu A2STtqGlPpeQ7RlXkR04jFpy8GjNFCXV4kc6u1EgWnLqDKCHirz5BEuDcQi3zyY9r2xA 1MlerzVCiPQo9/Z/d0qJe16xOHL4hERgpIyvmDFyWdnXUGt1RVICwDtCuv0cRU1Ba6uO eSiDeLbzOQEluggJDHUXQ68p9Ns2NaUvRkjaqxkLyWSA/0iFbmLoIRLlDb31mmq8WIFC kOQw== X-Gm-Message-State: APjAAAVjm6j+McRUn45J6lqNPqeU6+vb8UvocWWSSUG4d+QqNN8cj8/v 00amOC/4US9wjufYpGSk8BY= X-Received: by 2002:a2e:9e16:: with SMTP id e22mr8129689ljk.220.1578849465609; Sun, 12 Jan 2020 09:17:45 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id i13sm4506628ljg.89.2020.01.12.09.17.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 09:17:45 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Mikko Perttunen , Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 7/8] i2c: tegra: Always terminate DMA transfer Date: Sun, 12 Jan 2020 20:14:29 +0300 Message-Id: <20200112171430.27219-8-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200112171430.27219-1-digetx@gmail.com> References: <20200112171430.27219-1-digetx@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is possible that I2C could error out in the middle of DMA transfer and in this case DMA channel needs to be reset, otherwise a follow up transfer will fail because DMA channel stays blocked. Tested-by: Thierry Reding Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 1a390e1bff72..3c7c86d4b0e4 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -1220,11 +1220,12 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, time_left = tegra_i2c_wait_completion_timeout( i2c_dev, &i2c_dev->dma_complete, xfer_time); + dmaengine_terminate_sync(i2c_dev->msg_read ? + i2c_dev->rx_dma_chan : + i2c_dev->tx_dma_chan); + if (time_left == 0) { dev_err(i2c_dev->dev, "DMA transfer timeout\n"); - dmaengine_terminate_sync(i2c_dev->msg_read ? - i2c_dev->rx_dma_chan : - i2c_dev->tx_dma_chan); tegra_i2c_init(i2c_dev, true); return -ETIMEDOUT; } @@ -1237,11 +1238,6 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, memcpy(i2c_dev->msg_buf, i2c_dev->dma_buf, msg->len); } - - if (i2c_dev->msg_err != I2C_ERR_NONE) - dmaengine_synchronize(i2c_dev->msg_read ? - i2c_dev->rx_dma_chan : - i2c_dev->tx_dma_chan); } time_left = tegra_i2c_wait_completion_timeout( -- 2.24.0