Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Aug 2001 10:16:02 -0700
From:      Scott Renfro <scott@renfro.org>
To:        JT <luser@ahab.com>
Cc:        Nick Sayer <nsayer@quack.kfu.com>, mobile@FreeBSD.ORG
Subject:   Re: ATA idle spindown patch.
Message-ID:  <20010823101602.F31614@bonsai.home.renfro.org>
In-Reply-To: <20010822235650.C410@zed.unbeat.com>; from luser@ahab.com on Wed, Aug 22, 2001 at 11:56:50PM -0400
References:  <200107280841.f6S8fvR80063@freebsd.dk> <3B6354F9.2070801@quack.kfu.com> <3B635732.6030409@quack.kfu.com> <20010822235650.C410@zed.unbeat.com>

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

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

On Wed, Aug 22, 2001 at 11:56:50PM -0400, JT wrote:
>
> I tried the patch with this modification, but I haven't noticed it spin down
> at all, not that I'm very patient (though I *can* verify sysctl
> hw.ata.suspend=300). I haven't the knowledge to really understand how this
> patch works, but:

Attached is the modified sysctl patch that I've been applying as part of
each buildworld/kernel cycle.  I'm running with a value of 120; much
less than 120 and I tend to get cycling (up-down-up-down, etc.).  It's
been working great.

> 	a) What stuff could keep the drive from spinning down?  I can think of
> 		i) cron?
> 		ii) fetchmail?
> 		iii) ???

Also syslog.  I've appended the list of processes I have running right
now and the drive has stayed spun down just fine.

> 	b) What would it take to write a userland program that could request
> 	an immediate spindown (even if suid)?  

I have a patch for this as well, but it is much more involved.  Requires
an ataioctl and requires more diligence in implementation to ensure that
a suspend command isn't sent to the device in the middle of other
operations.

The sysctl approach is working well for me.  I'm willing to wait
patiently for Soren to have the time to get the ioctl done right.

--Scott

Here's the uniq'd list of processes running on my (spundown) laptop
right now...

  (bufdaemon)     (pagedaemon)    (swapper)       (syncer)
  (vmdaemon)      X               _su             adjkerntz
  apmd            aterm           bash            bbapm
  bbkeys          bbrun           blackbox        cfsd
  dhclient        getty           init            lpd
  micro_inetd     mountd          moused          mutt
  pccardd         portmap         sh              smbd
  ssh             syslogd         uniq            usbd
  xautolock       xconsole        xdm             xemacs


-- 
Scott Renfro <scott@renfro.org>                          +1 650 862 4206

--d6Gm4EdcadzBjdND
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="ata-spindown-sysctl.diff"

--- sys/dev/ata/ata-disk.c.orig	Thu Jul 26 14:54:54 2001
+++ sys/dev/ata/ata-disk.c	Wed Aug  1 01:48:06 2001
@@ -86,9 +86,11 @@
 static int ata_dma = 1; 
 static int ata_wc = 1; 
 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);
@@ -98,6 +100,8 @@
 	   "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 (secs)");
 
 /* defines */
 #define	AD_MAX_RETRIES	3
@@ -182,6 +186,12 @@
 			0, 0, 0, 0, ATA_C_F_DIS_SRVIRQ, ATA_WAIT_INTR))
 	    printf("ad%d: disabling service interrupt failed\n", adp->lun);
     }
+    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,
@@ -897,6 +907,13 @@
 		    ata_wmode(AD_PARAM), ata_umode(AD_PARAM));
     else
 	ata_dmainit(adp->controller, adp->unit, ata_pmode(AD_PARAM), -1, -1);
+    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_READY))
+        printf("ad%d: suspend mode failed\n", adp->lun);
+    }
+
 }
 
 static int

--d6Gm4EdcadzBjdND--

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?20010823101602.F31614>