Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1148539pxv; Fri, 9 Jul 2021 19:33:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4jUovb/qEnxra8aB4he5KRDwcY+THANN9kcpHWXrZ5VG257CnnbQw+3/1wZf0l4do8JCF X-Received: by 2002:a05:6402:4311:: with SMTP id m17mr31701364edc.346.1625884426329; Fri, 09 Jul 2021 19:33:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884426; cv=none; d=google.com; s=arc-20160816; b=trcpMzK808Nup2Rujm5/He/kh9Hc/gRPAXIEFrV3HLG9fD+VAVxZqMWpK9TBBHDuIa 51RqpE2mEZ7urnal/7C3zUKJjgetepD86lznqXxRdQSybl32AQObdN+OFuj1iZUETZIx a3Gsj1wz9VBtHMYFmlth5AwPAZHyNOMglHT8ppeH2XWbyYZt/Xmt/1s2L3hhvJEw4jBQ Z5PytmKRDEQNYYxFcu395WGPb1j6pfBkd4uoq7CUShx5HRx0X+HhpDSVSb/rNa9kaY2F J9HaHfFd2k3NSeHJ3XCJ8bsruB2VR4WIY9yqcSxAXW458lyi2HXwBOetzT+P3Yj2qb1g HEAg== 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=N1SbPuz1+gp96sI9WfJdskNaapazIKQrrXdnAgFobIU=; b=Haq8M+AYi1r7uqMpOnqM1d+zcYCep/kFer4B50H5pYPmj/pAO+YlIezei+BK/CZYpx pMxvoRTvpxm4daMFiPitMPpBXhaQO1GhbIF5dG+tB1EMAEascT2FjGbd0noAffEokXS9 ++edKx/zT85dEOCndXAvGQADVYKyEilHt5FS8qLhPnPchWjluUGM5LtaJ71MDT6f4Wnh MWnYyi3CDl25pK+c1CbJSPrGrzk6EPfQG6SH5U6HOfVpFf1jigzy044poEqKJJZgb6xQ ftkOSHmOkEBH61/cr5KM73Cd5IrauHEJCijWAIjfKcHtLgzSpzLfKPTif8yzJKFgxRo3 Yo4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OSV3ql4N; 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 j23si10630847eje.719.2021.07.09.19.33.23; Fri, 09 Jul 2021 19:33:46 -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=OSV3ql4N; 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 S235354AbhGJCep (ORCPT + 99 others); Fri, 9 Jul 2021 22:34:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:43064 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234773AbhGJC3o (ORCPT ); Fri, 9 Jul 2021 22:29:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A8BBD613AF; Sat, 10 Jul 2021 02:26:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625884020; bh=jVncZAnMggGZeg3UTgJN68Hmf3jbpO01ey4iR3L8YYo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OSV3ql4NYqlHmeOjkyBnoBy4f4iHwN/FB7Zt6rvKc85PchwGkBW8bop/ag2GthWzT ij8zVvmRoRQj6/KI2gcwnFcM8to8Tv7+VRwJT4hGbPESg0odXZC9CkcYODSzaPAkUR ayrtFDrAG2HHXfOCM+dGPylEDZJBeeXFTk4uzRXX/eIf7J6sF0fklc7eNZnClrqx3S Dw2wa6XaTo1o/Gd4C8LKm37tUPWantQDGmrdOuj6oCjjpPTqmUlQ69i9mu1eixs7Ca yW3y7MBqV54oL376DbM5+1+eq2Y2nrks8mpvUJr5Ah4aIggTu/5xiroLmdSOFXKEC4 UYkA6gjwfwdHg== 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.10 90/93] i2c: core: Disable client irq on reboot/shutdown Date: Fri, 9 Jul 2021 22:24:24 -0400 Message-Id: <20210710022428.3169839-90-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710022428.3169839-1-sashal@kernel.org> References: <20210710022428.3169839-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 c13e7f107dd3..bdce6d3e5327 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 @@ -585,6 +586,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