Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp567605ybz; Fri, 24 Apr 2020 05:34:51 -0700 (PDT) X-Google-Smtp-Source: APiQypIu8dbO5S5Lxncs5kxC6SA499SrDxNuzec4l5IX7n+bMaJoKkmMICVizEXbN1niS3sWr7oa X-Received: by 2002:a17:906:3296:: with SMTP id 22mr7144978ejw.195.1587731691751; Fri, 24 Apr 2020 05:34:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587731691; cv=none; d=google.com; s=arc-20160816; b=ZnXHceZ5JkC+1glt0jbc7QcVnnAFlQKHWB8xwtszqM0jSA+ACa+KZmqaG+LxnS7dqv e5qVznZnR2e5/1GSb+Uqz4Zli2vjSAPeB9tH2eJRnmQ3kfoMN7jB3xmH6LouDmSesHdb 43aPfCzFgxbs5Gq2DXFUtf1f3mkk6lINkPXank0RRedCGmWlPsSG5iy77Jb1jammG6XM KyrpiOUKLpgeeb8K9ryvvbopqnc86JEmoYwtVD1bM0BL1BWpf4qcvEReZjJoNfGHWIqI FjbsBhEtiVQbofAEynRo2TBKYrplkKYG/gEg6Bi0tJ48UUa98rZSiBYLeagKH1XF/3t9 Ws1Q== 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=YcIKysMApUmCy0tYRmVvTWr8c1mjFdFmLFr1/BRKAlQ=; b=zXinup6FNjIbohBfwK/SVHJzKd2ABZLZu1TQdb5pbF8FlmKxfqBsqZRmroQl2Aq1S8 1rrrR6zmOL0+3NpE8+J/i7hfVuvYIeVKuYuDvjvI3O1NlIJqfeXt+SWM48no/xWnRwFk uPC5B93PkOaXD/o+1WRWVcl3pLp30xAeWfFafSY33l3chD3CjWLlkqxuGqy7+/T+V80y F8ZdFCureJiONAKEbBBsUgk8cfxPuiahn/pzZPqAjv49j8Y/CqYFpRAii3UzzTwa9aB0 aIhZ/W93piLUuGO6wyiYFgR3TGuwPzybbiZ26WQHKgMYkA3Xq0E8kNfDt/v8VvqEXK2x 9f3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="KDYxHJ//"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g4si412946ejb.192.2020.04.24.05.34.28; Fri, 24 Apr 2020 05:34:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="KDYxHJ//"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727832AbgDXMbh (ORCPT + 99 others); Fri, 24 Apr 2020 08:31:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:52776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727864AbgDXMXM (ORCPT ); Fri, 24 Apr 2020 08:23:12 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 85A2621582; Fri, 24 Apr 2020 12:23:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587730992; bh=AiHZMRGZN++JkczioNXBdzkyrnsdGgspzRfy4nft0mg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KDYxHJ//hrlq75jPlPKbi1+rFZubZFD6BlX4Ds59z3He/5aa/MFJiO/lgblG/4CvB k+n2bsIwYOJlodCK/O8O+7ekWoBUBe7sh8d1MV6HtH60E0hM3Vze/+oNwaeZgYmtVY 1fJ78Dg/+5kyVTyr2YSmeHmcj6fnd81Cur1gDCHI= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dmitry Osipenko , Wolfram Sang , Sasha Levin , linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH AUTOSEL 5.6 30/38] i2c: tegra: Better handle case where CPU0 is busy for a long time Date: Fri, 24 Apr 2020 08:22:28 -0400 Message-Id: <20200424122237.9831-30-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424122237.9831-1-sashal@kernel.org> References: <20200424122237.9831-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dmitry Osipenko [ Upstream commit a900aeac253729411cf33c6cb598c152e9e4137f ] 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 Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- 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 cbc2ad49043e4..0daa863fb26f2 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.20.1