From patchwork Sat May 29 15:14:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12287935 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FA0BC4708F for ; Sat, 29 May 2021 15:14:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 02751611CA for ; Sat, 29 May 2021 15:14:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229821AbhE2PQL (ORCPT ); Sat, 29 May 2021 11:16:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58581 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229814AbhE2PQK (ORCPT ); Sat, 29 May 2021 11:16:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622301273; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KbLduYRKwqWTfuSOSbe1GKOQIYkXZyV7Z64Q3lIATZE=; b=MDdvWvXTD9HnUDJAXxKVplzgv0s9NfhLluJ3Fu7xrCO3qGSQjeAeAytDPOLyBgFmuyhb/5 HxnC8AXO52qQ9oeJNVE/pZ3FiJXXrwuNT5Zrr+JW3qDk+2vZH+PQD6ROD0tbaTe/a+gCfR K9SqtrMQtojSBdqRfBn1GsYOoauCA3Q= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-594-RotmWBvoP8OX4WVFFXeJPw-1; Sat, 29 May 2021 11:14:32 -0400 X-MC-Unique: RotmWBvoP8OX4WVFFXeJPw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6AAAF1007476; Sat, 29 May 2021 15:14:31 +0000 (UTC) Received: from x1.localdomain (ovpn-112-39.ams2.redhat.com [10.36.112.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E8121002F12; Sat, 29 May 2021 15:14:30 +0000 (UTC) From: Hans de Goede To: Jiri Kosina , Benjamin Tissoires Cc: Hans de Goede , linux-input@vger.kernel.org Subject: [PATCH 1/4] HID: core: Add hid_hw_may_wakeup() function Date: Sat, 29 May 2021 17:14:21 +0200 Message-Id: <20210529151424.12212-2-hdegoede@redhat.com> In-Reply-To: <20210529151424.12212-1-hdegoede@redhat.com> References: <20210529151424.12212-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add a hid_hw_may_wakeup() function, which is the equivalent of hid_hw_may_wakeup() for hid devices. In most cases this just returns device_may_wakeup(hdev->dev.parent), but for some ll-drivers this is not correct. E.g. usb_hid_driver instantiated hid devices have their parent set to the usb-interface to which the usb_hid_driver is bound, but the power/wakeup* sysfs attributes are part of the usb-device, which is the usb-interface's parent. For these special cases a new may_wakeup callback is added to hid_ll_driver, so that ll-drivers can override the default behavior. Signed-off-by: Hans de Goede Reviewed-by: Benjamin Tissoires --- include/linux/hid.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/hid.h b/include/linux/hid.h index 271021e20a3f..4d2b2212f079 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -800,6 +800,7 @@ struct hid_driver { * @raw_request: send raw report request to device (e.g. feature report) * @output_report: send output report to device * @idle: send idle request to device + * @may_wakeup: return if device may act as a wakeup source during system-suspend */ struct hid_ll_driver { int (*start)(struct hid_device *hdev); @@ -824,6 +825,7 @@ struct hid_ll_driver { int (*output_report) (struct hid_device *hdev, __u8 *buf, size_t len); int (*idle)(struct hid_device *hdev, int report, int idle, int reqtype); + bool (*may_wakeup)(struct hid_device *hdev); }; extern struct hid_ll_driver i2c_hid_ll_driver; @@ -1149,6 +1151,22 @@ static inline int hid_hw_idle(struct hid_device *hdev, int report, int idle, return 0; } +/** + * hid_may_wakeup - return if the hid device may act as a wakeup source during system-suspend + * + * @hdev: hid device + */ +static inline bool hid_hw_may_wakeup(struct hid_device *hdev) +{ + if (hdev->ll_driver->may_wakeup) + return hdev->ll_driver->may_wakeup(hdev); + + if (hdev->dev.parent) + return device_may_wakeup(hdev->dev.parent); + + return false; +} + /** * hid_hw_wait - wait for buffered io to complete * From patchwork Sat May 29 15:14:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12287937 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5990C4708E for ; Sat, 29 May 2021 15:14:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A53D611CA for ; Sat, 29 May 2021 15:14:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229816AbhE2PQM (ORCPT ); Sat, 29 May 2021 11:16:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37905 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229814AbhE2PQL (ORCPT ); Sat, 29 May 2021 11:16:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622301274; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C1TPDTcbBTXZRJi9ZK9OMh/WSxdQzPTC8wUsE47BhLI=; b=WqJprCpyh8yOOR6+pAex3aFpk9wu65wV6tHu5o1V4iAJ9pDGsM8uB/4t8GH2EW0a06TY8U 0oQaRlN4fmkUgAExNMlOVgc7PIgFxWf0rwdg3Kd7UdmWBz56KsHywjgwZBxD3jnNTKflMs RmSxf0lRVeJefTU3qopx/CU4gQ7jY3I= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-104-zWncVgEXO8idmkjC8-gziA-1; Sat, 29 May 2021 11:14:33 -0400 X-MC-Unique: zWncVgEXO8idmkjC8-gziA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9AED4801AEE; Sat, 29 May 2021 15:14:32 +0000 (UTC) Received: from x1.localdomain (ovpn-112-39.ams2.redhat.com [10.36.112.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF1AF1002F12; Sat, 29 May 2021 15:14:31 +0000 (UTC) From: Hans de Goede To: Jiri Kosina , Benjamin Tissoires Cc: Hans de Goede , linux-input@vger.kernel.org Subject: [PATCH 2/4] HID: usbhid: Implement may_wakeup ll-driver callback Date: Sat, 29 May 2021 17:14:22 +0200 Message-Id: <20210529151424.12212-3-hdegoede@redhat.com> In-Reply-To: <20210529151424.12212-1-hdegoede@redhat.com> References: <20210529151424.12212-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Without a ll-driver callback hid_hw_may_wakeup() will return: device_may_wakeup(hdev->dev.parent), usb_hid_driver instantiated hid devices have their parent set to the usb-interface to which the usb_hid_driver is bound, but the power/wakeup* sysfs attributes are part of the usb-device. Add a may_wakeup ll-driver callback which calls device_may_wakeup() on the usb-device instead. Signed-off-by: Hans de Goede --- drivers/hid/usbhid/hid-core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 86257ce6d619..3d792c6f1b1a 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -1304,6 +1304,13 @@ static int usbhid_idle(struct hid_device *hid, int report, int idle, return hid_set_idle(dev, ifnum, report, idle); } +static bool usbhid_may_wakeup(struct hid_device *hid) +{ + struct usb_device *dev = hid_to_usb_dev(hid); + + return device_may_wakeup(&dev->dev); +} + struct hid_ll_driver usb_hid_driver = { .parse = usbhid_parse, .start = usbhid_start, @@ -1316,6 +1323,7 @@ struct hid_ll_driver usb_hid_driver = { .raw_request = usbhid_raw_request, .output_report = usbhid_output_report, .idle = usbhid_idle, + .may_wakeup = usbhid_may_wakeup, }; EXPORT_SYMBOL_GPL(usb_hid_driver); From patchwork Sat May 29 15:14:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12287941 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE29EC4708E for ; Sat, 29 May 2021 15:14:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 97DDA61185 for ; Sat, 29 May 2021 15:14:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229822AbhE2PQP (ORCPT ); Sat, 29 May 2021 11:16:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50555 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229800AbhE2PQP (ORCPT ); Sat, 29 May 2021 11:16:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622301278; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3Kh8T+AK8scQOjBC5Y4/SiEqv6hgY4HLxT3AttZvNDo=; b=P1nut5tXVYlpdfugh+j9jBW4pmJCAP6cpoN9PdFcudRoJzAlrix8BWbtXPJEyNRbn4rhOU nDDt+iIVUWz5ggiiZAKcE+e8CSpNTDdrcv7t1ApTXoxv2a3Y8bHd9nloO+xy/9FRuvAcUg 05iaBOSX2GOJdHSTaTLmM3+UuRE5VDg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-5-W5Pmr6_aPHuE64K3jGt43g-1; Sat, 29 May 2021 11:14:34 -0400 X-MC-Unique: W5Pmr6_aPHuE64K3jGt43g-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C9A59107ACCA; Sat, 29 May 2021 15:14:33 +0000 (UTC) Received: from x1.localdomain (ovpn-112-39.ams2.redhat.com [10.36.112.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE3D6100AE43; Sat, 29 May 2021 15:14:32 +0000 (UTC) From: Hans de Goede To: Jiri Kosina , Benjamin Tissoires Cc: Hans de Goede , linux-input@vger.kernel.org Subject: [PATCH 3/4] HID: logitech-dj: Implement may_wakeup ll-driver callback Date: Sat, 29 May 2021 17:14:23 +0200 Message-Id: <20210529151424.12212-4-hdegoede@redhat.com> In-Reply-To: <20210529151424.12212-1-hdegoede@redhat.com> References: <20210529151424.12212-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Without a ll-driver callback hid_hw_may_wakeup() will return: device_may_wakeup(hdev->dev.parent), but for the hid devices instantiated by logitech-dj for devices behind the receiver the logitech-dj hid(pp)-device is the parent. Add a logi_dj_ll_may_wakeup() callback which calls hid_hw_may_wakeup() on the logitech-dj hid(pp) parent-hid-device. Signed-off-by: Hans de Goede --- drivers/hid/hid-logitech-dj.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c index 18d37b3765f3..a0017b010c34 100644 --- a/drivers/hid/hid-logitech-dj.c +++ b/drivers/hid/hid-logitech-dj.c @@ -1497,6 +1497,13 @@ static void logi_dj_ll_stop(struct hid_device *hid) dbg_hid("%s\n", __func__); } +static bool logi_dj_ll_may_wakeup(struct hid_device *hid) +{ + struct dj_device *djdev = hid->driver_data; + struct dj_receiver_dev *djrcv_dev = djdev->dj_receiver_dev; + + return hid_hw_may_wakeup(djrcv_dev->hidpp); +} static struct hid_ll_driver logi_dj_ll_driver = { .parse = logi_dj_ll_parse, @@ -1505,6 +1512,7 @@ static struct hid_ll_driver logi_dj_ll_driver = { .open = logi_dj_ll_open, .close = logi_dj_ll_close, .raw_request = logi_dj_ll_raw_request, + .may_wakeup = logi_dj_ll_may_wakeup, }; static int logi_dj_dj_event(struct hid_device *hdev, From patchwork Sat May 29 15:14:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12287939 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D690C47082 for ; Sat, 29 May 2021 15:14:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E5A37611CA for ; Sat, 29 May 2021 15:14:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229814AbhE2PQO (ORCPT ); Sat, 29 May 2021 11:16:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47738 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229800AbhE2PQO (ORCPT ); Sat, 29 May 2021 11:16:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622301277; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E6z2KQCwXUL7cBDRQvr6zbE2G+6RgL/BGKju6hE72/M=; b=N9aZRWDfQCgQyF4zruvWEFovYGZyCgVXfX4p4uQXv0wO8JqRHp7d9BgmkUTvk4zC16X8nj Si+Kjacz+5kg2xHLU7XXeRWPHR5OBhCOCIlECHKllQx9T3mUzpIkjhgyyguEWFJ3P3AGL7 cg7gWpB3o1ycLpyHOC1GFjOSmpn5NO8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-223-XP-5NVgGNNGc1lsJtZ2u2Q-1; Sat, 29 May 2021 11:14:36 -0400 X-MC-Unique: XP-5NVgGNNGc1lsJtZ2u2Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 06551800FF0; Sat, 29 May 2021 15:14:35 +0000 (UTC) Received: from x1.localdomain (ovpn-112-39.ams2.redhat.com [10.36.112.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A6631002F12; Sat, 29 May 2021 15:14:33 +0000 (UTC) From: Hans de Goede To: Jiri Kosina , Benjamin Tissoires Cc: Hans de Goede , linux-input@vger.kernel.org Subject: [PATCH 4/4] HID: multitouch: Disable event reporting on suspend when the device is not a wakeup-source Date: Sat, 29 May 2021 17:14:24 +0200 Message-Id: <20210529151424.12212-5-hdegoede@redhat.com> In-Reply-To: <20210529151424.12212-1-hdegoede@redhat.com> References: <20210529151424.12212-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Disable event reporting on suspend when the hid device is not a wakeup-source. This should help save some extra power in this case. Signed-off-by: Hans de Goede --- drivers/hid/hid-multitouch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index cfb68e443ddd..c5a7523f97ac 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -1764,7 +1764,8 @@ static int mt_suspend(struct hid_device *hdev, pm_message_t state) struct mt_device *td = hid_get_drvdata(hdev); /* High latency is desirable for power savings during S3/S0ix */ - if (td->mtclass.quirks & MT_QUIRK_DISABLE_WAKEUP) + if ((td->mtclass.quirks & MT_QUIRK_DISABLE_WAKEUP) || + !hid_hw_may_wakeup(hdev)) mt_set_modes(hdev, HID_LATENCY_HIGH, false, false); else mt_set_modes(hdev, HID_LATENCY_HIGH, true, true);