Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3779842pxv; Mon, 19 Jul 2021 08:33:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhAqXN2eHaFeB+jbNWmVtwBJKbUzzB21+JHN1zAwqnJF2e93II9kgvSB3ZK2IJEORZFO6f X-Received: by 2002:a50:fd8e:: with SMTP id o14mr35169137edt.80.1626708821517; Mon, 19 Jul 2021 08:33:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626708821; cv=none; d=google.com; s=arc-20160816; b=OIJK9I3PdTLDoNNkTP/Q4ehPW3oukdHjGmnPdRv2jw1uG/DFrD4hiZyqZ0G8DkVEsc KmpGrf9vXnLth8bY9Zf92ozHfw3uADtCwbOsBi2Qqcfy0Ko4I0Z1MJMlZZyF45+wl7QD t/XbKT2SltBnTg2FN/oN59Wt9560ZZ0OxiEvOOQXSWKY+lN6sGUW1rKuXey2isLV9k0c HKNyKisScBajd/i1SDFiXnR/fWflf40biNNlGKcQcPXur9ka67+zR2QP1iewxmH029yC Wi9EUBsuhpFNKs5VNNYSG8tAon9LIuo0GrQpcly1P2Mt2N4sDbGvuGkR68QYZ9zOkj5b RJBg== 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=vheicLGx/SBWgHt9bHcvanNbg+ZU6IiPo8vcO1CLhRg=; b=J5KFtJ0iUaUMulY7untAQ4C+GouWPuFnUwz3JOPsxi+8PHR4gh3SCNj1zBC0cn0aVf NZteA/AwhSgqw8rb7Rr3kqtn2IKT5PDyEGl8Ve1dp5/FLmzwBNeSFve/r9aiDDTveFrE ejdS5v0r+zfdCxUKZavUBCa83LNWhKd9oP5uxZHX/x2d0QBmrcNXGq7+/hzN/FtFCO5t ScfDtSSG2b/WrLr7NqVhqyJi7nsHjyIqYBGtpmTa1JBtUaixdCopWczr/5h67FypeYJ3 5qB3s5t6DyQFvmP7rDmdpRQMPuFy+LorWQiKrO2DJGtBqJM8e4KQAlI4I6auRCiWksrz rV+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=owuGBLZ+; 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 o5si21464655edq.76.2021.07.19.08.33.19; Mon, 19 Jul 2021 08:33:41 -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=owuGBLZ+; 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 S238193AbhGSOoa (ORCPT + 99 others); Mon, 19 Jul 2021 10:44:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:46720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242893AbhGSOb4 (ORCPT ); Mon, 19 Jul 2021 10:31:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1FB3760720; Mon, 19 Jul 2021 15:12:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707545; bh=BC0d3JEZTjVg/cD/fz//KnLazwuydKt7zuKa+28OpfY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=owuGBLZ+woZlKUM7wzibP7/A2NjW+YklKGLzkPIVyIXHZH3M8icF5E8QFIBDBBXkH lwj9KB3GoUpWCXXuGz9U7uHiqoZferYMku6Zicoh3WsxlpY70fj4m3j9iBhhnho2sz kNl6ojDSuigAbHRj1dtxSN2NhigwrPDcfRbv64wE= 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 4.9 206/245] i2c: core: Disable client irq on reboot/shutdown Date: Mon, 19 Jul 2021 16:52:28 +0200 Message-Id: <20210719144947.063704746@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.288257948@linuxfoundation.org> References: <20210719144940.288257948@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.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 4fd7bfda2f9d..67e44e990777 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -1003,6 +1004,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