Path of IRP_MN_WAIT_WAKE

I was going through DDK documents and i want to verify my understanding
regarding Path of IRP_MN_WAIT_WAKE from experienced developers.

A device’s (capable of wakeup) power policy owner sends IRP_MN_WAKEUP to the
PDO i.e bus driver
which in turn creates another IRP and send it forward and it will keep on
sending till it reaches ACPI driver.

Path of IRP_MN_WAIT_WAKE on PC card capable of wakeup:
PC Card driver ->PC Card Controller driver ->PCI bus driver ->ACPI driver

Path of IRP_MN_WAIT_WAKE on usb mouse capable of wakeup:
USB device driver ->USB hub driver->USB Controller driver->PCI bus
driver->ACPI driver

Path of IRP_MN_WAIT_WAKE on mini-pci network card capable of wakeup:
Mini-PCI device driver -> PCI bus driver->ACPI driver

Is there any scenario in which IRP_MN_WAIT_WAKE doesn’t need to propogate to
ACPI driver.

Thanks
Ashish

> Is there any scenario in which IRP_MN_WAIT_WAKE doesn’t need to propogate
to

ACPI driver.

Yes, ACPI has filter drivers that handle this as well. Actually for
something like a USB device the stack would be something like:

USB device driver ->USB hub driver->USB Controller driver->ACPI filter
driver

But, all IRP_MN_WAIT_WAKE IRPs will end at an ACPI driver at some point in
the stack. ACPI is responsible for wake signal detection and IRP completion
at the bottom. At least as I understand it.


Bill McKenzie

wrote in message news:xxxxx@ntdev…
>
> I was going through DDK documents and i want to verify my understanding
> regarding Path of IRP_MN_WAIT_WAKE from experienced developers.
>
> A device’s (capable of wakeup) power policy owner sends IRP_MN_WAKEUP to
the
> PDO i.e bus driver
> which in turn creates another IRP and send it forward and it will keep on
> sending till it reaches ACPI driver.
>
> Path of IRP_MN_WAIT_WAKE on PC card capable of wakeup:
> PC Card driver ->PC Card Controller driver ->PCI bus driver ->ACPI driver
>
> Path of IRP_MN_WAIT_WAKE on usb mouse capable of wakeup:
> USB device driver ->USB hub driver->USB Controller driver->PCI bus
> driver->ACPI driver
>
> Path of IRP_MN_WAIT_WAKE on mini-pci network card capable of wakeup:
> Mini-PCI device driver -> PCI bus driver->ACPI driver
>
> Is there any scenario in which IRP_MN_WAIT_WAKE doesn’t need to propogate
to
> ACPI driver.
>
> Thanks
> Ashish
>
>
>

Thanks a lot

-----Original Message-----
From: Bill McKenzie [mailto:xxxxx@driver.attbbs.com]
Sent: Friday, July 12, 2002 3:42 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Path of IRP_MN_WAIT_WAKE

Is there any scenario in which IRP_MN_WAIT_WAKE doesn’t need to
propogate
to
ACPI driver.

Yes, ACPI has filter drivers that handle this as well. Actually for
something like a USB device the stack would be something like:

USB device driver ->USB hub driver->USB Controller driver->ACPI filter
driver

But, all IRP_MN_WAIT_WAKE IRPs will end at an ACPI driver at some point in
the stack. ACPI is responsible for wake signal detection and IRP completion
at the bottom. At least as I understand it.


Bill McKenzie

wrote in message news:xxxxx@ntdev…
>
> I was going through DDK documents and i want to verify my
> understanding regarding Path of IRP_MN_WAIT_WAKE from experienced
> developers.
>
> A device’s (capable of wakeup) power policy owner sends IRP_MN_WAKEUP
> to
the
> PDO i.e bus driver
> which in turn creates another IRP and send it forward and it will keep
> on sending till it reaches ACPI driver.
>
> Path of IRP_MN_WAIT_WAKE on PC card capable of wakeup:
> PC Card driver ->PC Card Controller driver ->PCI bus driver ->ACPI
> driver
>
> Path of IRP_MN_WAIT_WAKE on usb mouse capable of wakeup:
> USB device driver ->USB hub driver->USB Controller driver->PCI bus
> driver->ACPI driver
>
> Path of IRP_MN_WAIT_WAKE on mini-pci network card capable of wakeup:
> Mini-PCI device driver -> PCI bus driver->ACPI driver
>
> Is there any scenario in which IRP_MN_WAIT_WAKE doesn’t need to
> propogate
to
> ACPI driver.
>
> Thanks
> Ashish
>
>
>


You are currently subscribed to ntdev as: xxxxx@itronix.com
To unsubscribe send a blank email to %%email.unsub%%

Actually, while ACPI does filter any device that is described in the
ACPI BIOS, the filters don’t have much to do with IRP_MN_WAIT_WAKE in
most cases. **

It’s also worth noting that the IRP_MN_WAIT_WAKE that you send from the
power policy manager (probably your FDO) always stops at the PDO. The
bus driver that owns the PDO may create a completely separate
IRP_MN_WAIT_WAKE which it sends down the parent stack to arm the bus for
wakeup. That parent may create yet another one to send down the
grandparent’s stack. This always continues until it reaches a driver
that can arm the machine for wakeup. This is the ACPI driver in all
machines that we care about, though architecturally, it could be
something else.

Additionally, the sending of these IRPs and their completion may have
nothing to do with waking the entire machine. You may take your device
out of the D0 while the machine is still in S0, so that the machine uses
less electricity (which is particularly important while running on
batteries.) Remember that WDM deals in the sleeping and waking of
devices, not the entire machine. Waking the machine may be a side
effect of bringing your device into D0. But the primary action of a
wakeup signal is to request that a specific device enter the working
state.

In this case, the ACPI driver’s only role is to notify the PCI driver
that the PME# signal has been triggered.

Jake Oshins
Windows Kernel Group

** The one exception to this statement occurs when the ACPI BIOS
describes a machine wherein the wake signal for a specific device is
directly wired to the chipset power management logic, rather than the
PCI-standard PME#.

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
Subject: Re: Path of IRP_MN_WAIT_WAKE
From: “Bill McKenzie”
Date: Fri, 12 Jul 2002 17:42:09 -0500
X-Message-Number: 19

> Is there any scenario in which IRP_MN_WAIT_WAKE doesn’t need to
propogate
to
> ACPI driver.

Yes, ACPI has filter drivers that handle this as well. Actually for
something like a USB device the stack would be something like:

USB device driver ->USB hub driver->USB Controller driver->ACPI filter
driver

But, all IRP_MN_WAIT_WAKE IRPs will end at an ACPI driver at some point
in
the stack. ACPI is responsible for wake signal detection and IRP
completion
at the bottom. At least as I understand it.


Bill McKenzie

wrote in message news:xxxxx@ntdev…
>
> I was going through DDK documents and i want to verify my
understanding
> regarding Path of IRP_MN_WAIT_WAKE from experienced developers.
>
> A device’s (capable of wakeup) power policy owner sends IRP_MN_WAKEUP
to
the
> PDO i.e bus driver
> which in turn creates another IRP and send it forward and it will keep
on
> sending till it reaches ACPI driver.
>
> Path of IRP_MN_WAIT_WAKE on PC card capable of wakeup:
> PC Card driver ->PC Card Controller driver ->PCI bus driver ->ACPI
driver
>
> Path of IRP_MN_WAIT_WAKE on usb mouse capable of wakeup:
> USB device driver ->USB hub driver->USB Controller driver->PCI bus
> driver->ACPI driver
>
> Path of IRP_MN_WAIT_WAKE on mini-pci network card capable of wakeup:
> Mini-PCI device driver -> PCI bus driver->ACPI driver
>
> Is there any scenario in which IRP_MN_WAIT_WAKE doesn’t need to
propogate
to
> ACPI driver.
>
> Thanks
> Ashish
>
>
>

It didn’t know that the bus driver ‘may’ create a new IRP for the parent
stack, I thought it was a ‘must’. Otherwise, cancelling this IRP could get
really screwy yes? As in a driver could potentially need to cancel an IRP
it didn’t create.

Remember that WDM deals in the sleeping and waking of
devices, not the entire machine. Waking the machine may be a side
effect of bringing your device into D0. But the primary action of a
wakeup signal is to request that a specific device enter the working
state.

The documentation clearly makes it sound more than a side effect, at least
as I read it in the DDK. For instance in the docs for IRP_MN_WAIT_WAKE
under Input, what does this mean:

“Parameters.WaitWake.SystemWake contains the lowest (least-powered) system
power state from which the device should be allowed to awaken the system.”

Or how about this:
"Operation
A driver sends IRP_MN_WAIT_WAKE for either of two reasons:

1… To enable its device to awaken a sleeping system in response to an
external wake-up signal.
2… To enable its device to awaken from a device sleep state in response
to an external wake-up signal. "
It appears waking the system was an intent of this IRP, or at least one
possible intent, no?


Bill McKenzie

“Jake Oshins” wrote in message
news:xxxxx@ntdev…

Actually, while ACPI does filter any device that is described in the
ACPI BIOS, the filters don’t have much to do with IRP_MN_WAIT_WAKE in
most cases.

It’s also worth noting that the IRP_MN_WAIT_WAKE that you send from the
power policy manager (probably your FDO) always stops at the PDO. The
bus driver that owns the PDO may create a completely separate
IRP_MN_WAIT_WAKE which it sends down the parent stack to arm the bus for
wakeup. That parent may create yet another one to send down the
grandparent’s stack. This always continues until it reaches a driver
that can arm the machine for wakeup. This is the ACPI driver in all
machines that we care about, though architecturally, it could be
something else.

Additionally, the sending of these IRPs and their completion may have
nothing to do with waking the entire machine. You may take your device
out of the D0 while the machine is still in S0, so that the machine uses
less electricity (which is particularly important while running on
batteries.) Remember that WDM deals in the sleeping and waking of
devices, not the entire machine. Waking the machine may be a side
effect of bringing your device into D0. But the primary action of a
wakeup signal is to request that a specific device enter the working
state.

In this case, the ACPI driver’s only role is to notify the PCI driver
that the PME# signal has been triggered.

Jake Oshins
Windows Kernel Group

The one exception to this statement occurs when the ACPI BIOS
describes a machine wherein the wake signal for a specific device is
directly wired to the chipset power management logic, rather than the
PCI-standard PME#.

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
Subject: Re: Path of IRP_MN_WAIT_WAKE
From: “Bill McKenzie”
Date: Fri, 12 Jul 2002 17:42:09 -0500
X-Message-Number: 19

> Is there any scenario in which IRP_MN_WAIT_WAKE doesn’t need to
propogate
to
> ACPI driver.

Yes, ACPI has filter drivers that handle this as well. Actually for
something like a USB device the stack would be something like:

USB device driver ->USB hub driver->USB Controller driver->ACPI filter
driver

But, all IRP_MN_WAIT_WAKE IRPs will end at an ACPI driver at some point
in
the stack. ACPI is responsible for wake signal detection and IRP
completion
at the bottom. At least as I understand it.


Bill McKenzie

wrote in message news:xxxxx@ntdev…
>
> I was going through DDK documents and i want to verify my
understanding
> regarding Path of IRP_MN_WAIT_WAKE from experienced developers.
>
> A device’s (capable of wakeup) power policy owner sends IRP_MN_WAKEUP
to
the
> PDO i.e bus driver
> which in turn creates another IRP and send it forward and it will keep
on
> sending till it reaches ACPI driver.
>
> Path of IRP_MN_WAIT_WAKE on PC card capable of wakeup:
> PC Card driver ->PC Card Controller driver ->PCI bus driver ->ACPI
driver
>
> Path of IRP_MN_WAIT_WAKE on usb mouse capable of wakeup:
> USB device driver ->USB hub driver->USB Controller driver->PCI bus
> driver->ACPI driver
>
> Path of IRP_MN_WAIT_WAKE on mini-pci network card capable of wakeup:
> Mini-PCI device driver -> PCI bus driver->ACPI driver
>
> Is there any scenario in which IRP_MN_WAIT_WAKE doesn’t need to
propogate
to
> ACPI driver.
>
> Thanks
> Ashish
>
>
>

Sorry. I didn’t mean to imply that the bus driver could re-use the IRP
sent to it by the device’s FDO. The ‘may’ was only there because some
wakeup scenarios can be handled without sending an IRP through the
parent stacks.

About the intention of IRP_MN_WAIT_WAKE, the DDK is (again) misleading.
You’ll end up designing yourself into a corner if you design with the
system state in mind. Drivers should only concern themselves with
whether or not their devices are in D0. If the hardware, via a wakeup
signal, requests that a device be moved into D0, then the system power
manager (which is not in your driver stacks) will guarantee that the
system brought into S0.

The confusion is understandable, as many drivers never put take their
devices out of D0 unless the system leaves S0.

Also, the DDK was written before people really understood the
ramifications of wakeup. The people who were my immediate predecessors
designed WDM. And wakeup was the last and least-well-understood thing
that they did. (You might argue that a few of the dark corners of PnP
were of the same standing, but I think that wakeup was the worst case.)
In their defense, plug and play and power management hardware existed
before WDM. But the concept of a general mechanism to support waking a
single device while the system is in S0 didn’t exist beforehand. It
took a while before this began to appear.

I then spent three years figure out how to make it work coherently, and
I strongly believe that you need to work only in terms of device power
states when you send IRP_MN_WAIT_WAKE.

I’m guessing that I’ll get a lot of responses from people who think that
they should design with the system state in mind. Please send them.
Let’s talk them out.

Jake Oshins
Windows Kernel Group

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
Subject: Re: Path of IRP_MN_WAIT_WAKE
From: “Bill McKenzie”
Date: Sat, 13 Jul 2002 01:20:44 -0500
X-Message-Number: 2

It didn’t know that the bus driver ‘may’ create a new IRP for the parent
stack, I thought it was a ‘must’. Otherwise, cancelling this IRP could
get
really screwy yes? As in a driver could potentially need to cancel an
IRP
it didn’t create.

>Remember that WDM deals in the sleeping and waking of
>devices, not the entire machine. Waking the machine may be a side
>effect of bringing your device into D0. But the primary action of a
>wakeup signal is to request that a specific device enter the working
>state.

The documentation clearly makes it sound more than a side effect, at
least
as I read it in the DDK. For instance in the docs for IRP_MN_WAIT_WAKE
under Input, what does this mean:

“Parameters.WaitWake.SystemWake contains the lowest (least-powered)
system
power state from which the device should be allowed to awaken the
system.”

Or how about this:
"Operation
A driver sends IRP_MN_WAIT_WAKE for either of two reasons:

1… To enable its device to awaken a sleeping system in response to an
external wake-up signal.
2… To enable its device to awaken from a device sleep state in
response
to an external wake-up signal. "
It appears waking the system was an intent of this IRP, or at least one
possible intent, no?


Bill McKenzie

“Jake Oshins” wrote in message
news:xxxxx@ntdev…

Actually, while ACPI does filter any device that is described in the
ACPI BIOS, the filters don’t have much to do with IRP_MN_WAIT_WAKE in
most cases.

It’s also worth noting that the IRP_MN_WAIT_WAKE that you send from the
power policy manager (probably your FDO) always stops at the PDO. The
bus driver that owns the PDO may create a completely separate
IRP_MN_WAIT_WAKE which it sends down the parent stack to arm the bus for
wakeup. That parent may create yet another one to send down the
grandparent’s stack. This always continues until it reaches a driver
that can arm the machine for wakeup. This is the ACPI driver in all
machines that we care about, though architecturally, it could be
something else.

Additionally, the sending of these IRPs and their completion may have
nothing to do with waking the entire machine. You may take your device
out of the D0 while the machine is still in S0, so that the machine uses
less electricity (which is particularly important while running on
batteries.) Remember that WDM deals in the sleeping and waking of
devices, not the entire machine. Waking the machine may be a side
effect of bringing your device into D0. But the primary action of a
wakeup signal is to request that a specific device enter the working
state.

In this case, the ACPI driver’s only role is to notify the PCI driver
that the PME# signal has been triggered.

Jake Oshins
Windows Kernel Group

The one exception to this statement occurs when the ACPI BIOS
describes a machine wherein the wake signal for a specific device is
directly wired to the chipset power management logic, rather than the
PCI-standard PME#.

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
Subject: Re: Path of IRP_MN_WAIT_WAKE
From: “Bill McKenzie”
Date: Fri, 12 Jul 2002 17:42:09 -0500
X-Message-Number: 19

> Is there any scenario in which IRP_MN_WAIT_WAKE doesn’t need to
propogate
to
> ACPI driver.

Yes, ACPI has filter drivers that handle this as well. Actually for
something like a USB device the stack would be something like:

USB device driver ->USB hub driver->USB Controller driver->ACPI filter
driver

But, all IRP_MN_WAIT_WAKE IRPs will end at an ACPI driver at some point
in
the stack. ACPI is responsible for wake signal detection and IRP
completion
at the bottom. At least as I understand it.


Bill McKenzie

> Sorry. I didn’t mean to imply that the bus driver could re-use the IRP

sent to it by the device’s FDO. The ‘may’ was only there because some
wakeup scenarios can be handled without sending an IRP through the
parent stacks.

This is completely unclear from the docs. From the DDK, it appears to me
that only the ACPI bus and ACPI filter drivers can handle a wake signal, in
that only those drivers can detect the wake signal, properly bring the
system into a working state, and signal other drivers to wake their devices
by completing the correct wake IRPs. Can you explain how wake works really?
Especially how a stack could skip sending the wake IRP to an ACPI agent?

I’m guessing that I’ll get a lot of responses from people who think that
they should design with the system state in mind. Please send them.
Let’s talk them out.

Well, while I agree that only the device power state is of any concern to
the driver of a particular device, it is the waking of the system that the
IRP_MN_WAIT_WAKE IRP is primarily there for yes? I can’t imagine that a NIC
is concerned with waking the NIC. The NIC is concerned with waking the
system due to appropriate network traffic. A device driver will never send
a system power state, but that doesn’t mean it isn’t concerned with the
state of the system, right?

Your suggesting that the wake mechanism be used to bring an individual
device back to life is interesting, but probably not very common. I can’t
imagine what type of device could handle this, and how much power it would
save if it could. Most devices that can power down when idle can and
probably should power all the way down and power back up when a handle is
open or some such. Like a COM port usage model. I imagine that most
devices could handle this model. Using some standby state that allowed wake
signalling would require more power, and seem unneccesary for most devices.
I would only design a device like this if it needed to wake the system. So,
what types of devices do this and why?


Bill McKenzie

“Jake Oshins” wrote in message
news:xxxxx@ntdev…

Sorry. I didn’t mean to imply that the bus driver could re-use the IRP
sent to it by the device’s FDO. The ‘may’ was only there because some
wakeup scenarios can be handled without sending an IRP through the
parent stacks.

About the intention of IRP_MN_WAIT_WAKE, the DDK is (again) misleading.
You’ll end up designing yourself into a corner if you design with the
system state in mind. Drivers should only concern themselves with
whether or not their devices are in D0. If the hardware, via a wakeup
signal, requests that a device be moved into D0, then the system power
manager (which is not in your driver stacks) will guarantee that the
system brought into S0.

The confusion is understandable, as many drivers never put take their
devices out of D0 unless the system leaves S0.

Also, the DDK was written before people really understood the
ramifications of wakeup. The people who were my immediate predecessors
designed WDM. And wakeup was the last and least-well-understood thing
that they did. (You might argue that a few of the dark corners of PnP
were of the same standing, but I think that wakeup was the worst case.)
In their defense, plug and play and power management hardware existed
before WDM. But the concept of a general mechanism to support waking a
single device while the system is in S0 didn’t exist beforehand. It
took a while before this began to appear.

I then spent three years figure out how to make it work coherently, and
I strongly believe that you need to work only in terms of device power
states when you send IRP_MN_WAIT_WAKE.

I’m guessing that I’ll get a lot of responses from people who think that
they should design with the system state in mind. Please send them.
Let’s talk them out.

Jake Oshins
Windows Kernel Group

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
Subject: Re: Path of IRP_MN_WAIT_WAKE
From: “Bill McKenzie”
Date: Sat, 13 Jul 2002 01:20:44 -0500
X-Message-Number: 2

It didn’t know that the bus driver ‘may’ create a new IRP for the parent
stack, I thought it was a ‘must’. Otherwise, cancelling this IRP could
get
really screwy yes? As in a driver could potentially need to cancel an
IRP
it didn’t create.

>Remember that WDM deals in the sleeping and waking of
>devices, not the entire machine. Waking the machine may be a side
>effect of bringing your device into D0. But the primary action of a
>wakeup signal is to request that a specific device enter the working
>state.

The documentation clearly makes it sound more than a side effect, at
least
as I read it in the DDK. For instance in the docs for IRP_MN_WAIT_WAKE
under Input, what does this mean:

“Parameters.WaitWake.SystemWake contains the lowest (least-powered)
system
power state from which the device should be allowed to awaken the
system.”

Or how about this:
"Operation
A driver sends IRP_MN_WAIT_WAKE for either of two reasons:

1… To enable its device to awaken a sleeping system in response to an
external wake-up signal.
2… To enable its device to awaken from a device sleep state in
response
to an external wake-up signal. "
It appears waking the system was an intent of this IRP, or at least one
possible intent, no?


Bill McKenzie

“Jake Oshins” wrote in message
news:xxxxx@ntdev…

Actually, while ACPI does filter any device that is described in the
ACPI BIOS, the filters don’t have much to do with IRP_MN_WAIT_WAKE in
most cases.

It’s also worth noting that the IRP_MN_WAIT_WAKE that you send from the
power policy manager (probably your FDO) always stops at the PDO. The
bus driver that owns the PDO may create a completely separate
IRP_MN_WAIT_WAKE which it sends down the parent stack to arm the bus for
wakeup. That parent may create yet another one to send down the
grandparent’s stack. This always continues until it reaches a driver
that can arm the machine for wakeup. This is the ACPI driver in all
machines that we care about, though architecturally, it could be
something else.

Additionally, the sending of these IRPs and their completion may have
nothing to do with waking the entire machine. You may take your device
out of the D0 while the machine is still in S0, so that the machine uses
less electricity (which is particularly important while running on
batteries.) Remember that WDM deals in the sleeping and waking of
devices, not the entire machine. Waking the machine may be a side
effect of bringing your device into D0. But the primary action of a
wakeup signal is to request that a specific device enter the working
state.

In this case, the ACPI driver’s only role is to notify the PCI driver
that the PME# signal has been triggered.

Jake Oshins
Windows Kernel Group

The one exception to this statement occurs when the ACPI BIOS
describes a machine wherein the wake signal for a specific device is
directly wired to the chipset power management logic, rather than the
PCI-standard PME#.

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
Subject: Re: Path of IRP_MN_WAIT_WAKE
From: “Bill McKenzie”
Date: Fri, 12 Jul 2002 17:42:09 -0500
X-Message-Number: 19

> Is there any scenario in which IRP_MN_WAIT_WAKE doesn’t need to
propogate
to
> ACPI driver.

Yes, ACPI has filter drivers that handle this as well. Actually for
something like a USB device the stack would be something like:

USB device driver ->USB hub driver->USB Controller driver->ACPI filter
driver

But, all IRP_MN_WAIT_WAKE IRPs will end at an ACPI driver at some point
in
the stack. ACPI is responsible for wake signal detection and IRP
completion
at the bottom. At least as I understand it.


Bill McKenzie

>I then spent three years figure out how to make it work coherently,
and

I strongly believe that you need to work only in terms of device
power
states when you send IRP_MN_WAIT_WAKE.

There is (was?) a place in wakeup docs which seems to be very strange.

Let’s imagine a bus driver like USBHUB, which has 2 devices on it
capable of waking the system. Let them be USB keyboard and USB mouse.
So, there will be 2 wait/wake IRPs - one for keyboard stack, another
to mouse stack. The USBHUB bus driver will receive 2 wait/wake IRPs to
2 different PDOs.

According to the documentation, the bus driver must send 2 wait/wake
IRPs (other IRPs, not reuse of PDO’s IRPs) down to its FDO stack - in
this USB-related sample, down to UHCD, then ACPI and PCI.SYS.

Is it not strange? Will ACPI and PCI bus driver tolerate 2 or more
pending wait/wake IRPs?
If yes - then all bus and function drivers must handle correctly this
case of several pending wait/wake IRPs. Is it documented?
If not - then a) the documentation is incorrect and b) USBHUB or
similar bus driver must be smart enough to send not more then 1
wait/wake IRP down its FDO stack, even if it receives several IRPs to
several of its PDOs.

What is the correct case?

Max

As I understand it, the bus driver will receive two wait wake IRPs to its
PDOs, but the bus FDO will only send one down. It tracks wake capable
children though, as the following paragraph explains, from the DDK docs
“Understanding the Path of Wait/Wake IRPs through a Device Tree”:

“Although a parent driver might enumerate more than one child that can be
enabled for wait/wake, only one wait/wake IRP can be pending for a PDO. In
such cases, the parent driver should make sure that it keeps a wait/wake IRP
pending whenever any of its devices is enabled for wake-up. To do so, the
driver should increment an internal counter each time it receives a
wait/wake IRP. Each time the driver completes a wait/wake IRP, it decrements
the count and, if the resulting value is nonzero, sends another wait/wake
IRP to its device stack.”


Bill McKenzie

“Maxim S. Shatskih” wrote in message
news:xxxxx@ntdev…
>
> >I then spent three years figure out how to make it work coherently,
> and
> >I strongly believe that you need to work only in terms of device
> power
> >states when you send IRP_MN_WAIT_WAKE.
>
> There is (was?) a place in wakeup docs which seems to be very strange.
>
> Let’s imagine a bus driver like USBHUB, which has 2 devices on it
> capable of waking the system. Let them be USB keyboard and USB mouse.
> So, there will be 2 wait/wake IRPs - one for keyboard stack, another
> to mouse stack. The USBHUB bus driver will receive 2 wait/wake IRPs to
> 2 different PDOs.
>
> According to the documentation, the bus driver must send 2 wait/wake
> IRPs (other IRPs, not reuse of PDO’s IRPs) down to its FDO stack - in
> this USB-related sample, down to UHCD, then ACPI and PCI.SYS.
>
> Is it not strange? Will ACPI and PCI bus driver tolerate 2 or more
> pending wait/wake IRPs?
> If yes - then all bus and function drivers must handle correctly this
> case of several pending wait/wake IRPs. Is it documented?
> If not - then a) the documentation is incorrect and b) USBHUB or
> similar bus driver must be smart enough to send not more then 1
> wait/wake IRP down its FDO stack, even if it receives several IRPs to
> several of its PDOs.
>
> What is the correct case?
>
> Max
>
>
>
>
>

Interestingly enough, though, this would pretty well make waking an
individual device, an impossibility. As in, how would the bus possibly know
which of its wake capable devices caused the wake signal? I guess this is
hardware specific, as in, the host controller manufacturer or whoever better
make this accessible to the bus driver, right? Then what do you do if more
than one device yanked the wake signal, does the bus complete the wake IRPs
for each of those devices and decrement the count accordingly? It certainly
is unclear from the docs.


Bill McKenzie

“Bill McKenzie” wrote in message
news:xxxxx@ntdev…
>
> As I understand it, the bus driver will receive two wait wake IRPs to its
> PDOs, but the bus FDO will only send one down. It tracks wake capable
> children though, as the following paragraph explains, from the DDK docs
> “Understanding the Path of Wait/Wake IRPs through a Device Tree”:
>
> “Although a parent driver might enumerate more than one child that can be
> enabled for wait/wake, only one wait/wake IRP can be pending for a PDO. In
> such cases, the parent driver should make sure that it keeps a wait/wake
IRP
> pending whenever any of its devices is enabled for wake-up. To do so, the
> driver should increment an internal counter each time it receives a
> wait/wake IRP. Each time the driver completes a wait/wake IRP, it
decrements
> the count and, if the resulting value is nonzero, sends another wait/wake
> IRP to its device stack.”
>
> –
> Bill McKenzie
>
>
>
> “Maxim S. Shatskih” wrote in message
> news:xxxxx@ntdev…
> >
> > >I then spent three years figure out how to make it work coherently,
> > and
> > >I strongly believe that you need to work only in terms of device
> > power
> > >states when you send IRP_MN_WAIT_WAKE.
> >
> > There is (was?) a place in wakeup docs which seems to be very strange.
> >
> > Let’s imagine a bus driver like USBHUB, which has 2 devices on it
> > capable of waking the system. Let them be USB keyboard and USB mouse.
> > So, there will be 2 wait/wake IRPs - one for keyboard stack, another
> > to mouse stack. The USBHUB bus driver will receive 2 wait/wake IRPs to
> > 2 different PDOs.
> >
> > According to the documentation, the bus driver must send 2 wait/wake
> > IRPs (other IRPs, not reuse of PDO’s IRPs) down to its FDO stack - in
> > this USB-related sample, down to UHCD, then ACPI and PCI.SYS.
> >
> > Is it not strange? Will ACPI and PCI bus driver tolerate 2 or more
> > pending wait/wake IRPs?
> > If yes - then all bus and function drivers must handle correctly this
> > case of several pending wait/wake IRPs. Is it documented?
> > If not - then a) the documentation is incorrect and b) USBHUB or
> > similar bus driver must be smart enough to send not more then 1
> > wait/wake IRP down its FDO stack, even if it receives several IRPs to
> > several of its PDOs.
> >
> > What is the correct case?
> >
> > Max
> >
> >
> >
> >
> >
>
>
>
>

I’ll try to answer both Max and Bill in one message.

It was very much the intent of the WDM architects (and everyone, like
myself, who has come after them) to enable devices to be placed in low
power states while the machine is in the S0 state. While this may not
seem very meaningful for desktop and server machines, it’s critical in
laptops.

I currently use two laptops in my everyday life. One is a huge
sixteen-inch screen and the kitchen sink variety that I use for my
everyday coding and development. The other is a low-power Tualatin
processor based ultra-slim that I use when traveling. (They are the IBM
Thinkpad A21p and the IBM Thinkpad s30 for those who are overly
interested.) The big one has (I think) a fourteen-cell battery pack and
a typical power budget somewhere upwards of 25W.

We took a machine that was identical to the little one once and
evicerated a battery pack for it, hooking up test leads. We found that,
at idle, the little one used between 1.0W and 1.5W. Remember that this
is a machine around four pounds with a 4 hour battery life. Intel tells
us that the processor is responsible for about .6W at idle. The rest of
the power is consumed mostly by the backlight, the ethernet PHY and the
1394 PHY. (It’s a Japanese-market machine, which is why it has both
built in.) Before we added code to USB to put it into a low-power state
at idle, the power budget would have been around a watt higher. As you
can see, in this type of machine, 300mW can be an extra half-hour of
battery time, which is very significant.

Let’s take the ethernet as an example. It’s rarely in use when the
machine is running on batteries. So you’d really like to shut it down.
But you’d still want it to come back on line as soon as you plugged it
into a hub. This is accomplishable using the very IRP_MN_WAIT_WAKE
mechanisms that are in WDM. The NDIS stack sends IRP_MN_WAIT_WAKE to
its PDO, which is PCI.sys. PCI.sys then sends another to its parent,
which in this case is ACPI.sys. The NDIS driver then moves the NIC out
of D0 and shuts down the PHY, which is the power-hungry part. When the
ethernet cable is plugged back in, it triggers PME# and the series of
IRPs is completed, causing the NDIS stack to bring the NIC back into D0.

USB is a similar case, though it has a couple of interesting
particularities. First, USB defines a wake mechanism that is contained
within USB. So it’s entirely possible that USB may power down a single
port in response to a keyboard stack sending IRP_MN_WAIT_WAKE. Since
the other ports are still active, the controller will remain active, not
sending an IRP to its parent. (This is the ‘may’ case we were talking
about before.) If the user touches the keyboard, then the keyboard
device will signal for wakeup using the USB mechanism, and the
controller (root hub) driver will complete the keyboard driver’s IRP.
Of course, if all ports have been powered down, then the root hub will
power itself down, which will require an IRP to its parent to enable
wakeup.

USB is also interesting because, when active, it requires periodic DMA
traffic. While this doesn’t require much power in the USB controller or
the memory controller, it forces the processor to stay in an active
state, so that the processor caches are kept coherent. This means that
USB, or any other device that you guys may be working with which uses a
lot of DMA, can cause a machine like my small laptop to add another
watt, (sometimes 2 or 3 watts,) to its active power usage. That’s a
huge reduction in battery life.

And, yes Max, the USB controller has got to be prepared to pend a
separate IRP_MN_WAIT_WAKE from each of its child devices. It only has
to send one to its parent in response, and only if the parent isn’t
capable of handling the children’s IRPs by itself. (To review, this
would either be because it can’t detect a wakeup signal from its child,
probably because the child is just triggering PME# directly. Or it
could be because the parent itself has been moved out of D0, meaning
that it will trigger wakeup when its child does, probably through PME#.)

If you want more information, I wrote a white paper a couple of years
ago that was intended to help motherboard manufacturers deal route
wakeup signals in ways that could actually work. It also covers some
issues that you’ve touched on. It’s at:

http://www.microsoft.com/hwdev/tech/onnow/GPE_routing.asp

Postscript: NDIS and other miniport stacks hide the details of WDM. So
you have to get them to do run-time power management in ways that may
seem strange. If you want or need details about a particular port
model, I’ll pass your questions along to the owners.

Hope this helps. Please ask more questions if it’s still not clear.

Jake Oshins
Windows Kernel Group

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
Subject: Re: Path of IRP_MN_WAIT_WAKE
From: “Bill McKenzie”
Date: Sun, 14 Jul 2002 02:16:14 -0500
X-Message-Number: 3

> Sorry. I didn’t mean to imply that the bus driver could re-use the
IRP
> sent to it by the device’s FDO. The ‘may’ was only there because some
> wakeup scenarios can be handled without sending an IRP through the
> parent stacks.

This is completely unclear from the docs. From the DDK, it appears to
me
that only the ACPI bus and ACPI filter drivers can handle a wake signal,
in
that only those drivers can detect the wake signal, properly bring the
system into a working state, and signal other drivers to wake their
devices
by completing the correct wake IRPs. Can you explain how wake works
really?
Especially how a stack could skip sending the wake IRP to an ACPI agent?

> I’m guessing that I’ll get a lot of responses from people who think
that
> they should design with the system state in mind. Please send them.
> Let’s talk them out.

Well, while I agree that only the device power state is of any concern
to
the driver of a particular device, it is the waking of the system that
the
IRP_MN_WAIT_WAKE IRP is primarily there for yes? I can’t imagine that a
NIC
is concerned with waking the NIC. The NIC is concerned with waking the
system due to appropriate network traffic. A device driver will never
send
a system power state, but that doesn’t mean it isn’t concerned with the
state of the system, right?

Your suggesting that the wake mechanism be used to bring an individual
device back to life is interesting, but probably not very common. I
can’t
imagine what type of device could handle this, and how much power it
would
save if it could. Most devices that can power down when idle can and
probably should power all the way down and power back up when a handle
is
open or some such. Like a COM port usage model. I imagine that most
devices could handle this model. Using some standby state that allowed
wake
signalling would require more power, and seem unneccesary for most
devices.
I would only design a device like this if it needed to wake the system.
So,
what types of devices do this and why?


Bill McKenzie

“Jake Oshins” wrote in message
news:xxxxx@ntdev…

Sorry. I didn’t mean to imply that the bus driver could re-use the IRP
sent to it by the device’s FDO. The ‘may’ was only there because some
wakeup scenarios can be handled without sending an IRP through the
parent stacks.

About the intention of IRP_MN_WAIT_WAKE, the DDK is (again) misleading.
You’ll end up designing yourself into a corner if you design with the
system state in mind. Drivers should only concern themselves with
whether or not their devices are in D0. If the hardware, via a wakeup
signal, requests that a device be moved into D0, then the system power
manager (which is not in your driver stacks) will guarantee that the
system brought into S0.

The confusion is understandable, as many drivers never put take their
devices out of D0 unless the system leaves S0.

Also, the DDK was written before people really understood the
ramifications of wakeup. The people who were my immediate predecessors
designed WDM. And wakeup was the last and least-well-understood thing
that they did. (You might argue that a few of the dark corners of PnP
were of the same standing, but I think that wakeup was the worst case.)
In their defense, plug and play and power management hardware existed
before WDM. But the concept of a general mechanism to support waking a
single device while the system is in S0 didn’t exist beforehand. It
took a while before this began to appear.

I then spent three years figure out how to make it work coherently, and
I strongly believe that you need to work only in terms of device power
states when you send IRP_MN_WAIT_WAKE.

I’m guessing that I’ll get a lot of responses from people who think that
they should design with the system state in mind. Please send them.
Let’s talk them out.

Jake Oshins
Windows Kernel Group

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
Subject: Re: Path of IRP_MN_WAIT_WAKE
From: “Bill McKenzie”
Date: Sat, 13 Jul 2002 01:20:44 -0500
X-Message-Number: 2

It didn’t know that the bus driver ‘may’ create a new IRP for the parent
stack, I thought it was a ‘must’. Otherwise, cancelling this IRP could
get
really screwy yes? As in a driver could potentially need to cancel an
IRP
it didn’t create.

>Remember that WDM deals in the sleeping and waking of
>devices, not the entire machine. Waking the machine may be a side
>effect of bringing your device into D0. But the primary action of a
>wakeup signal is to request that a specific device enter the working
>state.

The documentation clearly makes it sound more than a side effect, at
least
as I read it in the DDK. For instance in the docs for IRP_MN_WAIT_WAKE
under Input, what does this mean:

“Parameters.WaitWake.SystemWake contains the lowest (least-powered)
system
power state from which the device should be allowed to awaken the
system.”

Or how about this:
"Operation
A driver sends IRP_MN_WAIT_WAKE for either of two reasons:

1… To enable its device to awaken a sleeping system in response to an
external wake-up signal.
2… To enable its device to awaken from a device sleep state in
response
to an external wake-up signal. "
It appears waking the system was an intent of this IRP, or at least one
possible intent, no?


Bill McKenzie

“Jake Oshins” wrote in message
news:xxxxx@ntdev…

Actually, while ACPI does filter any device that is described in the
ACPI BIOS, the filters don’t have much to do with IRP_MN_WAIT_WAKE in
most cases.

It’s also worth noting that the IRP_MN_WAIT_WAKE that you send from the
power policy manager (probably your FDO) always stops at the PDO. The
bus driver that owns the PDO may create a completely separate
IRP_MN_WAIT_WAKE which it sends down the parent stack to arm the bus for
wakeup. That parent may create yet another one to send down the
grandparent’s stack. This always continues until it reaches a driver
that can arm the machine for wakeup. This is the ACPI driver in all
machines that we care about, though architecturally, it could be
something else.

Additionally, the sending of these IRPs and their completion may have
nothing to do with waking the entire machine. You may take your device
out of the D0 while the machine is still in S0, so that the machine uses
less electricity (which is particularly important while running on
batteries.) Remember that WDM deals in the sleeping and waking of
devices, not the entire machine. Waking the machine may be a side
effect of bringing your device into D0. But the primary action of a
wakeup signal is to request that a specific device enter the working
state.

In this case, the ACPI driver’s only role is to notify the PCI driver
that the PME# signal has been triggered.

Jake Oshins
Windows Kernel Group

The one exception to this statement occurs when the ACPI BIOS
describes a machine wherein the wake signal for a specific device is
directly wired to the chipset power management logic, rather than the
PCI-standard PME#.

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
Subject: Re: Path of IRP_MN_WAIT_WAKE
From: “Bill McKenzie”
Date: Fri, 12 Jul 2002 17:42:09 -0500
X-Message-Number: 19

> Is there any scenario in which IRP_MN_WAIT_WAKE doesn’t need to
propogate
to
> ACPI driver.

Yes, ACPI has filter drivers that handle this as well. Actually for
something like a USB device the stack would be something like:

USB device driver ->USB hub driver->USB Controller driver->ACPI filter
driver

But, all IRP_MN_WAIT_WAKE IRPs will end at an ACPI driver at some point
in
the stack. ACPI is responsible for wake signal detection and IRP
completion
at the bottom. At least as I understand it.


Bill McKenzie

Okay, I get it, but I guess I don’t get the architecture. What I don’t
understand is why the wake signal in this case wasn’t always kept or shared
internal to the bus. According to one of the “On Now” white papers, the FDO
portion of the bus driver is required to stay at or above the device power
state of the bus’s most powered child device, and the bus should attempt to
power itself down if all child devices are powered down and the bus hardware
can handle such. This makes sense, and it can be implemented in the bus
driver. As such, it seems that if a device can be determined by its own
driver to be idle, and it is the power policy owner for its stack, there is
no need for a wake IRP at all. Rather, the device driver should just send a
device power IRP to its own stack requesting the device power down to D3.
If all child devices for some bus power down to D3, and the bus hardware is
capable of handling, then the bus driver should detect this and power the
bus hardware to D3. Then, if a wake signal is detected by the bus, it could
power itself up first, then any child devices that needed it. If the bus
needs power to detect the wake signal, then just don’t allow it to power
itself down in the bus driver. No need to involve ACPI, no need to involve
an IRP. Then, the wake IRP could serve the single purpose of signalling
system wakes.

Example, NIC that is capable of waking system, and needs to be able to power
down when system is at S0. First, NIC is unconnected, driver for NIC should
have capability for determining this, and be able to request a power IRP to
power itself down to device power state that allows wake signal. Sometime
later NIC is connected to something, signal is generated, driver for NIC
should be able to determine this, and request power IRP to power NIC up.
Bus may or may not have powered itself down when NIC powered itself down.
If bus is powered down, NIC PDO, needs to block power-up IRP for NIC until
bus FDO has successfully powered up. If bus cannot power up, PDO fails
power up. Otherwise, NIC powers up. Now, same wake signal can be wired to
ACPI for system wakes. If system is in idle state when wake signal occurs,
ACPI attempts to power up system. NIC will also attempt power up, but will
fail because bus will not be able to power up as the system is not yet
powered. However, ACPI will bring system up and then complete pending wake
IRP, this will signal NIC and bus to try again. Viola everyone powers up
correctly. Now, this might require some synchronization to work correctly,
but that could be completely handled in the power manager, and drivers would
be unaffected. I may be missing something obvious here, as I am not
attempting to say I know better than you guys, but I would like to know why
this wouldn’t work.

This same power setup leads me to the same confustion WRT USB selective
suspend, but that is another thread.


Bill McKenzie

“Jake Oshins” wrote in message
news:xxxxx@ntdev…

I’ll try to answer both Max and Bill in one message.

It was very much the intent of the WDM architects (and everyone, like
myself, who has come after them) to enable devices to be placed in low
power states while the machine is in the S0 state. While this may not
seem very meaningful for desktop and server machines, it’s critical in
laptops.

I currently use two laptops in my everyday life. One is a huge
sixteen-inch screen and the kitchen sink variety that I use for my
everyday coding and development. The other is a low-power Tualatin
processor based ultra-slim that I use when traveling. (They are the IBM
Thinkpad A21p and the IBM Thinkpad s30 for those who are overly
interested.) The big one has (I think) a fourteen-cell battery pack and
a typical power budget somewhere upwards of 25W.

We took a machine that was identical to the little one once and
evicerated a battery pack for it, hooking up test leads. We found that,
at idle, the little one used between 1.0W and 1.5W. Remember that this
is a machine around four pounds with a 4 hour battery life. Intel tells
us that the processor is responsible for about .6W at idle. The rest of
the power is consumed mostly by the backlight, the ethernet PHY and the
1394 PHY. (It’s a Japanese-market machine, which is why it has both
built in.) Before we added code to USB to put it into a low-power state
at idle, the power budget would have been around a watt higher. As you
can see, in this type of machine, 300mW can be an extra half-hour of
battery time, which is very significant.

Let’s take the ethernet as an example. It’s rarely in use when the
machine is running on batteries. So you’d really like to shut it down.
But you’d still want it to come back on line as soon as you plugged it
into a hub. This is accomplishable using the very IRP_MN_WAIT_WAKE
mechanisms that are in WDM. The NDIS stack sends IRP_MN_WAIT_WAKE to
its PDO, which is PCI.sys. PCI.sys then sends another to its parent,
which in this case is ACPI.sys. The NDIS driver then moves the NIC out
of D0 and shuts down the PHY, which is the power-hungry part. When the
ethernet cable is plugged back in, it triggers PME# and the series of
IRPs is completed, causing the NDIS stack to bring the NIC back into D0.

USB is a similar case, though it has a couple of interesting
particularities. First, USB defines a wake mechanism that is contained
within USB. So it’s entirely possible that USB may power down a single
port in response to a keyboard stack sending IRP_MN_WAIT_WAKE. Since
the other ports are still active, the controller will remain active, not
sending an IRP to its parent. (This is the ‘may’ case we were talking
about before.) If the user touches the keyboard, then the keyboard
device will signal for wakeup using the USB mechanism, and the
controller (root hub) driver will complete the keyboard driver’s IRP.
Of course, if all ports have been powered down, then the root hub will
power itself down, which will require an IRP to its parent to enable
wakeup.

USB is also interesting because, when active, it requires periodic DMA
traffic. While this doesn’t require much power in the USB controller or
the memory controller, it forces the processor to stay in an active
state, so that the processor caches are kept coherent. This means that
USB, or any other device that you guys may be working with which uses a
lot of DMA, can cause a machine like my small laptop to add another
watt, (sometimes 2 or 3 watts,) to its active power usage. That’s a
huge reduction in battery life.

And, yes Max, the USB controller has got to be prepared to pend a
separate IRP_MN_WAIT_WAKE from each of its child devices. It only has
to send one to its parent in response, and only if the parent isn’t
capable of handling the children’s IRPs by itself. (To review, this
would either be because it can’t detect a wakeup signal from its child,
probably because the child is just triggering PME# directly. Or it
could be because the parent itself has been moved out of D0, meaning
that it will trigger wakeup when its child does, probably through PME#.)

If you want more information, I wrote a white paper a couple of years
ago that was intended to help motherboard manufacturers deal route
wakeup signals in ways that could actually work. It also covers some
issues that you’ve touched on. It’s at:

http://www.microsoft.com/hwdev/tech/onnow/GPE_routing.asp

Postscript: NDIS and other miniport stacks hide the details of WDM. So
you have to get them to do run-time power management in ways that may
seem strange. If you want or need details about a particular port
model, I’ll pass your questions along to the owners.

Hope this helps. Please ask more questions if it’s still not clear.

Jake Oshins
Windows Kernel Group

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
Subject: Re: Path of IRP_MN_WAIT_WAKE
From: “Bill McKenzie”
Date: Sun, 14 Jul 2002 02:16:14 -0500
X-Message-Number: 3

> Sorry. I didn’t mean to imply that the bus driver could re-use the
IRP
> sent to it by the device’s FDO. The ‘may’ was only there because some
> wakeup scenarios can be handled without sending an IRP through the
> parent stacks.

This is completely unclear from the docs. From the DDK, it appears to
me
that only the ACPI bus and ACPI filter drivers can handle a wake signal,
in
that only those drivers can detect the wake signal, properly bring the
system into a working state, and signal other drivers to wake their
devices
by completing the correct wake IRPs. Can you explain how wake works
really?
Especially how a stack could skip sending the wake IRP to an ACPI agent?

> I’m guessing that I’ll get a lot of responses from people who think
that
> they should design with the system state in mind. Please send them.
> Let’s talk them out.

Well, while I agree that only the device power state is of any concern
to
the driver of a particular device, it is the waking of the system that
the
IRP_MN_WAIT_WAKE IRP is primarily there for yes? I can’t imagine that a
NIC
is concerned with waking the NIC. The NIC is concerned with waking the
system due to appropriate network traffic. A device driver will never
send
a system power state, but that doesn’t mean it isn’t concerned with the
state of the system, right?

Your suggesting that the wake mechanism be used to bring an individual
device back to life is interesting, but probably not very common. I
can’t
imagine what type of device could handle this, and how much power it
would
save if it could. Most devices that can power down when idle can and
probably should power all the way down and power back up when a handle
is
open or some such. Like a COM port usage model. I imagine that most
devices could handle this model. Using some standby state that allowed
wake
signalling would require more power, and seem unneccesary for most
devices.
I would only design a device like this if it needed to wake the system.
So,
what types of devices do this and why?


Bill McKenzie

“Jake Oshins” wrote in message
news:xxxxx@ntdev…

Sorry. I didn’t mean to imply that the bus driver could re-use the IRP
sent to it by the device’s FDO. The ‘may’ was only there because some
wakeup scenarios can be handled without sending an IRP through the
parent stacks.

About the intention of IRP_MN_WAIT_WAKE, the DDK is (again) misleading.
You’ll end up designing yourself into a corner if you design with the
system state in mind. Drivers should only concern themselves with
whether or not their devices are in D0. If the hardware, via a wakeup
signal, requests that a device be moved into D0, then the system power
manager (which is not in your driver stacks) will guarantee that the
system brought into S0.

The confusion is understandable, as many drivers never put take their
devices out of D0 unless the system leaves S0.

Also, the DDK was written before people really understood the
ramifications of wakeup. The people who were my immediate predecessors
designed WDM. And wakeup was the last and least-well-understood thing
that they did. (You might argue that a few of the dark corners of PnP
were of the same standing, but I think that wakeup was the worst case.)
In their defense, plug and play and power management hardware existed
before WDM. But the concept of a general mechanism to support waking a
single device while the system is in S0 didn’t exist beforehand. It
took a while before this began to appear.

I then spent three years figure out how to make it work coherently, and
I strongly believe that you need to work only in terms of device power
states when you send IRP_MN_WAIT_WAKE.

I’m guessing that I’ll get a lot of responses from people who think that
they should design with the system state in mind. Please send them.
Let’s talk them out.

Jake Oshins
Windows Kernel Group

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
Subject: Re: Path of IRP_MN_WAIT_WAKE
From: “Bill McKenzie”
Date: Sat, 13 Jul 2002 01:20:44 -0500
X-Message-Number: 2

It didn’t know that the bus driver ‘may’ create a new IRP for the parent
stack, I thought it was a ‘must’. Otherwise, cancelling this IRP could
get
really screwy yes? As in a driver could potentially need to cancel an
IRP
it didn’t create.

>Remember that WDM deals in the sleeping and waking of
>devices, not the entire machine. Waking the machine may be a side
>effect of bringing your device into D0. But the primary action of a
>wakeup signal is to request that a specific device enter the working
>state.

The documentation clearly makes it sound more than a side effect, at
least
as I read it in the DDK. For instance in the docs for IRP_MN_WAIT_WAKE
under Input, what does this mean:

“Parameters.WaitWake.SystemWake contains the lowest (least-powered)
system
power state from which the device should be allowed to awaken the
system.”

Or how about this:
"Operation
A driver sends IRP_MN_WAIT_WAKE for either of two reasons:

1… To enable its device to awaken a sleeping system in response to an
external wake-up signal.
2… To enable its device to awaken from a device sleep state in
response
to an external wake-up signal. "
It appears waking the system was an intent of this IRP, or at least one
possible intent, no?


Bill McKenzie

“Jake Oshins” wrote in message
news:xxxxx@ntdev…

Actually, while ACPI does filter any device that is described in the
ACPI BIOS, the filters don’t have much to do with IRP_MN_WAIT_WAKE in
most cases.

It’s also worth noting that the IRP_MN_WAIT_WAKE that you send from the
power policy manager (probably your FDO) always stops at the PDO. The
bus driver that owns the PDO may create a completely separate
IRP_MN_WAIT_WAKE which it sends down the parent stack to arm the bus for
wakeup. That parent may create yet another one to send down the
grandparent’s stack. This always continues until it reaches a driver
that can arm the machine for wakeup. This is the ACPI driver in all
machines that we care about, though architecturally, it could be
something else.

Additionally, the sending of these IRPs and their completion may have
nothing to do with waking the entire machine. You may take your device
out of the D0 while the machine is still in S0, so that the machine uses
less electricity (which is particularly important while running on
batteries.) Remember that WDM deals in the sleeping and waking of
devices, not the entire machine. Waking the machine may be a side
effect of bringing your device into D0. But the primary action of a
wakeup signal is to request that a specific device enter the working
state.

In this case, the ACPI driver’s only role is to notify the PCI driver
that the PME# signal has been triggered.

Jake Oshins
Windows Kernel Group

The one exception to this statement occurs when the ACPI BIOS
describes a machine wherein the wake signal for a specific device is
directly wired to the chipset power management logic, rather than the
PCI-standard PME#.

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
Subject: Re: Path of IRP_MN_WAIT_WAKE
From: “Bill McKenzie”
Date: Fri, 12 Jul 2002 17:42:09 -0500
X-Message-Number: 19

> Is there any scenario in which IRP_MN_WAIT_WAKE doesn’t need to
propogate
to
> ACPI driver.

Yes, ACPI has filter drivers that handle this as well. Actually for
something like a USB device the stack would be something like:

USB device driver ->USB hub driver->USB Controller driver->ACPI filter
driver

But, all IRP_MN_WAIT_WAKE IRPs will end at an ACPI driver at some point
in
the stack. ACPI is responsible for wake signal detection and IRP
completion
at the bottom. At least as I understand it.


Bill McKenzie

>First, USB defines a wake mechanism that is contained within USB. So it’s
entirely possible that USB may power down a single

port in response to a keyboard stack sending IRP_MN_WAIT_WAKE. Since the
other ports are still active, the controller will remain active, not sending
an IRP to its
parent. (This is the ‘may’ case we were talking about before.) If the
user touches the keyboard, then the keyboard device will signal for wakeup
using the USB
mechanism, and the controller (root hub) driver will complete the keyboard
driver’s IRP.

Jake ACPI filter driver doesnot play any role in above mention case Right
since it is not waking up the whole system?

-----Original Message-----
From: Jake Oshins [mailto:xxxxx@windows.microsoft.com]
Sent: Sunday, July 14, 2002 11:44 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Path of IRP_MN_WAIT_WAKE

I’ll try to answer both Max and Bill in one message.

It was very much the intent of the WDM architects (and everyone, like
myself, who has come after them) to enable devices to be placed in low power
states while the machine is in the S0 state. While this may not seem very
meaningful for desktop and server machines, it’s critical in laptops.

I currently use two laptops in my everyday life. One is a huge sixteen-inch
screen and the kitchen sink variety that I use for my everyday coding and
development. The other is a low-power Tualatin processor based ultra-slim
that I use when traveling. (They are the IBM Thinkpad A21p and the IBM
Thinkpad s30 for those who are overly
interested.) The big one has (I think) a fourteen-cell battery pack and a
typical power budget somewhere upwards of 25W.

We took a machine that was identical to the little one once and evicerated a
battery pack for it, hooking up test leads. We found that, at idle, the
little one used between 1.0W and 1.5W. Remember that this is a machine
around four pounds with a 4 hour battery life. Intel tells us that the
processor is responsible for about .6W at idle. The rest of the power is
consumed mostly by the backlight, the ethernet PHY and the 1394 PHY. (It’s
a Japanese-market machine, which is why it has both built in.) Before we
added code to USB to put it into a low-power state at idle, the power budget
would have been around a watt higher. As you can see, in this type of
machine, 300mW can be an extra half-hour of battery time, which is very
significant.

Let’s take the ethernet as an example. It’s rarely in use when the machine
is running on batteries. So you’d really like to shut it down. But you’d
still want it to come back on line as soon as you plugged it into a hub.
This is accomplishable using the very IRP_MN_WAIT_WAKE mechanisms that are
in WDM. The NDIS stack sends IRP_MN_WAIT_WAKE to its PDO, which is PCI.sys.
PCI.sys then sends another to its parent, which in this case is ACPI.sys.
The NDIS driver then moves the NIC out of D0 and shuts down the PHY, which
is the power-hungry part. When the ethernet cable is plugged back in, it
triggers PME# and the series of IRPs is completed, causing the NDIS stack to
bring the NIC back into D0.

USB is a similar case, though it has a couple of interesting
particularities. First, USB defines a wake mechanism that is contained
within USB. So it’s entirely possible that USB may power down a single port
in response to a keyboard stack sending IRP_MN_WAIT_WAKE. Since the other
ports are still active, the controller will remain active, not sending an
IRP to its parent. (This is the ‘may’ case we were talking about before.)
If the user touches the keyboard, then the keyboard device will signal for
wakeup using the USB mechanism, and the controller (root hub) driver will
complete the keyboard driver’s IRP. Of course, if all ports have been
powered down, then the root hub will power itself down, which will require
an IRP to its parent to enable wakeup.

USB is also interesting because, when active, it requires periodic DMA
traffic. While this doesn’t require much power in the USB controller or the
memory controller, it forces the processor to stay in an active state, so
that the processor caches are kept coherent. This means that USB, or any
other device that you guys may be working with which uses a lot of DMA, can
cause a machine like my small laptop to add another watt, (sometimes 2 or 3
watts,) to its active power usage. That’s a huge reduction in battery life.

And, yes Max, the USB controller has got to be prepared to pend a separate
IRP_MN_WAIT_WAKE from each of its child devices. It only has to send one to
its parent in response, and only if the parent isn’t capable of handling the
children’s IRPs by itself. (To review, this would either be because it
can’t detect a wakeup signal from its child, probably because the child is
just triggering PME# directly. Or it could be because the parent itself has
been moved out of D0, meaning that it will trigger wakeup when its child
does, probably through PME#.)

If you want more information, I wrote a white paper a couple of years ago
that was intended to help motherboard manufacturers deal route wakeup
signals in ways that could actually work. It also covers some issues that
you’ve touched on. It’s at:

http://www.microsoft.com/hwdev/tech/onnow/GPE_routing.asp

Postscript: NDIS and other miniport stacks hide the details of WDM. So you
have to get them to do run-time power management in ways that may seem
strange. If you want or need details about a particular port model, I’ll
pass your questions along to the owners.

Hope this helps. Please ask more questions if it’s still not clear.

Jake Oshins
Windows Kernel Group

This posting is provided “AS IS” with no warranties, and confers no rights.

-----Original Message-----
Subject: Re: Path of IRP_MN_WAIT_WAKE
From: “Bill McKenzie”
Date: Sun, 14 Jul 2002 02:16:14 -0500
X-Message-Number: 3

> Sorry. I didn’t mean to imply that the bus driver could re-use the
IRP
> sent to it by the device’s FDO. The ‘may’ was only there because some
> wakeup scenarios can be handled without sending an IRP through the
> parent stacks.

This is completely unclear from the docs. From the DDK, it appears to me
that only the ACPI bus and ACPI filter drivers can handle a wake signal, in
that only those drivers can detect the wake signal, properly bring the
system into a working state, and signal other drivers to wake their devices
by completing the correct wake IRPs. Can you explain how wake works really?
Especially how a stack could skip sending the wake IRP to an ACPI agent?

> I’m guessing that I’ll get a lot of responses from people who think
that
> they should design with the system state in mind. Please send them.
> Let’s talk them out.

Well, while I agree that only the device power state is of any concern to
the driver of a particular device, it is the waking of the system that the
IRP_MN_WAIT_WAKE IRP is primarily there for yes? I can’t imagine that a NIC
is concerned with waking the NIC. The NIC is concerned with waking the
system due to appropriate network traffic. A device driver will never send
a system power state, but that doesn’t mean it isn’t concerned with the
state of the system, right?

Your suggesting that the wake mechanism be used to bring an individual
device back to life is interesting, but probably not very common. I can’t
imagine what type of device could handle this, and how much power it would
save if it could. Most devices that can power down when idle can and
probably should power all the way down and power back up when a handle is
open or some such. Like a COM port usage model. I imagine that most
devices could handle this model. Using some standby state that allowed wake
signalling would require more power, and seem unneccesary for most devices.
I would only design a device like this if it needed to wake the system. So,
what types of devices do this and why?


Bill McKenzie

“Jake Oshins” wrote in message
news:xxxxx@ntdev…

Sorry. I didn’t mean to imply that the bus driver could re-use the IRP sent
to it by the device’s FDO. The ‘may’ was only there because some wakeup
scenarios can be handled without sending an IRP through the parent stacks.

About the intention of IRP_MN_WAIT_WAKE, the DDK is (again) misleading.
You’ll end up designing yourself into a corner if you design with the system
state in mind. Drivers should only concern themselves with whether or not
their devices are in D0. If the hardware, via a wakeup signal, requests
that a device be moved into D0, then the system power manager (which is not
in your driver stacks) will guarantee that the system brought into S0.

The confusion is understandable, as many drivers never put take their
devices out of D0 unless the system leaves S0.

Also, the DDK was written before people really understood the ramifications
of wakeup. The people who were my immediate predecessors designed WDM. And
wakeup was the last and least-well-understood thing that they did. (You
might argue that a few of the dark corners of PnP were of the same standing,
but I think that wakeup was the worst case.) In their defense, plug and play
and power management hardware existed before WDM. But the concept of a
general mechanism to support waking a single device while the system is in
S0 didn’t exist beforehand. It took a while before this began to appear.

I then spent three years figure out how to make it work coherently, and I
strongly believe that you need to work only in terms of device power states
when you send IRP_MN_WAIT_WAKE.

I’m guessing that I’ll get a lot of responses from people who think that
they should design with the system state in mind. Please send them. Let’s
talk them out.

Jake Oshins
Windows Kernel Group

This posting is provided “AS IS” with no warranties, and confers no rights.

-----Original Message-----
Subject: Re: Path of IRP_MN_WAIT_WAKE
From: “Bill McKenzie”
Date: Sat, 13 Jul 2002 01:20:44 -0500
X-Message-Number: 2

It didn’t know that the bus driver ‘may’ create a new IRP for the parent
stack, I thought it was a ‘must’. Otherwise, cancelling this IRP could get
really screwy yes? As in a driver could potentially need to cancel an IRP
it didn’t create.

>Remember that WDM deals in the sleeping and waking of
>devices, not the entire machine. Waking the machine may be a side
>effect of bringing your device into D0. But the primary action of a
>wakeup signal is to request that a specific device enter the working
>state.

The documentation clearly makes it sound more than a side effect, at least
as I read it in the DDK. For instance in the docs for IRP_MN_WAIT_WAKE
under Input, what does this mean:

“Parameters.WaitWake.SystemWake contains the lowest (least-powered) system
power state from which the device should be allowed to awaken the system.”

Or how about this:
"Operation
A driver sends IRP_MN_WAIT_WAKE for either of two reasons:

1… To enable its device to awaken a sleeping system in response to an
external wake-up signal.
2… To enable its device to awaken from a device sleep state in response
to an external wake-up signal. " It appears waking the system was an intent
of this IRP, or at least one possible intent, no?


Bill McKenzie

“Jake Oshins” wrote in message
news:xxxxx@ntdev…

Actually, while ACPI does filter any device that is described in the ACPI
BIOS, the filters don’t have much to do with IRP_MN_WAIT_WAKE in most cases.


It’s also worth noting that the IRP_MN_WAIT_WAKE that you send from the
power policy manager (probably your FDO) always stops at the PDO. The bus
driver that owns the PDO may create a completely separate IRP_MN_WAIT_WAKE
which it sends down the parent stack to arm the bus for wakeup. That parent
may create yet another one to send down the grandparent’s stack. This
always continues until it reaches a driver that can arm the machine for
wakeup. This is the ACPI driver in all machines that we care about, though
architecturally, it could be something else.

Additionally, the sending of these IRPs and their completion may have
nothing to do with waking the entire machine. You may take your device out
of the D0 while the machine is still in S0, so that the machine uses less
electricity (which is particularly important while running on
batteries.) Remember that WDM deals in the sleeping and waking of devices,
not the entire machine. Waking the machine may be a side effect of bringing
your device into D0. But the primary action of a wakeup signal is to
request that a specific device enter the working state.

In this case, the ACPI driver’s only role is to notify the PCI driver that
the PME# signal has been triggered.

Jake Oshins
Windows Kernel Group

The one exception to this statement occurs when the ACPI BIOS describes
a machine wherein the wake signal for a specific device is directly wired to
the chipset power management logic, rather than the PCI-standard PME#.

This posting is provided “AS IS” with no warranties, and confers no rights.

-----Original Message-----
Subject: Re: Path of IRP_MN_WAIT_WAKE
From: “Bill McKenzie”
Date: Fri, 12 Jul 2002 17:42:09 -0500
X-Message-Number: 19

> Is there any scenario in which IRP_MN_WAIT_WAKE doesn’t need to
propogate
to
> ACPI driver.

Yes, ACPI has filter drivers that handle this as well. Actually for
something like a USB device the stack would be something like:

USB device driver ->USB hub driver->USB Controller driver->ACPI filter
driver

But, all IRP_MN_WAIT_WAKE IRPs will end at an ACPI driver at some point in
the stack. ACPI is responsible for wake signal detection and IRP completion
at the bottom. At least as I understand it.


Bill McKenzie


You are currently subscribed to ntdev as: xxxxx@itronix.com
To unsubscribe send a blank email to %%email.unsub%%

>I currently use two laptops in my everyday life. One is a huge

sixteen-inch screen and the kitchen sink

Sorry, but what does “kitchen sink” means in this context?
I’m not a native English speaker, so, sometimes I have hardships
understanding idioms. :slight_smile:

Also I remember to see “kitchen sink” in some other computer-related
context.

the power is consumed mostly by the backlight, the ethernet PHY and
the
1394 PHY.

So, OHCI1394 will not power down PHY (thus causing the node to
disappear from 1394 bus and a bus reset) while going low power?

http://www.microsoft.com/hwdev/tech/onnow/GPE_routing.asp

Thanks!

Max

“Maxim S. Shatskih” wrote in message
news:xxxxx@ntdev…
>
> >I currently use two laptops in my everyday life. One is a huge
> >sixteen-inch screen and the kitchen sink
>
> Sorry, but what does “kitchen sink” means in this context?
> I’m not a native English speaker, so, sometimes I have hardships
> understanding idioms. :slight_smile:

“Kitchen Sink” means “and everything you can think of”. It’s a common
(American) English idiom.

With PCI devices, the bus driver can read the PMEStatus bit of each of
the devices on the bus. With other bus drivers, you should have a
bus-specific mechanism.

In rare cases, bus drivers just have to complete all the pending
instances of IRP_MN_WAIT_WAKE, letting each of the devices figure out if
the signal was spurious. FDOs then have to re-send the IRP if the
completion was spurious. (They probably just re-send anyhow, if they
want to remain armed.)

Jake Oshins
Windows Kernel Group

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
Subject: Re: Path of IRP_MN_WAIT_WAKE
From: “Bill McKenzie”
Date: Mon, 15 Jul 2002 00:52:01 -0500
X-Message-Number: 6

Interestingly enough, though, this would pretty well make waking an
individual device, an impossibility. As in, how would the bus possibly
know
which of its wake capable devices caused the wake signal? I guess this
is
hardware specific, as in, the host controller manufacturer or whoever
better
make this accessible to the bus driver, right? Then what do you do if
more
than one device yanked the wake signal, does the bus complete the wake
IRPs
for each of those devices and decrement the count accordingly? It
certainly
is unclear from the docs.


Bill McKenzie

“Bill McKenzie” wrote in message
news:xxxxx@ntdev…
>
> As I understand it, the bus driver will receive two wait wake IRPs to
its
> PDOs, but the bus FDO will only send one down. It tracks wake capable
> children though, as the following paragraph explains, from the DDK
docs
> “Understanding the Path of Wait/Wake IRPs through a Device Tree”:
>
> “Although a parent driver might enumerate more than one child that can
be
> enabled for wait/wake, only one wait/wake IRP can be pending for a
PDO. In
> such cases, the parent driver should make sure that it keeps a
wait/wake
IRP
> pending whenever any of its devices is enabled for wake-up. To do so,
the
> driver should increment an internal counter each time it receives a
> wait/wake IRP. Each time the driver completes a wait/wake IRP, it
decrements
> the count and, if the resulting value is nonzero, sends another
wait/wake
> IRP to its device stack.”
>
> –
> Bill McKenzie
>
>

You’re saying that the bus driver should send a power-up IRP through the
stack of the child device when the wake has occurred. This has a couple
of problems.

  1. The PDO probably isn’t the power policy owner. So now you have two
    devices that are trying to “own” transitions.

  2. The child may actually already be in D0, passing through a wakeup
    signal from one of its children.

In the PCI case, this is frequently true. The PME# signal may be
running through some implasible parts of the machine. I’ve tried really
hard to convince motherboard makers that they want to make wake signals
pass through the same heirarchical relationships as a device’s data
does, but they all claim that that would be hard, or at least expensive.

Jake Oshins
Windows Kernel Group

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
Subject: Re: Path of IRP_MN_WAIT_WAKE
From: “Bill McKenzie”
Date: Mon, 15 Jul 2002 02:58:51 -0500
X-Message-Number: 8

Okay, I get it, but I guess I don’t get the architecture. What I don’t
understand is why the wake signal in this case wasn’t always kept or
shared
internal to the bus. According to one of the “On Now” white papers, the
FDO
portion of the bus driver is required to stay at or above the device
power
state of the bus’s most powered child device, and the bus should attempt
to
power itself down if all child devices are powered down and the bus
hardware
can handle such. This makes sense, and it can be implemented in the bus
driver. As such, it seems that if a device can be determined by its own
driver to be idle, and it is the power policy owner for its stack, there
is
no need for a wake IRP at all. Rather, the device driver should just
send a
device power IRP to its own stack requesting the device power down to
D3.
If all child devices for some bus power down to D3, and the bus hardware
is
capable of handling, then the bus driver should detect this and power
the
bus hardware to D3. Then, if a wake signal is detected by the bus, it
could
power itself up first, then any child devices that needed it. If the
bus
needs power to detect the wake signal, then just don’t allow it to power
itself down in the bus driver. No need to involve ACPI, no need to
involve
an IRP. Then, the wake IRP could serve the single purpose of signalling
system wakes.

Example, NIC that is capable of waking system, and needs to be able to
power
down when system is at S0. First, NIC is unconnected, driver for NIC
should
have capability for determining this, and be able to request a power IRP
to
power itself down to device power state that allows wake signal.
Sometime
later NIC is connected to something, signal is generated, driver for NIC
should be able to determine this, and request power IRP to power NIC up.
Bus may or may not have powered itself down when NIC powered itself
down.
If bus is powered down, NIC PDO, needs to block power-up IRP for NIC
until
bus FDO has successfully powered up. If bus cannot power up, PDO fails
power up. Otherwise, NIC powers up. Now, same wake signal can be wired
to
ACPI for system wakes. If system is in idle state when wake signal
occurs,
ACPI attempts to power up system. NIC will also attempt power up, but
will
fail because bus will not be able to power up as the system is not yet
powered. However, ACPI will bring system up and then complete pending
wake
IRP, this will signal NIC and bus to try again. Viola everyone powers
up
correctly. Now, this might require some synchronization to work
correctly,
but that could be completely handled in the power manager, and drivers
would
be unaffected. I may be missing something obvious here, as I am not
attempting to say I know better than you guys, but I would like to know
why
this wouldn’t work.

This same power setup leads me to the same confustion WRT USB selective
suspend, but that is another thread.


Bill McKenzie

“Jake Oshins” wrote in message
news:xxxxx@ntdev…

I’ll try to answer both Max and Bill in one message.

It was very much the intent of the WDM architects (and everyone, like
myself, who has come after them) to enable devices to be placed in low
power states while the machine is in the S0 state. While this may not
seem very meaningful for desktop and server machines, it’s critical in
laptops.

I currently use two laptops in my everyday life. One is a huge
sixteen-inch screen and the kitchen sink variety that I use for my
everyday coding and development. The other is a low-power Tualatin
processor based ultra-slim that I use when traveling. (They are the IBM
Thinkpad A21p and the IBM Thinkpad s30 for those who are overly
interested.) The big one has (I think) a fourteen-cell battery pack and
a typical power budget somewhere upwards of 25W.

We took a machine that was identical to the little one once and
evicerated a battery pack for it, hooking up test leads. We found that,
at idle, the little one used between 1.0W and 1.5W. Remember that this
is a machine around four pounds with a 4 hour battery life. Intel tells
us that the processor is responsible for about .6W at idle. The rest of
the power is consumed mostly by the backlight, the ethernet PHY and the
1394 PHY. (It’s a Japanese-market machine, which is why it has both
built in.) Before we added code to USB to put it into a low-power state
at idle, the power budget would have been around a watt higher. As you
can see, in this type of machine, 300mW can be an extra half-hour of
battery time, which is very significant.

Let’s take the ethernet as an example. It’s rarely in use when the
machine is running on batteries. So you’d really like to shut it down.
But you’d still want it to come back on line as soon as you plugged it
into a hub. This is accomplishable using the very IRP_MN_WAIT_WAKE
mechanisms that are in WDM. The NDIS stack sends IRP_MN_WAIT_WAKE to
its PDO, which is PCI.sys. PCI.sys then sends another to its parent,
which in this case is ACPI.sys. The NDIS driver then moves the NIC out
of D0 and shuts down the PHY, which is the power-hungry part. When the
ethernet cable is plugged back in, it triggers PME# and the series of
IRPs is completed, causing the NDIS stack to bring the NIC back into D0.

USB is a similar case, though it has a couple of interesting
particularities. First, USB defines a wake mechanism that is contained
within USB. So it’s entirely possible that USB may power down a single
port in response to a keyboard stack sending IRP_MN_WAIT_WAKE. Since
the other ports are still active, the controller will remain active, not
sending an IRP to its parent. (This is the ‘may’ case we were talking
about before.) If the user touches the keyboard, then the keyboard
device will signal for wakeup using the USB mechanism, and the
controller (root hub) driver will complete the keyboard driver’s IRP.
Of course, if all ports have been powered down, then the root hub will
power itself down, which will require an IRP to its parent to enable
wakeup.

USB is also interesting because, when active, it requires periodic DMA
traffic. While this doesn’t require much power in the USB controller or
the memory controller, it forces the processor to stay in an active
state, so that the processor caches are kept coherent. This means that
USB, or any other device that you guys may be working with which uses a
lot of DMA, can cause a machine like my small laptop to add another
watt, (sometimes 2 or 3 watts,) to its active power usage. That’s a
huge reduction in battery life.

And, yes Max, the USB controller has got to be prepared to pend a
separate IRP_MN_WAIT_WAKE from each of its child devices. It only has
to send one to its parent in response, and only if the parent isn’t
capable of handling the children’s IRPs by itself. (To review, this
would either be because it can’t detect a wakeup signal from its child,
probably because the child is just triggering PME# directly. Or it
could be because the parent itself has been moved out of D0, meaning
that it will trigger wakeup when its child does, probably through PME#.)

If you want more information, I wrote a white paper a couple of years
ago that was intended to help motherboard manufacturers deal route
wakeup signals in ways that could actually work. It also covers some
issues that you’ve touched on. It’s at:

http://www.microsoft.com/hwdev/tech/onnow/GPE_routing.asp

Postscript: NDIS and other miniport stacks hide the details of WDM. So
you have to get them to do run-time power management in ways that may
seem strange. If you want or need details about a particular port
model, I’ll pass your questions along to the owners.

Hope this helps. Please ask more questions if it’s still not clear.

Jake Oshins
Windows Kernel Group

This posting is provided “AS IS” with no warranties, and confers no
rights.

Sorry. There’s an idiom in English; “everything and the kitchen sink.”
It means “more things than you can account for,” particularly implying
that the machine was perhaps overdesigned.

I’m not specifically familiar with 1394. But the guys from the 1394
team here tell me that they have to leave the PHY powered on.

  • Jake

-----Original Message-----
Subject: RE: Path of IRP_MN_WAIT_WAKE
From: “Maxim S. Shatskih”
Date: Tue, 16 Jul 2002 00:30:56 +0400
X-Message-Number: 22

>I currently use two laptops in my everyday life. One is a huge
>sixteen-inch screen and the kitchen sink

Sorry, but what does “kitchen sink” means in this context?
I’m not a native English speaker, so, sometimes I have hardships
understanding idioms. :slight_smile:

Also I remember to see “kitchen sink” in some other computer-related
context.

>the power is consumed mostly by the backlight, the ethernet PHY and
the
>1394 PHY.

So, OHCI1394 will not power down PHY (thus causing the node to
disappear from 1394 bus and a bus reset) while going low power?

>http://www.microsoft.com/hwdev/tech/onnow/GPE_routing.asp

Thanks!

Max

It’s true that the ACPI filter plays no role in this scenario, but for a
different reason. The root hub handles it.

Let’s make a distinction between “the ACPI driver” and “the ACPI
filter.” The ACPI driver has many device objects, at most one of which
will be a filter in a specific device stack.

In this case, the USB root hub (which is a PCI device) may have an ACPI
filter. This won’t be involved in USB device wakeup, ever. If the root
hub is powered off, (whether the system is in S0 or not,) then the ACPI
filter may be involved in wakeup, specifically in the case that the PME#
signal from USB is directly routed to the ACPI control circuitry in the
chipset.

  • Jake

-----Original Message-----
Subject: RE: Path of IRP_MN_WAIT_WAKE
From: xxxxx@Itronix.com
Date: Mon, 15 Jul 2002 10:28:42 -0700
X-Message-Number: 20

First, USB defines a wake mechanism that is contained within USB. So
it’s
entirely possible that USB may power down a single
port in response to a keyboard stack sending IRP_MN_WAIT_WAKE. Since
the
other ports are still active, the controller will remain active, not
sending
an IRP to its
parent. (This is the ‘may’ case we were talking about before.) If the
user touches the keyboard, then the keyboard device will signal for
wakeup
using the USB
mechanism, and the controller (root hub) driver will complete the
keyboard
driver’s IRP.

Jake ACPI filter driver doesnot play any role in above mention case
Right
since it is not waking up the whole system?

-----Original Message-----
From: Jake Oshins [mailto:xxxxx@windows.microsoft.com]
Sent: Sunday, July 14, 2002 11:44 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Path of IRP_MN_WAIT_WAKE

I’ll try to answer both Max and Bill in one message.

It was very much the intent of the WDM architects (and everyone, like
myself, who has come after them) to enable devices to be placed in low
power
states while the machine is in the S0 state. While this may not seem
very
meaningful for desktop and server machines, it’s critical in laptops.

I currently use two laptops in my everyday life. One is a huge
sixteen-inch
screen and the kitchen sink variety that I use for my everyday coding
and
development. The other is a low-power Tualatin processor based
ultra-slim
that I use when traveling. (They are the IBM Thinkpad A21p and the IBM
Thinkpad s30 for those who are overly
interested.) The big one has (I think) a fourteen-cell battery pack and
a
typical power budget somewhere upwards of 25W.

We took a machine that was identical to the little one once and
evicerated a
battery pack for it, hooking up test leads. We found that, at idle, the
little one used between 1.0W and 1.5W. Remember that this is a machine
around four pounds with a 4 hour battery life. Intel tells us that the
processor is responsible for about .6W at idle. The rest of the power
is
consumed mostly by the backlight, the ethernet PHY and the 1394 PHY.
(It’s
a Japanese-market machine, which is why it has both built in.) Before
we
added code to USB to put it into a low-power state at idle, the power
budget
would have been around a watt higher. As you can see, in this type of
machine, 300mW can be an extra half-hour of battery time, which is very
significant.

Let’s take the ethernet as an example. It’s rarely in use when the
machine
is running on batteries. So you’d really like to shut it down. But
you’d
still want it to come back on line as soon as you plugged it into a hub.
This is accomplishable using the very IRP_MN_WAIT_WAKE mechanisms that
are
in WDM. The NDIS stack sends IRP_MN_WAIT_WAKE to its PDO, which is
PCI.sys.
PCI.sys then sends another to its parent, which in this case is
ACPI.sys.
The NDIS driver then moves the NIC out of D0 and shuts down the PHY,
which
is the power-hungry part. When the ethernet cable is plugged back in,
it
triggers PME# and the series of IRPs is completed, causing the NDIS
stack to
bring the NIC back into D0.

USB is a similar case, though it has a couple of interesting
particularities. First, USB defines a wake mechanism that is contained
within USB. So it’s entirely possible that USB may power down a single
port
in response to a keyboard stack sending IRP_MN_WAIT_WAKE. Since the
other
ports are still active, the controller will remain active, not sending
an
IRP to its parent. (This is the ‘may’ case we were talking about
before.)
If the user touches the keyboard, then the keyboard device will signal
for
wakeup using the USB mechanism, and the controller (root hub) driver
will
complete the keyboard driver’s IRP. Of course, if all ports have been
powered down, then the root hub will power itself down, which will
require
an IRP to its parent to enable wakeup.

USB is also interesting because, when active, it requires periodic DMA
traffic. While this doesn’t require much power in the USB controller or
the
memory controller, it forces the processor to stay in an active state,
so
that the processor caches are kept coherent. This means that USB, or
any
other device that you guys may be working with which uses a lot of DMA,
can
cause a machine like my small laptop to add another watt, (sometimes 2
or 3
watts,) to its active power usage. That’s a huge reduction in battery
life.

And, yes Max, the USB controller has got to be prepared to pend a
separate
IRP_MN_WAIT_WAKE from each of its child devices. It only has to send
one to
its parent in response, and only if the parent isn’t capable of handling
the
children’s IRPs by itself. (To review, this would either be because it
can’t detect a wakeup signal from its child, probably because the child
is
just triggering PME# directly. Or it could be because the parent itself
has
been moved out of D0, meaning that it will trigger wakeup when its child
does, probably through PME#.)

If you want more information, I wrote a white paper a couple of years
ago
that was intended to help motherboard manufacturers deal route wakeup
signals in ways that could actually work. It also covers some issues
that
you’ve touched on. It’s at:

http://www.microsoft.com/hwdev/tech/onnow/GPE_routing.asp

Postscript: NDIS and other miniport stacks hide the details of WDM. So
you
have to get them to do run-time power management in ways that may seem
strange. If you want or need details about a particular port model,
I’ll
pass your questions along to the owners.

Hope this helps. Please ask more questions if it’s still not clear.

Jake Oshins
Windows Kernel Group

This posting is provided “AS IS” with no warranties, and confers no
rights.

I guess I still don’t understand wake IRPs for device wake up. It seems
that system wake and device wake should be separated. I can see where a
mechanism might be needed such that some device could power itself down and
only wake up when something important happens. I can also see where a
device might want the whole system to wake if something important happens.
But, I can imagine that most non-NIC/mouse/keyboard devices that wanted to
use the device wake would not necessarily want to wake the system if it is
in standby. How could one specify this today with wake IRPs? As I see it a
driver that sends down a wake IRP is then capa ble of waking the system
whether it wants to or not.

I do not think the bus should be requesting power IRPs for its children,
rather it would seem to me that you could setup a mechanism such that the
driver for a device could register a handler or some such for the wake
signal. I think of PME and I see an over glorified interrupt that can be
yanked at lower power and allows hardware access at lower power as well for
status and such. Why not have a special ISR for this? This would eliminate
the need for the bus to get involved, beyond calling the correct handler.
Anyway, an IRP will do as well, it just seems weird to me.


Bill McKenzie

“Jake Oshins” wrote in message
news:xxxxx@ntdev…

With PCI devices, the bus driver can read the PMEStatus bit of each of
the devices on the bus. With other bus drivers, you should have a
bus-specific mechanism.

In rare cases, bus drivers just have to complete all the pending
instances of IRP_MN_WAIT_WAKE, letting each of the devices figure out if
the signal was spurious. FDOs then have to re-send the IRP if the
completion was spurious. (They probably just re-send anyhow, if they
want to remain armed.)

Jake Oshins
Windows Kernel Group

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
Subject: Re: Path of IRP_MN_WAIT_WAKE
From: “Bill McKenzie”
Date: Mon, 15 Jul 2002 00:52:01 -0500
X-Message-Number: 6

Interestingly enough, though, this would pretty well make waking an
individual device, an impossibility. As in, how would the bus possibly
know
which of its wake capable devices caused the wake signal? I guess this
is
hardware specific, as in, the host controller manufacturer or whoever
better
make this accessible to the bus driver, right? Then what do you do if
more
than one device yanked the wake signal, does the bus complete the wake
IRPs
for each of those devices and decrement the count accordingly? It
certainly
is unclear from the docs.


Bill McKenzie

“Bill McKenzie” wrote in message
news:xxxxx@ntdev…
>
> As I understand it, the bus driver will receive two wait wake IRPs to
its
> PDOs, but the bus FDO will only send one down. It tracks wake capable
> children though, as the following paragraph explains, from the DDK
docs
> “Understanding the Path of Wait/Wake IRPs through a Device Tree”:
>
> “Although a parent driver might enumerate more than one child that can
be
> enabled for wait/wake, only one wait/wake IRP can be pending for a
PDO. In
> such cases, the parent driver should make sure that it keeps a
wait/wake
IRP
> pending whenever any of its devices is enabled for wake-up. To do so,
the
> driver should increment an internal counter each time it receives a
> wait/wake IRP. Each time the driver completes a wait/wake IRP, it
decrements
> the count and, if the resulting value is nonzero, sends another
wait/wake
> IRP to its device stack.”
>
> –
> Bill McKenzie
>
>