Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1003517pxb; Wed, 6 Apr 2022 06:30:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqB1Pw4186UDPjL2Tny7Y/0LZO1k9PPjgRP8DoeJW8z5TDapR8SLfhHxHCNqiCxAobkc43 X-Received: by 2002:a65:4144:0:b0:374:315a:7dff with SMTP id x4-20020a654144000000b00374315a7dffmr7102168pgp.506.1649251800912; Wed, 06 Apr 2022 06:30:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649251800; cv=none; d=google.com; s=arc-20160816; b=GGhj9Z2fgeZFWHHx0cHhpFE57QDv6SMgeVGYl7kcihVkHSiK1oO9fzKONqpYiX2VfH rhlvH+lRLOJJetHk6EVbivf+hLfREOL4cF0qKZUjdivDGUi5oupCTbQykwJWvD9fuE9e ECpOU/gHiBkF5vkEr0Cp1Upr9obVrMOW0MZ8l3yJCmO6OKY8hI4TyYa/gPTog1TFOhmk lR2hT0tviaR9KFHpehIlEV3t7EbJ8sw3VxcBkRsKb+xcm76c027C4xZzBQi3JRg3cIji N2ubKfkhYKy38LdP9wo3qxtYMi8v/tND1xHnd4N4o7/bavOwZn4UbiDr4MukxN1Y2fDg 21rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=rUcQAq0vjlshvqXC9fxGxCxA2tHHU+OFvjPcEAQC0Vg=; b=Zuz7tby3J1Dg9I4C3mhOV7k0ZGzylVQ6SWMBXcaTeTc/QBR7mV8Np/1brxxxctSJGC jACLWzcKrQc1sGPDOj+9yNbPpiARaGDshgUgB2NIc31sKgZQj0B5Gu6w38iTvB6+0Gxl Ggw8O9sF+4vORorOgsB4jPoHh+w2jx+fhY86ID6Obx54ukMJ9xRGQqB2p1jDJAodsd35 YGSzp0QEyGGtbZ3yXKiUUhWG8n181Coy6Rn/I8sFb44W9dbYFnYPXZjWdlwUyPfMQHcL 2JqNmR+WqTvRfTIjUx3uJt9CTa1kSJ3mBNAJ5xhpicePa1sEyadNC0rvw9V9aSz9eZRi MqmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FrsnyGkA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d7-20020a170902728700b00153b2d164fbsi15097277pll.259.2022.04.06.06.30.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 06:30:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FrsnyGkA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6FE825CAD24; Wed, 6 Apr 2022 04:09:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1582012AbiDEXlo (ORCPT + 99 others); Tue, 5 Apr 2022 19:41:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352509AbiDEKEk (ORCPT ); Tue, 5 Apr 2022 06:04:40 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F9CFBABBC; Tue, 5 Apr 2022 02:53:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649152401; x=1680688401; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=VDvK04o8caLp/soQY/A5TNib+Od/eTs0oaHnfnSXUpM=; b=FrsnyGkAIkTD0AcRxqYLFSi5XIyq4VA/CIf89Obgl//h2vsoLi/xhh2g SAgjvBUlouH1ZvsXf8HNqP7Uzgcb0TcMjODl/6MFr+ZOZirLvrqhzZ0ar 20qo7NfGr24hf5YnYTyXGnT2C/eD/wkIFEz2lHuxBq9NoKdFzd9yOvNY9 KN51ujmKxnh1b/63bCh4mtorwdWaj4D58EQa3gvF90FaMds+Fcd6UQQae aci5/ocdnsn+Zh4pHTGKHj0eUFwK21+8BVdNbbhk0SpLk220FZr/8X9/X /w/P42AcL1Wa8wh4JI2/Kcd75w75diqetS21XAAoBrFLvM7efYeT2wDg5 Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10307"; a="323883734" X-IronPort-AV: E=Sophos;i="5.90,236,1643702400"; d="scan'208";a="323883734" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2022 02:53:21 -0700 X-IronPort-AV: E=Sophos;i="5.90,236,1643702400"; d="scan'208";a="505219314" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.162]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2022 02:53:18 -0700 Received: by lahna (sSMTP sendmail emulation); Tue, 05 Apr 2022 12:53:16 +0300 Date: Tue, 5 Apr 2022 12:53:16 +0300 From: Mika Westerberg To: "Rafael J. Wysocki" Cc: Linux PCI , Linux PM , LKML , Bjorn Helgaas Subject: Re: [PATCH v1 1/2] PCI: PM: Avoid leaving devices in D0-uninitialized in pci_power_up() Message-ID: References: <4198163.ejJDZkT8p0@kreacher> <3623886.MHq7AAxBmi@kreacher> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3623886.MHq7AAxBmi@kreacher> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 On Mon, Apr 04, 2022 at 05:41:13PM +0200, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > In theory, pci_power_up() may leave a device in D0-uninitialized > during a transition from D3cold to D0. > > Say, a PCIe device depending on some ACPI power resources is put into > D3cold, so the power resources in question are all turned off. Then, > pci_power_up() is called to put it into D0. > > It first calls pci_platform_power_transition() which invokes > platform_pci_set_power_state() to turn on the ACPI power resources > depended on by the device and, if that is successful, it calls > pci_update_current_state() to update the current_state field of > the PCI device object. If the device's configuration space is > accessible at this point, which is the case if > platform_pci_set_power_state() leaves it in D0-uninitialized (and > there's nothing to prevent it from doing so), current_state will be > set to PCI_D0 and the pci_raw_set_power_state() called subsequently > will notice that the device is in D0 already and do nothing. > However, that is not correct, because it may be still necessary to > restore the device's BARs at this point. > > To address this issue, set current_state temporarily to PCI_D3hot > in the cases in which pci_raw_set_power_state() may need to do more > than just changing the power state of the device. > > Signed-off-by: Rafael J. Wysocki Reviewed-by: Mika Westerberg