Re: [RFC v2 5/5] PCIe, Add PCIe runtime D3cold support

From: Rafael J. Wysocki
Date: Thu May 10 2012 - 15:23:16 EST


On Tuesday, May 08, 2012, Huang Ying wrote:
> On Tue, 2012-05-08 at 10:22 +0800, Huang Ying wrote:
> > On Mon, 2012-05-07 at 23:22 +0200, Rafael J. Wysocki wrote:
> > > On Saturday, May 05, 2012, huang ying wrote:
> [...]
> > > > >> --- a/drivers/pci/pci-acpi.c
> > > > >> +++ b/drivers/pci/pci-acpi.c
> > > > >> @@ -48,6 +48,21 @@ static void pci_acpi_wake_dev(acpi_handl
> > > > >> if (event != ACPI_NOTIFY_DEVICE_WAKE || !pci_dev)
> > > > >> return;
> > > > >>
> > > > >> + if (pci_dev->current_state == PCI_D3cold) {
> > > > >> + unsigned int count = 0;
> > > > >> +
> > > > >> + /*
> > > > >> + * Powering on bridge need to resume whole hierarchy,
> > > > >> + * just resume the children to avoid the bridge going
> > > > >> + * suspending as soon as resumed
> > > > >> + */
> > > > >
> > > > > Don't you need to resume the bridge before you start walking the hierarchy
> > > > > below it?
> > > >
> > > > When we resume the hierarchy below the bridge, its parent, the bridge,
> > > > will be resumed firstly. That is:
> > > >
> > > > rpm_resume(child)
> > > > rpm_resume(parent)
> > > > ->runtime_suspend(child)
> > > >
> > > > >> + if (pci_dev->subordinate)
> > > > >> + count = pci_wakeup_bus(pci_dev->subordinate);
> > > > >> + if (count == 0)
> > > > >> + pm_runtime_resume(&pci_dev->dev);
> > > > >
> > > > > What's the count for, exactly?
> > > >
> > > > If there is no devices under the bridge, count returned will be 0,
> > > > then we will resume bridge itself.
> > >
> > > So it looks like you will resume the bridge in both cases, right?
> > >
> > > Why don't you call pm_runtime_get_sync() on the bridge first and then
> > > go for resuming the devices below it, then?
> >
> > OK. I will do that.
>
> After some thinking, have some question on this method.
>
> Do you suggest something like below?
>
> pm_runtime_get_sync(&pci_dev->dev);
> pci_wakeup_bus(pci_dev->subordinate);
> pm_runtime_put(&pci_dev->dev);
>
> If so, because pci_wakeup_bus() will call pm_request_resume() on
> subordinate devices, which is asynchronous, bridge may go suspended
> (powered off) again after pm_runtime_put(), if resuming of subordinate
> devices are still pending in work queue.

I don't think this is a big problem. Worst case it will be resumed
again by the first resuming child, but I doubt we'll see much of that
in practice.

Alternatively, you can use pm_runtime_put_noidle() followed by
pm_runtime_schedule_suspend() with appropriate delay.

Thanks,
Rafael
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/