Subject: Re: 1.4.1, APM, SCSI disk spin down how?
To: Anne Bennett <anne@alcor.concordia.ca>
From: Ken Hornstein <kenh@cmf.nrl.navy.mil>
List: port-i386
Date: 07/25/2000 22:37:32
Anne,

I did some of the admittedly minor work with power management on IDE
drives, so let me explain what you're up against.

The way that power management is done on IDE drives is simple; you
send a command to the drives to tell it to spin down after N seconds
of inactivity.  The drive wakes up when the operating system accesses
the drive.  It's completely transparent to the operating system.

Now, you _could_ make the operating system do the power management
of IDE drives directly, and perhaps Windows does that.  But all of
the free Unixes that I'm aware of simply let the drive do it, for
better or for worse.

So, what does this have to do with SCSI drives?  Well, AFAIK, SCSI
drives don't have the feature of IDE drives that enables you to
do the power management on the drive; you need to do it.  But this
presents a problem; you need to make the SCSI device driver aware of
what you're doing, otherwise the operating system won't know that
it has to turn on the drive when it goes to access it.  Thus, the
work done on the i386 APM probably won't help you.

Okay, fine, you probably knew all of that.  Well, this is my
way of explaining that you definately need some kernel support for
doing this.  What _I_ would do is set a flag marking that device as
down, so the device driver knows to spin it up when it goes next
to access it.  Maybe define a new ioctl that told the SCSI subsystem
to put this device to sleep.

Adding a new ioctl isn't that hard; look at how it's done in
sdioctl() in sys/dev/scsipi/sd.c.

>Also, can someone confirm that SSS_START and SSS_STOP should indeed
>cause the disks to spin up and spin down?  There's no documentation
>(that I can find), even in the source itself.

This all ties back to the SCSI specification.  You really need to read 
that to understand what that means (the short answer: "SSS_STOP may
do what you want, it depends on the device").  You might want to
read the SCSI specification.  It costs money to buy it from ANSI,
but you can get the latest draft standard from them at:

http://www.t10.org/drafts.htm

From looking at it, it seems that newer drives support doing power
management themselves, but I don't know how "new" they have to be.

--Ken