Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3486838pxb; Mon, 4 Apr 2022 18:32:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjBe8uLjlg8c7h/8Az9rZrVBNMTqOXRifZlaiLmDXxpGFmQQ+zuyHJzBbwCilPSbCd05nR X-Received: by 2002:a63:cf09:0:b0:372:d564:8024 with SMTP id j9-20020a63cf09000000b00372d5648024mr818770pgg.251.1649122358006; Mon, 04 Apr 2022 18:32:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649122358; cv=none; d=google.com; s=arc-20160816; b=TADXeJVMgVo93UlCIvx3t5wrl6qwOO2yNi+R3HE+oLcPZKdSEhPFEC4jUt9jipPxuj GqgJVPSST9J6JRv2xMIBsU8Zsl1g0iUaLiYy3q+boXpzuzVzVLThByUH1eQ5vKlbxXf1 cRJGKLPf/ptEZXW9ksWBFC83rlkAaUTXmx75qkk/ilKWNT5rAcBy8Eq0C+W3GKEAYedc GkxxbJwSEwg71wQQwZ6d28RNVy5lFag9W5WXJLeDAxJM6p4hdto0mX333c4SjCk61Ori 6gRrxvQmQaXemJcsudLw3bQi6zfc3qglIYDAzfWPR8/T7b9AAklO3s5V3Yb8SO3EPJhg mZsw== 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=AfnqlU9DnjHRyC95ESS4NNKYBevzsn8+m1QSfaOhcnM=; b=IKc61NWr9F5fjxtYXnTX+MnPJjndzuDgP1x+mggZr0IoCp/Lisq1zu6SZvhOEwfhcI reseSQ21k0yd/jLixdEsL7NA/Ozg0Mp6/6ozFmhJtVqUcgYm7wX9CxNwlmXWy8wGNnDU n7hCBs2lk11XmwK+z8s8kr/wODJ2/T6uoxwzcYsR1ZFtPiHFA7ZFWZsEAHLKK68rSc3Z ClUDwrcql/b+pjBk15bKU17cSm5kdkYQIfFVs2al2UB0ER4MLGl3JRjO8X2Ur7F+4TMx gpbL5uszd/BNu72QcPP3tf5hCWZEMe02zmlsVluwp3eG643/zpQMkM3YwObCjhaH9vfw iUzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id l15-20020a17090a384f00b001bd14e01fcfsi508220pjf.189.2022.04.04.18.32.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 18:32:37 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 59E4A78FEF; Mon, 4 Apr 2022 17:22:52 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378640AbiDDPof (ORCPT + 99 others); Mon, 4 Apr 2022 11:44:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347003AbiDDPoe (ORCPT ); Mon, 4 Apr 2022 11:44:34 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0831393F5; Mon, 4 Apr 2022 08:42:37 -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 663112fc46d070d8; Mon, 4 Apr 2022 17:42:36 +0200 Received: from kreacher.localnet (unknown [213.134.181.62]) (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 3F1BC66BCD3; Mon, 4 Apr 2022 17:42:35 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PCI Cc: Linux PM , LKML , Bjorn Helgaas , Mika Westerberg Subject: [PATCH v1 2/2] PCI: PM: Resume bus after putting the bridge into D0 entirely Date: Mon, 04 Apr 2022 17:42:27 +0200 Message-ID: <1807986.atdPhlSkOF@kreacher> In-Reply-To: <4198163.ejJDZkT8p0@kreacher> References: <4198163.ejJDZkT8p0@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.181.62 X-CLIENT-HOSTNAME: 213.134.181.62 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvvddrudejvddgkeejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvjeelgffhiedukedtleekkedvudfggefhgfegjefgueekjeelvefggfdvledutdenucfkphepvddufedrudefgedrudekuddriedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekuddriedvpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeehpdhrtghpthhtoheplhhinhhugidqphgtihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehhvghlghgrrghssehkvghrnhgvlhdrohhrghdprhgtphhtthhopehmihhk rgdrfigvshhtvghrsggvrhhgsehlihhnuhigrdhinhhtvghlrdgtohhm 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 It is rather counter-intuitive to attempt to resume devices on a bus segment before completing a transition of their parent bridge into D0, so do that when the transition is complete. This matters especially when the transition in question is not successful, in which case it doesn't make sense to even try to resume the child devices at all. Signed-off-by: Rafael J. Wysocki --- drivers/pci/pci.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) Index: linux-pm/drivers/pci/pci.c =================================================================== --- linux-pm.orig/drivers/pci/pci.c +++ linux-pm/drivers/pci/pci.c @@ -1310,15 +1310,24 @@ static int pci_dev_wait(struct pci_dev * int pci_power_up(struct pci_dev *dev) { pci_power_t old_state = dev->current_state; + int ret; pci_platform_power_transition(dev, PCI_D0); + /* + * For transitions from D3hot or deeper (including unknown), force + * PCI_PM_CTRL register write, D3*->D0 transition delay and BARS + * restoration. + */ + if (old_state >= PCI_D3hot) + dev->current_state = PCI_D3hot; + ret = pci_raw_set_power_state(dev, PCI_D0); /* * Mandatory power management transition delays are handled in * pci_pm_resume_noirq() and pci_pm_runtime_resume() of the * corresponding bridge. */ - if (dev->runtime_d3cold) { + if (!ret && dev->runtime_d3cold) { /* * When powering on a bridge from D3cold, the whole hierarchy * may be powered on into D0uninitialized state, resume them to @@ -1327,15 +1336,7 @@ int pci_power_up(struct pci_dev *dev) pci_resume_bus(dev->subordinate); } - /* - * For transitions from D3hot or deeper and initial power-up, force - * PCI_PM_CTRL register write, D3*->D0 transition delay and BARS - * restoration. - */ - if (old_state >= PCI_D3hot) - dev->current_state = PCI_D3hot; - - return pci_raw_set_power_state(dev, PCI_D0); + return ret; } /**