Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1813313iog; Thu, 16 Jun 2022 14:34:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vP2bZWax7rFvbdqPpQW6J9x3sOMrpTvfXoaOs0QoJ5GZweeKJFvRxPscPhnKGvtt8cPajq X-Received: by 2002:a63:9255:0:b0:40a:89f9:7c5f with SMTP id s21-20020a639255000000b0040a89f97c5fmr4616465pgn.621.1655415245467; Thu, 16 Jun 2022 14:34:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655415245; cv=none; d=google.com; s=arc-20160816; b=pzHHrSaRTNsBDy/AApOaJy3g+ePNwwiVg8OMuQMWqwLw8mTThUTf8qfatNsBgMItWe +a5TbCRSZ9/OvN9dSTrVcY5mQRYBznCW/PiTUIZv65yrbKfkAEG/tI0BqbrNEjvREp64 /x8yPEZoUeJRPidN1+hX9bWNf58xD+tfrDuaAaSvFJPhZZ7DFijhNMSFTVqSy3S4jty+ e6lCoBqq7R5r1d7rrjwXPVWdNbZX0xbhiFAq2dgTGqDnfByHozlYpdTKYQTASvNmF61J 8kYhcO+p1k19/PqJxIUZazrKkZeooOQFsBigOMDorbBMGJ1H09HyzRQ7lIeOxl98qiTj Qebg== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kV95XOZEvIgZqOCOy3gdqWE+09foABFf9GAdklbo6zM=; b=ve7g2u+0bQFd3qyaOQ61nJ70DV9/N6RA7GjtAoJQDZ607ANAuimrsMcrMfhldeLDeR dA0TRxEi8rmTdylVqGjbEGBMYfN8uYxdBdXcXDYttr5DkD+JB2TElgaT0qW3R00B/t+u 6C6spHzxItReeCKK0A4mUroN9syQEUwZ2Ecxv4u4dxGnispGf2dP9mcQwBQfidrLsqXs 7PutvPYm9Eg/BQfPWiJhrh3lzQS0HNS56VxxGjGppZb1tZxweRIRAJxYFvfJ7v92cIyd IrLNfPJyuFO4j7fovnHj089qlSo0pCEMItir8dE0Q7Qx6EOiJXF6jP0TZY00AsRAZD8T Qjfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZjWHAJa0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 1-20020a630b01000000b003fc88542b01si3554127pgl.208.2022.06.16.14.33.52; Thu, 16 Jun 2022 14:34:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZjWHAJa0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379047AbiFPV2Q (ORCPT + 99 others); Thu, 16 Jun 2022 17:28:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378766AbiFPV2M (ORCPT ); Thu, 16 Jun 2022 17:28:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37BC1EE3D; Thu, 16 Jun 2022 14:28:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C7DD661DE4; Thu, 16 Jun 2022 21:28:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1A52C34114; Thu, 16 Jun 2022 21:28:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655414888; bh=1CU5zyC7ahylIILyU2GxX1JPoG9KI5pbPGCBjCkKTCE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZjWHAJa0Rzbf1BhYH02gP+CLc68+xt2yAwgeWczotqS9sPE/UEsEoyogEFo4+C/4H hasXwXq9MxQBTv69F0ozW9kxDXsD0mK3/F09OUb4ZLixFi3FT8NgPmhCEsPawE2Nxh lL5bIgfx8sCit7qmIZugBpyLczHa1ga94f0KBzuE= Date: Thu, 16 Jun 2022 23:28:05 +0200 From: Greg KH To: Mario Limonciello Cc: Jiri Kosina , Benjamin Tissoires , "open list:USB HID/HIDBP DRIVERS [USB KEYBOARDS, MICE, REM..." , "open list:HID CORE LAYER" , open list , Richard Gong Subject: Re: [PATCH v2] HID: usbhid: set mouse as a wakeup resource Message-ID: References: <20220616183142.14472-1-mario.limonciello@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220616183142.14472-1-mario.limonciello@amd.com> X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 16, 2022 at 01:31:42PM -0500, Mario Limonciello wrote: > The USB HID transport layer doesn't set mice for wakeup by default so users > can not wake system from s2idle using wired USB mouse. However, users can > wake the same system from Modern Standby on Windows with the same wired > USB mouse. > > Microsoft documentation indicates that all USB mice and touchpads should > be waking the system from Modern Standby. To align expectations from users > make this behavior the same when the system is configured by the OEM and > the user to use s2idle in Linux. > > Link: https://docs.microsoft.com/en-us/windows-hardware/design/device-experiences/modern-standby-wake-sources#input-devices-1 > Link: https://lore.kernel.org/linux-usb/20220404214557.3329796-1-richard.gong@amd.com/ > Suggested-by: Richard Gong > Signed-off-by: Mario Limonciello > --- > More people keep coming to us confused that they couldn't wake a Linux system > up from sleep using a mouse, so this patch is being revived. How many different devices did you test this on? > > Microsoft documentation doesn't indicate any allowlist for this behavior, and > they actually prescribe it for all USB mice and touchpads. > v1->v2: > * Resubmit by Mario > * Update commit message > * Only activate on systems configured by user and OEM for using s2idle > > drivers/hid/usbhid/hid-core.c | 36 ++++++++++++++++++++++++----------- > 1 file changed, 25 insertions(+), 11 deletions(-) > > diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c > index 4490e2f7252a..3a1214ecec49 100644 > --- a/drivers/hid/usbhid/hid-core.c > +++ b/drivers/hid/usbhid/hid-core.c > @@ -12,6 +12,7 @@ > /* > */ > > +#include > #include > #include > #include > @@ -26,6 +27,7 @@ > #include > #include > #include > +#include > > #include > > @@ -1176,17 +1178,29 @@ static int usbhid_start(struct hid_device *hid) > usb_autopm_put_interface(usbhid->intf); > } > > - /* Some keyboards don't work until their LEDs have been set. > - * Since BIOSes do set the LEDs, it must be safe for any device > - * that supports the keyboard boot protocol. > - * In addition, enable remote wakeup by default for all keyboard > - * devices supporting the boot protocol. > - */ > - if (interface->desc.bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT && > - interface->desc.bInterfaceProtocol == > - USB_INTERFACE_PROTOCOL_KEYBOARD) { > - usbhid_set_leds(hid); > - device_set_wakeup_enable(&dev->dev, 1); > + if (interface->desc.bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT) { > + switch (interface->desc.bInterfaceProtocol) { > + /* Some keyboards don't work until their LEDs have been set. > + * Since BIOSes do set the LEDs, it must be safe for any device > + * that supports the keyboard boot protocol. > + * In addition, enable remote wakeup by default for all keyboard > + * devices supporting the boot protocol. > + */ > + case USB_INTERFACE_PROTOCOL_KEYBOARD: > + usbhid_set_leds(hid); > + device_set_wakeup_enable(&dev->dev, 1); > + break; > +#ifdef CONFIG_ACPI Why a #ifdef? > + /* Setup remote wakeup by default for mice supporting boot > + * protocol if the system supports s2idle > + */ > + case USB_INTERFACE_PROTOCOL_MOUSE: > + if (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0 && That seems odd, there's no acpi/pm call for this instead? > + pm_suspend_default_s2idle()) > + device_set_wakeup_enable(&dev->dev, 1); > + break; > +#endif thanks, greg k-h