Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1180732rwo; Wed, 2 Aug 2023 09:51:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlGeUdwkhg+ZgOhT5XcshEchq0TvvuOXWxd6Re0SQEsK+HHzihnJj57JD0KiNaTwLTW5NDu+ X-Received: by 2002:a17:907:b0a:b0:975:942e:81e7 with SMTP id h10-20020a1709070b0a00b00975942e81e7mr5254797ejl.37.1690995089084; Wed, 02 Aug 2023 09:51:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690995089; cv=none; d=google.com; s=arc-20160816; b=azV6rwAHw734yravgwwRlheeC2s5zNdzAfm+1rKR87erCq7oxqWLiBo+hrilYOot9O wCb84FX6H3lLDxl6Fm2N5JUAJz6t1GiapUl7W+D2EnEsh3zkIJGcdT0IiC4TD5XUAsTT 8QkQ0zWKb4IHPYc9wdi68rt0q9j3tASJocllVvM/fqG9ZoX4tyCz1I8ZSVCHPsBE+/pl 9HVs9rQ76uUvSfCLAw/q+GBO+bPZnU5uslTfQKt7dnIPyNAGy5U0MXS+eMY8LlmOm6Ea BGCZ02rXqYQctWXhqyxLmWHXiJOeQhEpQF9BSiDqqgqlXj7CwpX9CePqjibXjsa65kXt q/kw== 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; bh=lJitv8Jy1wIcZk+FtHedKj28d5MGMy3cbD4Ta0ujhxw=; fh=JhfcjkTWP3AH/HEPRyp1G02o9cOOlx+LygWGhEcqrGg=; b=acYCKE2n/ClytR8zq6Ii6R+Loc9Q0WfBOZ69Ull8WVzM099FMN8LlniJpsUVdNkeqK +0IC4ZuiNjg2RoYOKcKt/IRiwsE/ARoWe1yWE8ofFNWYqZw6500PTa3FePr4npw3tcH/ UP0KkZLQf6UzKU/SdDV8S7E2iuYw/ZP9BxpSM9Xv7vol8WjaS+RwQdYVAovhog9w5XKh o+MTy2Wsl2r2ElWGiBLUifCML1bBV1XbdB2r6XkngbHo+7R6GxHvxmw1+Aqfpt4okk4/ nxKn7/tgfxDFZ6gTxabhBIWeo5NhEumRaIt7MIbh7TPnKmIhxjxjnzFzxqlrfB/a2UTg IVEA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q23-20020a170906a09700b00997e71d0377si1347581ejy.366.2023.08.02.09.51.04; Wed, 02 Aug 2023 09:51:29 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235207AbjHBP0l (ORCPT + 99 others); Wed, 2 Aug 2023 11:26:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235232AbjHBP0X (ORCPT ); Wed, 2 Aug 2023 11:26:23 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id D5F0244BA for ; Wed, 2 Aug 2023 08:23:52 -0700 (PDT) Received: (qmail 207244 invoked by uid 1000); 2 Aug 2023 11:23:46 -0400 Date: Wed, 2 Aug 2023 11:23:46 -0400 From: Alan Stern To: "Gagniuc, Alexandru" Cc: "linux-usb@vger.kernel.org" , "netdev@vger.kernel.org" , "davem@davemloft.net" , "edumazet@google.com" , "kuba@kernel.org" , "pabeni@redhat.com" , "hayeswang@realtek.com" , "jflf_kernel@gmx.com" , "bjorn@mork.no" , "svenva@chromium.org" , "linux-kernel@vger.kernel.org" , "Zhang, Eniac" , "stable@vger.kernel.org" Subject: Re: [PATCH v2] r8152: Suspend USB device before shutdown when WoL is enabled Message-ID: References: <2c12d7a0-3edb-48b3-abf7-135e1a8838ca@rowland.harvard.edu> <20230719173756.380829-1-alexandru.gagniuc@hp.com> <3c4fd3d8-2b0b-492e-aacc-afafcea98417@rowland.harvard.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 Wed, Aug 02, 2023 at 02:56:43PM +0000, Gagniuc, Alexandru wrote: > On Wed, Jul 19, 2023 at 02:36:25PM -0400, Alan Stern wrote: > > On Wed, Jul 19, 2023 at 05:37:56PM +0000, Alexandru Gagniuc wrote: > > > For Wake-on-LAN to work from S5 (shutdown), the USB link must be put > > > in U3 state. If it is not, and the host "disappears", the chip will > > > no longer respond to WoL triggers. > > > > > > To resolve this, add a notifier block and register it as a reboot > > > notifier. When WoL is enabled, work through the usb_device struct to > > > get to the suspend function. Calling this function puts the link in > > > the correct state for WoL to function. > > > > How do you know that the link will _remain_ in the correct state? > > The objective is to get to xhci_set_link_state() with the USB_SS_PORT_LS_U3 > argument. This is achieved through usb_port_suspend() in drivers/usb/host/hub.c, > and the function is implemented in drivers/usb/host/xhci-hub.c. > > This is the only path in the kernel that I am aware of for setting the U3 link > state. Given that it is part of the USB subsystem, I am fairly confident it will > show consistent behavior across platforms. That does not answer my question. I agree that making this change will put the link into the U3 state. But I don't have any reason to think that some other software won't later put the link into some other state. > > That is, how do you know that the shutdown processing for the USB host > > controller won't disable the link entirely, thereby preventing WoL from > > working? > > We are talking to the USB hub in order to set the link state. I don't see how > specifics of the host controller would influence behavior. Specifics of the host controller probably won't influence behavior. However, specifics of the _software_ can make a big difference. > I do expect a > controller which advertises S4/S5 in /proc/acpi/wakeup to not do anything that > would sabotage this capability. Disabling the link entirely would probalby > violate that promise. Not if the kernel _tells_ the controller to disable the link. > Think of USB-C docks with a power button showing up as a HID class. The scenario > herein would disable the power button. I would take that to be a bug in the host > controller driver if the S4/S5 capability is advertised. Indeed. And I am asking how you can be sure the host controller driver (or some other part of the software stack) doesn't have this bug. Alan Stern