Subject: Re: pmf(9): shutdown & D1/D2 states
To: None <>
From: Marco Trillo <>
List: tech-kern
Date: 12/23/2007 23:33:29

On 12/23/07, David Young <> wrote:
> I would like to get some feedback on changes that I would like to make
> to the power management (PM) framework, pmf(9), to support D1 and D2
> power-saving states and wake-up events, and also to distinguish device
> shutdown from device suspension.
> [...]
> * D1/D2 States: D1
> According to my understanding of D1 state (Jared McNeill filled me in),
> it is a power-reduced state where the device state is not lost.  A device
> may reduce its capacities in D1 state, but it is still operational.
> According to this definition, an 802.11 adapter in D1 state may switch
> to 802.11 power-save mode: it powers-down its transmitter & receiver,
> but it stays associated with a network.  It powers up both xmtr and rcvr
> when there is something to transmit, and it powers up its rcvr at periodic
> awake times.  In this way, it stays connected, but it is a bit sluggish.

This seems to be useful for implementing some sort of power management
in an audio device for macppc.

audio(4) currently watches for activity in the audio device and, if
the device is idle within 30 seconds, a timeout is triggered. This
timeout calls the device suspend function.

The audio device I mentioned for macppc supports an 'analog power
down' mode which powers off the analog section of the codec. This is a
cheap operation, it can be turned back on without delays, and it
preserves the device state (but of course it disables the audio output
/ input).
The timeout mechanism seems to be good to perform this analog power
down; however, this shouldn't be done with the device suspend
function, as this device also supports other power management state:
'clocks stopped' (which loses device state, is more expensive and I
think it shouldn't be done with the timeout mechanism to get good

So having support for more fine-grained power states seems to be good
for this. However, the description of the 'analog power down' mode
doesn't seem to match exactly neither the D1 nor the D2 modes, as it
disables the audio operation.
The D1 mode is however the mode which best matches this feature, as
this should be completely transparent when using the audio device. (It
can cause a pop in the output when powering off, but since most models
have external mutes for the outputs, this shouldn't be a problem.).

So this device could register two different handlers: one for the D1
mode (which does the 'analog power down') which is called when the
idle timeout occurs, and other for the real suspend or light-suspend
modes (which, in addition to the analog power down, turns off the
clocks of the serial bus and releases the clock sources).

What do you think ?