USB problem when using Standby or Hibernate

I have a USB WDM written using the W2K DDK and have the following
problem when entering or coming out of Standby or Hibernate.

The USB device is accessed by a DLL we supply to our customers which
they can call at any time and as frequently as they like.

  1. When entering the required power mode, the driver issues a power down
    (see text 1), which it completes successfully. After this happens our
    DLL can make a call to the WDM to access the USB device but it has been
    powered down so it fails.

  2. When leaving the required power mode and resuming to normal
    operation, our DLL can call the WDM but the USB device has yet to be
    powered on so it fails. The device does get started - driver applies
    power at system power on (see text 2)

Is there anyway to queue the requests made by the DLL to the WDM? Or
another way around this problem?

At the moment the call fails so our customers software leaves them with
an error message stating that our hardware could not be found, not very
elegant.

Daryl Baker

Text 1 - Power Down

5.42711490 IrpMjPower - in
5.42712160 IrpMjPower - SystemPower
5.42712803 IrpMjPower - SystemPower - QUERY_POWER
5.42713585 IrpMjPower - SystemPower - power OFF 1
5.42714256 IrpMjPower - SkipRequest
6.00563647 IrpMjPower - in
6.00564345 IrpMjPower - SystemPower
6.00565016 IrpMjPower - SystemPower - SET_POWER
6.00565658 IrpMjPower - SystemPower - power OFF
6.00566357 IrpMjPower - MarkPending
6.00567754 IrpMjPower - in
6.00568396 IrpMjPower - DevicePower
6.00569039 IrpMjPower - DevicePower OFF
6.00569709 IrpMjPower - SkipRequest
6.00572671 SystemPowerComplete
6.00573509 IrpMjPower - out=00000000

Text 2 - Power On

15.21790535 IrpMjPower - in
15.21791205 IrpMjPower - SystemPower
15.21791876 IrpMjPower - SystemPower - SET_POWER
15.21792490 IrpMjPower - SystemPower - power ON
15.21793133 IrpMjPower - MarkPending
15.21793748 IrpMjPower - MarkPending 2
15.21794586 IrpMjPower - in
15.21795228 IrpMjPower - DevicePower
15.21795871 IrpMjPower - DevicePower ON
15.21796513 IrpMjPower - WaitForCompletion
15.43685440 DevicePowerComplete
15.43686279 SystemPowerComplete
15.43687312 IrpMjPower - out=00000000

Put the PIRP into a queue when in low power and then drain the queue when you resume to D0. this is not as simple as it sounds though b/c you will have to coordinate device state with active irps. What happens if you have an active DLL IRP when the machine goes into low power? Do you wait for the current request to complete before moving into a Dx state? If not and you move into Dx with an active transfer, the active transfer will fail when the low power transition occurs. What this boils down to is this.

  1. in the i/o request path, grab a lock. Check the power state. If in d0 active, send the request (after dropping the lock. If in Dx pending or in Dx, put the request on a list.

  2. in the device power irp path, grab the same lock. If there are no active requests, goto a Dx state. If there are active requests, goto a Dx pending state. If in a dx pending state, wait for pending i/o to complete.

  3. when an i/o complete, grab the same lock. If the device is in a dx pending state and this was the last pending i/o (keep a count), set the event that you are waiting on in 2).

d


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Daryl Baker
Sent: Thursday, October 21, 2004 9:03 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] USB problem when using Standby or Hibernate

I have a USB WDM written using the W2K DDK and have the following problem when entering or coming out of Standby?or Hibernate.
?
The USB device is accessed by a DLL we supply to our customers?which they can call?at any time?and as frequently as they like.
?

  1. When entering the required power mode, the driver issues a power down (see text 1), which it completes successfully.? After this happens?our DLL can make a call to the WDM to access the USB device but it has been powered down so it fails.
    ?
  2. When leaving the required power mode and resuming to normal operation, our DLL?can call the WDM?but the USB device has yet to be powered on so it fails. The device does get?started?- driver applies power at system power on (see text 2)
    ?
    Is there anyway to queue the requests made by the DLL to the WDM? Or?another way around this problem?
    ?
    At the moment the call fails?so our customers software leaves them with an error message stating that our hardware could not be found, not very elegant.
    ?
    Daryl Baker
    ?
    ?
    Text 1 - Power Down
    ?
    5.42711490?IrpMjPower - in?
    5.42712160?IrpMjPower - SystemPower?
    5.42712803?IrpMjPower - SystemPower - QUERY_POWER?
    5.42713585?IrpMjPower - SystemPower - power OFF 1?
    5.42714256?IrpMjPower - SkipRequest?
    6.00563647?IrpMjPower - in?
    6.00564345?IrpMjPower - SystemPower?
    6.00565016?IrpMjPower - SystemPower - SET_POWER?
    6.00565658?IrpMjPower - SystemPower - power OFF?
    6.00566357?IrpMjPower - MarkPending?
    6.00567754?IrpMjPower - in?
    6.00568396?IrpMjPower - DevicePower?
    6.00569039?IrpMjPower - DevicePower OFF?
    6.00569709?IrpMjPower - SkipRequest?
    6.00572671?SystemPowerComplete?
    6.00573509?IrpMjPower - out=00000000?
    ?
    ?
    Text 2 - Power On
    ?
    15.21790535?IrpMjPower - in?
    15.21791205?IrpMjPower - SystemPower?
    15.21791876?IrpMjPower - SystemPower - SET_POWER?
    15.21792490?IrpMjPower - SystemPower - power ON?
    15.21793133?IrpMjPower - MarkPending?
    15.21793748?IrpMjPower - MarkPending 2?
    15.21794586?IrpMjPower - in?
    15.21795228?IrpMjPower - DevicePower?
    15.21795871?IrpMjPower - DevicePower ON?
    15.21796513?IrpMjPower - WaitForCompletion?
    15.43685440?DevicePowerComplete?
    15.43686279?SystemPowerComplete?
    15.43687312?IrpMjPower - out=00000000?
    ?

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

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com