Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796354619; b=j0A0nbB5Z0hpnilBHJfsA9dmVRyW4dvtcwx0y/qvoy3Mb/7hrOgb+iuyCyVt2x9OesF+ JQbGutNZHkuzlxXTEQ6WWF0p5PuC0bfw07S6tk7c7CUA0LPozlPTggQK0SXkuJoe1SCWI kGRH1tVpYhXIWh9s1CDcZRhr4u91A4VXb1D//jtEPUGqLrmEfmnxilZBidAttRJ4VAV6K hNigTd39pX1F4QoNroJO7uVpPTpyHholbnGS4+oDGwmCBfp0lHgDXkYRN77CaDKXUb7Af RlD3lq/ofWepugAhuQG0WJSEvWhoTTeSJbrGq0Uv4sSOA3la0a15aSy5klUD/wu5w6Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796354619; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=ybWU73rGCjrJ+FlyM4UYi+M19z+NKVQ8Uz7/UHkR8jM=; b=ny7Us5YztmU5EKzmYvY/6JVUHSMz16B1Nk787C1T5I4kdpR1ab6D+JdYzn+XEYiamUxy 76h5aPPYNR7bke+hiU+JHO3PWuJMtdKK3bIunn8kOPfMSpExPx8QKsGCXJdw7wXVvR5bM Ke8ORMCES2oXkUFkc2HvfkSei6Chjw346506MrSdZB2mGkKlWWyDUwRzW7qJyDBM8zv4L yOelCeoxNtMloy3PZ50rvx2yMLyZOn81OzqJTawfbOhoODestI8sVOsa8aMf6sqBpbwQQ 01bb+YP7KYTv2aYAtBd0qteECaPA+6ORfDk4QDGdLglnGKpfcGIvwjNJBccZ5XgYKrQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=xl8gEsYW; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2002606A32C; Fri, 4 Dec 2026 03:23:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=xl8gEsYW Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CA9E1F00931; Fri, 4 Dec 2026 03:23:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796354618; bh=ybWU73rGCjrJ+FlyM4UYi+M19z+NKVQ8Uz7/UHkR8jM=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=xl8gEsYW9kRvRk5J8W4txv13acjKDMZzabxrnfgWjNqdLco8ZR9NENykQu5elVlmg 9QUhrATtO1nU1Q0NBqRyFtSTzsG85o4ukBbxo1XT7GdBjvxAJ85A25j2wg96vwaUtc 3W8aEokfQ1hKB+Ym6ocCh2eRkCljPfVhZkbq4X+w= Date: Thu, 3 Dec 2026 18:53:55 +0100 From: Greg Kroah-Hartman To: Francisco =?iso-8859-1?Q?Beltr=E1n_Millal=E9n?= Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, Alan Stern , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/3] usb: hcd-pci: Honour pci_save_state() failure Message-ID: <2026120339-glaucoma-stagnant-adc8@gregkh> References: <20260930141914.6678-1-fbeltranmillalen@gmail.com> <20260930141914.6678-2-fbeltranmillalen@gmail.com> X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260930141914.6678-2-fbeltranmillalen@gmail.com> On Wed, Sep 30, 2026 at 11:19:12AM -0300, Francisco Beltrán Millalén wrote: > hcd_pci_suspend_noirq() ignores the return value of pci_save_state() and > goes on to pci_prepare_to_sleep(). > > The next patch makes pci_save_state() fail, without marking the state as > saved, when the config space of the device is not accessible. For such > a controller pci_prepare_to_sleep() does not work either: > pci_set_low_power_state() reads the PM control register as all ones and > marks the device D3cold. pci_pm_suspend_noirq() then finds a device > whose power state changed without its state being saved, and warns. > With an earlier version of the next patch on a MacBookPro14,3, whose > Thunderbolt xHCI controllers can be inaccessible at this point: > > xhci_hcd 0000:7d:00.0: PCI PM: State of device not saved by hcd_pci_suspend_noirq+0x0/0x180 > WARNING: CPU: 7 PID: 96793 at drivers/pci/pci-driver.c:888 pci_pm_suspend_noirq+0x2f4/0x300 > > Check the return value and, if the state could not be saved, return 0 > without putting the controller into a low-power state. The PCI core > then handles it as it handles a driver without a suspend_noirq callback: > it tries to save the state and to put the device into a low-power state > itself, which fails in the same way, but without the warning, as the > power state did not change inside the driver callback. > > Move the check that disables wakeup for a dead root hub ahead of it, so > that it is not skipped. > > Today pci_save_state() only fails if a capability save buffer is missing > or the VC state cannot be saved. In that case the controller is now left > in D0 instead of being put into a low-power state with an incomplete > saved state. > > Assisted-by: LLM > Signed-off-by: Francisco Beltrán Millalén > --- > v2: > - Rewrote the commit message: the failure handled here comes from the > next patch, not from pci_save_state() as it is today. > - Disable wakeup for a dead root hub before the early return. > - Dropped Alan's Acked-by because of both changes. > > drivers/usb/core/hcd-pci.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c > index cd2234759..7f8a56425 100644 > --- a/drivers/usb/core/hcd-pci.c > +++ b/drivers/usb/core/hcd-pci.c > @@ -541,8 +541,6 @@ static int hcd_pci_suspend_noirq(struct device *dev) > if (retval) > return retval; > > - pci_save_state(pci_dev); > - > /* If the root hub is dead rather than suspended, disallow remote > * wakeup. usb_hc_died() should ensure that both hosts are marked as > * dying, so we only need to check the primary roothub. > @@ -551,6 +549,19 @@ static int hcd_pci_suspend_noirq(struct device *dev) > device_set_wakeup_enable(dev, 0); > dev_dbg(dev, "wakeup: %d\n", device_may_wakeup(dev)); > > + /* > + * If the state could not be saved, most likely because the controller > + * is no longer accessible, putting it into a low-power state would > + * fail as well and leave it marked as D3cold, and the PCI core would > + * then warn that its state was not saved. Leave it to the PCI core > + * instead, as for a driver without a suspend_noirq callback. > + */ > + retval = pci_save_state(pci_dev); > + if (retval) { > + dev_dbg(dev, "--> not suspending, state not saved\n"); Why "--> "?