Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2695264pxb; Sun, 24 Apr 2022 23:40:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtbALWtyb930IkbNKPe5ys7hy+WH98+yyYbP0c/XxVdkdfH+MjtoXNCQryKLiIYkfwsmbV X-Received: by 2002:a17:907:6d0c:b0:6f3:85bc:c503 with SMTP id sa12-20020a1709076d0c00b006f385bcc503mr6806663ejc.301.1650868811115; Sun, 24 Apr 2022 23:40:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650868811; cv=none; d=google.com; s=arc-20160816; b=pwVYdQ9eZ6zL59ui/pE6Mc7cjFYZm03sk3YZP8swDioMpScfyp2LvAXmrE3cvCYPJu rz3VfYYi1E5TDOIqFzvolazt9NF+/Fpl50QYkyu6egLS7FU0/T9YUerivCWiJlIdf8fI tqqGhShwlVWREFwo8G2TRhuN6gKKprC8IUUWNBtj2j+fVUljjHxXDDP3cMoVKE+Fqj2/ kNajCiCakF623XpWtHSjgZOPXiQSfxWCJiAOpE6FoOQWZ2URPxo6WdTLQ4j44iK1+0NH 0em50vr5aT+kKs7WbG6RdNNusbufqUipuNbLk+JUc9xyNDqBRYnxtAFDuxvp7b2XeZjM SuWg== 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=j47Vo1fWdiGxGjnnlDlKmjoKJmfTL3lrwG4y6QHkurM=; b=ozBUGBUoPjQVWroGqb4oaZuSvhbn/s8WNdRHWcuT23UeyPvLVoDxaJvQz5Ze/hra74 c/avItTVO6xODB9AsK0HS/iYcb7pY8J/Nnj0vt69LudkORfEEMifW5NTzXAArbJRLV1b 5HfHOTPXxteSnjqIBFGSwJKa9B7GFmOcQ5IL89VTSf/tOE+e5cd20rkqgswGIghX/1or ph0OakmFhYfsGl1vIsk28LQJiMcjPzuCT2fxC3N2ykqJ2lekagb7G4mLJNW593uNKjkh ruKrg0zCXSnLIha2k3YUtymievHOyDF8xPYLaA1YdACyoRAQUNcz0hJw+jlkbjQu4xqC +53A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j4W+UeVu; 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 o12-20020a170906860c00b006f37fa72a71si3845887ejx.537.2022.04.24.23.39.46; Sun, 24 Apr 2022 23:40:11 -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=j4W+UeVu; 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 S231240AbiDWPEg (ORCPT + 99 others); Sat, 23 Apr 2022 11:04:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229807AbiDWPEe (ORCPT ); Sat, 23 Apr 2022 11:04:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28B1A1668F0; Sat, 23 Apr 2022 08:01:36 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 52267612C8; Sat, 23 Apr 2022 15:01:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27BCCC385A0; Sat, 23 Apr 2022 15:01:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650726095; bh=uaq6jNypdiikbr84HxxnRbgSGuCdBE8n2XWA2kVi2Go=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=j4W+UeVu3/Vi110qIfDgsZqhpYu8qMnJWI5iwdqmEpz6rWP2cQz6EBroNuEBknJSt Pajs7dX7YzmIgbttwC9wDbnRxYZV+ydbrIk7w/o6T8XiPN+o7fk7kKZyl6V2t8SlqS y2Vp0AlB/QEOBmxSznnjFkmK1SmrVmzGqvxuDu7/4C91717uTC5+JM+2VtKVYlCLoa GSn+cdsFeV7jmjOjLNH6WByptK7hTvUzISBNOpHmM/bpS34kwjP4y6d5i213GV86wT X6Ml966XTBxMhEKT4pyIyNqqu8WnOMSB8q42TueLKq1HmPXKsaikWy5t2IMnOrNibw xpaRC8DS/Cu/w== Date: Sat, 23 Apr 2022 10:01:32 -0500 From: Bjorn Helgaas To: "Jingar, Rajvi" Cc: "bhelgaas@google.com" , "david.e.box@linux.intel.com" , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-pm@vger.kernel.org" , "Wysocki, Rafael J" , Kai-Heng Feng , "mika.westerberg@linux.intel.com" , "koba.ko@canonical.com" , "baolu.lu@linux.intel.com" , "sathyanarayanan.kuppuswamy@linux.intel.com" , Russell Currey , Oliver O'Halloran , "linuxppc-dev@lists.ozlabs.org" Subject: Re: [PATCH v4 2/2] PCI/PM: Fix pci_pm_suspend_noirq() to disable PTM Message-ID: <20220423150132.GA1552054@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 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 Sat, Apr 23, 2022 at 12:43:14AM +0000, Jingar, Rajvi wrote: > > -----Original Message----- > > From: Bjorn Helgaas > > On Thu, Apr 14, 2022 at 07:54:02PM +0200, Rafael J. Wysocki wrote: > > > On 3/25/2022 8:50 PM, Rajvi Jingar wrote: > > > > For the PCIe devices (like nvme) that do not go into D3 state still need to > > > > disable PTM on PCIe root ports to allow the port to enter a lower-power PM > > > > state and the SoC to reach a lower-power idle state as a whole. Move the > > > > pci_disable_ptm() out of pci_prepare_to_sleep() as this code path is not > > > > followed for devices that do not go into D3. This patch fixes the issue > > > > seen on Dell XPS 9300 with Ice Lake CPU and Dell Precision 5530 with Coffee > > > > Lake CPU platforms to get improved residency in low power idle states. > > > > > > > > Fixes: a697f072f5da ("PCI: Disable PTM during suspend to save power") > > > > Signed-off-by: Rajvi Jingar > > > > Suggested-by: David E. Box > > > > --- > > > > drivers/pci/pci-driver.c | 10 ++++++++++ > > > > drivers/pci/pci.c | 10 ---------- > > > > 2 files changed, 10 insertions(+), 10 deletions(-) > > > > > > > > diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c > > > > index 8b55a90126a2..ab733374a260 100644 > > > > --- a/drivers/pci/pci-driver.c > > > > +++ b/drivers/pci/pci-driver.c > > > > @@ -847,6 +847,16 @@ static int pci_pm_suspend_noirq(struct device *dev) > > > > if (!pci_dev->state_saved) { > > > > pci_save_state(pci_dev); > > > > + /* > > > > + * There are systems (for example, Intel mobile chips since > > Coffee > > > > + * Lake) where the power drawn while suspended can be > > significantly > > > > + * reduced by disabling PTM on PCIe root ports as this allows the > > > > + * port to enter a lower-power PM state and the SoC to reach a > > > > + * lower-power idle state as a whole. > > > > + */ > > > > + if (pci_pcie_type(pci_dev) == PCI_EXP_TYPE_ROOT_PORT) > > > > + pci_disable_ptm(pci_dev); > > > > Why is disabling PTM dependent on pci_dev->state_saved? The point of > > this is to change the behavior of the device, and it seems like we > > want to do that regardless of whether the driver has used > > pci_save_state(). > > Because we use the saved state to restore PTM on the root port. > And it's under this condition that the root port state gets saved. Yes, I understand that pci_restore_ptm_state() depends on a previous call to pci_save_ptm_state(). The point I'm trying to make is that pci_disable_ptm() changes the state of the device, and that state change should not depend on whether the driver has used pci_save_state(). When we're putting a device into a low-power state, I think we want to disable PTM *always*, no matter what the driver did. And I think we want to do it for all devices, not just Root Ports. Bjorn