Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4834021iob; Mon, 9 May 2022 02:45:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNrszWKaFzo4OYWpKkcy+Mph51ejGNH0yOGbl5YfnQIW9XjugYO2mAMh2vW7QMu1NN62kB X-Received: by 2002:a63:894a:0:b0:3ab:23c7:33ff with SMTP id v71-20020a63894a000000b003ab23c733ffmr12591404pgd.245.1652089502211; Mon, 09 May 2022 02:45:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652089502; cv=none; d=google.com; s=arc-20160816; b=fzynJDDnf2TRNRP6baDM3qSZLYqkLhpOaOy/XpyQg/laRjPppqy3mkHkJWOz/kBDeH xWn9mKL0e58ezegr+uct9qGb7lsPBviIZBVfb/A0WXqqquDaNbHuaP3wCK0XT8aBCoJI dCOuffkMxpuhZa0lBv07wRrkTTeZPn67PhWEEcSoy3IsAm0r0zIQlbnug671Iw5VLPEP C73CZs+yWeKhBqhSesDq6jH45KtljrA4TgFYusAVTXiiKtb6MEp+0Wufk3eHky72f28D wl27hGjkiSKchsJBZXMmSNZW4l6YbmyGRpHwSstJ0PQHJFdj8fJXvDdfz8BUg6KNsuh9 4Q6g== 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=2K46MMuuo0nDp35djiDHFfiL7Z2ZEIj/gkahq9MEFkI=; b=Ta87P36Nc996JHDxXG2169H9yCRhC73JhqoknLOjWDJmCe2moRYNUbRTKQWxWCyda7 0aPb4+xzMSt2F6CNpPalXX9oiFT8AVy/6JPZdd54D9RmlT2rNmxnx7A4pFiQ8i0C/nQq f19/CN0Yetzo7yHZOANSsyWaNCVaVZdVbq6HIwTUkxPE6/QL+j6E0kDseZkLleu7G2XF 0+cYr8WDNMKVvwgI+u8YNuhecfV1SgFZDjuBsvuhFvfr+0DeFGCMh0xlmTeVes4ZIllT PjthQEz0S/3JbCGsvsee0XebOpJddzXCCm6PGjyNZNmNyDlrznGJ8FgxSeceIEQutiEz S1kg== 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 na18-20020a17090b4c1200b001d97f80deb9si16169345pjb.0.2022.05.09.02.45.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 02:45:02 -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 5B30422240F; Mon, 9 May 2022 02:28:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243945AbiEESdU (ORCPT + 99 others); Thu, 5 May 2022 14:33:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385357AbiEESaW (ORCPT ); Thu, 5 May 2022 14:30:22 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D6125DA63; Thu, 5 May 2022 11:21:03 -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 33f5f557048ad12f; Thu, 5 May 2022 20:19:32 +0200 Received: from kreacher.localnet (unknown [213.134.161.219]) (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 BE64266C2F2; Thu, 5 May 2022 20:19:31 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PCI Cc: LKML , Linux PM , Mika Westerberg , Bjorn Helgaas , Nathan Chancellor , Anders Roxell Subject: [PATCH v1 08/11] PCI/PM: Do not restore BARs if device is not in D0 Date: Thu, 05 May 2022 20:14:24 +0200 Message-ID: <1849718.CQOukoFCf9@kreacher> In-Reply-To: <4738492.GXAFRqVoOG@kreacher> References: <4738492.GXAFRqVoOG@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.161.219 X-CLIENT-HOSTNAME: 213.134.161.219 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedrfedugdduvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppedvudefrddufeegrdduiedurddvudelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudeiuddrvdduledphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepjedprhgtphhtthhopehlihhnuhigqdhptghisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepmhhikhgrrdifvghsthgvrhgsvghrgheslhhinhhugidrihhnthgv lhdrtghomhdprhgtphhtthhopehhvghlghgrrghssehkvghrnhgvlhdrohhrghdprhgtphhtthhopehnrghthhgrnheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprghnuggvrhhsrdhrohigvghllheslhhinhgrrhhordhorhhg X-DCC--Metrics: v370.home.net.pl 1024; Body=7 Fuz1=7 Fuz2=7 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 Do not attempt to restore the device's BARs in pci_set_full_power_state() if the actual current power state of the device is not D0. Signed-off-by: Rafael J. Wysocki --- drivers/pci/pci.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) Index: linux-pm/drivers/pci/pci.c =================================================================== --- linux-pm.orig/drivers/pci/pci.c +++ linux-pm/drivers/pci/pci.c @@ -1273,25 +1273,25 @@ static int pci_set_full_power_state(stru pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); dev->current_state = pmcsr & PCI_PM_CTRL_STATE_MASK; - if (dev->current_state != PCI_D0) + if (dev->current_state != PCI_D0) { pci_info_ratelimited(dev, "Refused to change power state from %s to D0\n", pci_power_name(dev->current_state)); - - /* - * According to section 5.4.1 of the "PCI BUS POWER MANAGEMENT - * INTERFACE SPECIFICATION, REV. 1.2", a device transitioning - * from D3hot to D0 _may_ perform an internal reset, thereby - * going to "D0 Uninitialized" rather than "D0 Initialized". - * For example, at least some versions of the 3c905B and the - * 3c556B exhibit this behaviour. - * - * At least some laptop BIOSen (e.g. the Thinkpad T21) leave - * devices in a D3hot state at boot. Consequently, we need to - * restore at least the BARs so that the device will be - * accessible to its driver. - */ - if (ret > 0) + } else if (ret > 0) { + /* + * According to section 5.4.1 of the "PCI BUS POWER MANAGEMENT + * INTERFACE SPECIFICATION, REV. 1.2", a device transitioning + * from D3hot to D0 _may_ perform an internal reset, thereby + * going to "D0 Uninitialized" rather than "D0 Initialized". + * For example, at least some versions of the 3c905B and the + * 3c556B exhibit this behaviour. + * + * At least some laptop BIOSen (e.g. the Thinkpad T21) leave + * devices in a D3hot state at boot. Consequently, we need to + * restore at least the BARs so that the device will be + * accessible to its driver. + */ pci_restore_bars(dev); + } if (dev->bus->self) pcie_aspm_pm_state_change(dev->bus->self);