Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp869329pxb; Wed, 29 Sep 2021 11:21:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzq0g3XofwvxiVvtGKZsPFXTovVPRhPGhPObGxZc1lX6CAHeTtm9IbcbpTDLxXP6KB7CEnt X-Received: by 2002:a05:6402:705:: with SMTP id w5mr1630965edx.366.1632939694677; Wed, 29 Sep 2021 11:21:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632939694; cv=none; d=google.com; s=arc-20160816; b=lu7b34l37F5B2ry2T15mJQUNs6sYZ516Hf/Am+THvYTojqhdxlEwUzOVmPedy79Iaa 6H/Dp+CvOYSE1jyZLUZ+WQdtXKHkUI3boiXlf8vP/h+U115Ksb8QwlgIwJ90uQLalOID hxec8Nul41/iCG2VmZIwV3ZqqnM94vMRbA3JMrmdtkk0bSO0PvTVkMIX4s6rojCzU70+ o63B+if3AUFzQpceNJGdcwkLzxy8In9bQolY15oUajt8aC6AsBFVZn40AV0+yYUlQIII G++Rz6GWrjcWg3VKLL6pZt8nFoBsIPcQ4yiTCmJ5o3WLju8bHhpU2eXCJ8Zl01gcZhOh UtHA== 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=q1horCAyNGZ6UFXWbXRRywhMNy8ZrllTO/IFcyhD7P4=; b=b48ZbePFAnznKDKnBqELPslD7XIE/clzvIWhVEMv/6z77WNaKFfecTCzfFyXEzUPDK FeFp5CcmrDKsy/vvy7RLQmQiTSVBZuh8vjQPqIxztVuEacW6lc/akQKO9sxwep719PuG +2/p3EFEO8Gm6LQWYwYdvjtgl8GNq58YG4g8gAcl7Cxmj98vunh9dFbe+6RIMpLZnIaT ZETgXhsFg7wSG0h8ctcdsaJt8rE1vtADXznUijsZU5BI/dMUgL9oysq8fzwhs3Y/8fry DEBObC9VrGsQ+TukS9dcIqZlcBUoE7hzmALM6c3NSgSegGhglPor3qSs0cuCP5TBeMLg dNpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w2si690210ejn.164.2021.09.29.11.21.10; Wed, 29 Sep 2021 11:21:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345940AbhI2SR4 (ORCPT + 99 others); Wed, 29 Sep 2021 14:17:56 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:57226 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345856AbhI2SRv (ORCPT ); Wed, 29 Sep 2021 14:17:51 -0400 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 3.0.0) id 8ea974ecddce1e07; Wed, 29 Sep 2021 20:16:09 +0200 Received: from kreacher.localnet (unknown [213.134.161.209]) (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 48D1D66A71A; Wed, 29 Sep 2021 20:16:08 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI , Ferry Toth Cc: Linux PCI , LKML , Bjorn Helgaas , Andy Shevchenko , Mika Westerberg Subject: [PATCH v3 1/3] PCI: PM: Rearrange pci_target_state() Date: Wed, 29 Sep 2021 20:09:39 +0200 Message-ID: <8849452.CDJkKcVGEf@kreacher> In-Reply-To: <7312660.EvYhyI6sBW@kreacher> References: <1800633.tdWV9SEqCh@kreacher> <7312660.EvYhyI6sBW@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.161.209 X-CLIENT-HOSTNAME: 213.134.161.209 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvtddrudekvddguddvudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepteeggfelteegudehueegieekveduleeuledvueefjeefffegfeejudfgteefhefhnecuffhomhgrihhnpehkvghrnhgvlhdrohhrghenucfkphepvddufedrudefgedrudeiuddrvddtleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvudefrddufeegrdduiedurddvtdelpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepfhhnthhothhhsehgmhgrihhlrdgtohhmpdhrtghpthhtoheplhhinhhugidqphgtihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdp rhgtphhtthhopehhvghlghgrrghssehkvghrnhgvlhdrohhrghdprhgtphhtthhopegrnhgurhhihidrshhhvghvtghhvghnkhhosehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohepmhhikhgrrdifvghsthgvrhgsvghrgheslhhinhhugidrihhnthgvlhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=7 Fuz1=7 Fuz2=7 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki Make pci_target_state() return D3cold or D0 without checking PME support if the current power state of the device is D3cold or if it does not support the standard PCI PM, respectively. Next, drop the tergat_state local variable that has become redundant from it. Signed-off-by: Rafael J. Wysocki --- Same as the v2: https://patchwork.kernel.org/project/linux-acpi/patch/2559274.X9hSmTKtgW@kreacher/ --- drivers/pci/pci.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) Index: linux-pm/drivers/pci/pci.c =================================================================== --- linux-pm.orig/drivers/pci/pci.c +++ linux-pm/drivers/pci/pci.c @@ -2583,8 +2583,6 @@ EXPORT_SYMBOL(pci_wake_from_d3); */ static pci_power_t pci_target_state(struct pci_dev *dev, bool wakeup) { - pci_power_t target_state = PCI_D3hot; - if (platform_pci_power_manageable(dev)) { /* * Call the platform to find the target state for the device. @@ -2594,32 +2592,29 @@ static pci_power_t pci_target_state(stru switch (state) { case PCI_POWER_ERROR: case PCI_UNKNOWN: - break; + return PCI_D3hot; + case PCI_D1: case PCI_D2: if (pci_no_d1d2(dev)) - break; - fallthrough; - default: - target_state = state; + return PCI_D3hot; } - return target_state; + return state; } - if (!dev->pm_cap) - target_state = PCI_D0; - /* * If the device is in D3cold even though it's not power-manageable by * the platform, it may have been powered down by non-standard means. * Best to let it slumber. */ if (dev->current_state == PCI_D3cold) - target_state = PCI_D3cold; + return PCI_D3cold; + else if (!dev->pm_cap) + return PCI_D0; if (wakeup && dev->pme_support) { - pci_power_t state = target_state; + pci_power_t state = PCI_D3hot; /* * Find the deepest state from which the device can generate @@ -2634,7 +2629,7 @@ static pci_power_t pci_target_state(stru return PCI_D0; } - return target_state; + return PCI_D3hot; } /**