Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1151671pxv; Fri, 9 Jul 2021 19:40:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdo4w0bXQi48elTZl4BQDosvdeNIE04c3ESjlTDxREM5PqQDSO7t/azk8Zsjwd98Mrv/jH X-Received: by 2002:a92:dcce:: with SMTP id b14mr5573281ilr.39.1625884825720; Fri, 09 Jul 2021 19:40:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884825; cv=none; d=google.com; s=arc-20160816; b=z/TKdTi1vkpS7GaB/j7OXbWn9RxMkz6wPPpBM252+UXLt4pNN6/DXGp/dg/OsIpomp cw8dNqpUAD21/m1XogVu2D3WoWPO8FEcl0QcnGbgp2Fz5+u2DzMkSVZSnmN/ZOSG+H+y Pl2Bm4UucnsWq3PTT+ARKycmTA+RX7pmyplrnOpwe4FMwSml1txmvgZ67DHnRHFN6jF5 sbBoUmL+QqxMBfAVIsajhXDLiYfUBUxp+ED4g4EVIngIGmuPUx1uXjF/Ok4aM3mx++YG YjSxAivGU3r/XkWHhsNPLnzAYIckOqk6EJu2GHeNlvZtWHiZ1m3LgeCwz/GmhUJMADWU BvrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=T4T/RykuqMwNCwVc3fJ6YEmmZLUf6MbcS0R5r557Wls=; b=Kr+ZnbnwXCYrZyYe3oauW28ihuRJCZXANuvSzZUH6rjCLTWNxiCic3+LjuLDaFF+gN VuEccbMhBldSCTQ1u0Pwku27sBQdlV4iy31+E+VvT2fNlusoX8tc129mnBBzoGE8PpVT cO62wd4WI16h/Z2Uj/O9g77sQ/hED0NG9Y25ayowIII9C3UBI7zxJeXKVIauHQMgsw9s OeukS940MVKqLCc+H9NJCC0i61HhriC3qwIBNonEdkvwhTECArCA1kg3luwL7fuDX1q5 zteDdgOfN6D1Wa4WO3jaZqB/am5kdMOGCTpzuyTuC8yfDd6gOStr9Eq1lnvHzVzxnBBI aa0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AZ2S0ggB; 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 h4si7941538ilq.151.2021.07.09.19.40.12; Fri, 09 Jul 2021 19:40:25 -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=k20201202 header.b=AZ2S0ggB; 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 S235260AbhGJCls (ORCPT + 99 others); Fri, 9 Jul 2021 22:41:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:58380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234927AbhGJCjS (ORCPT ); Fri, 9 Jul 2021 22:39:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 466E9613F2; Sat, 10 Jul 2021 02:35:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625884513; bh=5vvKhpf1wnKOQ7hM+FGiCC3Nq6hpYTSywIeiLaqR0SQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AZ2S0ggBHIV925UhyK+nBBQzXY1jCDiUDUlg+rdYtyqsCY7bpLV3MkCxhGc2C5gLR GfTBiOxggVC8bCyFOZGCEPXHUWN/SSjgMH/zE0ZeheOuWuAGa8eH0zJFdrYBUwS46U CQ25LsgxGPcr6ZabgY9wFummRVee+L5mbCRvhra8LLgUODB7mvMBK09miS4+zkUuPQ 8whYRwtIr3BfGamQ/YYsUP/Ahiq22ilGIDOraUYkN9Gc97I08Bh16IfMDXzYHtdueO uigRLJzl7CmPtBZ0eHKULVzek0XNt2t5d9V5fHBeY7/nWi+yugiAwSFalpv3GDOrL2 D65icWKFSYGLA== 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.19 38/39] i2c: core: Disable client irq on reboot/shutdown Date: Fri, 9 Jul 2021 22:32:03 -0400 Message-Id: <20210710023204.3171428-38-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710023204.3171428-1-sashal@kernel.org> References: <20210710023204.3171428-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 39be53b6f983..2a43f4e46af0 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -457,6 +458,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