Hi All,

I have a question on how the disk spin down is affected for a SATA hard
drive. Would the windows storage stack send a START STOP UNIT command
to stop the disk?

regards
vs

Re: Disk spin down by vs

vs
Sat Sep 09 03:30:27 CDT 2006


Let me rephrase the question, when the power management policy
indicates that a disk should be spun down after say 30 minutes, who
initiates the spin down i.e. who runs the timers monitoring the writes
and what SCSI command gets sent to the miniport to initiate the spin
down?

regards
vs

vs wrote:
> Hi All,
>
> I have a question on how the disk spin down is affected for a SATA hard
> drive. Would the windows storage stack send a START STOP UNIT command
> to stop the disk?
>
> regards
> vs


Re: Disk spin down by Maxim

Maxim
Sat Sep 09 19:42:57 CDT 2006

> Let me rephrase the question, when the power management policy
> indicates that a disk should be spun down after say 30 minutes, who
> initiates the spin down i.e. who runs the timers monitoring the writes
> and what SCSI command gets sent to the miniport to initiate the spin
> down?

The storage port driver does this for its PDOs, usually using the
PoRegisterDeviceForIdleDetection logic. Since ->DeviceType is FILE_DEVICE_DISK,
the Po's routine uses the current power policy and the disk spindown time from
it.

Then, when the disk was idle for some time, Po itself sends a device power-down
IRP to the devnode. The class drivers (Disk/ClassPnP) create and send the
associated START STOP UNIT command down to the same storage port's PDO.

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


Re: Disk spin down by vs

vs
Mon Sep 11 03:26:05 CDT 2006

Thanks Maxim.

I have written my own storage port driver. In order to acheive the disk
spin down on idle I need to use the PoRegisterDeviceForIdleDetection.
Once done the Power Manager and the class drivers will determine when
to generate the START STOP UNIT command to stop the device. Also I
assume the class drivers will generate the START STOP UNIT to start the
device before issuing any further IO commands.

So the only responsibility of the port driver is to register for idle
detection using timeout -1 and call the PoSetDeviceBusy in my StartIO
routines. Did I get that right?

regards
vs

Maxim S. Shatskih wrote:
> > Let me rephrase the question, when the power management policy
> > indicates that a disk should be spun down after say 30 minutes, who
> > initiates the spin down i.e. who runs the timers monitoring the writes
> > and what SCSI command gets sent to the miniport to initiate the spin
> > down?
>
> The storage port driver does this for its PDOs, usually using the
> PoRegisterDeviceForIdleDetection logic. Since ->DeviceType is FILE_DEVICE_DISK,
> the Po's routine uses the current power policy and the disk spindown time from
> it.
>
> Then, when the disk was idle for some time, Po itself sends a device power-down
> IRP to the devnode. The class drivers (Disk/ClassPnP) create and send the
> associated START STOP UNIT command down to the same storage port's PDO.
>
> --
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> maxim@storagecraft.com
> http://www.storagecraft.com


Re: Disk spin down by Maxim

Maxim
Mon Sep 11 04:05:22 CDT 2006

> Once done the Power Manager and the class drivers will determine when
> to generate the START STOP UNIT command to stop the device.

Correct. Look at Disk/ClassPnP class driver source, it sends START STOP UNIT in
response to the D power IRP.

For CDs, it terminates the possible music play when the Dn power IRP arrives
:-)

>Also I
> assume the class drivers will generate the START STOP UNIT to start the
> device before issuing any further IO commands.

I don't think so. If IO arrives to powered down disk PDO - then your port's PDO
must initiate powering it up using PoRequestPowerIrp to state D0.

>to register for idle detection using timeout -1

...yes, and set the correct ->DeviceType in the PDO - FILE_DEVICE_DISK, for
instance - according to SCSI INQUIRY data.

>and call the PoSetDeviceBusy in my StartIO routines.

No. PoSetDeviceBusy must be called in DispatchInternalDeviceControl _before the
queue_ on each request with a SRB in it. You can even go further and call it
only for each request which requires the device motor to be spinning - read the
SCSI spec for the list. Some commands - like INQUIRY and some MODE SENSE - can
be executed on the drive with the motor powered off.

Also, do not forget that, if the PDO is in state > D0, you must call
PoStartNextPowerIrp to D0 instead of PoSetDeviceBusy.

The queue consumer must be blocked while the device is in > D0. This stop flag
can be combined with "locked queue" flag governed by LOCK_QUEUE IOCTL and used
by "bypass locked queue" IRPs - these IRPs (like the START STOP UNIT for
resume) bypass both "powered down" queue and "locked" queue. I believe these 2
queues are the same in SCSIPORT.

"Frozen" queue is another thing.

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