Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp23532pxj; Wed, 2 Jun 2021 23:18:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz90jGi+OkfuAu+aKqCxQwkSStNcz6RnJF+u0x/7eXjc0ettK+6GN+TlmOsyx27rQIAuq24 X-Received: by 2002:a17:906:fcb4:: with SMTP id qw20mr16142036ejb.344.1622701109023; Wed, 02 Jun 2021 23:18:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622701109; cv=none; d=google.com; s=arc-20160816; b=zVUMuEE+G3JPij+F0PrDRfiC4ItKHvQaqmzy3QPcoXrWOjewEtVEFYfrAk0W5vrW/b f+burD9Vr7o2fwQRHFjzHil4bBhHYVGLVnGHKt0C6gfDDaQA2OInDsqHvpWBllWAvkXq 8/UF84z5tAO0gyzuifbPrKTQfZlfMjtOjoMfyOewPsmcc2PmYvCgUL3VLr5//zHgsEHO Jc1kFxIOu4LfIl897+csG5IMI+a4BJnyaVpfAz36j8Z2QCOxQTgoa/UVeOQ2HOyz25Qc bCPyX0766oR8UKsNmzzE25+o8UFQIKP3lN7QlAp4q3j688mJsy+t9Y25M5Rrw7+5oM03 AA2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:user-agent:from :references:in-reply-to:mime-version:dkim-signature; bh=e3PDKrL5MVOFhdI4AdMvQfhjcpRkxau04Ply0138w7E=; b=KS+qqOTBnTKzbHdua41JZtv6FbVJN4mMo9y/5IL9sgQAUd5S1Q9Xl7nzm726qyOFq3 TKx/Wg0GF1TebclsOxbAN3r6wkxbQjATIiNAJOapqNss6M44zFxaOrDReh1lZmpOYYVN cu/L5iw0RCnMFmu6wEIHeWBdXGs60lQbH1KKC3oqH2K23sCUnvNfVOFTM3hq9kKY67nm mOKXkZhuksdbBsCkutD1lzTFaLqk16tWc+QPLxUoNUfyUpg9d1huSD42ycgXxxjGpafg IQNo0FeowDhhE7BuBqqT4uz4o29grL53YkTTYEPdk5h74MQQwwJCMP8y3oWOkjSAo3ZE ZaQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LAemQ8PV; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p21si1193896ejn.31.2021.06.02.23.18.01; Wed, 02 Jun 2021 23:18:29 -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=@chromium.org header.s=google header.b=LAemQ8PV; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229685AbhFCGQc (ORCPT + 99 others); Thu, 3 Jun 2021 02:16:32 -0400 Received: from mail-oi1-f171.google.com ([209.85.167.171]:39739 "EHLO mail-oi1-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbhFCGQc (ORCPT ); Thu, 3 Jun 2021 02:16:32 -0400 Received: by mail-oi1-f171.google.com with SMTP id m137so1359703oig.6 for ; Wed, 02 Jun 2021 23:14:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:user-agent:date:message-id :subject:to:cc; bh=e3PDKrL5MVOFhdI4AdMvQfhjcpRkxau04Ply0138w7E=; b=LAemQ8PV7z/sZ5epDYtMuLEXUGtStxQKEHRht7XgX/IxKUJiGCdh0Eplyp1k9ExmQo bcurPq3MV8FHoiU9iybK/cgbxOzbSfVwIlWcrO47AuMn9lHDa8W4aPQgI9V2SmCZboCS 1IKUirWjiGGLdTW2Dy00FWB7sqnBp+gPaN2gM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from :user-agent:date:message-id:subject:to:cc; bh=e3PDKrL5MVOFhdI4AdMvQfhjcpRkxau04Ply0138w7E=; b=ZD5T/KsEI/+7RHOZm/Yf95fASz8VuwXm69j15Qo1982CEoqZ/lAQq4Rowh8wuaU1ow jW5xJs95TAeFwj/1rL/ShXWloAtmUxPKjgRaYZHUOLDtiFhlA+5w8IlSOdb7fIaM0icI ajNPMBKGMuhxc/K6bV1nUCbbZrtUCASpR/9bx47eXEX0vGXPbsEof8I5O7SwYJf9Xo70 kiPWutJtDjlh1JihM6Yvq/7WPFMNn13rkygFNnndSKnaL6wtXl/e/k7KX+SLraA1D7Wp g7iZDoNTkG1u4gP17JT4p1xcwjgL1wGAlTPaTxPbfawq6/By9LKikmbm+nklEq78fnql gaMw== X-Gm-Message-State: AOAM531P8jx8xCZO2Tu/r1WCjNNP4mDBxXzkBIw2hUDYmBCk1/k49oy8 i/2UJjY+A7zVgfm+qYYP88J04sMSHJZvWg6uS0FpdA== X-Received: by 2002:a54:4501:: with SMTP id l1mr24414113oil.19.1622700820736; Wed, 02 Jun 2021 23:13:40 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Wed, 2 Jun 2021 23:13:40 -0700 MIME-Version: 1.0 In-Reply-To: References: <20210510220012.2003285-1-swboyd@chromium.org> From: Stephen Boyd User-Agent: alot/0.9.1 Date: Wed, 2 Jun 2021 23:13:40 -0700 Message-ID: Subject: Re: [PATCH] Input: elan_i2c: Disable irq on shutdown To: Dmitry Torokhov Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, Jingle Wu , Wolfram Sang Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Dmitry Torokhov (2021-06-02 21:33:41) > On Wed, Jun 02, 2021 at 06:33:49PM -0700, Stephen Boyd wrote: > > Quoting Dmitry Torokhov (2021-06-02 18:18:17) > > > > > > I do not think keeping counter balanced would be important here, as we > > > are shutting down, and upon reboot everything will be reinitialized from > > > scratch. Also, we are lucky in that there is just a handful of I2C > > > drivers defining shutdown() methods. > > > > > > > Please don't make me shave this yak. > > > > > > I'm afraid someone has to... I'm adding Wolfram to CC to get his take on > > > this. > > > > > > > I suppose another option would be to introduce some common function that > > i2c drivers can use for their shutdown op, like i2c_generic_shutdown() > > that would disable the irq? I would guess that it isn't a great idea to > > blanket disable the irq in case some i2c driver wants to do something > > that may require that irq to come in once more during shutdown to signal > > that things are off or something like that. > > > > Would having this common function that this driver opts into work for > > you? > > Opting in in this fashion will still require changes in the majority > of drivers (any I2C touchscreen or touchpad may be touched while system > is being shut down, so all of them will need to have interrupt freed or > disabled, or they may initiate I2C transfer). How about something like > this; Yes, this approach should work. I assume a device that doesn't have a shutdown function will be happy to let the i2c core disable the irq for it so it looks low risk. Will you send a proper patch to Wolfram or would you like me to wrap it up and resend? > > diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c > index 38107c0c318c..c835e7bb71de 100644 > --- a/drivers/i2c/i2c-core-base.c > +++ b/drivers/i2c/i2c-core-base.c > @@ -603,9 +603,12 @@ static void i2c_device_shutdown(struct device *dev) > > if (!client || !dev->driver) > return; > + > 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) >