From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1042C6FA83 for ; Fri, 2 Sep 2022 20:41:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229899AbiIBUln (ORCPT ); Fri, 2 Sep 2022 16:41:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229490AbiIBUlm (ORCPT ); Fri, 2 Sep 2022 16:41:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ED1EFBA40; Fri, 2 Sep 2022 13:41:41 -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 02F1F61173; Fri, 2 Sep 2022 20:41:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30202C433C1; Fri, 2 Sep 2022 20:41:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662151300; bh=6QlO4nz3EjJTiHZOSW3Y1nsOMZEgsGLzRZeWwqrgPwk=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=laupyLzJHEyaAM+ILEF68RWgAeBDPfzLOzyKzZy8NKXhw2NeQjo2SGmWbGx0mUj3H 5nkLFvF0sbm9alfGdetu3nCgvNOqqkC1MwJI45swjOG613hs2kZkIHBqHsBSRjbnlA qFIWmNzOQZo2pJ4e/tDe7nqJ3aXU9hRUlL0Q2VpkdW6z9nTVNJIirO/u7IB316MN38 g+PWfVu0EPvjC+3k80nYvDa/EJdEg2AxdoyhpGRSA8K24QZ/W2BbJt4qYoOaLvIByX DOoOQAT4OeQoMOWJtBXxDJ2Ye9N9JzTQHoznKmT7qk/X8P/QplMUbQHjAWl5GfuLPe rZuaTwewjAqDg== Date: Fri, 2 Sep 2022 15:41:38 -0500 From: Bjorn Helgaas To: Sathyanarayanan Kuppuswamy Cc: Kai-Heng Feng , Rajvi Jingar , "Rafael J . Wysocki" , Koba Ko , Mika Westerberg , "David E . Box" , linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Helgaas Subject: Re: [PATCH 2/4] PCI/PTM: Enable PTM when restoring state Message-ID: <20220902204138.GA357053@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On Fri, Sep 02, 2022 at 10:25:54AM -0700, Sathyanarayanan Kuppuswamy wrote: > On 9/2/22 7:58 AM, Bjorn Helgaas wrote: > > From: Bjorn Helgaas > > > > The suspend path may disable PTM before saving config state, which means > > the PCI_PTM_CTRL_ENABLE bit in the saved state may be cleared even though > > we want PTM to be enabled when resuming. > > If suspend is disabling PTM separately, why not enable it during the resume > operation? Why club it with PTM state restoration? The long answer is in my previous reply [1]. The short answer is that pci_enable_ptm() only works with Endpoints, so if we enable PTM in the resume path, we need to rework it to handle Root Ports and Switch Ports as well. [1] https://lore.kernel.org/r/20220902203848.GA370638@bhelgaas > > If "dev->ptm_enabled" is set, it means PTM should be enabled, so make sure > > PCI_PTM_CTRL_ENABLE is set when restoring the PTM state. > > > > Signed-off-by: Bjorn Helgaas > > --- > > drivers/pci/pcie/ptm.c | 8 ++++++++ > > 1 file changed, 8 insertions(+) > > > > diff --git a/drivers/pci/pcie/ptm.c b/drivers/pci/pcie/ptm.c > > index b6a417247ce3..3115601a85ef 100644 > > --- a/drivers/pci/pcie/ptm.c > > +++ b/drivers/pci/pcie/ptm.c > > @@ -82,6 +82,14 @@ void pci_restore_ptm_state(struct pci_dev *dev) > > return; > > > > cap = (u16 *)&save_state->cap.data[0]; > > + > > + /* > > + * The suspend path may disable PTM before saving config state. > > + * Make sure PCI_PTM_CTRL_ENABLE is set if PTM should be enabled. > > + */ > > + if (dev->ptm_enabled) > > + *cap |= PCI_PTM_CTRL_ENABLE; > > + > > pci_write_config_word(dev, ptm + PCI_PTM_CTRL, *cap); > > } > > > > -- > Sathyanarayanan Kuppuswamy > Linux Kernel Developer