Mike Larkin <[email protected]> wrote:

> On Thu, Mar 28, 2019 at 07:02:11AM +0000, Shivaprashanth H wrote:
> > hi Larkin,
> > 
> > yes. I am looking to port the hibernate feature from openbsd to freebsd.
> > 
> > so in freebsd, i see dev/ada
> > 
> 
> I don't know what physical device that corresponds to. According to the
> FreeBSD man page, that could really be anything that communicates using
> the ATA command set.
> 
> Once you find out what physical device it is, you'll need to implement
> a side-effect-free I/O routine. The ones we've built so far
> (wd/ahci/nvme/sdmmc) all reimplement a write function that uses private
> memory carved out of an area reserved in memory called the piglet. The
> machine is quiesced by that point (no interrupts, etc) and the write
> routine is required to only touch memory in the page it has been assigned
> in the piglet. The one that is likely closest to your needs is 
> ahci_hibernate_io, found in /sys/dev/ic/ahci.c. The layout of the private
> area in the piglet is described by the struct at the head of that function.
> 
> Note that in the case softraid(4) is being used, the private page is shared
> between both the side effect free softraid I/O functions and whatever
> underlying device-specific side effect free I/O function. IIRC when I 
> wrote that code, I put one struct at one end of the private page and
> the other struct at the other end. I am not sure if FreeBSD has a similar
> concept.
> 
> Good luck.

And then, you'll need the underlying VM functionality that handles this
concept called "piglet", a reserved zone for storaged so that the internal
state can be copied side-effect-free to/from disk..

And then you'll need the actual soft-state vs hard-state storage, and
all timeouts deactivated, in all drivers, the way that suspend/resume
handle it.

hibernate (and suspend/resume) took about 5 years to incrementally
develop in OpenBSD.

There are lots of pieces, which we built in relationship to our
own ACPI stack, and you may not have the pleasure of making the
same decisions we made.

the side-effect-free drivers are only a small piece of the total
framework. You may need more than good luck...


Reply via email to