Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1145814pxv; Fri, 9 Jul 2021 19:28:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqo6wQpomL4tgylJXrKQ7Du8aLtnc8l6p836fSA/hfKdeSn09XI5iR35A7303jG2ldt/FJ X-Received: by 2002:a05:6402:502:: with SMTP id m2mr26083662edv.57.1625884103731; Fri, 09 Jul 2021 19:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884103; cv=none; d=google.com; s=arc-20160816; b=zYrgo5+jChDheGSf1WUX3hAy13p+clee8b0c69kz3GnQb+R22fi9irUyLdPSCYCw+e l+n09cnTvIgBrnLdjUwq6lJJDMhihxzxXmR7LW+lebLNUdO7BNIR9wYxCDLDbtSiZs+X 6mUTaTVHNs1SOh0jWNQhqpajFjOKARBmNoFxjgbXPPsfLbZBQbbXXewbNqIgWzCM3+Pq So4xKVE6CO4PyXoZ5EsdS9lxgR64YlYJvPliU/aFFc46CKjNQd4AaKg5IY2EUWPOKw2G ktbbghxIoacXShg2mNQrjCg4KYZoZumLEiu+l4S2+iWTqqerwFqiK/3avljcBtjMl/Kn TIZA== 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=0Sd1h8N5jKS7yzhbazPMiwPU9nwi5hSLPd/R7QjOG3E=; b=O3FhBnKBE//PkRCY9qy+G0rpjwWLL1w+OioEpKbN/yb7G3RixiagpXZis6qhVxQ0Jh OpL0LYkF5uBTD2tp29cNWcOearPT6/1pwOkGowhxhLyKODyOjwYHs4n+qHRs3DSWp0kh 8ANox5+2rOPHXdzc9QQrhGF37taFXMk8gIzmBRei6GLSobpO6KhA6eXjlKyBQTFKXaMd tQAaV+Oe4e6vvMj1WdhScaxH5A31glPLh4Bl053bi/IB+WRairnyoN9+qdb7LSNE18kJ 2nQZixDR3xBJfHYzf/UUQbKLDb/beXIYo5UHxhue3dgnXkRA93+r3RBfSu6GA0G7CDot ieGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aKbVVUf0; 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 hv21si773786ejc.609.2021.07.09.19.28.00; Fri, 09 Jul 2021 19:28:23 -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=aKbVVUf0; 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 S234279AbhGJC3U (ORCPT + 99 others); Fri, 9 Jul 2021 22:29:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:42072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233789AbhGJC1R (ORCPT ); Fri, 9 Jul 2021 22:27:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CF5AD613F3; Sat, 10 Jul 2021 02:24:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883859; bh=ck5Q6GVks57jWIqjHyZOElFXukj7+nakjKh8+cKT8/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aKbVVUf09IS76F9e3tMY4AZ1+WrwbsWTKQvDBiI+Oq3VIbKTFc1HWofy/RPmfZY4f FgsR8XtTxZZmzypMy5u587JQe1Milp9LBnhzgSIIb8wPoCQApcR9qKV56XKcMdowNI P91XTNTauSRPeIGZ5j0AcPDSCSHpu4X4qPUS/EpHSpIA84ZTCH5rSNvTqYx3lpoHAV JrgSgvA8FjDHLbsK58mVhUrPePG3uSJ80ogUDLEl5i1qd7q7GMZjjXYG5SNmG5QSSD 9cIZD1lwm2O6Fu1XboF1TUjBZ617hv3u1cpqrO9DVjQag+GQhNT3GXLYN1kdJ3VhZb WdEk4QlxnmbFg== 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 5.12 101/104] i2c: core: Disable client irq on reboot/shutdown Date: Fri, 9 Jul 2021 22:21:53 -0400 Message-Id: <20210710022156.3168825-101-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710022156.3168825-1-sashal@kernel.org> References: <20210710022156.3168825-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 f21362355973..8e4be0d4ce34 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -587,6 +588,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