On Thu, Aug 01, 2019 at 12:26:51AM +0200, Rafael J. Wysocki wrote:
> On Wednesday, July 31, 2019 11:30:01 PM CEST Bjorn Helgaas wrote:
> > [+cc Thunderbolt folks, see
> > https://lore.kernel.org/r/578bd3f1-b185-471b-a3eb-ff71ba34b...@canonical.com
> > for beginning of thread]
> > 
> > On Thu, Aug 01, 2019 at 12:04:29AM +0800, Kai-Heng Feng wrote:
> > > Hi,
> > > 
> > > After commit "ACPI: PM: Allow transitions to D0 to occur in special 
> > > cases”,
> > 
> > This is f850a48a0799 ("ACPI: PM: Allow transitions to D0 to occur in
> > special cases").
> > 
> > > Thunderbolt on XPS 9380 spews the following when it runtime resumes:
> > > [   36.136554] pci_raw_set_power_state: 25 callbacks suppressed
> > > [   36.136558] pcieport 0000:03:00.0: Refused to change power state,
> > > currently in D3
> > 
> > We really should be smarter about what we print here, maybe something
> > like the patch below?
> > 
> > pci_raw_set_power_state() prints "Refused to change power state" if
> > (in this case) the value of (PCI_PM_CTRL & PCI_PM_CTRL_STATE_MASK) is
> > 0x3.  Most likely we got 0xffff from PCI_PM_CTRL because the device is
> > in D3cold.  If the device is in D3cold, pci_raw_set_power_state() has
> > no hope of doing anything because it only uses PCI PM config
> > registers, and they're inaccessible in D3cold.

> > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> > index 29ed5ec1ac27..63ca963ebff9 100644
> > --- a/drivers/pci/pci.c
> > +++ b/drivers/pci/pci.c
> > @@ -851,6 +852,11 @@ static int pci_raw_set_power_state(struct pci_dev 
> > *dev, pci_power_t state)
> >             return -EIO;
> >  
> >     pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
> > +   if (pmcsr == (u16) ~0) {
> 
> Is the "device not accessible" the only case in which we can get all ones 
> from this?
> 
> If so, the change will be fine by me.

There are several RsvdP bits in that register, so it's not possible to
read all ones except in error cases.  I'll finish up a patch for it.

Bjorn

Reply via email to