From: DaveH on
Hi,

I have a WDM driver which needs to bring its device from D3 back to D0 when
system is being transitioned to Sx. This is necessary to be able to clear any
wake status on device before going to sleep so the system doesn't bounce back
to S0 when wakes are enabled on the bus.

Currently what I'm doing is to set a completion routine for IRP_MN_SET_POWER
(system) and then call PoRequestPowerIrp to send a D0 device power IRP in the
completion routine while setting a completion callback routine for this IRP.
Driver then sends another power IRP to transition the device back to D3 in
the callback and sets another callback routine to complete the system power
set IRP after device is in D3.

While this doesn't seem to be a neat solution, I couldn't think of any other
way of achieving same functionality (I can't use idle detection and wake from
S0 due to a bug in PCI driver previously covered in this forum).

I haven't seen any side-effects when using this approach, however I'm not
sure if what I'm doing is safe as I'm sending the Sx power IRP down the stack
followed by a device D0 request rather than the normal Dx request.

Any recommendations is highly appreciated.
Many thanks.

From: Doron Holan [MSFT] on
what you are doing is fine. the bus driver usually does absolutely nothing
with Sx or S0 irps, it usually only can do something meaningful with Dx/D0
irps. btw, this is exactly what kmdf does when a device is armed for wake
for idle and the machine goes to sx.

d

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


"DaveH" <DaveH(a)discussions.microsoft.com> wrote in message
news:6F8D8829-EBEC-4BF0-8375-71C26892C110(a)microsoft.com...
> Hi,
>
> I have a WDM driver which needs to bring its device from D3 back to D0
> when
> system is being transitioned to Sx. This is necessary to be able to clear
> any
> wake status on device before going to sleep so the system doesn't bounce
> back
> to S0 when wakes are enabled on the bus.
>
> Currently what I'm doing is to set a completion routine for
> IRP_MN_SET_POWER
> (system) and then call PoRequestPowerIrp to send a D0 device power IRP in
> the
> completion routine while setting a completion callback routine for this
> IRP.
> Driver then sends another power IRP to transition the device back to D3 in
> the callback and sets another callback routine to complete the system
> power
> set IRP after device is in D3.
>
> While this doesn't seem to be a neat solution, I couldn't think of any
> other
> way of achieving same functionality (I can't use idle detection and wake
> from
> S0 due to a bug in PCI driver previously covered in this forum).
>
> I haven't seen any side-effects when using this approach, however I'm not
> sure if what I'm doing is safe as I'm sending the Sx power IRP down the
> stack
> followed by a device D0 request rather than the normal Dx request.
>
> Any recommendations is highly appreciated.
> Many thanks.
>

From: DaveH on
Thanks Doron. I was wondering how KMDF disarms idle wakes and am happy to
hear it's using my technique lol!

BTW, is it also ok to call PoRequestPowerIrp for a Dx state from within a D0
completion routine? This is in order to bring the device to D0 after a system
transition to S0, initialize it and then send it back to D3 without using
idle mechanism.

Thanks.


"Doron Holan [MSFT]" wrote:

> what you are doing is fine. the bus driver usually does absolutely nothing
> with Sx or S0 irps, it usually only can do something meaningful with Dx/D0
> irps. btw, this is exactly what kmdf does when a device is armed for wake
> for idle and the machine goes to sx.
>
> d
>
> --
> Please do not send e-mail directly to this alias. this alias is for
> newsgroup purposes only.
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
> "DaveH" <DaveH(a)discussions.microsoft.com> wrote in message
> news:6F8D8829-EBEC-4BF0-8375-71C26892C110(a)microsoft.com...
> > Hi,
> >
> > I have a WDM driver which needs to bring its device from D3 back to D0
> > when
> > system is being transitioned to Sx. This is necessary to be able to clear
> > any
> > wake status on device before going to sleep so the system doesn't bounce
> > back
> > to S0 when wakes are enabled on the bus.
> >
> > Currently what I'm doing is to set a completion routine for
> > IRP_MN_SET_POWER
> > (system) and then call PoRequestPowerIrp to send a D0 device power IRP in
> > the
> > completion routine while setting a completion callback routine for this
> > IRP.
> > Driver then sends another power IRP to transition the device back to D3 in
> > the callback and sets another callback routine to complete the system
> > power
> > set IRP after device is in D3.
> >
> > While this doesn't seem to be a neat solution, I couldn't think of any
> > other
> > way of achieving same functionality (I can't use idle detection and wake
> > from
> > S0 due to a bug in PCI driver previously covered in this forum).
> >
> > I haven't seen any side-effects when using this approach, however I'm not
> > sure if what I'm doing is safe as I'm sending the Sx power IRP down the
> > stack
> > followed by a device D0 request rather than the normal Dx request.
> >
> > Any recommendations is highly appreciated.
> > Many thanks.
> >
>
>
From: Doron Holan [MSFT] on
it depends on if you are waiting for the d0 irp to arrive in the dx
completion routine. i am guessing not. ideally you request the d0 irp in
the po completion routine (the one you pass to PoRequestPowerIrp), not an io
completion routine. on vista, only one power irp can be active in the
entire stack at once which means that if you request a d0 irp in the dx io
completion routine, it will not arrive until you complete the dx irp.

d

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


"DaveH" <DaveH(a)discussions.microsoft.com> wrote in message
news:FACE3656-1649-42E5-970D-D626F0165A12(a)microsoft.com...
> Thanks Doron. I was wondering how KMDF disarms idle wakes and am happy to
> hear it's using my technique lol!
>
> BTW, is it also ok to call PoRequestPowerIrp for a Dx state from within a
> D0
> completion routine? This is in order to bring the device to D0 after a
> system
> transition to S0, initialize it and then send it back to D3 without using
> idle mechanism.
>
> Thanks.
>
>
> "Doron Holan [MSFT]" wrote:
>
>> what you are doing is fine. the bus driver usually does absolutely
>> nothing
>> with Sx or S0 irps, it usually only can do something meaningful with
>> Dx/D0
>> irps. btw, this is exactly what kmdf does when a device is armed for
>> wake
>> for idle and the machine goes to sx.
>>
>> d
>>
>> --
>> Please do not send e-mail directly to this alias. this alias is for
>> newsgroup purposes only.
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>>
>> "DaveH" <DaveH(a)discussions.microsoft.com> wrote in message
>> news:6F8D8829-EBEC-4BF0-8375-71C26892C110(a)microsoft.com...
>> > Hi,
>> >
>> > I have a WDM driver which needs to bring its device from D3 back to D0
>> > when
>> > system is being transitioned to Sx. This is necessary to be able to
>> > clear
>> > any
>> > wake status on device before going to sleep so the system doesn't
>> > bounce
>> > back
>> > to S0 when wakes are enabled on the bus.
>> >
>> > Currently what I'm doing is to set a completion routine for
>> > IRP_MN_SET_POWER
>> > (system) and then call PoRequestPowerIrp to send a D0 device power IRP
>> > in
>> > the
>> > completion routine while setting a completion callback routine for this
>> > IRP.
>> > Driver then sends another power IRP to transition the device back to D3
>> > in
>> > the callback and sets another callback routine to complete the system
>> > power
>> > set IRP after device is in D3.
>> >
>> > While this doesn't seem to be a neat solution, I couldn't think of any
>> > other
>> > way of achieving same functionality (I can't use idle detection and
>> > wake
>> > from
>> > S0 due to a bug in PCI driver previously covered in this forum).
>> >
>> > I haven't seen any side-effects when using this approach, however I'm
>> > not
>> > sure if what I'm doing is safe as I'm sending the Sx power IRP down the
>> > stack
>> > followed by a device D0 request rather than the normal Dx request.
>> >
>> > Any recommendations is highly appreciated.
>> > Many thanks.
>> >
>>
>>