Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp57920lfe; Fri, 15 Apr 2022 19:22:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGD3CpzdjSvw77AhS5+63lVJEGQneZCX1axs6t2o78pvN3wOYJXAHHJxUtTgAn4XUYEmqj X-Received: by 2002:a17:90a:17ae:b0:1cb:6921:c89c with SMTP id q43-20020a17090a17ae00b001cb6921c89cmr7207165pja.37.1650075733733; Fri, 15 Apr 2022 19:22:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650075733; cv=none; d=google.com; s=arc-20160816; b=wb/T/vNJAD3nYMkjph+IRnm65PVhd0X+F6js5V2Uy1AVprBfld9ftTwPP+z4LXYoSs rFjAXlpWv3qUscac2xTXOLLZN+djvncsDowm7hulC8TGKGf97/1lo8aO7BHKxf7MGIq5 g9+uQmi5Zpo79b93Ab/3s2tJ9236g5cjxD4pM47ucr0xweRvNY1xXOCK1Wvf421dGFEN +vrWbrM4cFdug7gS/3P3rTBqdpDdSyW5eTfPGlU60/ju2CGXr9UGY2DOjw8n3QNhLtTI iy2xN2yTJtcDbXyBGYb+AG7pxoF/DdyIXPe1mpEANtecBtxtNLBvlFxvZ5QvwEDoIvPA 26Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Kfv/x2p4P9euKLKcmXGOeeOaVtnx1gsvDEjpRLDNFjI=; b=hkuC2nP31RyqAOz5vf3f+3Sjs+fUxZToLrxbADGKB3EGYRlcN/XHFqIPSjXbJJuOQL tHUOfeCXyfJNS/8qfSEruSSg8befyLDHvWNvKsqxRB9+7dIt7zmDsFNJLt7Nwsh2NLg5 LumQ9gSYEuJ0yFXGAWvA1JnkcVe5XL1I4qFNm/U1Hs7XULGplx9yZaqFtDfCRSOl2wiF 2UHLeV1aH2rD3chTiN8xaKHGWvxPYrlHAoTgpNwsPCQIcPUGGMIHI7cf4djj4DkCfaeU iG37pq5O1nE+3QurbBm8eu+d7kOmo+ma1uaL4YqZzWe/Smpei528/kQf+pYcOlpW3GNr PR7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q26-20020a656a9a000000b003816043ee97si3163385pgu.140.2022.04.15.19.22.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 19:22:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 371A463D4; Fri, 15 Apr 2022 18:36:14 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244446AbiDNNeV (ORCPT + 99 others); Thu, 14 Apr 2022 09:34:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244280AbiDNNZh (ORCPT ); Thu, 14 Apr 2022 09:25:37 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5908B8FE50; Thu, 14 Apr 2022 06:19:47 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.0.0) id c15ecf05f23514e4; Thu, 14 Apr 2022 15:19:45 +0200 Received: from kreacher.localnet (unknown [213.134.181.101]) (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 v370.home.net.pl (Postfix) with ESMTPSA id BA95566BE88; Thu, 14 Apr 2022 15:19:44 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PCI Cc: Linux PM , LKML , Bjorn Helgaas , Mika Westerberg Subject: [PATCH v3 9/9] PCI/PM: Replace pci_set_power_state() in pci_pm_thaw_noirq() Date: Thu, 14 Apr 2022 15:19:19 +0200 Message-ID: <2532996.Lt9SDvczpP@kreacher> In-Reply-To: <5838942.lOV4Wx5bFT@kreacher> References: <4419002.LvFx2qVVIh@kreacher> <11975904.O9o76ZdvQC@kreacher> <5838942.lOV4Wx5bFT@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.181.101 X-CLIENT-HOSTNAME: 213.134.181.101 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvvddrudelfedgieefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvjeelgffhiedukedtleekkedvudfggefhgfegjefgueekjeelvefggfdvledutdenucfkphepvddufedrudefgedrudekuddruddtudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvudefrddufeegrddukedurddutddupdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeehpdhrtghpthhtoheplhhinhhugidqphgtihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehhvghlghgrrghssehkvghrnhgvlhdrohhrghdprhgtphhtthhopehm ihhkrgdrfigvshhtvghrsggvrhhgsehlihhnuhigrdhinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki Calling pci_set_power_state() to put the given device into D0 in pci_pm_thaw_noirq() may cause it to restore the device's BARs, which is redundant before calling pci_restore_state(), so replace it with a direct pci_power_up() call followed by pci_update_current_state() if it returns a nonzeor value, in analogy with pci_pm_default_resume_early(). Avoid code duplication by introducing a wrapper function to contain the repeating pattern and calling it in both places. Signed-off-by: Rafael J. Wysocki Reviewed-by: Mika Westerberg --- v2 -> v3: * Added R-by from Mika. --- drivers/pci/pci-driver.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) Index: linux-pm/drivers/pci/pci-driver.c =================================================================== --- linux-pm.orig/drivers/pci/pci-driver.c +++ linux-pm/drivers/pci/pci-driver.c @@ -551,11 +551,15 @@ static void pci_pm_default_resume(struct pci_enable_wake(pci_dev, PCI_D0, false); } -static void pci_pm_default_resume_early(struct pci_dev *pci_dev) +static void pci_pm_power_up_and_verify_state(struct pci_dev *pci_dev) { if (pci_power_up(pci_dev)) pci_update_current_state(pci_dev, PCI_D0); +} +static void pci_pm_default_resume_early(struct pci_dev *pci_dev) +{ + pci_pm_power_up_and_verify_state(pci_dev); pci_restore_state(pci_dev); pci_pme_restore(pci_dev); } @@ -1080,7 +1084,7 @@ static int pci_pm_thaw_noirq(struct devi * in case the driver's "freeze" callbacks put it into a low-power * state. */ - pci_set_power_state(pci_dev, PCI_D0); + pci_pm_power_up_and_verify_state(pci_dev); pci_restore_state(pci_dev); if (pci_has_legacy_pm_support(pci_dev))