Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp972180iob; Wed, 4 May 2022 11:47:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvN7pZzVzzKwHy9VdmPe0yYga1xsaK6qLKdmje6SGUEbJ91D9yaMhdYiQhYHy6tAdmZCEi X-Received: by 2002:a05:6402:849:b0:427:edfe:1b7e with SMTP id b9-20020a056402084900b00427edfe1b7emr8890055edz.355.1651690029558; Wed, 04 May 2022 11:47:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651690029; cv=none; d=google.com; s=arc-20160816; b=Rtt8qB2/mAIz9mC4EW7SGKxvuTZMe6Gl4J340w+4M5sMoveiTBTN2oyZSG7YY+Lit9 iNjL847kaBNadRKYjZ/JB7LwM94+OhI6PVc9WySpUT6cblSH7P8Tf6zrEa04n4tWOV+F uvAB2a+MSQuI5VTvzXk3HhHB+oRuCDQ3fP73AdoHYxaF0/q7TgG6LwQH9P4wgk4msX68 UiP+3CqvZXQ1zPSdwkoyKchg8FLGsrppa+8afKHUk2pnwLEqpXPlRofLFDWytgF/OKU9 qVEnfaYkrf0d1dr5kKtkErkMmQr7bDzx9gnyWz79pOaleqr1Ks0Rouemc+3Fu4NhnH7e gFqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=3H4PHGcmcD+NCKJdcFxPs3wW4ElbujkBimfkF3e+URM=; b=rCbUEMoM63nLzitpdhCnyhAJGjQvb8k7T0aQ1CuCbHx8p3g+7Zxojk3Xnn7dTF0Shu 0gfpnH1cZ0Ms8X6YBcthjpzxigWMVXOMUbQ+2fDT3rdPxw8X/iOJ9YMwE5kPs4U86pLO 9OBs5Tw+LPKB59/1UcjnpGar6BYqQkCs0IBMjgTvsPgHw22IpzeTStIMpljCgWl892Z8 braVeaMEP32mJuxcSWb4u/U0Jh+MzthFkjz33dU/u598CGfwaTwtb3NrbU2mxh2SFyN/ PpT+WOCCBysILh0mtWc9Z57q7HXjjmHFZ85rCmyTSYscOxgG3KadhmQF7t3v4xc4VpiD Bw9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wzPHotuG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f14-20020a170906c08e00b006e87e97d30csi17157665ejz.197.2022.05.04.11.46.45; Wed, 04 May 2022 11:47:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wzPHotuG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352884AbiEDP6U (ORCPT + 99 others); Wed, 4 May 2022 11:58:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344713AbiEDP6S (ORCPT ); Wed, 4 May 2022 11:58:18 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E46EB46150 for ; Wed, 4 May 2022 08:54:41 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id b18so3077782lfv.9 for ; Wed, 04 May 2022 08:54:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=3H4PHGcmcD+NCKJdcFxPs3wW4ElbujkBimfkF3e+URM=; b=wzPHotuGedh31jRQr6oLxnKSgGm0pUbSOWzlWDVKvf5SurNBXuwBS1zf1XHsku3nYA u2RL+UY64tBWP9RD7n9N1ToLKcsH3HC2S/AjXKAELzKh1pndZXrsDVVXs9LFvt0fX0+C O/boUc5/+cO+IEzvYrD40t0//sxjKTL5enF/byZR54PbSwujJlNYqAJNHXWMa8EwGoHz V9zE5j1uqV8czPzatSQCtM6SWm0RMlMuO9a0a/tU+BirJu9ees19vHh6TxcvNz6d0IXf kv0FBc5LLB2eAOabKAHpVPvVRValB5OEGK7Mu25Qe2NbbajlygGpAcI7Y9eLLqlrPYFR Ak6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=3H4PHGcmcD+NCKJdcFxPs3wW4ElbujkBimfkF3e+URM=; b=1LdHVpYWmcp1iVH1FVrnVCzEg4oFZ//ykvNXWjXmU9/c18Bart+0diu208klqKYsJ3 AUfrAkB8bA0Er+HPcBaoqD7G+LZ63B90M6Orjof34sc0SyRdoLHrmuS6b9mp4abyy2sw FTVj24eQGAuq0/e9yApn+9DmCulNiq38vcv3DeWGVBn90jntmDoqrucf8vUt1LXOcR0r OYR6vcUOUEA/NtPMYEfeYlXwTw/bt7zrBBbaw8bEYAgZU07Y635dHh6O8bU7vCI9BWya m22WCZw1SH4/jnVH7cYBJAlLgLXFGCWcCjaw/uDt63URtiuuoiSOtONWcCsyxRAKAzXA kqwg== X-Gm-Message-State: AOAM530f+EjCg8ULUTtEpZm1E89A6yh3cAo9ZbdI2Kt1G41uLTyxxvGj U8/hLoYJ9mWGWT+jiAtQDpM9DA== X-Received: by 2002:a05:6512:234c:b0:473:c3ba:2cf1 with SMTP id p12-20020a056512234c00b00473c3ba2cf1mr1301333lfu.402.1651679680147; Wed, 04 May 2022 08:54:40 -0700 (PDT) Received: from mutt (c-9b28e555.07-21-73746f28.bbcust.telenor.se. [85.229.40.155]) by smtp.gmail.com with ESMTPSA id b25-20020ac25639000000b0047255d2119dsm1236703lff.204.2022.05.04.08.54.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 May 2022 08:54:39 -0700 (PDT) Date: Wed, 4 May 2022 17:54:36 +0200 From: Anders Roxell To: "Rafael J. Wysocki" Cc: Nathan Chancellor , "Rafael J. Wysocki" , Linux PCI , Linux PM , LKML , Bjorn Helgaas , Mika Westerberg Subject: Re: [PATCH v3 4/9] PCI/PM: Rework changing power states of PCI devices Message-ID: <20220504155435.GB2697452@mutt> References: <4419002.LvFx2qVVIh@kreacher> <11975904.O9o76ZdvQC@kreacher> <5838942.lOV4Wx5bFT@kreacher> <3687697.kQq0lBPeGt@kreacher> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On 2022-05-04 14:59, Rafael J. Wysocki wrote: > On Tue, May 3, 2022 at 7:59 PM Nathan Chancellor wrote: > > > > Hi Rafael, > > > > On Thu, Apr 14, 2022 at 03:11:21PM +0200, Rafael J. Wysocki wrote: > > > From: Rafael J. Wysocki > > > > > > There are some issues related to changing power states of PCI > > > devices, mostly related to carrying out unnecessary actions in some > > > places, and the code is generally hard to follow. > > > > > > 1. pci_power_up() has two callers, pci_set_power_state() and > > > pci_pm_default_resume_early(). The latter updates the current > > > power state of the device right after calling pci_power_up() > > > and it restores the entire config space of the device right > > > after that, so pci_power_up() itself need not read the > > > PCI_PM_CTRL register or restore the BARs after programming the > > > device into D0 in that case. > > > > > > 2. It is generally hard to get a clear view of the pci_power_up() > > > code flow, especially in some corner cases, due to all of the > > > involved PCI_PM_CTRL register reads and writes occurring in > > > pci_platform_power_transition() and in pci_raw_set_power_state(), > > > some of which are redundant. > > > > > > 3. The transitions from low-power states to D0 and the other way > > > around are unnecessarily tangled in pci_raw_set_power_state() > > > which causes it to use a redundant local variable and makes it > > > rather hard to follow. > > > > > > To address the above shortcomings, make the following changes: > > > > > > a. Remove the code handling transitions into D0 > > > from pci_raw_set_power_state() and rename it as > > > pci_set_low_power_state(). > > > > > > b. Add the code handling transitions into D0 directly > > > to pci_power_up() and to a new wrapper function > > > pci_set_full_power_state() calling it internally that is > > > only used in pci_set_power_state(). > > > > > > c. Make pci_power_up() avoid redundant PCI_PM_CTRL register reads > > > and make it work in the same way for transitions from any > > > low-power states (transitions from D1 and D2 are handled > > > slightly differently before the change). > > > > > > d. Put the restoration of the BARs and the PCI_PM_CTRL > > > register read confirming the power state change into > > > pci_set_full_power_state() to avoid doing that in > > > pci_pm_default_resume_early() unnecessarily. > > > > > > Signed-off-by: Rafael J. Wysocki > > > Reviewed-by: Mika Westerberg > > > > This change as commit 5bffe4c611f5 ("PCI/PM: Rework changing power > > states of PCI devices") causes my AMD-based system to fail to fully > > boot. As far as I can tell, this might be NVMe related, which might make > > getting a full log difficult, as journalctl won't have anywhere to save > > it. I see: > > > > nvme nvme0: I/O 8 QID 0 timeout, completion polled > > > > then shortly afterwards: > > > > nvme nvme0: I/O 24 QID 0 timeout, completion polled > > nvme nvme0: missing or invalid SUBNQN field > > > > then I am dropped into an emergency shell. > > Thanks for the report! > > > This is a log from the previous commit, which may give some hints about > > the configuration of this particular system. > > > > https://gist.github.com/nathanchance/8a56f0939410cb187896e904c72e41e7/raw/b47b2620bdd32d43c7a3b209fcfd9e3d4668f058/good-boot.log > > > > If there is any additional debugging information I can provide or > > patches I can try, please let me know! > > Please see what happens if the "if (dev->current_state == PCI_D0)" > check and the following "return 0" statement in pci_power_up() are > commented out. I've built an arm64 allmodconfig kernel on linux-next tag next-20220503, and tried to boot it. This is the boot error I see [1]. I bisected down to this patch [2] When I revert the following patches [3] the kernel boots fine. I also tried next-20220504 and I saw the same issue. Cheers, Anders [1] http://ix.io/3WT3 [2] http://ix.io/3WXT [3] http://ix.io/3WXU