Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3884880pxv; Mon, 19 Jul 2021 11:05:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyA1JA1/YDaGXt+ji2AlbixiYi59DtYfoOUXMiWCe7k+nGK0bYS2dNrrON0XD5vB9YX8jr6 X-Received: by 2002:a17:906:8683:: with SMTP id g3mr29355869ejx.126.1626717923503; Mon, 19 Jul 2021 11:05:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626717923; cv=none; d=google.com; s=arc-20160816; b=f8TDBVB25VbGCDaRgapBaBZNqA6uivJZ0GB15UrLYgQ3yLdXgnNro773wcdo+izNxY WPR4xHAD6Qj8FWE63ab8xkktwZE4wAKDAvQtxEvBCtFGToRIJXQbtGelF4a3+YsXPHJ7 0g/+9sg/0cbCqKhpKRhJlALF8PNQOtWQ2S62x/iopG/4S51mdVV+AiVpirCQnq/locXg x2eh7ZtIzdBelrTp/beISJAKV0tyY4stg10xk+zVqUAGC+TI43Svv6JF4JLyoRLAX4rN mTccKyOe1fULJEk1ZIHq7hE5S9+TjIrn5GQDEfojugLYkzeZ7bFHL5ufmxLsOtiKP/yi txSQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0Sd1h8N5jKS7yzhbazPMiwPU9nwi5hSLPd/R7QjOG3E=; b=esLGkrf9OGeuB5kz1uYTVMSM1vSkuSVTU6c75pO7pMxEQXYGuAkU11kKJq2xbhaPqx GNpuqr/8+7doKUGoXw2WTDboRgSe17xMiFGpv81UH19g14t3IhFa6+WdHQab9iSerR2R ElHtBzvqUUQeyPDP8rogv2p5bO32MHSEPd5lNbPeefUmF52OaLdCYh2BLSuX98W/Zax6 JDGYbgmpVZCcPYh1RIti+WI6NUA4XWrGdRiWxIZL38Z6VWsb4PTI7Kn1yFDO1+0qCkaX Tmd16HXAQ8I3Etk7EjmfrbaFwjT9AM/97EF0EEdwrQEF3rZMWQAN3E8uVI9WEJlXPN2G FLOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HWAFKjcI; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bm12si22291837edb.430.2021.07.19.11.05.00; Mon, 19 Jul 2021 11:05: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=@linuxfoundation.org header.s=korg header.b=HWAFKjcI; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245415AbhGSRXH (ORCPT + 99 others); Mon, 19 Jul 2021 13:23:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:43678 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348734AbhGSPoX (ORCPT ); Mon, 19 Jul 2021 11:44:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8F0C361431; Mon, 19 Jul 2021 16:22:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626711774; bh=ck5Q6GVks57jWIqjHyZOElFXukj7+nakjKh8+cKT8/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HWAFKjcI01It41nBasDH9xQbPfzE6PeTHH18mAJk6SMHYF207XFBtIcG1m73dyR01 LGYmx1XK0wIuWBg0JidzSY7gpjE4TfZZ7P6tMAzWIWm9YJ3z48zgx8S1XbqAtLbfIf jYJJxQ5vUkpZ9eDFv5Q/OMhsGnQMR+OuzLwXM+uU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Stephen Boyd , Dmitry Torokhov , Wolfram Sang , Sasha Levin Subject: [PATCH 5.12 128/292] i2c: core: Disable client irq on reboot/shutdown Date: Mon, 19 Jul 2021 16:53:10 +0200 Message-Id: <20210719144946.688893811@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144942.514164272@linuxfoundation.org> References: <20210719144942.514164272@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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