Subject: Re: [2.0-RC1] shutdown is not clean
To: Michael Gerhards <HM-Gerhards@uni.de>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: port-sparc64
Date: 11/01/2004 20:23:29
--7AUc2qLy4jB3hD7Z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Mon, Nov 01, 2004 at 01:14:21AM +0100, Michael Gerhards wrote:
> [...]
> And when I pressed the power button, I got these messages:
> login: Oct 31 04:57:34 ultra10 shutdown: halt by root: power button
> pressed
> Oct 31 04:57:35 ultra10 shutdown: halt by root: power button pressed
> Oct 31 04:57:43 ultra10 syslogd: Exiting on signal 15
> syncing disks... done
> wd0: ata_vers 2, trying flushcache anyway
> flush cache command completed
> 
> 
> So what does this tell us about the problem?

You drive claims to support only version 2 of ATA protocol, while it supports
some ATA-4 commands (WDC_FLUSHCACHE is part of the ATA command set since
ATA-4).

> At the moment, there is no
> problem, is it?

No, because my patch forces the execution of WDC_FLUSHCACHE regardless of the
revision. But it's not really an acceptable fix.
Could you see if the attached patch fix your problem ? If so I'll commit it.

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
     NetBSD: 26 ans d'experience feront toujours la difference
--

--7AUc2qLy4jB3hD7Z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff

Index: wd.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ata/wd.c,v
retrieving revision 1.296
diff -u -r1.296 wd.c
--- wd.c	28 Oct 2004 07:07:39 -0000	1.296
+++ wd.c	1 Nov 2004 19:22:23 -0000
@@ -1760,7 +1760,13 @@
 {
 	struct ata_command ata_c;
 
-	if (wd->drvp->ata_vers < 4) /* WDCC_FLUSHCACHE is here since ATA-4 */
+	/*
+	 * WDCC_FLUSHCACHE is here since ATA-4, but some drives report
+	 * only ATA-2 and still support it.
+	 */
+	if (wd->drvp->ata_vers < 4 &&
+	    ((wd->sc_params.atap_cmd_set2 & WDC_CMD2_FC) == 0 ||
+	    wd->sc_params.atap_cmd_set2 == 0xffff))
 		return ENODEV;
 	memset(&ata_c, 0, sizeof(struct ata_command));
 	if ((wd->sc_params.atap_cmd2_en & ATA_CMD2_LBA48) != 0 &&

--7AUc2qLy4jB3hD7Z--