How do put an ATA disk into sleep/standby mode?
John-Mark Gurney
gurney_j at efn.org
Sat Sep 13 01:16:32 PDT 2003
Darren Pilgrim wrote this message on Thu, Sep 11, 2003 at 17:55 -0700:
> In my workstation, running 5.1-R, I have two disks, one containing
> FreeBSD, the other Windows. Since the Windows disk isn't used at all
> when in FreeBSD, I would like to put it into standby or sleep mode
> (whichever is necessary) to make it spin down, reducing heat and noise
> production--both of which have become a real problem.
>
> This is at least technically possible, since spinning down a disk is
> part of the APM sleep mode. The capabilities list atacontrol reports
> for the disk in question shows power management and advanced power
> management as being supported, and I've gotten Windows to spin down this
> disk. I haven't had any luck figuring out how to do this in FreeBSD,
> though.
>
> So how do I accomplish this?
Well, in -current, sos has commited a frame work that will let a
userland utility to send arbitrary commands to the disks, and so
this will be possible from a utility.
I wanted this feature too, and I happen to be browsing around the ata
spec and noticed that you can include a spin down time as part of the
disk idle command.. The disk idle command appears to be quite harmless
as it just asks the drive to go to idle (if it was doing a read ahead
or something else). So, I have this patch. I originally did this
against 4.2-R I believe, but I think I have updated it to a more recent
version.. (the revisions it's against are in the patch)..
hope this helps you.
--
John-Mark Gurney Voice: +1 415 225 5579
"All that I will do, has been done, All that I have, has not."
-------------- next part --------------
Index: ata-all.h
===================================================================
RCS file: /home/ncvs/src/sys/dev/ata/ata-all.h,v
retrieving revision 1.26.2.4
diff -u -r1.26.2.4 ata-all.h
--- ata-all.h 2000/10/30 09:41:28 1.26.2.4
+++ ata-all.h 2002/07/23 20:02:25
@@ -74,6 +74,7 @@
#define ATA_C_READ_DMA 0xc8 /* read w/DMA command */
#define ATA_C_WRITE_DMA 0xca /* write w/DMA command */
#define ATA_C_WRITE_DMA_QUEUED 0xcc /* write w/DMA QUEUED command */
+#define ATA_C_IDLE 0xe3 /* idle command */
#define ATA_C_FLUSHCACHE 0xe7 /* flush cache to disk */
#define ATA_C_ATA_IDENTIFY 0xec /* get ATA params */
#define ATA_C_SETFEATURES 0xef /* features command */
Index: ata-disk.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/ata/ata-disk.c,v
retrieving revision 1.60.2.9
diff -u -r1.60.2.9 ata-disk.c
--- ata-disk.c 2000/11/04 23:04:52 1.60.2.9
+++ ata-disk.c 2002/07/23 20:44:15
@@ -174,6 +174,10 @@
printf("ad%d: disabling service interrupt failed\n", adp->lun);
}
+ /* set standbye timer for 10 minutes */
+ if (ata_command(adp->controller, adp->unit, ATA_C_IDLE, 0, 0, 0, 120, 0, ATA_WAIT_INTR))
+ printf("ad%d: failed to set standby timer.\n", adp->lun);
+
devstat_add_entry(&adp->stats, "ad", adp->lun, DEV_BSIZE,
DEVSTAT_NO_ORDERED_TAGS,
DEVSTAT_TYPE_DIRECT | DEVSTAT_TYPE_IF_IDE,
More information about the freebsd-current
mailing list