Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp5172119ybb; Tue, 24 Mar 2020 12:14:45 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsFxPd2YoWaITQStMB5Mupi9Rh6zF44TD7xePpxG7YR0Ys0ID7ywDL4wpMNfRnLHOGf+42j X-Received: by 2002:a9d:709a:: with SMTP id l26mr10595550otj.159.1585077285497; Tue, 24 Mar 2020 12:14:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585077285; cv=none; d=google.com; s=arc-20160816; b=U0WR/WCW/IlgyGiO4E3aBq0hEmyhw/p6+plCfzhMLz0Z+pEHaa5WIAX2miWFqJVEVU bqNHK7jDV2N+xEH6Qqz2OTMLLHzD2SHOeO06ki8ht0Wt4qIWAoARd/s0EpJk2Juuj328 /Q4FRSZBSNcEHzos0Hl3N5CqpkTn8SXF4Rw6a4RxdfXWHtBeaGI/Nifs5ZdCSoBi68W+ Ri+xzbvCYSxu1+KPTmpIN35Vx21KU8w0xmdNhkT7oie3zlfWEFDiUyTXihKHPWfIxdJe e5NLCECTFgCs4WofVcI2Pj6LLS5xrn+n7zr1BYX2EUmhp4olaGIp9JZ2o+8Ce8dIusPl YkIg== 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=jzcdODLP0bHV5KexQQTzdWyhTj19LdLpMLvVPCui0eA=; b=rJrMr/rS2J2vLGL28KODiSXYFaJMyBMpWrdwZAf/dEDnQIk5Onnk33qS9MJ5F85aDv z2zyiCC/+gu8Dtln543OQctxCJUJFnmHvFR30HAZkkFBLkXh4cimlGpgE4qvE2HlHm7N kzglg0zyO0W57I518qyLUkDWOoJZfXLbJfnDx1JJMYeEZF041re5v7HvCYShnP2tLtq2 dIT3NTQ63yQMalpPfeQEqJUnfunh4XjPfNiaxyq3vLxJNKb8Q2LccM2I6gb8lhgkhQYn Xd5KSBSrigCBUpE8kLxZfNB6R4nGmCsadNbDU6KHAFFnoCvxplwiZwXXGlwoyn6KcieA Bq/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l+gUJAYd; 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 v15si10339729oth.307.2020.03.24.12.14.31; Tue, 24 Mar 2020 12:14:45 -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=pass header.i=@gmail.com header.s=20161025 header.b=l+gUJAYd; 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 S1728138AbgCXTNg (ORCPT + 99 others); Tue, 24 Mar 2020 15:13:36 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:42161 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727999AbgCXTNb (ORCPT ); Tue, 24 Mar 2020 15:13:31 -0400 Received: by mail-lj1-f193.google.com with SMTP id q19so19791746ljp.9; Tue, 24 Mar 2020 12:13:29 -0700 (PDT) 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=jzcdODLP0bHV5KexQQTzdWyhTj19LdLpMLvVPCui0eA=; b=l+gUJAYdrgzLt3eLoI04QicNrazbv0v+FgYsKc5KoGBu5YFAIrTVAiCOBKdoV1ngoh 0deLxHa1n/6oUByrwhYO9rKBsC8iDCQJoyjr8SHwOGNl7YpwJxvJB+GEEOACJqZgC9qU TRnv9gtrZOIDcpih7GDiNyv8wu0HUswtMoJXj3JlyR2PxjN/vCf4BVcrdpPuLT2a6Vnd 8YWYQPvcAxt2m1bneX4xjIfz6krJozZvFnYpyNShqmdk6hMh9hzRHJ+RTvTHZa+mdTKv U0Zw9I5U4hqX4/JuOmytNJPNTZNkIJQWnfIoO/SSRsjY0h94mVLQCLDvMr6uYeV75g/L 92Bg== 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=jzcdODLP0bHV5KexQQTzdWyhTj19LdLpMLvVPCui0eA=; b=jKWqyyMp1IQ3j5wpWMDl3k73MNw1v7lIcTPKt2dnbk3ef+i77KO4tCxSSF44bu+NhQ FT1z0AmMH+gAC4fK/XnQHc8Q0F2WIzc2560sjVgTUro2X6qwo4oCeDoZ3HYsVZLuWdHB O51LPgT28Opw2LYqjs0ZM2dPKcsEyqxRbBcWkEdO5ywO9HZUAbgsXnbHk+4rYG1DM7yb hzW8r07uOgbxzPdhInbTPQpeLelvyS+QbHtppMvrB7O4CQu8yoPZM9tvpVlm1coWoQ7z MMgJGuFAkraM+ZG0Z04uq9nIYR5+Afo9Huka3Zkx+FYOY+jl2Vpn6mstrS6561WG6rb1 pXdw== X-Gm-Message-State: ANhLgQ2LFW3hJ5Wputerv4X64GKiYbSsj6VtBfzsmvfVlAIahkIu47d4 ohF6oI44sV6UWYzfr3/tSSc= X-Received: by 2002:a2e:93c5:: with SMTP id p5mr17839557ljh.192.1585077208915; Tue, 24 Mar 2020 12:13:28 -0700 (PDT) Received: from localhost.localdomain (94-29-39-224.dynamic.spd-mgts.ru. [94.29.39.224]) by smtp.gmail.com with ESMTPSA id z23sm6347723ljz.52.2020.03.24.12.13.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2020 12:13:28 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] i2c: tegra: Synchronize DMA before termination Date: Tue, 24 Mar 2020 22:12:17 +0300 Message-Id: <20200324191217.1829-3-digetx@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200324191217.1829-1-digetx@gmail.com> References: <20200324191217.1829-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 DMA transfer could be completed, but CPU (which handles DMA interrupt) may get too busy and can't handle the interrupt in a timely manner, despite of DMA IRQ being raised. In this case the DMA state needs to synchronized before terminating DMA transfer in order not to miss the DMA transfer completion. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 0daa863fb26f..0c6dac770fc3 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -1223,6 +1223,15 @@ 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); + /* + * Synchronize DMA first, since dmaengine_terminate_sync() + * performs synchronization after the transfer's termination + * and we want to get a completion if transfer succeeded. + */ + dmaengine_synchronize(i2c_dev->msg_read ? + i2c_dev->rx_dma_chan : + i2c_dev->tx_dma_chan); + dmaengine_terminate_sync(i2c_dev->msg_read ? i2c_dev->rx_dma_chan : i2c_dev->tx_dma_chan); -- 2.25.1