Re: pm runtime and system suspend resume

From: Alan Stern
Date: Wed Jun 20 2012 - 10:40:13 EST


On Wed, 20 Jun 2012, chao xie wrote:

> >> It seems work well, but i have question about the suspend/resume of
> >> device. When the whole system will go to deep idle, and it will
> >> suspend the devices. for the function do device suspend
> >> __device_suspend,
> >
> > What source file is that function in?
> >
>
> The function is located at drivers/base/power/main.c
>
> >> it will call pm_runtime_get_noresume(dev). As i
> >> think it will make the device not do runtime suspend any more. Is that
> >> correct?
> >
> > It sounds wrong. Why would a suspend routine do that?
> >
>
> I do knot know, but the code is there.

Okay, now I understand your question. The problem is that system
suspend uses a separate mechanism from runtime suspend, and we don't
want the two things to happen at the same time. Therefore
__device_suspend does a get_noresume in order to prevent runtime
suspend from occurring in the middle of a system suspend.

> >> There is the question, how device driver handle the logic surrounds
> >> it? I want to add pm_runtime_put_sync in dev->driver->pm->suspend
> >> function, and pm_runtime_get_sync in dev->driver->pm->resume.
> >
> > You must not do that. If you do, your driver will hang.
> >
>
> why it will hang?

Sorry, I misunderstood your question. It will not hang. But why do
you want to add those calls?

> >> Because
> >> __device_suspend increase the usage_count, pm_runtime_put_sync will
> >> not do real work.
> >> So is that right that i directly call pm_runtime_suspend in
> >> dev->driver->pm->suspend and pm_runtime_resume in
> >> dev->driver->pm->resume?

No, don't call pm_runtime_suspend. Just call your driver's
runtime_suspend routine directly. Same for resume.

> Finally the real question is who will deal with the dev->pm_domain?
> when system go to sleep.

The __device_suspend routine in drivers/base/main.c uses
dev->pm_domain.

> The driver will use pm_runtime_get/put to deal with dev->pm_domain
> when it want to work or is in idle. Then when system go to sleep, the
> driver need care about dev->pm_domain too.
> Usally, dev->pm_domain is a easy way to handle the difference SOCs
> with same device IP. For example, USB. Many vendor may have same usb
> IP but difference phy and clock configuration. putting these stuff
> into dev->pm_domain can make driver be shared by different SOCs.

Alan Stern

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