Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1511838iob; Thu, 5 May 2022 03:04:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPX2wzfOq+iqUQhVe5mewUNCLmEsx9yoHxa1pfYuCRDDxa5XP/VSnYgMAlMHyHOUi5DN05 X-Received: by 2002:a05:6402:5114:b0:427:cbe5:e9bd with SMTP id m20-20020a056402511400b00427cbe5e9bdmr20167101edd.255.1651745055919; Thu, 05 May 2022 03:04:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651745055; cv=none; d=google.com; s=arc-20160816; b=krwt9WYh5rYNGpHBWHMXeOBEz+rvRnMa1Zqne3c28w7MYmg78QukhrgAk8EBgoLpOQ gwP7dPqYBFG64onw3iRvblAjnLbziv/ZOhdC/fVUBEO5HH/5LAWwbqU3Op2yHhke9GEN +JpmuqsmFITJcVuu8VBK67RI5E8KOqSd0YVgYJzcNyJQEtKWPIhVUUlHJCnn/OS0GkcJ V5mYvJ+FxQQVcXzSpsLHJGqkOZ8Cod/ez/NvWdsm3epik2iBN9xNAx4P4Pq/ZiEQqLgn 5K64q3slskVV8jqp8PaL4xdUJEsTR9NyscsGmo7fkgnAyYjgm2H8oyxgXMqqjag5dz3e /pMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=QouxlmSzuJ7v06qDtBsQtxhFP7yv/yzXlSWYd36J58o=; b=DRWbp7FVn4/JBTruCkPLgsZZOibV4BKOmBuM97WnOZGpM+4qnTx1RqkmLqFl1wVH+D 9FuxAnIV1MNifr5s25z7f9iasHmODtOF5pAfYpnfiA9EjIynyFgQQUKLxnuWFVgRR4pD QBsXlhK605icrO3tY4bJmyogj3/ZThmO8ejYXH4nP0RjfzTB/1rjJigPiSFsWDSuexmi VG+rV5b2hq9dHZbeS7oGtj0dnbkdtRfFQ3TTG8WBnD9AUP3UBeh54jJ3JMpeQV9pXc+m 8sR+XAq0aG4+7Ut2FuNZwsEIrYf6tMM+KS87nz0qA5KqTvFgh1mHkaZQEYJkV05spfDD YWaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uh7kUaXi; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n8-20020a05640205c800b00427b7dfb60esi1842666edx.289.2022.05.05.03.03.50; Thu, 05 May 2022 03:04:15 -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=@kernel.org header.s=k20201202 header.b=uh7kUaXi; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358242AbiEDRZr (ORCPT + 99 others); Wed, 4 May 2022 13:25:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354579AbiEDRFT (ORCPT ); Wed, 4 May 2022 13:05:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F0ED5132B; Wed, 4 May 2022 09:54:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D5CD4B827AC; Wed, 4 May 2022 16:54:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50683C385B1; Wed, 4 May 2022 16:54:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651683251; bh=c6+7Ne4K8yZ0+BKb8IfJNxGJ6ZxxOYXvDdFYiQ0PJqM=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=uh7kUaXix6SXNpSHxcQafJqyVWArJKQx6BIJfPPwMl8cluoqPN3qGBf87C0JFYMh6 aUOJawCMaS6sZ7ndt9v8Sf0sPtPEJqffnJVQsm7THm2CtvsHU2AX9qaBlyBS7vDP9m bBpyKzWp23iRlbBOwpNx9iabOCVxCVRLsMlixJ8MgdAvsYok1P1GsQzwz6toDlNjFg KrvGLi8oVTmLGLVxGdCLImBEWD9YebI+IfxvCA9qRXcAtAjfXqKVEBuGQ4JmeWHHtg LTOlrf0DOG1SdR1yVvMgg4/hfJrfgI4FtzUcCeKB1h1s2iF5k/INugSy7H0797WFSM pkT9fnIfhu9NQ== Date: Wed, 4 May 2022 11:54:09 -0500 From: Bjorn Helgaas To: Nathan Chancellor Cc: "Rafael J. Wysocki" , Linux PCI , Linux PM , LKML , Mika Westerberg , Anders Roxell Subject: Re: [PATCH v3 4/9] PCI/PM: Rework changing power states of PCI devices Message-ID: <20220504165409.GA453565@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 [+cc Anders] On Tue, May 03, 2022 at 10:59:43AM -0700, Nathan Chancellor wrote: > 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. I dropped 5bffe4c611f5 and subsequent pci/pm patches temporarily while this gets worked out. Bjorn