Spin down HDD after disk sync or before power off

Jung-uk Kim jkim at FreeBSD.org
Fri Jan 29 23:32:39 UTC 2010


On Friday 29 January 2010 05:38 pm, Warren Block wrote:
> On Wed, 27 Jan 2010, Alexander Best wrote:
> > i believe the sound you hear is due to the emergency unload
> > sequence. i'm not 100% sure, but i think after applying the patch
> > the sound is gone. i recently replaced my old IDE hdd (which made
> > a very loud "click!" during shutdown) with a new SATA hdd. the
> > new one is very quiet and so it's not that easy to recognise any
> > changes in the spin down procedure.
> >
> > would be very nice if you could try the patch on one of the
> > notebooks you're referring to in order to see if the patch makes
> > a difference.
>
> Based on followups to this thread, here's the modified patch I've
> tested:
>
> --- sys/dev/ata/ata-disk.c.orig	2010-01-28 10:47:57.000000000 -0700
> +++ sys/dev/ata/ata-disk.c	2010-01-28 11:49:32.000000000 -0700
> @@ -191,6 +191,10 @@
>   {
>       struct ata_device *atadev = device_get_softc(dev);
>
> +    if (atadev->param.support.command2 & ATA_SUPPORT_POWERMGT)
> +	ata_controlcmd(dev, ATA_STANDBY_IMMEDIATE, 0, 0, 0);
> +    return 0;
> +
>       if (atadev->param.support.command2 & ATA_SUPPORT_FLUSHCACHE)
>   	ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0);
>       return 0;

<SKIP!>

I am not 100% sure but I think it should be something like the 
attached patch.

Jung-uk Kim
-------------- next part --------------
--- sys/dev/ata/ata-disk.c	2009-12-14 17:02:42.000000000 -0500
+++ sys/dev/ata/ata-disk.c	2010-01-29 17:58:12.000000000 -0500
@@ -187,16 +187,6 @@ ad_detach(device_t dev)
 }
 
 static int
-ad_shutdown(device_t dev)
-{
-    struct ata_device *atadev = device_get_softc(dev);
-
-    if (atadev->param.support.command2 & ATA_SUPPORT_FLUSHCACHE)
-	ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0);
-    return 0;
-}
-
-static int
 ad_reinit(device_t dev)
 {
     struct ata_channel *ch = device_get_softc(device_get_parent(dev));
@@ -241,6 +231,16 @@ ad_spindown(void *priv)
     ata_queue_request(request);
 }
 
+static int
+ad_shutdown(device_t dev)
+{
+    struct ata_device *atadev = device_get_softc(dev);
+
+    if (atadev->param.support.command2 & ATA_SUPPORT_FLUSHCACHE)
+	ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0);
+    ad_spindown(dev);
+    return 0;
+}
 
 static void 
 ad_strategy(struct bio *bp)


More information about the freebsd-hackers mailing list