IRP_MN_WAIT_WAKE and PoStartNextPowerIrp()

DDK docs states:

Calling this (PoStartNextPowerIrp) routine indicates that the driver is
finished with the previous power IRP, if any, and is ready to handle the
next power IRP. It must be called once by each driver for every
IRP_MN_QUERY_POWER or IRP_MN_SET_POWER request.

IRP_MN_WAIT_WAKE isn't mentioned there. I presume it is an omission and
function should be called. However, I'm a bit confused with BulkUsb sample
which calls it in its DispatchPower routine just before passing IRP to below
driver (which seem reasonable because nobody knows when it'll be completed)
and again in completion routine. If I haven't missed something, it is
called twice for the same IRP.

I wonder if it is an intention or a bug. It seems as a bug; also calling it
in completion routine seems dangerous because it can be called at any time
during other power IRP processing. I'm unsure about side effects -- is OS
able to identify double call for the same IRP and ignore it? What if there
isn't any other power IRP waiting -- is an extra call remembered possibly
causing problem hours later?

BTW, toaster sample doesn't call PoStartNextPowerIrp for IRP_MN_WAIT_WAKE at
all. Walter Oney in his generic code once in power dispatch.

Best regards,

Michal Vodicka
STMicroelectronics Design and Application s.r.o.
[michal.vodicka@st.com, http:://www.st.com]

Hi,
It seems that you are confusing BulkUsb_PoRequestCompletion and
BulkUsb_IrpCompletionRoutine functions or probably you are having older
version of DDK or you may be missing something.
In build 2195 DDK for win2K, BulkUsb sample, IRP_MN_WAIT_WAKE sets
BulkUsb_IrpCompletionRoutine as completion routine which contain following
body only in usbpnp.c file:

NTSTATUS
BulkUsb_IrpCompletionRoutine(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PVOID Context
)
{
PKEVENT event = Context;

// Set the input event
KeSetEvent(event,
1, // Priority increment for waiting thread.
FALSE); // Flag this call is not immediately followed by
wait.

// This routine must return STATUS_MORE_PROCESSING_REQUIRED because we
have not yet called
// IoFreeIrp() on this IRP.
return STATUS_MORE_PROCESSING_REQUIRED;

}

Also DDK documentation for same build does not specifies any minor function
but talks about all the Power IRPs.

Regards,
Dev

-----Original Message-----
From: Michal Vodicka [mailto:xxxxx@veridicom.cz.nospam]
Sent: Friday, November 21, 2003 11:39 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] IRP_MN_WAIT_WAKE and PoStartNextPowerIrp()

DDK docs states:

Calling this (PoStartNextPowerIrp) routine indicates that the driver is
finished with the previous power IRP, if any, and is ready to handle the
next power IRP. It must be called once by each driver for every
IRP_MN_QUERY_POWER or IRP_MN_SET_POWER request.

IRP_MN_WAIT_WAKE isn't mentioned there. I presume it is an omission and
function should be called. However, I'm a bit confused with BulkUsb sample
which calls it in its DispatchPower routine just before passing IRP to below
driver (which seem reasonable because nobody knows when it'll be completed)
and again in completion routine. If I haven't missed something, it is
called twice for the same IRP.

I wonder if it is an intention or a bug. It seems as a bug; also calling it
in completion routine seems dangerous because it can be called at any time
during other power IRP processing. I'm unsure about side effects -- is OS
able to identify double call for the same IRP and ignore it? What if there
isn't any other power IRP waiting -- is an extra call remembered possibly
causing problem hours later?

BTW, toaster sample doesn't call PoStartNextPowerIrp for IRP_MN_WAIT_WAKE at
all. Walter Oney in his generic code once in power dispatch.

Best regards,

Michal Vodicka
STMicroelectronics Design and Application s.r.o.
[michal.vodicka@st.com, http:://www.st.com]


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: dsingh@in.rainbow.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Sorry, I speak about XP (build 2600) and w2k3 DDK (build 3790), both docs
and example. Build 2195 is rather obsolete and uniteresting for me as my
driver has to work on XP and above only.

Up-to-date BulkUsb uses WaitWakeCompletionRoutine for IRP_MN_WAIT_WAKE and
calls PoStartNextPowerIrp there.

Best regards,

Michal Vodicka
STMicroelectronics Design and Application s.r.o.
[michal.vodicka@st.com, http:://www.st.com]


Hi,
It seems that you are confusing BulkUsb_PoRequestCompletion and
BulkUsb_IrpCompletionRoutine functions or probably you are having older
version of DDK or you may be missing something.

In build 2195 DDK for win2K, BulkUsb sample, IRP_MN_WAIT_WAKE sets
BulkUsb_IrpCompletionRoutine as completion routine which contain following
body only in usbpnp.c file:

NTSTATUS
BulkUsb_IrpCompletionRoutine(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PVOID Context
)
{
PKEVENT event = Context;

// Set the input event
KeSetEvent(event,
1, // Priority increment for waiting thread.
FALSE); // Flag this call is not immediately followed by
wait.

// This routine must return STATUS_MORE_PROCESSING_REQUIRED because we
have not yet called
// IoFreeIrp() on this IRP.
return STATUS_MORE_PROCESSING_REQUIRED;

}

Also DDK documentation for same build does not specifies any minor
function but talks about all the Power IRPs.

Regards,
Dev

-----Original Message-----
From: Michal Vodicka [mailto:xxxxx]
> Sent: Friday, November 21, 2003 11:39 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] IRP_MN_WAIT_WAKE and PoStartNextPowerIrp()
>
>
> DDK docs states:
> -----
> Calling this (PoStartNextPowerIrp) routine indicates that the driver is
> finished with the previous power IRP, if any, and is ready to handle the
> next power IRP. It must be called once by each driver for every
> IRP_MN_QUERY_POWER or IRP_MN_SET_POWER request.
> -----
> IRP_MN_WAIT_WAKE isn’t mentioned there. I presume it is an omission and
> function should be called. However, I’m a bit confused with BulkUsb sample
>
> which calls it in its DispatchPower routine just before passing IRP to
> below
> driver (which seem reasonable because nobody knows when it’ll be
> completed)
> and again in completion routine. If I haven’t missed something, it is
> called twice for the same IRP.
>
> I wonder if it is an intention or a bug. It seems as a bug; also calling
> it
> in completion routine seems dangerous because it can be called at any time
>
> during other power IRP processing. I’m unsure about side effects – is OS
> able to identify double call for the same IRP and ignore it? What if there
>
> isn’t any other power IRP waiting – is an extra call remembered possibly
> causing problem hours later?
>
> BTW, toaster sample doesn’t call PoStartNextPowerIrp for IRP_MN_WAIT_WAKE
> at
> all. Walter Oney in his generic code once in power dispatch.
>
> Best regards,
>
> Michal Vodicka
> STMicroelectronics Design and Application s.r.o.
> [michal.vodicka@st.com, http::]
>
>
></http::></mailto:xxxxx>

“Michal Vodicka” wrote in message
news:xxxxx@ntdev…
> IRP_MN_WAIT_WAKE isn’t mentioned there.

PoStartNextPowerIrp is only required to release IRPs from the queues
maintained by the power manager for query and set requests. It does not harm
when called for wait-wake or query-sequence requests.




Walter Oney
Training and Consulting
http://www.oneysoft.com

> ----------

From: xxxxx@oneysoft.com[SMTP:xxxxx@oneysoft.com]
Reply To: xxxxx@lists.osr.com
Sent: Saturday, November 29, 2003 4:53 PM
To: xxxxx@lists.osr.com
Subject: [ntdev] Re: IRP_MN_WAIT_WAKE and PoStartNextPowerIrp()

PoStartNextPowerIrp is only required to release IRPs from the queues
maintained by the power manager for query and set requests. It does not
harm
when called for wait-wake or query-sequence requests.

Thanks, it makes sense. Does it mean power manager simply ignores an IRP
which isn’t in any queue? I’m interested about effect of double call for one
IRP.

Best regards,

Michal Vodicka
STMicroelectronics Design and Application s.r.o.
[michal.vodicka@st.com, http:://www.st.com]

“Michal Vodicka” wrote in message
news:xxxxx@ntdev…
> Thanks, it makes sense. Does it mean power manager simply ignores an IRP
> which isn’t in any queue? I’m interested about effect of double call for
one
> IRP.

That I don’t know. I would recommend making just one call for any given IRP.
I’ll bet the verifier checks for that, for one thing.




Walter Oney
Training and Consulting
http://www.oneysoft.com

> ----------

From: xxxxx@oneysoft.com[SMTP:xxxxx@oneysoft.com]
Reply To: xxxxx@lists.osr.com
Sent: Sunday, November 30, 2003 11:23 PM
To: xxxxx@lists.osr.com
Subject: [ntdev] Re: IRP_MN_WAIT_WAKE and PoStartNextPowerIrp()

“Michal Vodicka” wrote in message
> news:xxxxx@ntdev…
> > Thanks, it makes sense. Does it mean power manager simply ignores an IRP
> > which isn’t in any queue? I’m interested about effect of double call for
> one
> > IRP.
>
> That I don’t know. I would recommend making just one call for any given
> IRP.
> I’ll bet the verifier checks for that, for one thing.
>
It would be nice for query and set power IRPs, I’ll try it when have time.
It doesn’t check for double call on wait-wake IRP because original bulkusb
code does it and verifier doesn’t report.

Best regards,

Michal Vodicka
STMicroelectronics Design and Application s.r.o.
[michal.vodicka@st.com, http:://www.st.com]

> It doesn’t check for double call on wait-wake IRP because original bulkusb

code does it and verifier doesn’t report.

PoStartNextPowerIrp is matched to PoCallDriver. If these requests are delivered
to you by PoCallDriver - then you must call PoStartNextPowerIrp.

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

> ----------

From: xxxxx@storagecraft.com[SMTP:xxxxx@storagecraft.com]
Reply To: xxxxx@lists.osr.com
Sent: Monday, December 01, 2003 5:19 PM
To: xxxxx@lists.osr.com
Subject: [ntdev] Re: IRP_MN_WAIT_WAKE and PoStartNextPowerIrp()

> It doesn’t check for double call on wait-wake IRP because original
bulkusb
> code does it and verifier doesn’t report.

PoStartNextPowerIrp is matched to PoCallDriver. If these requests are
delivered
to you by PoCallDriver - then you must call PoStartNextPowerIrp.

It is obvious. Or can be a request delivered some other way than by
PoCallDriver?

I was interested what occurs if PoStartNextPowerIrp is called twice for the
same IRP by mistake. I hoped somebody on the list knows exactly how this
function handles unusual conditions and IRPs other than query and set power;
well, it seems I have to disassemble it myself.

Best regards,

Michal Vodicka
STMicroelectronics Design and Application s.r.o.
[michal.vodicka@st.com, http:://www.st.com]