Module Name:    src
Committed By:   dyoung
Date:           Fri Nov  5 15:49:37 UTC 2010

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

Log Message:
Mark a buffer with EIO in wdstrategy() if the device is not "enabled"
(more like "present"), not if it is merely asleep.

If the device is not awake, get out of wdstart() right away.

Brett Lymn and KAMADA Ken'ichi report that this stops the kernel from
crashing after a suspend/resume cycle.


To generate a diff of this commit:
cvs rdiff -u -r1.384 -r1.385 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.

Modified files:

Index: src/sys/dev/ata/wd.c
diff -u src/sys/dev/ata/wd.c:1.384 src/sys/dev/ata/wd.c:1.385
--- src/sys/dev/ata/wd.c:1.384	Wed Feb 24 22:37:57 2010
+++ src/sys/dev/ata/wd.c	Fri Nov  5 15:49:37 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: wd.c,v 1.384 2010/02/24 22:37:57 dyoung Exp $ */
+/*	$NetBSD: wd.c,v 1.385 2010/11/05 15:49:37 dyoung Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.384 2010/02/24 22:37:57 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.385 2010/11/05 15:49:37 dyoung Exp $");
 
 #include "opt_ata.h"
 
@@ -489,9 +489,10 @@
 	}
 
 	/* If device invalidated (e.g. media change, door open,
-	 * device suspension), then error.
+	 * device detachment), then error.
 	 */
-	if ((wd->sc_flags & WDF_LOADED) == 0 || !device_is_active(wd->sc_dev)) {
+	if ((wd->sc_flags & WDF_LOADED) == 0 ||
+	    !device_is_enabled(wd->sc_dev)) {
 		bp->b_error = EIO;
 		goto done;
 	}
@@ -573,6 +574,10 @@
 
 	ATADEBUG_PRINT(("wdstart %s\n", device_xname(wd->sc_dev)),
 	    DEBUG_XFERS);
+
+	if (!device_is_active(wd->sc_dev))
+		return;
+
 	while (wd->openings > 0) {
 
 		/* Is there a buf for us ? */

Reply via email to