Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp323349pxu; Thu, 15 Oct 2020 05:04:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVjNqerX3ICjMxV7O6agO1CIR3HoIbhnXM2f1WaAGwlkNegxxIyXJBC5if30gQ/0zWnWkE X-Received: by 2002:a17:906:2b83:: with SMTP id m3mr3988694ejg.456.1602763459577; Thu, 15 Oct 2020 05:04:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602763459; cv=none; d=google.com; s=arc-20160816; b=Krbyn7069WxaPSme49s1ssuVWztayXqR7n2njCTscZB3szzlbJtjmDVBvP5jfRrAcw VOk3qnirM6TL+30ppMYxxgyLwOi9rvBPqOXgGS2nJ4u/1nxRCe0vzWxRUYjQi494/8dr AB7ET8JIGbNVrKp+/NhQJBg4Md33l/ypJ4WgNedNb9dDJEppGdenO/JFd1g0+QzKk6Ks c/YmXt4nYIkyypnnm7BLuxubOWi5EvBW7JSKb/HVRMRuuAE4Ms5bMZnuuOpfqNcAKtJk U2aMnHmTw0WG1/B8OWVLcfjE4IM7dVQBvuW5YzwYN2OCRojr4QRzTSrRArXRdIYpVpny w3iQ== 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:subject:reply-to:cc:from:to :dkim-signature:date; bh=LmKMfbM7Hkdq+2pNRnuptrCxbTHKyZc4+lIHOhhd0oc=; b=uHvMnPOsLHOQPAgPwpAkgN66QRGD9tv6a7uvFJsLolnRqxF4YuzMWq5MGysODYwQWp T2uJlR11iXd+Bu65Vq2ZHvpaF+5Mi1ERw2MHqF44AQ4M5z1wD9cTODu83VNg+7e7XNIK GZRqpedUrVlRuDTPdXMdgJfKjwDauM9yVZO4+g0QfldSIA9/HijASERIVEYd2vnwiidu 4FB5i9texJKLkKeZEbwt9Lm3z7cqhl5hR9QP+H1YFAPmKSDWp6JE0YEWTo/c/cqj4oJI TMb6LSh8JxozDVgZdbgq/dGZzarwEID2SNr5y8Uez74Tv6IUII7h288fMvOTL/7fbVet 779A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail header.b=YI2wAXus; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fy1si1922333ejb.649.2020.10.15.05.03.51; Thu, 15 Oct 2020 05:04:19 -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=@protonmail.com header.s=protonmail header.b=YI2wAXus; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731173AbgJOKeB (ORCPT + 99 others); Thu, 15 Oct 2020 06:34:01 -0400 Received: from mail-03.mail-europe.com ([91.134.188.129]:48906 "EHLO mail-03.mail-europe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726280AbgJOKeA (ORCPT ); Thu, 15 Oct 2020 06:34:00 -0400 Date: Thu, 15 Oct 2020 10:33:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1602758036; bh=LmKMfbM7Hkdq+2pNRnuptrCxbTHKyZc4+lIHOhhd0oc=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=YI2wAXusKjmgO/3QlwNAbO5kcl95jZbDDF9Mx7+1C06FP2QBrSwUIP3ZQFV7b6HEE C4aA04BWM+070lhYyjxe5ZD4YFmThIq5IvgAxfniUIndgXsxtk3hyp6J+tnL7DZYKO JF+fjW04QWCV/jinBEYE6zIfT4weD2ql71BPDbIY= To: Coiby Xu From: =?utf-8?Q?Barnab=C3=A1s_P=C5=91cze?= Cc: "linux-input@vger.kernel.org" , Jiri Kosina , Benjamin Tissoires , "linux-kernel@vger.kernel.org" Reply-To: =?utf-8?Q?Barnab=C3=A1s_P=C5=91cze?= Subject: Re: [PATCH] HID: i2c-hid: add polling mode based on connected GPIO chip's pin status Message-ID: In-Reply-To: <20201009081100.3154-1-coiby.xu@gmail.com> References: <20201009081100.3154-1-coiby.xu@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, I believe this patch causes I2C HID devices not to work with IRQs after res= uming from suspend. > [...] > #ifdef CONFIG_PM_SLEEP > @@ -1183,7 +1292,8 @@ static int i2c_hid_suspend(struct device *dev) > =09/* Save some power */ > =09i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); > > -=09disable_irq(client->irq); > +=09if (polling_mode =3D=3D I2C_POLLING_DISABLED) > +=09=09disable_irq(client->irq); > The IRQ is disabled when suspending if polling is *off*. > =09if (device_may_wakeup(&client->dev)) { > =09=09wake_status =3D enable_irq_wake(client->irq); > @@ -1216,7 +1326,7 @@ static int i2c_hid_resume(struct device *dev) > > =09=09if (ihid->pdata.post_power_delay_ms) > =09=09=09msleep(ihid->pdata.post_power_delay_ms); > -=09} else if (ihid->irq_wake_enabled) { > +=09} else if (ihid->irq_wake_enabled && polling_mode !=3D I2C_POLLING_DI= SABLED) { As a side note, I'm not sure if the 'polling_mode !=3D I2C_POLLING_DISABLED= ' part is necessary (or that it's necessary *here*). It causes 'i2c_hid_resume' an= d 'i2c_hid_suspend' to be "asymmetric" which - I believe - may cause problems= . > =09=09wake_status =3D disable_irq_wake(client->irq); > =09=09if (!wake_status) > =09=09=09ihid->irq_wake_enabled =3D false; > @@ -1225,7 +1335,8 @@ static int i2c_hid_resume(struct device *dev) > =09=09=09=09wake_status); > =09} > > -=09enable_irq(client->irq); > +=09if (polling_mode !=3D I2C_POLLING_DISABLED) > +=09=09enable_irq(client->irq); > The IRQ is enabled when resuming if polling is *on*. It should be enabled i= f polling is *off* in my opinion. > [...] Regards, Barnab=C3=A1s P=C5=91cze