Subject: Re: disks write-back cache
To: Sean Davis <dive@endersgame.net>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-kern
Date: 04/27/2003 16:34:03
--Kj7319i9nmIyA2yE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Sun, Apr 27, 2003 at 10:12:46AM -0400, Sean Davis wrote:
> > dkctl wd0 setcache none will work.
> No, it won't...
> eros# dkctl wd0 setcache none
> dkctl: /dev/rwd0d: setcache: Input/output error
> 
> in syslog:
> Apr 27 10:08:57 eros /netbsd: pciide1:0:0: lost interrupt
> Apr 27 10:08:58 eros /netbsd:   type: ata tc_bcount: 0 tc_skip: 0
> Apr 27 10:08:58 eros /netbsd: wd0: wd_setcache command error 0x128
> Apr 27 10:08:58 eros /netbsd: wd0e: DMA error writing fsbn 2691648 of
> 2691648-2691679 (wd0 bn 6885954; cn 6831 tn 4 sn 54), retrying
> Apr 27 10:08:58 eros /netbsd: wd0: soft error (corrected)

Ops, I forgot to initialise the timeout value. It uses 0 as timeout, wich
probably explain the behavior tou see here.
Please try wd.c 1.250 (see attached patch)
I also changed the retrictions on cache ops, the acceptable values are
now 'r' and 'rw' instead of 'w' and 'none'

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

--Kj7319i9nmIyA2yE
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.248
diff -u -r1.248 wd.c
--- wd.c	2003/04/26 09:54:15	1.248
+++ wd.c	2003/04/27 14:33:41
@@ -1,4 +1,4 @@
-/*	$NetBSD: wd.c,v 1.248 2003/04/26 09:54:15 bouyer Exp $ */
+/*	$NetBSD: wd.c,v 1.250 2003/04/27 14:33:20 bouyer Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.248 2003/04/26 09:54:15 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.250 2003/04/27 14:33:20 bouyer Exp $");
 
 #ifndef WDCDEBUG
 #define WDCDEBUG
@@ -1708,13 +1708,15 @@
 	    (params.atap_cmd_set1 & WDC_CMD1_CACHE) == 0)
 		return EOPNOTSUPP;
 
-	if (bits & ~DKCACHE_WRITE)
+	if ((bits & DKCACHE_READ) == 0 ||
+	    (bits & DKCACHE_SAVE) != 0)
 		return EOPNOTSUPP;
 
 	memset(&wdc_c, 0, sizeof(struct wdc_command));
 	wdc_c.r_command = SET_FEATURES;
 	wdc_c.r_st_bmask = 0;
 	wdc_c.r_st_pmask = 0;
+	wdc_c.timeout = 30000; /* 30s timeout */
 	wdc_c.flags = AT_WAIT;
 	if (bits & DKCACHE_WRITE)
 		wdc_c.r_precomp = WDSF_WRITE_CACHE_EN;

--Kj7319i9nmIyA2yE--