From nobody Mon May 11 02:06:56 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 004C0C433EF for ; Mon, 18 Apr 2022 21:01:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347918AbiDRVEX (ORCPT ); Mon, 18 Apr 2022 17:04:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347912AbiDRVEN (ORCPT ); Mon, 18 Apr 2022 17:04:13 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C5F62A25D for ; Mon, 18 Apr 2022 14:01:32 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id t4so21044400pgc.1 for ; Mon, 18 Apr 2022 14:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PsqaX0mMaHgNt26YkuFONS0WzSqOE6FUG9W4KvOufeg=; b=L/5wlo3XuKXWeDlWiHccl1mrvHuQMGk71l2/UJiNbukNtW8sBFk7L3voXHaL1t1x7c eW1iVPH/smzcAB2Fs+jUjbqUB8Mj4kNYfnfVIZZfxmdUiFjEulFXt8j/x67YiugvzWOW v6JEMH8hXeaeGAZWdVhp+rdshOfKJ9kBZSgeA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PsqaX0mMaHgNt26YkuFONS0WzSqOE6FUG9W4KvOufeg=; b=WqOw1sUj5qOBpAL6lHIyiaMwU6a6jUkWX1879UceXhwsxzhiiLGV4MhHebWkpy/lqw S0D6eKI1abjvdeHix+1UOYqI+rP+PIUPA37sHh0epZp5M3bDwaRO7uk+IdfYJ/hq8t3F G5UmJ6cR6FVr+Di5A1VosYFDFXJ1EQ/tRjoqaOJzdy2IrkTbdCDGS6zIbDc0xmB1aAu7 Kum86tlk5ZGl5Jp9q8xZMSR3qGZkDsTEAawBUIVTnbEbkvmxzAOJl1QytIfFIkhRr+M2 NP9KER8wB3QyoTRBW7owF5PK8aKw88KLBSOn9wmATBPuqCEaDcF8zophloyT68jnUqC3 M+cA== X-Gm-Message-State: AOAM532YeC/0fwRarPsYqqtM614iDzd503DxN9j4aSAQocheGgCWei76 3aR7OsJYaJ2gbCtr/H7O2fRW2w== X-Google-Smtp-Source: ABdhPJwWOGfdHF8dSOAUX+DIhWuMiCqrVT2iOcCFMnP0KBpLaFVSiKpts6tYslAe1hVJ14dNE1ac1w== X-Received: by 2002:a05:6a00:2496:b0:50a:6778:b8c1 with SMTP id c22-20020a056a00249600b0050a6778b8c1mr9247086pfv.47.1650315691606; Mon, 18 Apr 2022 14:01:31 -0700 (PDT) Received: from evgreen-glaptop.lan ([98.47.98.87]) by smtp.gmail.com with ESMTPSA id y15-20020a17090a1f4f00b001c7ecaf9e13sm14047973pjy.35.2022.04.18.14.01.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 14:01:31 -0700 (PDT) From: Evan Green To: Greg Kroah-Hartman Cc: Thomas Gleixner , Mathias Nyman , Alan Stern , Rajat Jain , Evan Green , Razvan Heghedus , Wei Ming Chen , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH v2 1/2] USB: core: Disable remote wakeup for freeze/quiesce Date: Mon, 18 Apr 2022 14:00:45 -0700 Message-Id: <20220418135819.v2.1.I2c636c4decc358f5e6c27b810748904cc69beada@changeid> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20220418210046.2060937-1-evgreen@chromium.org> References: <20220418210046.2060937-1-evgreen@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The PM_EVENT_FREEZE and PM_EVENT_QUIESCE messages should cause the device to stop generating interrupts. USB core was previously allowing devices that were already runtime suspended to keep remote wakeup enabled if they had gone down that way. This violates the contract with pm, and can potentially cause MSI interrupts to be lost. Change that so that if a device is runtime suspended with remote wakeups enabled, it will be resumed to ensure remote wakeup is always disabled across a freeze. Signed-off-by: Evan Green Acked-by: Alan Stern --- (no changes since v1) drivers/usb/core/driver.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 355ed33a21792b..93c8cf66adccec 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -1533,20 +1533,18 @@ static void choose_wakeup(struct usb_device *udev, = pm_message_t msg) { int w; =20 - /* Remote wakeup is needed only when we actually go to sleep. - * For things like FREEZE and QUIESCE, if the device is already - * autosuspended then its current wakeup setting is okay. + /* For FREEZE/QUIESCE, disable remote wakeups so no interrupts get genera= ted + * by the device. */ if (msg.event =3D=3D PM_EVENT_FREEZE || msg.event =3D=3D PM_EVENT_QUIESCE= ) { - if (udev->state !=3D USB_STATE_SUSPENDED) - udev->do_remote_wakeup =3D 0; - return; - } + w =3D 0; =20 - /* Enable remote wakeup if it is allowed, even if no interface drivers - * actually want it. - */ - w =3D device_may_wakeup(&udev->dev); + } else { + /* Enable remote wakeup if it is allowed, even if no interface drivers + * actually want it. + */ + w =3D device_may_wakeup(&udev->dev); + } =20 /* If the device is autosuspended with the wrong wakeup setting, * autoresume now so the setting can be changed. --=20 2.31.0 From nobody Mon May 11 02:06:56 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAFF0C433EF for ; Mon, 18 Apr 2022 21:01:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347926AbiDRVE2 (ORCPT ); Mon, 18 Apr 2022 17:04:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347893AbiDRVER (ORCPT ); Mon, 18 Apr 2022 17:04:17 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDA822A248 for ; Mon, 18 Apr 2022 14:01:36 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id s14so13316694plk.8 for ; Mon, 18 Apr 2022 14:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k9zAsbJbbMkbkhGPC3AiZK56sfvnFwgtRHAzZ3j6nuo=; b=LXaDrlWX1IzYqRN2I3vgl3tGCggTtV1OtXzNrURe7q91ArQBRtZK39bEfj1eR2FSJN U5QWDaSAL43GTHUwnJPVIXuSz4jZGctINjNXSlnl+HXZci4ELdfcUBNccDAhW0SFPVb7 XnaFLHO3P7c55YnsXK9dBmYtmM5mCnDTn5IuQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k9zAsbJbbMkbkhGPC3AiZK56sfvnFwgtRHAzZ3j6nuo=; b=4mx4NZnp2TP4hcENC2hNgpYSjWNpMz11yrPWa+kUjxMdfwXMn9qD3e5Me3b5NiZcaI 4JcaRB/UGC3kI8lQiWlfTwby9B41fdnXJU5cTvH9nh5kgNGh9sFSlRBw6AAxVKqUjQkv qJI3x7jct6PeL42xAYwSy6sl8Ya7pEtJCINp5IDDCyWxRsvB5x4+FMfcYb9syzys0KKd 304WI8NHtP+nrBcRSt1bBDBCta3JcqkHzOmxqb44gt65WW/wRW9ASb0cWR15HA+v7MMI bhJzhNL3nAPd/+Kp/wfcIJR7n13qeN7qwkZSVPiuYbzzmv34Jih+J/EVyu+0zKCuQ3Pm wm3Q== X-Gm-Message-State: AOAM530mjIXOkzJMy0T5U6IYlDXch4auE2wBrkyfJfztFjIfrvZlBALa /wdTs1sYmKxoJRZmxn4D5gwz1A== X-Google-Smtp-Source: ABdhPJxDQoIjPsWukM/9io/GhkgaoR5AO2cMZ4/8BJxG9Tm1JsIno+GplwiXnrxrFareEk5G+VGfQA== X-Received: by 2002:a17:902:e3c1:b0:158:faf5:a0be with SMTP id r1-20020a170902e3c100b00158faf5a0bemr6899956ple.102.1650315696029; Mon, 18 Apr 2022 14:01:36 -0700 (PDT) Received: from evgreen-glaptop.lan ([98.47.98.87]) by smtp.gmail.com with ESMTPSA id y15-20020a17090a1f4f00b001c7ecaf9e13sm14047973pjy.35.2022.04.18.14.01.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 14:01:35 -0700 (PDT) From: Evan Green To: Greg Kroah-Hartman Cc: Thomas Gleixner , Mathias Nyman , Alan Stern , Rajat Jain , Evan Green , Bjorn Helgaas , "Rafael J. Wysocki" , Youngjin Jang , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH v2 2/2] USB: hcd-pci: Fully suspend across freeze/thaw cycle Date: Mon, 18 Apr 2022 14:00:46 -0700 Message-Id: <20220418135819.v2.2.I8226c7fdae88329ef70957b96a39b346c69a914e@changeid> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20220418210046.2060937-1-evgreen@chromium.org> References: <20220418210046.2060937-1-evgreen@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The documentation for the freeze() method says that it "should quiesce the device so that it doesn't generate IRQs or DMA". The unspoken consequence of not doing this is that MSIs aimed at non-boot CPUs may get fully lost if they're sent during the period where the target CPU is offline. The current callbacks for USB HCD do not fully quiesce interrupts, specifically on XHCI. Change to use the full suspend/resume flow for freeze/thaw to ensure interrupts are fully quiesced. This fixes issues where USB devices fail to thaw during hibernation because XHCI misses its interrupt and cannot recover. Signed-off-by: Evan Green Acked-by: Alan Stern --- Changes in v2: - Added the patch modifying the remote wakeup state - Removed the change to freeze_noirq/thaw_noirq drivers/usb/core/hcd-pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index 8176bc81a635d6..ae5e6d572376be 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c @@ -616,10 +616,10 @@ const struct dev_pm_ops usb_hcd_pci_pm_ops =3D { .suspend_noirq =3D hcd_pci_suspend_noirq, .resume_noirq =3D hcd_pci_resume_noirq, .resume =3D hcd_pci_resume, - .freeze =3D check_root_hub_suspended, + .freeze =3D hcd_pci_suspend, .freeze_noirq =3D check_root_hub_suspended, .thaw_noirq =3D NULL, - .thaw =3D NULL, + .thaw =3D hcd_pci_resume, .poweroff =3D hcd_pci_suspend, .poweroff_noirq =3D hcd_pci_suspend_noirq, .restore_noirq =3D hcd_pci_resume_noirq, --=20 2.31.0