From patchwork Tue Oct 11 03:41:39 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: 1688449 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=Y/jQ+ebI; 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 4MmhSp62vLz20cX for ; Tue, 11 Oct 2022 14:43:06 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1oi6AT-0006GH-BL; Tue, 11 Oct 2022 03:42:57 +0000 Received: from smtp-relay-canonical-1.internal ([10.131.114.174] helo=smtp-relay-canonical-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oi6AP-00066o-Q5 for kernel-team@lists.ubuntu.com; Tue, 11 Oct 2022 03:42:53 +0000 Received: from localhost.localdomain (unknown [10.101.196.174]) (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-1.canonical.com (Postfix) with ESMTPSA id 8028742C01 for ; Tue, 11 Oct 2022 03:42:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1665459770; bh=NfKDTluRxkwvYYDCusp2X9Xq9W7PYla2Fa16l2wHEAs=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Y/jQ+ebIQxFM+yhQ8sQaeD3g4mNGeDRRovP7XG09r/MrhGRR58qfKb3jpav7ypIL0 SI3rP7pjjSZg/QfMECfdQAZ0b+160nSIfx4cVO7MkPkgHblMc9qC5DRngXTY+pY4Qz caioqPS4qkHeHjHZaVXVIwhtVUNuVqLs3zTTJhT5GQd2LiwjgIb2GCS/Uz8DjjyMNf BHTTJlkKDLVgDFubdelASMsDrw4xScJ+MKFM/s41j2MH9R9ShSGQU6dmrQq+5mFvmO G+mkcT9YxCEdXOFgI0lGQT/+tJw0PcylA9oqnlnTiRPqU0Wt2ssjG+fCjytk6/kWNV 05vTE15O+QU7Q== From: Kai-Heng Feng To: kernel-team@lists.ubuntu.com Subject: [J/K] [PATCH 10/10] PCI/PM: Simplify pci_pm_suspend_noirq() Date: Tue, 11 Oct 2022 11:41:39 +0800 Message-Id: <20221011034139.731146-12-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221011034139.731146-1-kai.heng.feng@canonical.com> References: <20221011034139.731146-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 linux-next) 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); }