Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Jul 2001 18:16:49 -0400
From:      Robert Sexton <robert@kudra.com>
To:        freebsd-mobile@freebsd.org
Subject:   ATA idle spindown patch.
Message-ID:  <20010724181649.A61408@kudra.com>

next in thread | raw e-mail | index | archive | help

--KsGdsel6WgEHnImy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

A few months ago, there was a discussion on how to get laptop hard
drives to spin down, and there was talk that maybe Soren was going to
add it to atacontrol.  Its been a while.  He's busy :-)

So heres a patch to implement it, hopefully the 'Right Way' (tm), but
without the bells and whistles.  Set hw.ata.suspend in /boot/loader.conf: 
hw.ata.suspend=300. (Choose your preferred idle time, or course)
The default is not to even attempt to try setting
the idle timer on the drive. So it should be harmless if not used.
There are other wrinkles with altering
the syncer to behave a little better, but a really useful solution is
complicated.

Season to taste.  I would appreciate knowing if it works on machines
with multiple drives, and especially any tricks people may have found
for getting hard drives to stay quiet.  ssh always seems to wake mine
up.

Needless to say, it applies to -CURRENT, although I've been using
it for a while.

-- 
Robert Sexton - robert@kudra.com, Cincinnati OH, USA
Build a man a fire, and he's warm for the rest of the night.  Set a man
on fire, and he's warm for the rest of his life - Terry Pratchett, "Jingo"

--KsGdsel6WgEHnImy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="ata.patch"

*** dev/ata/ata-disk.c.orig	Fri Jun  8 07:24:13 2001
--- dev/ata/ata-disk.c	Mon Jul 23 15:03:07 2001
***************
*** 85,93 ****
--- 85,95 ----
  static int ata_dma = 1;
  static int ata_wc = 0;
  static int ata_tags = 0; 
+ static int ata_suspend = 0;
  TUNABLE_INT("hw.ata.ata_dma", &ata_dma);
  TUNABLE_INT("hw.ata.wc", &ata_wc);
  TUNABLE_INT("hw.ata.tags", &ata_tags);
+ TUNABLE_INT("hw.ata.suspend", &ata_suspend);
  
  /* sysctl vars */
  SYSCTL_DECL(_hw_ata);
***************
*** 97,102 ****
--- 99,106 ----
  	   "ATA disk write caching");
  SYSCTL_INT(_hw_ata, OID_AUTO, tags, CTLFLAG_RD, &ata_tags, 0,
  	   "ATA disk tagged queuing support");
+ SYSCTL_INT(_hw_ata, OID_AUTO, suspend, CTLFLAG_RD, &ata_suspend, 0,
+ 	   "ATA disk suspend timer");
  
  /* defines */
  #define	AD_MAX_RETRIES	3
***************
*** 182,187 ****
--- 186,198 ----
  			0, 0, 0, 0, ATA_C_F_DIS_SRVIRQ, ATA_WAIT_INTR))
  	    ata_printf(scp, device, "disabling service interrupt failed\n");
      }
+ 
+     if ( ata_suspend > 0 ) {
+         /* attempt suspend mode. The drive uses increments of ten seconds */  
+         if (ata_command(adp->controller, adp->unit, 0xe2,
+                     0, 0, 0, ata_suspend/10, 0, ATA_WAIT_INTR))
+         printf("ad%d: suspend mode failed\n", adp->lun);
+ 	}
  
      devstat_add_entry(&adp->stats, "ad", adp->lun, DEV_BSIZE,
  		      DEVSTAT_NO_ORDERED_TAGS,

--KsGdsel6WgEHnImy--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-mobile" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010724181649.A61408>