Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1473845pxu; Fri, 16 Oct 2020 12:56:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKIdS//QP3dAjMEN3Rytjkzcjf9jJF/vFwkRYntFCGZ66zeIoGBD/R84CoLXjCMpv4T0aa X-Received: by 2002:aa7:de06:: with SMTP id h6mr5792027edv.31.1602878211797; Fri, 16 Oct 2020 12:56:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602878211; cv=none; d=google.com; s=arc-20160816; b=RTZ4q2FKqefVxiGHTuDyTl79Ings8waV3eA8qPqRyu7+uC3flXz4u9nPgG6ZfqOJcn GjDY4KVm6jAUhw3ciNsyrWQDJb9q/aICNOSwBfoAy85OI0nANVlrdyiTT87EQaop0lJQ uwGlgiXAZzpVDD0EQ3e4xU2ka8UV8w3kLqpcNCXA2e14ZZYL8jUpGfBcW4EoteCh1ZsT KhOSSFba0hO8L2LLQlZosj5NQsdJunMeiQ+fxICsJysPeptmVOVa/8K0nILXmDqc6mFo LD9Okyu+r/f8lQuS79UxQnm63pceY8n6GcEpyrbxqjkM3OexvTp68Wf3EIugc7QV3Ev4 QlVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:dkim-signature; bh=iMkXsCfghoDoYrHRrQkOVjUl0T169CFkkrvO3XpulfA=; b=l4qsDdYWJdb7lq5bipnh6b5DIbzx+Zm8tvLLmw2kcpxlMrKCK2yueZnSP77eMiu07t V8tORzrwdYOeUCYmDxTHPQjLmzOOs9F35GJDxTVZZ/9HbI6l0x1UChi12FvXo2oDX+dA QFqeKsHcD/x/USWvAF8jY8rUpd2IVFEaw/LYo8sCeLGrpZ+ExUQJmdK9jA9oM+VXVbQ2 sLlJjAU2fziIE8B5sq+tvI9Ofoaw6CHUSOe2WPn1229icEWpjNMkmFA3FLmKyrbZOWmY BkVwn0LXD27XEz33IvlPajP0cxJ8xbzRtTsft/SOeiTtzy3gsxcLYr17kwyjtEFn+btv wsCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dsexvZ9g; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y9si2467970ejq.143.2020.10.16.12.56.02; Fri, 16 Oct 2020 12:56:51 -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=@gmail.com header.s=20161025 header.b=dsexvZ9g; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2409095AbgJPOmZ (ORCPT + 99 others); Fri, 16 Oct 2020 10:42:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395258AbgJPOmW (ORCPT ); Fri, 16 Oct 2020 10:42:22 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08DC2C061755; Fri, 16 Oct 2020 07:42:22 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id j8so1629932pjy.5; Fri, 16 Oct 2020 07:42:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=iMkXsCfghoDoYrHRrQkOVjUl0T169CFkkrvO3XpulfA=; b=dsexvZ9gAreNbK3jvwKyURTWrMJHVAHgjkl/HT1BkfF8GmAVC8RIrkJ1ciemAwmgSp NVl3x3YhQ0HYB29u1o53bTfpn/36j5WvsVVFPG0aINWioScLvjcIzhTVzXY7cLyZc79B xyyRaKD/jMkwBxG0dKNIYtf5HbR5DWXptetg231LFXyUkVfjpYm5v5ekNciO6i+LyJG/ 5RZF2eyDoyUfa1z+Q8ATE9bTXtk9UZ7CI6fecdRSvzO9wQTXYFjw2/NjpV7tmdwsEGTc S8ZNBrzqa4ZvDdq1ZnJHqeJQqAtdOVL2bIC7CjHBJJFqbUvHZtW8SjEffEBhJJC23r4W FAPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=iMkXsCfghoDoYrHRrQkOVjUl0T169CFkkrvO3XpulfA=; b=UzfUGmkEQmSUd5fsfmDCu+2ZuI3PwGWXIcf+PFw2jSjPWyGFDM4+tc4CX6Llm6ruc9 TfVji5SJIvbhxkpODmSB880e5Nv7Emhfd/4Tr3kKepdzL+odCv/RpdxaT1ZJQnL+eJX0 9De3Lm0p+kG/nG+jt8Xih9CIZDV2HzemvF1/LAedFl//+rU4y+8hvV9NMoCyzXVxMhTX ATihF9DRyt6gSlNoC9gG/njmiEu7LdBbTyFxHHc6PJDqFH3O2RNuTy/uUWoqi9LVm8Xh /HEAhqpQI0dCA/ARtzXf4B1MZUIdoEtvrMo6kUo1Vv/ZqPD4ZJ9QPuWM6LdZsH/KWiON HFKg== X-Gm-Message-State: AOAM532Jwbsiq1YhrxNxrY+R9HCSklYzMTx13QC5zUafGa27clFWT8Kz B5vCWpcBOj7kYX2poUKACBU= X-Received: by 2002:a17:90b:4a10:: with SMTP id kk16mr4470498pjb.77.1602859341566; Fri, 16 Oct 2020 07:42:21 -0700 (PDT) Received: from localhost ([160.16.113.140]) by smtp.gmail.com with ESMTPSA id p6sm3468203pjd.1.2020.10.16.07.42.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Oct 2020 07:42:20 -0700 (PDT) From: Coiby Xu X-Google-Original-From: Coiby Xu Date: Fri, 16 Oct 2020 22:32:00 +0800 To: =?utf-8?Q?Barnab=C3=A1s_P=C5=91cze?= Cc: "linux-input@vger.kernel.org" , Jiri Kosina , Benjamin Tissoires , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] HID: i2c-hid: add polling mode based on connected GPIO chip's pin status Message-ID: <20201016143200.tev62sbttbac5kci@Rk> References: <20201009081100.3154-1-coiby.xu@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Barnabás, Thank you for reviewing theis patch! I've Cced a new version to you. On Thu, Oct 15, 2020 at 10:33:50AM +0000, Barnabás Pőcze wrote: >Hi, > >I believe this patch causes I2C HID devices not to work with IRQs after resuming >from suspend. > > >> [...] >> #ifdef CONFIG_PM_SLEEP >> @@ -1183,7 +1292,8 @@ static int i2c_hid_suspend(struct device *dev) >> /* Save some power */ >> i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); >> >> - disable_irq(client->irq); >> + if (polling_mode == I2C_POLLING_DISABLED) >> + disable_irq(client->irq); >> > >The IRQ is disabled when suspending if polling is *off*. > > >> if (device_may_wakeup(&client->dev)) { >> wake_status = enable_irq_wake(client->irq); >> @@ -1216,7 +1326,7 @@ static int i2c_hid_resume(struct device *dev) >> >> if (ihid->pdata.post_power_delay_ms) >> msleep(ihid->pdata.post_power_delay_ms); >> - } else if (ihid->irq_wake_enabled) { >> + } else if (ihid->irq_wake_enabled && polling_mode != I2C_POLLING_DISABLED) { > >As a side note, I'm not sure if the 'polling_mode != I2C_POLLING_DISABLED' part >is necessary (or that it's necessary *here*). It causes 'i2c_hid_resume' and >'i2c_hid_suspend' to be "asymmetric" which - I believe - may cause problems. > > >> wake_status = disable_irq_wake(client->irq); >> if (!wake_status) >> ihid->irq_wake_enabled = false; >> @@ -1225,7 +1335,8 @@ static int i2c_hid_resume(struct device *dev) >> wake_status); >> } >> >> - enable_irq(client->irq); >> + if (polling_mode != I2C_POLLING_DISABLED) >> + enable_irq(client->irq); >> > >The IRQ is enabled when resuming if polling is *on*. It should be enabled if polling is *off* >in my opinion. > > >> [...] > > >Regards, >Barnabás Pőcze -- Best regards, Coiby