NetBSD Problem Report #25366

Received: (qmail 11490 invoked by uid 605); 28 Apr 2004 14:40:09 -0000
Message-Id: <20040428144007.5C0B52AC7A@beowulf.gw.com>
Date: Wed, 28 Apr 2004 10:40:07 -0400 (EDT)
From: christos@zoulas.com
Sender: gnats-bugs-owner@NetBSD.org
Reply-To: christos@zoulas.com
To: gnats-bugs@gnats.NetBSD.org
Subject: wdc does not know about flushcache_ext
X-Send-Pr-Version: 3.95

>Number:         25366
>Category:       kern
>Synopsis:       wdc does not know about flushcache_ext
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bouyer
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Apr 28 14:41:00 +0000 2004
>Closed-Date:    Tue May 04 21:38:32 +0000 2004
>Last-Modified:  Fri May 14 06:10:01 +0000 2004
>Originator:     Christos Zoulas
>Release:        NetBSD 2.0E
>Organization:
	Galvanized Software, Inc.
>Environment:
NetBSD mx-temp.twosigma.com 2.0E NetBSD 2.0E (TWOSIGMA.MP) #3: Wed Apr 28 10:13:43 EDT 2004  christos@mx-temp.twosigma.com:/usr/src/sys/arch/i386/compile/TWOSIGMA.MP i386
Architecture: i386
Machine: i386
>Description:
	I have the following wdc:

piixide0 at pci0 dev 31 function 1
piixide0: Intel 82801CA IDE Controller (ICH3) (rev. 0x02)
piixide0: bus-master DMA support present
piixide0: primary channel wired to compatibility mode
piixide0: primary channel interrupting at ioapic0 pin 14 (irq 14)
atabus0 at piixide0 channel 0
piixide0: secondary channel wired to compatibility mode
piixide0: secondary channel interrupting at ioapic0 pin 15 (irq 15)
atabus1 at piixide0 channel 1

	And the following wd's:
wd0 at atabus0 drive 0: <WDC WD400BB-00DKA0>
wd0: drive supports 16-sector PIO transfers, LBA48 addressing
wd0: 38166 MB, 77545 cyl, 16 head, 63 sec, 512 bytes/sect x 78165360 sectors
wd0: 32-bit data port
wd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 5 (Ultra/100)
wd0(piixide0:0:0): using PIO mode 4, Ultra-DMA mode 5 (Ultra/100) (using DMA data transfers)
atapibus0 at atabus1: 2 targets
wd1 at atabus1 drive 0: <WDC WD400BB-00FRA0>
wd1: drive supports 16-sector PIO transfers, LBA48 addressing
wd1: 38166 MB, 77545 cyl, 16 head, 63 sec, 512 bytes/sect x 78165360 sectors
wd1: 32-bit data port
wd1: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 5 (Ultra/100)
wd1(piixide0:1:0): using PIO mode 4, Ultra-DMA mode 5 (Ultra/100) (using DMA data transfers)

When I reboot I get:
UP kernel: flush cache command didn't complete
MP kernel: panics with polled command aborted or something.

According to ATA application notes, if the controller/drive combination
support flushcache_ext and lba48, then flushcache_ext should be used instead
of flushcache in all cases.

>How-To-Repeat:
	setup raidframe on the above disks, and reboot while parity is
	rebuilding
>Fix:

Index: atareg.h
===================================================================
RCS file: /cvsroot/src/sys/dev/ata/atareg.h,v
retrieving revision 1.17
diff -u -u -r1.17 atareg.h
--- atareg.h	14 Mar 2004 20:11:24 -0000	1.17
+++ atareg.h	28 Apr 2004 14:27:43 -0000
@@ -120,6 +120,7 @@
 #define	WDCC_UNLOCK		0xdf	/* unlock drawer */

 #define	WDCC_FLUSHCACHE		0xe7	/* Flush cache */
+#define	WDCC_FLUSHCACHE_EXT	0xea	/* Flush cache ext */
 #define	WDCC_IDENTIFY		0xec	/* read parameters from controller */
 #define	SET_FEATURES		0xef	/* set features */

Index: wd.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ata/wd.c,v
retrieving revision 1.274
diff -u -u -r1.274 wd.c
--- wd.c	28 Feb 2004 06:28:47 -0000	1.274
+++ wd.c	28 Apr 2004 14:27:44 -0000
@@ -327,8 +327,11 @@
 	    wd->sc_dev.dv_xname, wd->sc_multi);

 	/* 48-bit LBA addressing */
-	if ((wd->sc_params.atap_cmd2_en & ATA_CMD2_LBA48) != 0)
+	if ((wd->sc_params.atap_cmd2_en & ATA_CMD2_LBA48) != 0) {
 		wd->sc_flags |= WDF_LBA48;
+		if ((wd->sc_params.atap_cmd2_en & ATA_CMD2_FCE) != 0)
+			wd->sc_flags |= WDF_FCE;
+	}

 	/* Prior to ATA-4, LBA was optional. */
 	if ((wd->sc_params.atap_capabilities1 & WDC_CAP_LBA) != 0)
@@ -1651,7 +1654,8 @@
 	if (wd->drvp->ata_vers < 4) /* WDCC_FLUSHCACHE is here since ATA-4 */
 		return;
 	memset(&wdc_c, 0, sizeof(struct wdc_command));
-	wdc_c.r_command = WDCC_FLUSHCACHE;
+	wdc_c.r_command = (wd->sc_flags & WDF_FCE) ?
+	    WDCC_FLUSHCACHE_EXT : WDCC_FLUSHCACHE;
 	wdc_c.r_st_bmask = WDCS_DRDY;
 	wdc_c.r_st_pmask = WDCS_DRDY;
 	wdc_c.flags = flags;
Index: wdvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/ata/wdvar.h,v
retrieving revision 1.26
diff -u -u -r1.26 wdvar.h
--- wdvar.h	14 Dec 2003 05:38:20 -0000	1.26
+++ wdvar.h	28 Apr 2004 14:27:44 -0000
@@ -59,6 +59,7 @@
 #define WDF_LBA		0x040 /* using LBA mode */
 #define WDF_KLABEL	0x080 /* retain label after 'full' close */
 #define WDF_LBA48	0x100 /* using 48-bit LBA mode */
+#define WDF_FCE		0x200 /* using flush cache ext */
 	u_int64_t sc_capacity;
 	int cyl; /* actual drive parameters */
 	int heads;
>Release-Note:
>Audit-Trail:

From: Alexander Yurchenko <grange@rt.mipt.ru>
To: christos@zoulas.com
Cc: gnats-bugs@gnats.NetBSD.org
Subject: Re: kern/25366: wdc does not know about flushcache_ext
Date: Wed, 28 Apr 2004 21:35:24 +0400

 On Wed, Apr 28, 2004 at 10:40:07AM -0400, christos@zoulas.com wrote:
 > --- wd.c	28 Feb 2004 06:28:47 -0000	1.274
 > +++ wd.c	28 Apr 2004 14:27:44 -0000
 > @@ -327,8 +327,11 @@
 >  	    wd->sc_dev.dv_xname, wd->sc_multi);
 >  
 >  	/* 48-bit LBA addressing */
 > -	if ((wd->sc_params.atap_cmd2_en & ATA_CMD2_LBA48) != 0)
 > +	if ((wd->sc_params.atap_cmd2_en & ATA_CMD2_LBA48) != 0) {
 >  		wd->sc_flags |= WDF_LBA48;
 > +		if ((wd->sc_params.atap_cmd2_en & ATA_CMD2_FCE) != 0)
 > +			wd->sc_flags |= WDF_FCE;
 > +	}

 Note, that WDC_CMD2_FC is not checked before executing FLUSH CACHE. Are
 you sure you want to check for ATA_CMD2_FCE? ATA/ATAPI-6 spec says that
 FLUSH CACHE EXT is mandatory for all devices implementing LBA48, so may
 be WDF_LBA48 whould be enough.


 -- 
    Alexander Yurchenko (aka grange)

From: christos@zoulas.com (Christos Zoulas)
To: Alexander Yurchenko <grange@rt.mipt.ru>
Cc: gnats-bugs@gnats.NetBSD.org
Subject: Re: kern/25366: wdc does not know about flushcache_ext
Date: Wed, 28 Apr 2004 13:59:08 -0400

 On Apr 28,  9:35pm, grange@rt.mipt.ru (Alexander Yurchenko) wrote:
 -- Subject: Re: kern/25366: wdc does not know about flushcache_ext

 | On Wed, Apr 28, 2004 at 10:40:07AM -0400, christos@zoulas.com wrote:
 | > --- wd.c	28 Feb 2004 06:28:47 -0000	1.274
 | > +++ wd.c	28 Apr 2004 14:27:44 -0000
 | > @@ -327,8 +327,11 @@
 | >  	    wd->sc_dev.dv_xname, wd->sc_multi);
 | >  
 | >  	/* 48-bit LBA addressing */
 | > -	if ((wd->sc_params.atap_cmd2_en & ATA_CMD2_LBA48) != 0)
 | > +	if ((wd->sc_params.atap_cmd2_en & ATA_CMD2_LBA48) != 0) {
 | >  		wd->sc_flags |= WDF_LBA48;
 | > +		if ((wd->sc_params.atap_cmd2_en & ATA_CMD2_FCE) != 0)
 | > +			wd->sc_flags |= WDF_FCE;
 | > +	}
 | 
 | Note, that WDC_CMD2_FC is not checked before executing FLUSH CACHE. Are
 | you sure you want to check for ATA_CMD2_FCE? ATA/ATAPI-6 spec says that
 | FLUSH CACHE EXT is mandatory for all devices implementing LBA48, so may
 | be WDF_LBA48 whould be enough.

 I don't know, what is the point of having the ATA_CMD2_FCE bit then if
 it is always going to be set if ATA_CMD2_LBA48 is set?

 christos

From: Alexander Yurchenko <grange@rt.mipt.ru>
To: Christos Zoulas <christos@zoulas.com>
Cc: gnats-bugs@gnats.NetBSD.org
Subject: Re: kern/25366: wdc does not know about flushcache_ext
Date: Thu, 29 Apr 2004 12:27:10 +0400

 On Wed, Apr 28, 2004 at 01:59:08PM -0400, Christos Zoulas wrote:
 > On Apr 28,  9:35pm, grange@rt.mipt.ru (Alexander Yurchenko) wrote:
 > -- Subject: Re: kern/25366: wdc does not know about flushcache_ext
 > 
 > | On Wed, Apr 28, 2004 at 10:40:07AM -0400, christos@zoulas.com wrote:
 > | > --- wd.c	28 Feb 2004 06:28:47 -0000	1.274
 > | > +++ wd.c	28 Apr 2004 14:27:44 -0000
 > | > @@ -327,8 +327,11 @@
 > | >  	    wd->sc_dev.dv_xname, wd->sc_multi);
 > | >  
 > | >  	/* 48-bit LBA addressing */
 > | > -	if ((wd->sc_params.atap_cmd2_en & ATA_CMD2_LBA48) != 0)
 > | > +	if ((wd->sc_params.atap_cmd2_en & ATA_CMD2_LBA48) != 0) {
 > | >  		wd->sc_flags |= WDF_LBA48;
 > | > +		if ((wd->sc_params.atap_cmd2_en & ATA_CMD2_FCE) != 0)
 > | > +			wd->sc_flags |= WDF_FCE;
 > | > +	}
 > | 
 > | Note, that WDC_CMD2_FC is not checked before executing FLUSH CACHE. Are
 > | you sure you want to check for ATA_CMD2_FCE? ATA/ATAPI-6 spec says that
 > | FLUSH CACHE EXT is mandatory for all devices implementing LBA48, so may
 > | be WDF_LBA48 whould be enough.
 > 
 > I don't know, what is the point of having the ATA_CMD2_FCE bit then if
 > it is always going to be set if ATA_CMD2_LBA48 is set?

 You just can have a drive that implements LBA48, claims that doesn't
 support FCE and finally requires FCE instead of FC. I'd suggest only
 check for LBA48. Strict checks never worked in ATA world unfortunately.

 > 
 > christos

 -- 
    Alexander Yurchenko (aka grange)

From: christos@zoulas.com (Christos Zoulas)
To: Alexander Yurchenko <grange@rt.mipt.ru>
Cc: gnats-bugs@gnats.NetBSD.org
Subject: Re: kern/25366: wdc does not know about flushcache_ext
Date: Thu, 29 Apr 2004 08:12:40 -0400

 On Apr 29, 12:27pm, grange@rt.mipt.ru (Alexander Yurchenko) wrote:
 -- Subject: Re: kern/25366: wdc does not know about flushcache_ext

 | You just can have a drive that implements LBA48, claims that doesn't
 | support FCE and finally requires FCE instead of FC. I'd suggest only
 | check for LBA48. Strict checks never worked in ATA world unfortunately.

 Well, it is easy to change if we ever see such a drive. Have you seen
 one?

 christos

From: Manuel Bouyer <bouyer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/25366 CVS commit: src/sys/dev/ata
Date: Mon,  3 May 2004 20:11:40 +0000 (UTC)

 Module Name:	src
 Committed By:	bouyer
 Date:		Mon May  3 20:11:40 UTC 2004

 Modified Files:
 	src/sys/dev/ata: atareg.h wd.c

 Log Message:
 When using LBA48, use Flush cache extended command if supported.
 From Christos Zoulas in PR 25366, with minor adjustements from me.


 To generate a diff of this commit:
 cvs rdiff -r1.17 -r1.18 src/sys/dev/ata/atareg.h
 cvs rdiff -r1.274 -r1.275 src/sys/dev/ata/wd.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback 
State-Changed-By: bouyer 
State-Changed-When: Mon May 3 20:12:17 UTC 2004 
State-Changed-Why:  
Hi, 
can you try the code I commited to current ? You need wd.c  1.275 and 
atareg.h 1.18. 
Thanks ! 
Responsible-Changed-From-To: kern-bug-people->bouyer 
Responsible-Changed-By: bouyer 
Responsible-Changed-When: Mon May 3 20:13:15 UTC 2004 
Responsible-Changed-Why:  
I commited a modified version of the patch. 

From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@gnats.netbsd.org, bouyer@netbsd.org, kern-bug-people@netbsd.org
Cc:  
Subject: Re: kern/25366
Date: Mon, 3 May 2004 16:40:47 -0400

 On May 3,  8:13pm, bouyer@netbsd.org (bouyer@netbsd.org) wrote:
 -- Subject: Re: kern/25366

 | Synopsis: wdc does not know about flushcache_ext
 | 
 | State-Changed-From-To: open->feedback
 | State-Changed-By: bouyer
 | State-Changed-When: Mon May 3 20:12:17 UTC 2004
 | State-Changed-Why: 
 | Hi,
 | can you try the code I commited to current ? You need wd.c  1.275 and
 | atareg.h 1.18.

 Close it, I looked at the code and it should work fine. We should pull this
 up to 2.0 because without it, you cannot reboot cleanly.

 thanks,

 christos

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: Christos Zoulas <christos@zoulas.com>
Cc: gnats-bugs@gnats.netbsd.org, kern-bug-people@netbsd.org
Subject: Re: kern/25366
Date: Mon, 3 May 2004 23:40:02 +0200

 On Mon, May 03, 2004 at 04:40:47PM -0400, Christos Zoulas wrote:
 > Close it, I looked at the code and it should work fine.

 Can you easily test on real hardware ?

 > We should pull this
 > up to 2.0 because without it, you cannot reboot cleanly.

 Sure, I was waiting for your comments.
 I'll submit a pullup request tomorow

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

From: christos@zoulas.com (Christos Zoulas)
To: Manuel Bouyer <bouyer@antioche.eu.org>
Cc: gnats-bugs@gnats.netbsd.org, kern-bug-people@netbsd.org
Subject: Re: kern/25366
Date: Mon, 3 May 2004 19:29:58 -0400

 On May 3, 11:40pm, bouyer@antioche.eu.org (Manuel Bouyer) wrote:
 -- Subject: Re: kern/25366

 | On Mon, May 03, 2004 at 04:40:47PM -0400, Christos Zoulas wrote:
 | > Close it, I looked at the code and it should work fine.
 | 
 | Can you easily test on real hardware ?

 Well, I really don't want to bring down my mail server during the week.
 But I am pretty sure it will work. I did test my changes. How often is
 flush called anyway?

 | Sure, I was waiting for your comments.
 | I'll submit a pullup request tomorow

 Thanks,

 christos

From: Manuel Bouyer <bouyer@antioche.lip6.fr>
To: Christos Zoulas <christos@zoulas.com>
Cc: gnats-bugs@gnats.NetBSD.org, kern-bug-people@NetBSD.org
Subject: Re: kern/25366
Date: Tue, 4 May 2004 09:57:45 +0200

 On Mon, May 03, 2004 at 07:29:58PM -0400, Christos Zoulas wrote:
 > On May 3, 11:40pm, bouyer@antioche.eu.org (Manuel Bouyer) wrote:
 > -- Subject: Re: kern/25366
 > 
 > | On Mon, May 03, 2004 at 04:40:47PM -0400, Christos Zoulas wrote:
 > | > Close it, I looked at the code and it should work fine.
 > | 
 > | Can you easily test on real hardware ?
 > 
 > Well, I really don't want to bring down my mail server during the week.

 I can understand that :)

 > But I am pretty sure it will work. I did test my changes. How often is
 > flush called anyway?

 At shutdown, and on the last device close.

 --
 Manuel Bouyer, LIP6, Universite Paris VI.           Manuel.Bouyer@lip6.fr
      NetBSD: 24 ans d'experience feront toujours la difference
 --

From: christos@zoulas.com (Christos Zoulas)
To: Manuel Bouyer <bouyer@antioche.lip6.fr>
Cc: gnats-bugs@gnats.NetBSD.org, kern-bug-people@NetBSD.org
Subject: Re: kern/25366
Date: Tue, 4 May 2004 09:53:34 -0400

 On May 4,  9:57am, bouyer@antioche.lip6.fr (Manuel Bouyer) wrote:
 -- Subject: Re: kern/25366

 | > flush called anyway?
 | 
 | At shutdown, and on the last device close.

 Ok, thanks. I will try it over the weekend then.

 christos
State-Changed-From-To: feedback->closed 
State-Changed-By: bouyer 
State-Changed-When: Tue May 4 21:36:55 UTC 2004 
State-Changed-Why:  
Christos can't test right now, but think it's close enouth from his patch 
to not cause problems, and asked me to close the PR. 

From: Julian Coleman <jdc@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/25366 CVS commit: [netbsd-2-0] src/sys/dev/ata
Date: Sun,  9 May 2004 08:18:40 +0000 (UTC)

 Module Name:	src
 Committed By:	jdc
 Date:		Sun May  9 08:18:40 UTC 2004

 Modified Files:
 	src/sys/dev/ata [netbsd-2-0]: atareg.h

 Log Message:
 Pull up revision 1.18 (requested by bouyer in ticket #262)

 When using LBA48, use Flush cache extended command if supported.
 From Christos Zoulas in PR 25366, with minor adjustements from me.


 To generate a diff of this commit:
 cvs rdiff -r1.17 -r1.17.2.1 src/sys/dev/ata/atareg.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


From: Julian Coleman <jdc@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/25366 CVS commit: [netbsd-2-0] src/sys/dev/ata
Date: Sun,  9 May 2004 08:19:18 +0000 (UTC)

 Module Name:	src
 Committed By:	jdc
 Date:		Sun May  9 08:19:18 UTC 2004

 Modified Files:
 	src/sys/dev/ata [netbsd-2-0]: wd.c

 Log Message:
 Pull up revision 1.275 (requested by bouyer in ticket #262)

 When using LBA48, use Flush cache extended command if supported.
 From Christos Zoulas in PR 25366, with minor adjustements from me.


 To generate a diff of this commit:
 cvs rdiff -r1.274 -r1.274.2.1 src/sys/dev/ata/wd.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


From: Julian Coleman <jdc@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/25366 CVS commit: [netbsd-1-6] src/sys/dev/ata
Date: Fri, 14 May 2004 06:07:35 +0000 (UTC)

 Module Name:	src
 Committed By:	jdc
 Date:		Fri May 14 06:07:35 UTC 2004

 Modified Files:
 	src/sys/dev/ata [netbsd-1-6]: wd.c

 Log Message:
 Pull up revision 1.275 via patch (requested by bouyer in ticket #1691)

 When using LBA48, use Flush cache extended command if supported.
 From Christos Zoulas in PR 25366, with minor adjustements from me.


 To generate a diff of this commit:
 cvs rdiff -r1.220.10.6 -r1.220.10.7 src/sys/dev/ata/wd.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


From: Julian Coleman <jdc@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/25366 CVS commit: [netbsd-1-6] src/sys/dev/ic
Date: Fri, 14 May 2004 06:09:36 +0000 (UTC)

 Module Name:	src
 Committed By:	jdc
 Date:		Fri May 14 06:09:36 UTC 2004

 Modified Files:
 	src/sys/dev/ic [netbsd-1-6]: wdcreg.h

 Log Message:
 Apply patch from revision 1.18 of sys/dev/ata/atareg.h
 (requested by bouyer in ticket #1691)

 When using LBA48, use Flush cache extended command if supported.
 From Christos Zoulas in PR 25366, with minor adjustements from me.


 To generate a diff of this commit:
 cvs rdiff -r1.25.4.1 -r1.25.4.2 src/sys/dev/ic/wdcreg.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.