Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp5171983ybb; Tue, 24 Mar 2020 12:14:37 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtCkpb9jyCkYEHHrMvfw/iEiEUOwrw2wOdOPio7Nxvz8CveqOXUIEoijtBlLHfQeHm0F38g X-Received: by 2002:a54:4387:: with SMTP id u7mr4661559oiv.139.1585077276838; Tue, 24 Mar 2020 12:14:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585077276; cv=none; d=google.com; s=arc-20160816; b=aIdRRMev8JQObPwoq1zona2k5nuctmx9h2OgoJJK6dJh15y85611ely3+qusa4c4np k0u8LoF3OwceK8x/Xo8hSzn9sxlzbC1/mAk6XZsdyBfM7bn418xtDLsDlxrnCVcXDTBM qzGYr8ejkEAQ/jOluOrtI7R74UX/xYL3Kzpll4oxNnx2KUBc8frrtdnDqNHx3U6WCIQq VC7vG4KI4PaJHOdTD+eeSx6tjVFBftNvsFbjyfZjFZNtwDtIK1U6m81aLqTYSfKz8jQW 4rRc7Qmn8fLCwmMY2RLEuaNC54NvQM08JA3ftRN/qDBaAeQzK0yim/v1mFjyYdP0xcIt o9Ng== 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=8e7+L+UHZHa2zA2O9LK9VZBpvO0sNomc3WT2/0CqCjU=; b=UO49hcqodWDNs0ZydtYAOBvBuXKVcC5qJHyIiFcayOvIAiEUTreze52Wu77uESAk8R tn9iuk4tG/XGhzILQKWqU4wpqUc86LEB9OPe+W6HDTpDhGi7qxhgKoYr/ju0UKAPoUj3 5CXpFoDFEDv2Gxgp+HckukXDZNKlYGpsjqhI96G98lygMJfkOQPoNRAgDTY3o7VSIdc3 f8HNwBKYYY8d0QpHEwpfw9ypKbuUVSjMnY0mB7+TmvurGUo38etSOUH5CJgumU+HgCOF Q3EPT87dH1lTBTr1gsKD6HiAe/R61Ht5S5zUF7Z2vR/8vp8GMGctr2/L0FX6rAYdSSu2 JxqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ByzkfVsg; 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 t12si1285712oth.0.2020.03.24.12.14.18; Tue, 24 Mar 2020 12:14:36 -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=ByzkfVsg; 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 S1728076AbgCXTNc (ORCPT + 99 others); Tue, 24 Mar 2020 15:13:32 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:38859 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727747AbgCXTN3 (ORCPT ); Tue, 24 Mar 2020 15:13:29 -0400 Received: by mail-lj1-f196.google.com with SMTP id w1so19829658ljh.5; Tue, 24 Mar 2020 12:13:28 -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=8e7+L+UHZHa2zA2O9LK9VZBpvO0sNomc3WT2/0CqCjU=; b=ByzkfVsgRm5bJi+U8RCJHRQt9tjP2J474FwUvPZZtITq5rx5+eU82yk90R3S+6x81T ZXMiflZ4qDlC3MA0hUkYLhnhVtjVKmMdo8EYgH3JAH0Sq28mQUYQXD9q9Xrh9w0pvvtt g2o/uj5Ke6DudG4zTgun1YXTssK+frT6CBzPN9hWnaK64YX18YLZm/gYOH1nU/d2FVBN bYbe9U+kY/Zl6i2wDxO73uIEZXAJIdS9RuXf5bxPpqpwRJjCIRFiWTntWt7MGaAQVSC2 iFMnewIylkBTehqrn56LrXk0RBrI+vKxGWjhh7PBNlrtmfhEVYAIovTEAKyo4tq4oN+9 qKrw== 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=8e7+L+UHZHa2zA2O9LK9VZBpvO0sNomc3WT2/0CqCjU=; b=iadn6XWpmDv8b5i9r+m0f3J4lSmY+KVzbLtYVtR2xiE9/aVsX4i528aXtmFMbZdR4c g9jUdMm8/KJebtTy19+B9L+zkLrvCR/F6hfLa9nQ1BkSLnJLiqEA5NPRspmRP1uKDCQs AFzO/GyYdh8E1yTEulI1tOM7GV18hzXEf/ShFT6wQdJoJtd44aAOFq81tjjYjX8IBu+p NwY8DmNZNRmXFQSGITSWLmB73hC7CzyCToIOT1eoKA8EveoEa998TCJeTjPH3IE+yfk0 TepTMwY4JEIaiXY4pyu/b+9i/BsB5dvLi4tEXak0XfHisYJXtRqharOpDEPm++O2vXwk yVcQ== X-Gm-Message-State: ANhLgQ2ZMbY660+IQ2YCN2DCZofmu3AgVZEZwLWXvniJZxn0dUSDrWv8 N01J2+hE2w+pfDeYj4K/uew= X-Received: by 2002:a2e:6809:: with SMTP id c9mr10101355lja.251.1585077207778; Tue, 24 Mar 2020 12:13:27 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2020 12:13:27 -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 1/2] i2c: tegra: Better handle case where CPU0 is busy for a long time Date: Tue, 24 Mar 2020 22:12:16 +0300 Message-Id: <20200324191217.1829-2-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 Boot CPU0 always handle I2C interrupt and under some rare circumstances (like running KASAN + NFS root) it may stuck in uninterruptible state for a significant time. In this case we will get timeout if I2C transfer is running on a sibling CPU, despite of IRQ being raised. In order to handle this rare condition, the IRQ status needs to be checked after completion timeout. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index cbc2ad49043e..0daa863fb26f 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -1000,14 +1000,13 @@ tegra_i2c_poll_completion_timeout(struct tegra_i2c_dev *i2c_dev, do { u32 status = i2c_readl(i2c_dev, I2C_INT_STATUS); - if (status) { + if (status) tegra_i2c_isr(i2c_dev->irq, i2c_dev); - if (completion_done(complete)) { - s64 delta = ktime_ms_delta(ktimeout, ktime); + if (completion_done(complete)) { + s64 delta = ktime_ms_delta(ktimeout, ktime); - return msecs_to_jiffies(delta) ?: 1; - } + return msecs_to_jiffies(delta) ?: 1; } ktime = ktime_get(); @@ -1034,14 +1033,18 @@ tegra_i2c_wait_completion_timeout(struct tegra_i2c_dev *i2c_dev, disable_irq(i2c_dev->irq); /* - * There is a chance that completion may happen after IRQ - * synchronization, which is done by disable_irq(). + * Under some rare circumstances (like running KASAN + + * NFS root) CPU, which handles interrupt, may stuck in + * uninterruptible state for a significant time. In this + * case we will get timeout if I2C transfer is running on + * a sibling CPU, despite of IRQ being raised. + * + * In order to handle this rare condition, the IRQ status + * needs to be checked after timeout. */ - if (ret == 0 && completion_done(complete)) { - dev_warn(i2c_dev->dev, - "completion done after timeout\n"); - ret = 1; - } + if (ret == 0) + ret = tegra_i2c_poll_completion_timeout(i2c_dev, + complete, 0); } return ret; -- 2.25.1