From owner-freebsd-hackers@FreeBSD.ORG Fri Jan 29 23:32:39 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from [127.0.0.1] (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by hub.freebsd.org (Postfix) with ESMTP id 800681065672; Fri, 29 Jan 2010 23:32:39 +0000 (UTC) (envelope-from jkim@FreeBSD.org) From: Jung-uk Kim To: freebsd-hackers@freebsd.org Date: Fri, 29 Jan 2010 18:32:05 -0500 User-Agent: KMail/1.6.2 References: In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Content-Type: Multipart/Mixed; boundary="Boundary-00=_NA3YLEXEScty5nJ" Message-Id: <201001291832.29086.jkim@FreeBSD.org> Cc: Alexander Best Subject: Re: Spin down HDD after disk sync or before power off X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jan 2010 23:32:39 -0000 --Boundary-00=_NA3YLEXEScty5nJ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline 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; I am not 100% sure but I think it should be something like the attached patch. Jung-uk Kim --Boundary-00=_NA3YLEXEScty5nJ Content-Type: text/plain; charset="iso-8859-1"; name="ata-disk.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ata-disk.diff" --- 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) --Boundary-00=_NA3YLEXEScty5nJ--