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

From: Huang Ying
Date: Tue May 08 2012 - 04:35:02 EST


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.


If we replace pm_runtime_put() with pm_runtime_put_noidle() as follow,

pm_runtime_get_sync(&pci_dev->dev);
pci_wakeup_bus(pci_dev->subordinate);
pm_runtime_put_noidle(&pci_dev->dev);

if before pm_runtime_put_noidle(), subordinate devices have already go
through resuming/suspending cycle and go suspended again (because of
preemption?), bridge may lose an opportunity to go suspended.

Or we can add a parameter to pci_wakeup_bus() which will resume the
first device synchronously?

Best Regards,
Huang Ying


--
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/