From patchwork Wed Sep 12 10:22:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anisse Astier X-Patchwork-Id: 10597321 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1DD2E14DB for ; Wed, 12 Sep 2018 10:22:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CE54299A8 for ; Wed, 12 Sep 2018 10:22:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00CE6299FE; Wed, 12 Sep 2018 10:22:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07FD1299A8 for ; Wed, 12 Sep 2018 10:22:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726672AbeILP0a (ORCPT ); Wed, 12 Sep 2018 11:26:30 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35631 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726552AbeILP0a (ORCPT ); Wed, 12 Sep 2018 11:26:30 -0400 Received: by mail-wr1-f66.google.com with SMTP id j26-v6so1442529wre.2 for ; Wed, 12 Sep 2018 03:22:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=astier-eu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=Pzb3heL5nxEfriSRCDVlN/EG+0jCFBQx7qeTalatyaA=; b=powzP+dBtJGdUQiWohO/KILy4oxS4+SU2MTCYo2bYQ50IkDeBJQe7cpm+dUfIPZO7B w9CS1n4D1I2SIQQJrDLwYR6iturYl3s3NuWRtQOIIXBLFsOpzkAHBJSpc9NmSvs4WWT+ VIIAG3l0UIMA8mq5N3cQVweHRLGDEk3+tzNVnQSx/cl2YTOutL4Dw99WHp87bPceVboZ 6Ywku+vfa7xOdl39Noexjb5LQRSyjovuwCwd5xIbeYDuwl2IvdOKYyoE1IOp1Db/KzVb fQVKQUi8Fk0n43uPRpdOGBOD5ZaIQ+zqYXpee2ZhsmT0WMqyonMXLTOfnMcrH00whXGT DmnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Pzb3heL5nxEfriSRCDVlN/EG+0jCFBQx7qeTalatyaA=; b=kvqyrgV1lzYPgZqsaKnan+7VfI79fMIzCKBymF0FWRfZCmVH4chCeKkN+i1ZsZooEq NCiRGwpcMpjzx7VVYu/HuM5VLBRkoDOEuKTrgIr2ij7LZBlS8WOH+225KQir0/BGxDEn CFLmXvzKsIjH1zwwNUuyk7Cfa6J+uY6Z6F4PMsoxPJAOefAhfEqrXgiEdYrciOuCMtBE X2fAjp9m0Cbko80eD37J9Lr068wTHWxAO/CB0IR5HDf+oqqq0zQlimVIkCc5+Ha5Uqqz E463uB+1+Ler9b5P6NakCwF1yMJEp6D3RrxMaaqCgiSoVM9ENaeMkAuzO8/epSJcwp6Z JA8A== X-Gm-Message-State: APzg51DTGtmjRMF2TOgevU9lN5V2k4R+Co7w0vXPUyBn1evDRtG2dED1 7cH3hda/IFg8MgEg7K1RhMiXakmawNg= X-Google-Smtp-Source: ANB0VdYh6bz7Q3JKo9o6pduAGosmRcDiiuxgDLht8ymdG4JsqW87RxLxBoaPC664LIXPDw+cXhmMTw== X-Received: by 2002:adf:8b50:: with SMTP id v16-v6mr996465wra.282.1536747756271; Wed, 12 Sep 2018 03:22:36 -0700 (PDT) Received: from jaya.substantiel.local ([92.103.140.194]) by smtp.gmail.com with ESMTPSA id x16-v6sm633522wro.84.2018.09.12.03.22.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Sep 2018 03:22:35 -0700 (PDT) From: Anisse Astier To: linux-input@vger.kernel.org Cc: Anisse Astier , Jiri Kosina , Benjamin Tissoires , Hans de Goede , Dmitry Torokhov Subject: [PATCH] HID: i2c-hid: slower runtime PM operations on hantick touchpad Date: Wed, 12 Sep 2018 12:22:13 +0200 Message-Id: <20180912102213.12518-1-anisse@astier.eu> X-Mailer: git-send-email 2.17.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This hantick HTIX5288 touchpad can quickly fall in a wrong state if there are too many open/close operations. This will either make it stop reporting any input, or will shift all the input reads by a few bytes, making it impossible to decode. Here, we synchronously block the the runtime suspend by 2.5 seconds; this was found experimentally, and sleeping less will not result in a non-working touchpad. This quirk will also result in a non-responsive touchpad for 2.5s if userspace closes, then opens a device quickly, but this was deemed an appropriate compromise versus a non-working touchpad. This fast repetition of sleep/wakeup is also more likely to happen when using runtime PM, which is why the quirk is done there, and not for all power downs, which would include suspend or module removal. Signed-off-by: Anisse Astier Cc: stable@vger.kernel.org --- This patch feels a bit hack-ish, but I don't really know how to debug this issue further. I'm looking forward to your feedback. Regards, Anisse drivers/hid/i2c-hid/i2c-hid.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index 847b55ad0d60..f894d9225df6 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c @@ -48,6 +48,7 @@ #define I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV BIT(0) #define I2C_HID_QUIRK_NO_IRQ_AFTER_RESET BIT(1) #define I2C_HID_QUIRK_RESEND_REPORT_DESCR BIT(2) +#define I2C_HID_QUIRK_SLOW_DOWN_RUNTIME_PM BIT(3) /* flags */ #define I2C_HID_STARTED 0 @@ -172,6 +173,8 @@ static const struct i2c_hid_quirks { I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV }, { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288, I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, + { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288, + I2C_HID_QUIRK_SLOW_DOWN_RUNTIME_PM }, { USB_VENDOR_ID_SIS_TOUCH, USB_DEVICE_ID_SIS10FB_TOUCH, I2C_HID_QUIRK_RESEND_REPORT_DESCR }, { 0, 0 } @@ -1259,6 +1262,10 @@ static int i2c_hid_resume(struct device *dev) static int i2c_hid_runtime_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); + struct i2c_hid *ihid = i2c_get_clientdata(client); + + if (ihid->quirks & I2C_HID_QUIRK_SLOW_DOWN_RUNTIME_PM) + msleep(2500); i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); disable_irq(client->irq);