linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Platform-specific suspend/resume code in drivers
@ 2016-06-07  8:56 Mason
  2016-06-07 15:06 ` Alan Stern
  0 siblings, 1 reply; 13+ messages in thread
From: Mason @ 2016-06-07  8:56 UTC (permalink / raw)
  To: linux-pm, Linux ARM
  Cc: Rafael J. Wysocki, Kevin Hilman, Ulf Hansson, Viresh Kumar,
	Pavel Machek, Arnd Bergmann, Mans Rullgard, Sebastian Frias,
	Mark Rutland

Hello everyone,

I want to implement system-wide suspend-to-RAM on my platform
(an ARM Cortex A9 based SoC).

I'm hoping some of you can clear some of my confusion :-(

AFAIU, what happens to the hardware in the suspended state is
very board/platform specific. The SoC may stop some clocks;
it may even cut the power to some parts of the chip.

AFAIU, once power is cut, the value of internal and visible
registers (called "state" or "context" IIUC) is lost.

Therefore, each driver is supposed to either

1) save context on suspend & restore it on resume, or
2) re-initialize the device on resume (if context is unimportant)

Is that correct?

(Note: Kevin Hilman mentioned using a feature called "regmap" to
help in saving/restoring context.)

Documentation/power/devices.txt mentions putting such save/restore
code in suspend_late/resume_early callbacks. Is that the preferred
solution today?

Should these routines be guarded by #ifdef CONFIG_PM or #ifdef CONFIG_SUSPEND ?

Another point of confusion for me is this: drivers are supposed to
be shared among platforms, right? So my platform-specific suspend
code should be enabled only if my platform is detected at run-time?

So this means I need to add in the probe function, for every driver
my platform uses:

  if (platform == MY_PLATFORM) {
    ops.suspend = my_suspend;
    ops.resume  = my_resume;
  }

Is that correct?


While I'm listing the points I don't understand... It seems Linux
handles suspend/resume "transparently". I mean the CPU calls all
the functions leading to the suspend action, then when the system
comes back online, it continues at the next instruction, as if
nothing had happened. So the stack and registers need to be exactly
in the same state.

But on my system, the firmware expects a return address for *where*
to return on resume. Should I pass it the next instruction pointer?
The address of the resume function?

I see arch/arm/kernel/psci_smp.c seems to have the same notion.
=> drivers/firmware/psci.c

References:
arch/arm/kernel/suspend.c
kernel/power/suspend.c

Regards.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-06-18 14:36 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-07  8:56 Platform-specific suspend/resume code in drivers Mason
2016-06-07 15:06 ` Alan Stern
2016-06-08 16:26   ` Mason
2016-06-08 17:45     ` Alan Stern
2016-06-08 21:26       ` Mason
2016-06-09 15:05         ` Alan Stern
2016-06-10 11:03           ` Mason
2016-06-10 14:19             ` Alan Stern
2016-06-10 22:32             ` Kevin Hilman
2016-06-10 13:39           ` Geert Uytterhoeven
2016-06-09  8:52       ` Sebastian Frias
2016-06-09 15:14         ` Alan Stern
2016-06-18 14:35         ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).