There's a part of the DDK docs that says that "The IoCompletion
routine should perform whatever tasks the driver requires to return
the device to the working state."

(referring to the IoCompletion set for a wait/wake IRP in "Handling a
Wait/Wake IRP in a Function (FDO) or Filter Driver (Filter DO)")

Shouldn't this technically only be the case for the power policy
owner? Don't the other drivers in a stack just pass the wait/wake IRP
back up and only return to the working state when a subsequent
set-power IRP is received from the power policy owner?

Re: Wait/wake technicality by Maxim

Maxim
Wed Oct 11 19:22:22 CDT 2006

> There's a part of the DDK docs that says that "The IoCompletion
> routine should perform whatever tasks the driver requires to return
> the device to the working state."
>
> (referring to the IoCompletion set for a wait/wake IRP in "Handling a
> Wait/Wake IRP in a Function (FDO) or Filter Driver (Filter DO)")
>
> Shouldn't this technically only be the case for the power policy
> owner? Don't the other drivers in a stack just pass the wait/wake IRP
> back up and only return to the working state when a subsequent
> set-power IRP is received from the power policy owner?

No. The driver which drives the real hardware must do this. This is usually ==
PPO, but not always - for storage LUNs (Disk/CdRom) - the PDO is the PPO, for
kbd/mouse - the upper filter of kbd/mouclass is a PPO.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com


Re: Wait/wake technicality by BubbaGump

BubbaGump
Wed Oct 11 20:14:05 CDT 2006

On Thu, 12 Oct 2006 04:22:22 +0400, "Maxim S. Shatskih"
<maxim@storagecraft.com> wrote:

>> There's a part of the DDK docs that says that "The IoCompletion
>> routine should perform whatever tasks the driver requires to return
>> the device to the working state."
>>
>> (referring to the IoCompletion set for a wait/wake IRP in "Handling a
>> Wait/Wake IRP in a Function (FDO) or Filter Driver (Filter DO)")
>>
>> Shouldn't this technically only be the case for the power policy
>> owner? Don't the other drivers in a stack just pass the wait/wake IRP
>> back up and only return to the working state when a subsequent
>> set-power IRP is received from the power policy owner?
>
>No. The driver which drives the real hardware must do this. This is usually ==
>PPO, but not always - for storage LUNs (Disk/CdRom) - the PDO is the PPO, for
>kbd/mouse - the upper filter of kbd/mouclass is a PPO.

You must have misread my question. I know the driver that drives the
real hardware must be the one to return it to a working state. My
question is whether it should do this immediately upon seeing a
wait/wake IRP as it passes through its completion routine or to not do
anything until the power policy owner sees the wait/wake IRP and
decides to send a set-power IRP back down. Isn't an individual
driver's responsibility only to decide _how_ to bring its device back
to a working state while its the power policy owner's responsibility
to decide _when_ to do it (coordinating with other power IRPs and
system state)?


Re: Wait/wake technicality by BubbaGump

BubbaGump
Wed Oct 11 20:25:44 CDT 2006

On Thu, 12 Oct 2006 04:22:22 +0400, "Maxim S. Shatskih"
<maxim@storagecraft.com> wrote:

>> There's a part of the DDK docs that says that "The IoCompletion
>> routine should perform whatever tasks the driver requires to return
>> the device to the working state."
>>
>> (referring to the IoCompletion set for a wait/wake IRP in "Handling a
>> Wait/Wake IRP in a Function (FDO) or Filter Driver (Filter DO)")
>>
>> Shouldn't this technically only be the case for the power policy
>> owner? Don't the other drivers in a stack just pass the wait/wake IRP
>> back up and only return to the working state when a subsequent
>> set-power IRP is received from the power policy owner?
>
>No. The driver which drives the real hardware must do this. This is usually ==
>PPO, but not always - for storage LUNs (Disk/CdRom) - the PDO is the PPO, for
>kbd/mouse - the upper filter of kbd/mouclass is a PPO.

It would be helpful if it was explained to which of the several
questions "No." is directed and to which of the several actions "must
do this" refers.


Re: Wait/wake technicality by BubbaGump

BubbaGump
Wed Oct 11 22:12:57 CDT 2006

On Wed, 11 Oct 2006 21:14:07 -0400, BubbaGump <> wrote:

>On Thu, 12 Oct 2006 04:22:22 +0400, "Maxim S. Shatskih"
><maxim@storagecraft.com> wrote:
>
>>> There's a part of the DDK docs that says that "The IoCompletion
>>> routine should perform whatever tasks the driver requires to return
>>> the device to the working state."
>>>
>>> (referring to the IoCompletion set for a wait/wake IRP in "Handling a
>>> Wait/Wake IRP in a Function (FDO) or Filter Driver (Filter DO)")
>>>
>>> Shouldn't this technically only be the case for the power policy
>>> owner? Don't the other drivers in a stack just pass the wait/wake IRP
>>> back up and only return to the working state when a subsequent
>>> set-power IRP is received from the power policy owner?
>>
>>No. The driver which drives the real hardware must do this. This is usually ==
>>PPO, but not always - for storage LUNs (Disk/CdRom) - the PDO is the PPO, for
>>kbd/mouse - the upper filter of kbd/mouclass is a PPO.
>
>You must have misread my question. I know the driver that drives the
>real hardware must be the one to return it to a working state.

It might be important to say that "working state" has a different
meaning for different device objects in the stack. For an upper
filter DO, it could mean whether some worker thread is running. For
an FDO, it could mean whether interrupts are enabled. For a PDO, it
could mean whether power is physically applied to the hardware. Each
driver maintains its own device object, right, and changes its
operating state based on device power IRPs received at the top of the
stack from whichever one of the drivers in the stack happens to be the
power policy owner, right?

The power policy owner doesn't seem very important. All it does is
generate device power IRPs when it receive system power IRPs or
wait/wake IRPs. Any driver in the stack could do that. It seems
arbitrary which one does. I hear this talk about a particular driver
knowing more about power policy, but I haven't seen any concrete
examples for why a particular layer is chosen. Why filter DO for
keyboard and mouse? Why PDO for storage?


Re: Wait/wake technicality by BubbaGump

BubbaGump
Wed Oct 11 22:25:53 CDT 2006

On Thu, 12 Oct 2006 04:22:22 +0400, "Maxim S. Shatskih"
<maxim@storagecraft.com> wrote:

>> There's a part of the DDK docs that says that "The IoCompletion
>> routine should perform whatever tasks the driver requires to return
>> the device to the working state."
>>
>> (referring to the IoCompletion set for a wait/wake IRP in "Handling a
>> Wait/Wake IRP in a Function (FDO) or Filter Driver (Filter DO)")
>>
>> Shouldn't this technically only be the case for the power policy
>> owner? Don't the other drivers in a stack just pass the wait/wake IRP
>> back up and only return to the working state when a subsequent
>> set-power IRP is received from the power policy owner?
>
>No. The driver which drives the real hardware must do this. This is usually ==
>PPO, but not always - for storage LUNs (Disk/CdRom) - the PDO is the PPO, for
>kbd/mouse - the upper filter of kbd/mouclass is a PPO.

There's something else I was thinking. What would be the point of the
power policy owner sending a set-power IRP back down the stack to tell
drivers to power up, upon seeing the completion of a wait/wake IRP, if
all drivers in the stack had already powered up as the wait/wake IRP
completed up the stack? It'd be pointless.

(Actually, I think it is pointless to send a different IRP back down
and then back up again, to indicate that the drivers should power up,
when they would have already known that they should power up when the
wait/wake passed through them on the way up the first time. But, it's
documented that way, and it doesn't seem any less pointless than the
similar up and down motion involved with system power IRPs.)


Re: Wait/wake technicality by Doron

Doron
Tue Oct 17 01:30:13 CDT 2006

b/c these decisions were made ad-hoc on a per device class basis. it made
sense for kbdclass/mouclass to be the PPO based on the legacy
behaviors/assumptions previous to pnp. storage has a different history, so
PDOs made more sense

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


<BubbaGump> wrote in message
news:19bri2dq47jssq7r9hccje752a9meb667k@4ax.com...
> On Wed, 11 Oct 2006 21:14:07 -0400, BubbaGump <> wrote:
>
>>On Thu, 12 Oct 2006 04:22:22 +0400, "Maxim S. Shatskih"
>><maxim@storagecraft.com> wrote:
>>
>>>> There's a part of the DDK docs that says that "The IoCompletion
>>>> routine should perform whatever tasks the driver requires to return
>>>> the device to the working state."
>>>>
>>>> (referring to the IoCompletion set for a wait/wake IRP in "Handling a
>>>> Wait/Wake IRP in a Function (FDO) or Filter Driver (Filter DO)")
>>>>
>>>> Shouldn't this technically only be the case for the power policy
>>>> owner? Don't the other drivers in a stack just pass the wait/wake IRP
>>>> back up and only return to the working state when a subsequent
>>>> set-power IRP is received from the power policy owner?
>>>
>>>No. The driver which drives the real hardware must do this. This is
>>>usually ==
>>>PPO, but not always - for storage LUNs (Disk/CdRom) - the PDO is the PPO,
>>>for
>>>kbd/mouse - the upper filter of kbd/mouclass is a PPO.
>>
>>You must have misread my question. I know the driver that drives the
>>real hardware must be the one to return it to a working state.
>
> It might be important to say that "working state" has a different
> meaning for different device objects in the stack. For an upper
> filter DO, it could mean whether some worker thread is running. For
> an FDO, it could mean whether interrupts are enabled. For a PDO, it
> could mean whether power is physically applied to the hardware. Each
> driver maintains its own device object, right, and changes its
> operating state based on device power IRPs received at the top of the
> stack from whichever one of the drivers in the stack happens to be the
> power policy owner, right?
>
> The power policy owner doesn't seem very important. All it does is
> generate device power IRPs when it receive system power IRPs or
> wait/wake IRPs. Any driver in the stack could do that. It seems
> arbitrary which one does. I hear this talk about a particular driver
> knowing more about power policy, but I haven't seen any concrete
> examples for why a particular layer is chosen. Why filter DO for
> keyboard and mouse? Why PDO for storage?
>



Re: Wait/wake technicality by Peter

Peter
Wed Oct 18 12:44:26 CDT 2006

The PPO does one other thing - it manages idle detection for the device.

In storage i made the PDO the PPO for several reasons:

1) Storage PDOs are RAW capable, so they will get started even if there's no
function driver installed. By making the PDO the PPO we can do idle
detection and Sx -> Dx mapping for raw storage devices. Without this
powering down a system with a raw storage device would be much more
complicated.

2) In order to manage idle detection you need to keep track of what I/O is
active. the storage port driver already does this as part of the interface
with the class drivers, so it made the most logical sense for the port
driver to manage all of the power transitions.

Other stacks are free to make other decisions. For example the USB stack
doesn't allow RAW access to its PDOs, so it can assume that a device which
was started has a PPO loaded on it.

-p

"BubbaGump" wrote in message
news:19bri2dq47jssq7r9hccje752a9meb667k@4ax.com...
> On Wed, 11 Oct 2006 21:14:07 -0400, BubbaGump <> wrote:
>
>>On Thu, 12 Oct 2006 04:22:22 +0400, "Maxim S. Shatskih"
>><maxim@storagecraft.com> wrote:
>>
>>>> There's a part of the DDK docs that says that "The IoCompletion
>>>> routine should perform whatever tasks the driver requires to return
>>>> the device to the working state."
>>>>
>>>> (referring to the IoCompletion set for a wait/wake IRP in "Handling a
>>>> Wait/Wake IRP in a Function (FDO) or Filter Driver (Filter DO)")
>>>>
>>>> Shouldn't this technically only be the case for the power policy
>>>> owner? Don't the other drivers in a stack just pass the wait/wake IRP
>>>> back up and only return to the working state when a subsequent
>>>> set-power IRP is received from the power policy owner?
>>>
>>>No. The driver which drives the real hardware must do this. This is
>>>usually ==
>>>PPO, but not always - for storage LUNs (Disk/CdRom) - the PDO is the PPO,
>>>for
>>>kbd/mouse - the upper filter of kbd/mouclass is a PPO.
>>
>>You must have misread my question. I know the driver that drives the
>>real hardware must be the one to return it to a working state.
>
> It might be important to say that "working state" has a different
> meaning for different device objects in the stack. For an upper
> filter DO, it could mean whether some worker thread is running. For
> an FDO, it could mean whether interrupts are enabled. For a PDO, it
> could mean whether power is physically applied to the hardware. Each
> driver maintains its own device object, right, and changes its
> operating state based on device power IRPs received at the top of the
> stack from whichever one of the drivers in the stack happens to be the
> power policy owner, right?
>
> The power policy owner doesn't seem very important. All it does is
> generate device power IRPs when it receive system power IRPs or
> wait/wake IRPs. Any driver in the stack could do that. It seems
> arbitrary which one does. I hear this talk about a particular driver
> knowing more about power policy, but I haven't seen any concrete
> examples for why a particular layer is chosen. Why filter DO for
> keyboard and mouse? Why PDO for storage?
>


Re: Wait/wake technicality by BubbaGump

BubbaGump
Wed Oct 18 14:34:55 CDT 2006

That makes sense.

The terminology used in the device stack hierarchy confused me at one
point. I used to think the "functional device object" was always the
one provided by an outside driver writer until I realized that the
class drivers already provide the FDO so that a driver writer is left
to hook in a PDO from below (at least for storage, assuming all
outside storage drivers aren't just miniports).




On Wed, 18 Oct 2006 10:44:26 -0700, "Peter Wieland [MSFT]"
<peterwie@online.microsoft.com> wrote:

>The PPO does one other thing - it manages idle detection for the device.
>
>In storage i made the PDO the PPO for several reasons:
>
>1) Storage PDOs are RAW capable, so they will get started even if there's no
>function driver installed. By making the PDO the PPO we can do idle
>detection and Sx -> Dx mapping for raw storage devices. Without this
>powering down a system with a raw storage device would be much more
>complicated.
>
>2) In order to manage idle detection you need to keep track of what I/O is
>active. the storage port driver already does this as part of the interface
>with the class drivers, so it made the most logical sense for the port
>driver to manage all of the power transitions.
>
>Other stacks are free to make other decisions. For example the USB stack
>doesn't allow RAW access to its PDOs, so it can assume that a device which
>was started has a PPO loaded on it.