From: Mason <slash.tmp@free.fr>
To: linux-pm <linux-pm@vger.kernel.org>,
Linux ARM <linux-arm-kernel@lists.infradead.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
Kevin Hilman <khilman@kernel.org>,
Ulf Hansson <ulf.hansson@linaro.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
Pavel Machek <pavel@ucw.cz>, Arnd Bergmann <arnd@arndb.de>,
Mans Rullgard <mans@mansr.com>,
Sebastian Frias <sf84@laposte.net>,
Mark Rutland <mark.rutland@arm.com>
Subject: Platform-specific suspend/resume code in drivers
Date: Tue, 7 Jun 2016 10:56:40 +0200 [thread overview]
Message-ID: <57568C48.709@free.fr> (raw)
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.
WARNING: multiple messages have this Message-ID (diff)
From: slash.tmp@free.fr (Mason)
To: linux-arm-kernel@lists.infradead.org
Subject: Platform-specific suspend/resume code in drivers
Date: Tue, 7 Jun 2016 10:56:40 +0200 [thread overview]
Message-ID: <57568C48.709@free.fr> (raw)
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.
next reply other threads:[~2016-06-07 8:57 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-07 8:56 Mason [this message]
2016-06-07 8:56 ` Platform-specific suspend/resume code in drivers Mason
2016-06-07 15:06 ` Alan Stern
2016-06-07 15:06 ` Alan Stern
2016-06-08 16:26 ` Mason
2016-06-08 16:26 ` Mason
2016-06-08 17:45 ` Alan Stern
2016-06-08 17:45 ` Alan Stern
2016-06-08 21:26 ` Mason
2016-06-08 21:26 ` Mason
2016-06-09 15:05 ` Alan Stern
2016-06-09 15:05 ` Alan Stern
2016-06-10 11:03 ` Mason
2016-06-10 11:03 ` Mason
2016-06-10 14:19 ` Alan Stern
2016-06-10 14:19 ` Alan Stern
2016-06-10 22:32 ` Kevin Hilman
2016-06-10 22:32 ` Kevin Hilman
2016-06-10 13:39 ` Geert Uytterhoeven
2016-06-10 13:39 ` Geert Uytterhoeven
2016-06-09 8:52 ` Sebastian Frias
2016-06-09 8:52 ` Sebastian Frias
2016-06-09 15:14 ` Alan Stern
2016-06-09 15:14 ` Alan Stern
2016-06-18 14:35 ` Pavel Machek
2016-06-18 14:35 ` Pavel Machek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=57568C48.709@free.fr \
--to=slash.tmp@free.fr \
--cc=arnd@arndb.de \
--cc=khilman@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=mans@mansr.com \
--cc=mark.rutland@arm.com \
--cc=pavel@ucw.cz \
--cc=rjw@rjwysocki.net \
--cc=sf84@laposte.net \
--cc=ulf.hansson@linaro.org \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.