From patchwork Wed Nov 6 07:26:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Chiu X-Patchwork-Id: 2007269 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XjxbL5wY3z1xxf for ; Wed, 6 Nov 2024 18:26:37 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1t8aQn-0000B5-L5; Wed, 06 Nov 2024 07:26:21 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1t8aQl-00007n-Ho for kernel-team@lists.ubuntu.com; Wed, 06 Nov 2024 07:26:19 +0000 Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 57D623F215 for ; Wed, 6 Nov 2024 07:26:19 +0000 (UTC) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-20e67b82aa6so72695105ad.0 for ; Tue, 05 Nov 2024 23:26:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730877977; x=1731482777; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v8JhAAq3VNZ6mRKv3l1NVTItU2YpQrwcUU5U4QqkVcU=; b=IB1t1Qhk/UO9pL7Ked6KJ3J+HMHAvQj/3bv4D8gDhsShnJDIHcmErZZVNO62vaf7Zn qVWlF7YZB7pbXci56jpUoEqmffabCPoadankTSRHCyhZw6K0TGshvYp8QAoDhHg5nxNF HJpmx4rBKTYNMNNm7PL26UD+UbIvcBWwIZQmxoyj2zFuCki9WwZwVUgLTcU6Ypy4XXn2 fignYkkf49jczn657EFYBb/XVQ+VFyj4moNbG/uU6WkjcZjMKAl0Jm9MIJqHICjYwenV eHt4GYVa3adSH9jiSmPl7nic/fpG3fYCQ/J7KH/bRYtxdi2RXzZYugo8zkTvwMZHnKFm Hf3Q== X-Gm-Message-State: AOJu0YwCA49MUWhr5olLq6zzAUK7JK39CE5WuLJ0AIHCPul9WnMp5nxc 1++18IX1v59VdX39JNAx3Pg7cGWH+T/Fb9gG0j6pk2LGcLl4LaMz8jLSWubGs3xCBLoI6ucevXr 352h6EQsBdh05iqDQ7G3fUh8RLmysqIFpZdkWAXAQ64cTPE3igF5xcqgvh9prUsBGlOFx5Pk0dw MgX0PPM47kq1z6 X-Received: by 2002:a17:902:dacf:b0:20c:7be3:2832 with SMTP id d9443c01a7336-2111af6c545mr275037555ad.31.1730877977287; Tue, 05 Nov 2024 23:26:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IH6Cr6beM+qUqalFUsSMACJcJUiO9e6blVXKilEvTtxVEL0FgZHR4jiHjhp0HMxU1kWtUGcLg== X-Received: by 2002:a17:902:dacf:b0:20c:7be3:2832 with SMTP id d9443c01a7336-2111af6c545mr275037345ad.31.1730877976878; Tue, 05 Nov 2024 23:26:16 -0800 (PST) Received: from u-XPS-9320.. (114-36-196-194.dynamic-ip.hinet.net. [114.36.196.194]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211056ee3e4sm90221045ad.3.2024.11.05.23.26.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2024 23:26:16 -0800 (PST) From: Chris Chiu To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/1][SRU][N] UBUNTU: SAUCE: USB: Fix the issue of task recovery failure caused by USB status when S4 wakes up Date: Wed, 6 Nov 2024 15:26:13 +0800 Message-Id: <20241106072613.95472-2-chris.chiu@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241106072613.95472-1-chris.chiu@canonical.com> References: <20241106072613.95472-1-chris.chiu@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Duan Chenghao https://bugs.launchpad.net/bugs/2085410 When a device is inserted into the USB port and an S4 wakeup is initiated, after the USB-hub initialization is completed, it will automatically enter suspend mode. Upon detecting a device on the USB port, it will proceed with resume and set the hcd to the HCD_FLAG_WAKEUP_PENDING state. During the S4 wakeup process, peripherals are put into suspend mode, followed by task recovery. However, upon detecting that the hcd is in the HCD_FLAG_WAKEUP_PENDING state, it will return an EBUSY status, causing the S4 suspend to fail and subsequent task recovery to not proceed. - [ 27.594598][ 1] PM: pci_pm_freeze(): hcd_pci_suspend+0x0/0x28 returns -16 [ 27.594601][ 1] PM: dpm_run_callback(): pci_pm_freeze+0x0/0x100 returns -16 [ 27.603420][ 1] ehci-pci 0000:00:04.1: pci_pm_freeze+0x0/0x100 returned 0 after 3 usecs [ 27.612233][ 1] ehci-pci 0000:00:05.1: pci_pm_freeze+0x0/0x100 returned -16 after 17223 usecs [ 27.810067][ 1] PM: Device 0000:00:05.1 failed to quiesce async: error -16 [ 27.816988][ 1] PM: quiesce of devices aborted after 1833.282 msecs [ 27.823302][ 1] PM: start quiesce of devices aborted after 1839.975 msecs ...... [ 31.303172][ 1] PM: recover of devices complete after 3473.039 msecs [ 31.309818][ 1] PM: Failed to load hibernation image, recovering. [ 31.348188][ 1] PM: Basic memory bitmaps freed [ 31.352686][ 1] OOM killer enabled. [ 31.356232][ 1] Restarting tasks ... done. [ 31.360609][ 1] PM: resume from hibernation failed (0) [ 31.365800][ 1] PM: Hibernation image not present or could not be loaded. The "do_wakeup" is determined based on whether the controller's power/wakeup attribute is set. The current issue necessitates considering the type of suspend that is occurring. If the suspend type is either PM_EVENT_FREEZE or PM_EVENT_QUIESCE, then "do_wakeup" should be set to false. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202410151722.rfjtknRz-lkp@intel.com/ Signed-off-by: Alan Stern Signed-off-by: Duan Chenghao (cherry picked from commit https://lore.kernel.org/linux-usb/20241024024038.26157-1-duanchenghao@kylinos.cn/) Signed-off-by: Chris Chiu --- drivers/usb/core/hcd-pci.c | 15 +++++++++++++-- include/linux/pm.h | 3 ++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index ee3156f49533..c7637eefa2fc 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c @@ -421,7 +421,12 @@ static int suspend_common(struct device *dev, pm_message_t msg) bool do_wakeup; int retval; - do_wakeup = PMSG_IS_AUTO(msg) ? true : device_may_wakeup(dev); + if (PMSG_IS_AUTO(msg)) + do_wakeup = true; + else if (PMSG_NO_WAKEUP(msg)) + do_wakeup = false; + else + do_wakeup = device_may_wakeup(dev); /* Root hub suspend should have stopped all downstream traffic, * and all bus master traffic. And done so for both the interface @@ -520,6 +525,11 @@ static int hcd_pci_suspend(struct device *dev) return suspend_common(dev, PMSG_SUSPEND); } +static int hcd_pci_freeze(struct device *dev) +{ + return suspend_common(dev, PMSG_FREEZE); +} + static int hcd_pci_suspend_noirq(struct device *dev) { struct pci_dev *pci_dev = to_pci_dev(dev); @@ -589,6 +599,7 @@ static int hcd_pci_restore(struct device *dev) #else #define hcd_pci_suspend NULL +#define hcd_pci_freeze NULL #define hcd_pci_suspend_noirq NULL #define hcd_pci_poweroff_late NULL #define hcd_pci_resume_noirq NULL @@ -623,7 +634,7 @@ const struct dev_pm_ops usb_hcd_pci_pm_ops = { .suspend_noirq = hcd_pci_suspend_noirq, .resume_noirq = hcd_pci_resume_noirq, .resume = hcd_pci_resume, - .freeze = hcd_pci_suspend, + .freeze = hcd_pci_freeze, .freeze_noirq = check_root_hub_suspended, .thaw_noirq = NULL, .thaw = hcd_pci_resume, diff --git a/include/linux/pm.h b/include/linux/pm.h index a2f3e53a8196..2f62035969a6 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -570,7 +570,8 @@ const struct dev_pm_ops name = { \ { .event = PM_EVENT_AUTO_RESUME, }) #define PMSG_IS_AUTO(msg) (((msg).event & PM_EVENT_AUTO) != 0) - +#define PMSG_NO_WAKEUP(msg) (((msg).event & \ + (PM_EVENT_FREEZE | PM_EVENT_QUIESCE)) != 0) /* * Device run-time power management status. *