lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220902204138.GA357053@bhelgaas>
Date:   Fri, 2 Sep 2022 15:41:38 -0500
From:   Bjorn Helgaas <helgaas@...nel.org>
To:     Sathyanarayanan Kuppuswamy 
        <sathyanarayanan.kuppuswamy@...ux.intel.com>
Cc:     Kai-Heng Feng <kai.heng.feng@...onical.com>,
        Rajvi Jingar <rajvi.jingar@...ux.intel.com>,
        "Rafael J . Wysocki" <rafael@...nel.org>,
        Koba Ko <koba.ko@...onical.com>,
        Mika Westerberg <mika.westerberg@...ux.intel.com>,
        "David E . Box" <david.e.box@...ux.intel.com>,
        linux-pci@...r.kernel.org, linux-pm@...r.kernel.org,
        linux-kernel@...r.kernel.org, Bjorn Helgaas <bhelgaas@...gle.com>
Subject: Re: [PATCH 2/4] PCI/PTM: Enable PTM when restoring state

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 <bhelgaas@...gle.com>
> > 
> > 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 <bhelgaas@...gle.com>
> > ---
> >  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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ