From patchwork Thu Sep 15 12:09:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 1678261 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=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=ASVs5EqY; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (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 4MSwy844Fqz1ypd for ; Thu, 15 Sep 2022 22:10:24 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1oYnh9-0007c0-8g; Thu, 15 Sep 2022 12:10:15 +0000 Received: from smtp-relay-canonical-0.internal ([10.131.114.83] helo=smtp-relay-canonical-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oYngz-0007Js-Kd for kernel-team@lists.ubuntu.com; Thu, 15 Sep 2022 12:10:05 +0000 Received: from HP-EliteBook-840-G7.. (1-171-215-55.dynamic-ip.hinet.net [1.171.215.55]) (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-canonical-0.canonical.com (Postfix) with ESMTPSA id 33DCC3FA03 for ; Thu, 15 Sep 2022 12:10:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1663243802; bh=0tdWuDv8NpO6hSWQSi5882ioB0bKvrM1pmERq+LGoaI=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ASVs5EqYQPtzTYAGqDV49RoGDTzuLpziU7Xn1aC7mG7K9VEuLHaIRcXO16RhhtaEM ahy36G1E9OF2dEECaVCobzv2ZHZPIMJ9QbA+yWHadl0A17YMRCrfF6kFBb59LZ+nEV 0B2MaEUWrkUpfPP69y+TUz2hYRbX/J4DH7HKqVodSjx+WxA0g9kNeXlFwdr1pJAyx0 PgmskBwxweLf52TCVdqQfEUTUwy+2zuTEPGTmC65xlzS57phvGq7VHGeuz32eA8+dX 4l4YvgGWtxif68c9UUvf8zgSR+/KKthiwDynvMbxxjMBAEjPThZYOHSCjJG5U8E26V gjimIHeiaRzyw== From: Kai-Heng Feng To: kernel-team@lists.ubuntu.com Subject: [J/K/Unstable/OEM-5.17/OEM-6.0] [PATCH 10/10] UBUNTU: SAUCE: PCI/PM: Simplify pci_pm_suspend_noirq() Date: Thu, 15 Sep 2022 20:09:33 +0800 Message-Id: <20220915120933.91333-12-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220915120933.91333-1-kai.heng.feng@canonical.com> References: <20220915120933.91333-1-kai.heng.feng@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: Rajvi Jingar BugLink: https://bugs.launchpad.net/bugs/1988797 We always want to save the device state unless the driver has already done it. Rearrange the checking in pci_pm_suspend_noirq() to make this more clear. No functional change intended. [bhelgaas: commit log, rewrap comment] Link: https://lore.kernel.org/r/20220830104913.1620539-1-rajvi.jingar@linux.intel.com Signed-off-by: Rajvi Jingar Signed-off-by: Bjorn Helgaas Reviewed-by: Rafael J. Wysocki (cherry picked from commit 4c00cba122f3f3ae54aa5a3a1aec3afc7a2e6f94 git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git pci/pm) Signed-off-by: Kai-Heng Feng --- drivers/pci/pci-driver.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 5d8c37c3e15a2..107d77f3c8467 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -873,20 +873,15 @@ static int pci_pm_suspend_noirq(struct device *dev) } } - if (pci_dev->skip_bus_pm) { + if (!pci_dev->state_saved) { + pci_save_state(pci_dev); + /* - * Either the device is a bridge with a child in D0 below it, or - * the function is running for the second time in a row without - * going through full resume, which is possible only during - * suspend-to-idle in a spurious wakeup case. The device should - * be in D0 at this point, but if it is a bridge, it may be - * necessary to save its state. + * If the device is a bridge with a child in D0 below it, + * it needs to stay in D0, so check skip_bus_pm to avoid + * putting it into a low-power state in that case. */ - if (!pci_dev->state_saved) - pci_save_state(pci_dev); - } else if (!pci_dev->state_saved) { - pci_save_state(pci_dev); - if (pci_power_manageable(pci_dev)) + if (!pci_dev->skip_bus_pm && pci_power_manageable(pci_dev)) pci_prepare_to_sleep(pci_dev); }