From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: "Huang, Ying" <ying.huang@intel.com>, Pavel Machek <pavel@ucw.cz>,
nigel@nigel.suspend2.net,
Andrew Morton <akpm@linux-foundation.org>,
Vivek Goyal <vgoyal@redhat.com>,
linux-kernel@vger.kernel.org,
linux-pm@lists.linux-foundation.org,
Kexec Mailing List <kexec@lists.infradead.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: Re: [PATCH -mm] kexec jump -v9
Date: Fri, 16 May 2008 01:20:08 +0200 [thread overview]
Message-ID: <200805160120.09057.rjw@sisk.pl> (raw)
In-Reply-To: <m163tfi5sq.fsf@frodo.ebiederm.org>
On Friday, 16 of May 2008, Eric W. Biederman wrote:
> "Rafael J. Wysocki" <rjw@sisk.pl> writes:
>
> > Well, it looks like we do similar things concurrently. Please have a look
> > here: http://kerneltrap.org/Linux/Separating_Suspend_and_Hibernation
>
> Yes. Part of the reason I wanted to separate these two conversations
> I knew something was going on.
>
> > Similar patches are in the Greg's tree already.
>
> Taking a look.
>
> I just can't get past the fact in that the only reason hibernation can
> not use the widely implemented and tested probe/remove is because of
> filesystems on block devices, and that you are proposing to add 4
> methods for each and every driver to handle that case, when they
> don't need ANYTHING!
Why exactly do you think that removing()/probing() devices just for creating
a hibernation image is a good idea?
Also, ->poweroff() is actually similar to the late phase of ->suspend().
> I wonder how hard teaching the upper layers to deal with
> hotplug/remove is?
>
> The more I look at this the more I get the impression that
> hibernation and suspend should be solved in separate patches. I'm
> not at all convinced that is what is good for the goose is good for
> the gander for things like your prepare method.
This was discussed a lot with people who had exactly opposite opinions.
With BenH in particular (CCed).
> Hibernation seems to be an extreme case of hotplug.
I don't agree with that.
> Suspend seems to be just an extreme case of putting unused
> devices in low power state.
Ditto.
> ....
>
>
> I don't like the fact that these methods are power management specific.
Please be more specific.
> How should this impact the greater kernel ecosystem.
>
> + * The externally visible transitions are handled with the help of the following
> + * callbacks included in this structure:
> + *
> + * @prepare: Prepare the device for the upcoming transition, but do NOT change
> + * its hardware state. Prevent new children of the device from being
> + * registered after @prepare() returns (the driver's subsystem and
> + * generally the rest of the kernel is supposed to prevent new calls to the
> + * probe method from being made too once @prepare() has succeeded). If
> + * @prepare() detects a situation it cannot handle (e.g. registration of a
> + * child already in progress), it may return -EAGAIN, so that the PM core
> + * can execute it once again (e.g. after the new child has been registered)
> + * to recover from the race condition. This method is executed for all
> + * kinds of suspend transitions and is followed by one of the suspend
> + * callbacks: @suspend(), @freeze(), or @poweroff().
> + * The PM core executes @prepare() for all devices before starting to
> + * execute suspend callbacks for any of them, so drivers may assume all of
> + * the other devices to be present and functional while @prepare() is being
> + * executed. In particular, it is safe to make GFP_KERNEL memory
> + * allocations from within @prepare(), although they are likely to fail in
> + * case of hibernation, if a substantial amount of memory is requested.
> + * However, drivers may NOT assume anything about the availability of the
> + * user space at that time and it is not correct to request firmware from
> + * within @prepare() (it's too late to do that).
> + *
> + * @complete: Undo the changes made by @prepare(). This method is executed for
> + * all kinds of resume transitions, following one of the resume callbacks:
> + * @resume(), @thaw(), @restore(). Also called if the state transition
> + * fails before the driver's suspend callback (@suspend(), @freeze(),
> + * @poweroff()) can be executed (e.g. if the suspend callback fails for one
> + * of the other devices that the PM core has unsucessfully attempted to
> + * suspend earlier).
> + * The PM core executes @complete() after it has executed the appropriate
> + * resume callback for all devices.
>
> The names above are terrible. Perhaps: @pause/@unpause.
The names have been discussed either and I don't intend to change them now.
Sorry.
> @pause Stop all device driver user space facing activities, and prepare
> for a possible power state transition.
>
> Essentially these should be very much like bringing an ethernet
> interface down. The device is still there but we can't do anything
> with it. The only difference is that this may not be user visible.
>
> + * @suspend: Executed before putting the system into a sleep state in which the
> + * contents of main memory are preserved. Quiesce the device, put it into
> + * a low power state appropriate for the upcoming system state (such as
> + * PCI_D3hot), and enable wakeup events as appropriate.
> + *
> + * @resume: Executed after waking the system up from a sleep state in which the
> + * contents of main memory were preserved. Put the device into the
> + * appropriate state, according to the information saved in memory by the
> + * preceding @suspend(). The driver starts working again, responding to
> + * hardware events and software requests. The hardware may have gone
> + * through a power-off reset, or it may have maintained state from the
> + * previous suspend() which the driver may rely on while resuming. On most
> + * platforms, there are no restrictions on availability of resources like
> + * clocks during @resume().
>
> Unless I have misread something.
Yes, you have.
> These are exactly the same as @poweroff and @restore.
For many drivers @suspend will be equivalent to @freeze + @poweroff probably.
Also, @restore is not the same as @resume, because @restore cannot assume
anything about the state of devices, whereas @resume can.
> @suspend place the device in a low power state.
> Enable wakeup events.
>
> Can we use this for cases when we need low power but haven't
> stopped the cpu? I think so.
And you are wrong.
We tried that, it didn't work.
> + * @freeze: Hibernation-specific, executed before creating a hibernation image.
> + * Quiesce operations so that a consistent image can be created, but do NOT
> + * otherwise put the device into a low power device state and do NOT emit
> + * system wakeup events. Save in main memory the device settings to be
> + * used by @restore() during the subsequent resume from hibernation or by
> + * the subsequent @thaw(), if the creation of the image or the restoration
> + * of main memory contents from it fails.
> + *
> + * @thaw: Hibernation-specific, executed after creating a hibernation image OR
> + * if the creation of the image fails. Also executed after a failing
> + * attempt to restore the contents of main memory from such an image.
> + * Undo the changes made by the preceding @freeze(), so the device can be
> + * operated in the same way as immediately before the call to @freeze().
>
> Just @detach/@reattach.
>
> @detach Detach the driver from the hardware, while keeping the driver
> instance for the hardware alive.
>
> Essentially this is what the shutdown method is today.
> Except for being ready for a reattach.
>
> @reattach
> See if the hardware for the driver is present and reclaim
> it and bring it up to speed for processing requests.
No, I don't think so. I don't want the driver to detach, but to quiesce the
hardware.
> + * @poweroff: Hibernation-specific, executed after saving a hibernation image.
> + * Quiesce the device, put it into a low power state appropriate for the
> + * upcoming system state (such as PCI_D3hot), and enable wakeup events as
> + * appropriate.
> + *
> + * @restore: Hibernation-specific, executed after restoring the contents of main
> + * memory from a hibernation image. Driver starts working again,
> + * responding to hardware events and software requests. Drivers may NOT
> + * make ANY assumptions about the hardware state right prior to @restore().
> + * On most platforms, there are no restrictions on availability of
> + * resources like clocks during @restore().
> + *
>
> If we have events we care about we just need to do:
> reattach(); suspend(); It is all the same from the point of view of
> the device. Not the system but the device.
That I can agree with, if I understood you correctly. :-)
Still, having more specialized callbacks is not generally bad IMO, they
can reuse the code just fine.
Thanks,
Rafael
next prev parent reply other threads:[~2008-05-15 23:20 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-06 3:13 Huang, Ying
2008-03-11 21:10 ` Vivek Goyal
2008-03-11 21:59 ` Nigel Cunningham
2008-03-11 23:55 ` Eric W. Biederman
2008-03-12 0:09 ` david
2008-03-12 2:14 ` Huang, Ying
2008-03-12 18:53 ` Vivek Goyal
2008-03-13 0:01 ` Eric W. Biederman
2008-03-11 22:18 ` Rafael J. Wysocki
2008-03-12 2:02 ` Eric W. Biederman
2008-03-12 2:26 ` Huang, Ying
2008-03-11 23:24 ` Pavel Machek
2008-03-11 23:49 ` Rafael J. Wysocki
2008-03-12 1:55 ` Huang, Ying
2008-03-12 15:01 ` [linux-pm] " Alan Stern
2008-03-12 21:53 ` Rafael J. Wysocki
2008-03-13 0:33 ` Eric W. Biederman
2008-03-13 17:03 ` Rafael J. Wysocki
2008-03-13 23:07 ` Eric W. Biederman
2008-03-14 1:31 ` Rafael J. Wysocki
[not found] ` <m1prtsug2e.fsf@ebiederm.dsl.xmission.com>
2008-03-18 23:52 ` Pavel Machek
2008-03-19 0:08 ` Rafael J. Wysocki
2008-03-19 2:33 ` Alan Stern
[not found] ` <m1ve3jtmxk.fsf@ebiederm.dsl.xmission.com>
2008-03-19 15:01 ` Alan Stern
2008-03-19 19:28 ` Rafael J. Wysocki
2008-03-20 10:40 ` Pavel Machek
2008-03-20 22:45 ` Rafael J. Wysocki
2008-03-20 23:01 ` Alan Stern
2008-03-20 23:22 ` Pavel Machek
2008-03-20 23:40 ` Rafael J. Wysocki
2008-03-21 0:36 ` Rafael J. Wysocki
2008-03-21 0:52 ` Alan Stern
2008-03-21 22:05 ` Nigel Cunningham
2008-03-22 16:21 ` Pavel Machek
2008-03-22 17:45 ` Rafael J. Wysocki
2008-03-22 20:49 ` Alan Stern
2008-03-22 21:29 ` Rafael J. Wysocki
2008-05-14 22:38 ` Eric W. Biederman
2008-05-14 23:47 ` Rafael J. Wysocki
2008-05-15 20:55 ` Eric W. Biederman
2008-05-15 21:20 ` Rafael J. Wysocki
2008-05-14 20:41 ` Maxim Levitsky
2008-05-14 23:34 ` Eric W. Biederman
2008-03-12 8:57 ` Pavel Machek
2008-03-12 0:00 ` Nigel Cunningham
2008-03-12 1:45 ` Huang, Ying
2008-03-12 2:17 ` Eric W. Biederman
2008-03-12 6:54 ` Huang, Ying
2008-03-12 19:37 ` Vivek Goyal
2008-03-14 8:03 ` Huang, Ying
2008-03-21 19:12 ` Vivek Goyal
2008-03-25 7:25 ` Huang, Ying
2008-03-12 19:47 ` Vivek Goyal
2008-04-09 9:34 ` Pavel Machek
2008-04-09 12:30 ` Vivek Goyal
2008-05-14 16:03 ` Vivek Goyal
2008-05-14 17:49 ` Vivek Goyal
2008-05-14 20:52 ` Vivek Goyal
2008-05-15 2:32 ` Huang, Ying
2008-05-15 20:09 ` Vivek Goyal
2008-05-16 1:48 ` Huang, Ying
2008-05-16 1:51 ` Vivek Goyal
2008-05-16 2:08 ` Huang, Ying
2008-05-16 12:13 ` Pavel Machek
2008-05-15 5:41 ` Huang, Ying
2008-05-15 18:42 ` Eric W. Biederman
2008-05-16 0:51 ` Vivek Goyal
2008-05-16 1:35 ` Eric W. Biederman
2008-05-16 1:55 ` Huang, Ying
2008-05-27 7:27 ` Huang, Ying
2008-05-27 22:15 ` Vivek Goyal
2008-05-28 1:35 ` Huang, Ying
2008-05-14 22:30 ` Eric W. Biederman
2008-05-14 23:55 ` Rafael J. Wysocki
2008-05-15 22:03 ` Eric W. Biederman
2008-05-15 23:20 ` Rafael J. Wysocki [this message]
2008-05-16 12:18 ` Pavel Machek
2008-05-16 14:20 ` [linux-pm] " Alan Stern
2008-05-15 1:42 ` Huang, Ying
2008-05-15 19:05 ` Rafael J. Wysocki
2008-05-15 14:14 ` [linux-pm] " Alan Stern
2008-05-15 20:48 ` Eric W. Biederman
2008-05-15 21:07 ` Alan Stern
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=200805160120.09057.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=akpm@linux-foundation.org \
--cc=benh@kernel.crashing.org \
--cc=ebiederm@xmission.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=nigel@nigel.suspend2.net \
--cc=pavel@ucw.cz \
--cc=vgoyal@redhat.com \
--cc=ying.huang@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®