From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EC1CC07E99 for ; Sat, 10 Jul 2021 02:40:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4AAF0613D3 for ; Sat, 10 Jul 2021 02:40:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233090AbhGJCnI (ORCPT ); Fri, 9 Jul 2021 22:43:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:58442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235803AbhGJCjr (ORCPT ); Fri, 9 Jul 2021 22:39:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B411961435; Sat, 10 Jul 2021 02:36:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625884561; bh=gX80I4HjBwctd2RK6SB6nTUgM99aqqGzzWuj3XnhyDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fp/YLjqb2PoCot5lhJp/UJkw6o3FECuc4AyYzPNEaayDWpaIvPx/mfSPoGcbmcyLY 3K/OjG9Usw92H/zB+/Ec806o+eggzTpAwyomI7ow+rJKUQHGogxN+eWBHCcMjpqiy3 qLKuq1xUVdPLOmoP9zfftwSg2ju3DNJfh3EZkyVxKMY1+OT0HiDXlKAPLSRbrV/vqA KVfiFxH1pJNzOVbHwTFznMT9fHxBW4dw0xUDNm4sTALidf6qiwRhZxLuRsAbTstOvB lbVsFVlzRpGiSw+jIPyReDMu3SRUao8ID0Sku3NHwcNTzOlWqGLXzmrf6lr1W6rmTD 7prLsArZRyBxQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dmitry Torokhov , kernel test robot , Stephen Boyd , Wolfram Sang , Sasha Levin , linux-i2c@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 32/33] i2c: core: Disable client irq on reboot/shutdown Date: Fri, 9 Jul 2021 22:35:14 -0400 Message-Id: <20210710023516.3172075-32-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710023516.3172075-1-sashal@kernel.org> References: <20210710023516.3172075-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dmitry Torokhov [ Upstream commit b64210f2f7c11c757432ba3701d88241b2b98fb1 ] If an i2c client receives an interrupt during reboot or shutdown it may be too late to service it by making an i2c transaction on the bus because the i2c controller has already been shutdown. This can lead to system hangs if the i2c controller tries to make a transfer that is doomed to fail because the access to the i2c pins is already shut down, or an iommu translation has been torn down so i2c controller register access doesn't work. Let's simply disable the irq if there isn't a shutdown callback for an i2c client when there is an irq associated with the device. This will make sure that irqs don't come in later than the time that we can handle it. We don't do this if the i2c client device already has a shutdown callback because presumably they're doing the right thing and quieting the device so irqs don't come in after the shutdown callback returns. Reported-by: kernel test robot [swboyd@chromium.org: Dropped newline, added commit text, added interrupt.h for robot build error] Signed-off-by: Stephen Boyd Signed-off-by: Dmitry Torokhov Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/i2c-core-base.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 39065a5d50fc..b7fe8075f2b8 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -452,6 +453,8 @@ static void i2c_device_shutdown(struct device *dev) driver = to_i2c_driver(dev->driver); if (driver->shutdown) driver->shutdown(client); + else if (client->irq > 0) + disable_irq(client->irq); } static void i2c_client_dev_release(struct device *dev) -- 2.30.2