Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add a new config_detach() flag, DETACH_POWEROFF, which i...



details:   https://anonhg.NetBSD.org/src/rev/ed3c234af9bb
branches:  trunk
changeset: 816128:ed3c234af9bb
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sun Jun 19 09:35:06 2016 +0000

description:
Add a new config_detach() flag, DETACH_POWEROFF, which is set when
detaching devices at shutdown time with RB_POWERDOWN.
When detaching wd(4), put the drive in standby before detach
for DETACH_POWEROFF.
Fix PR kern/51252

diffstat:

 sys/dev/ata/wd.c         |   6 ++++--
 sys/kern/subr_autoconf.c |  12 +++++++++---
 sys/sys/device.h         |   3 ++-
 3 files changed, 15 insertions(+), 6 deletions(-)

diffs (84 lines):

diff -r 909e72437687 -r ed3c234af9bb sys/dev/ata/wd.c
--- a/sys/dev/ata/wd.c  Sun Jun 19 09:23:16 2016 +0000
+++ b/sys/dev/ata/wd.c  Sun Jun 19 09:35:06 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wd.c,v 1.420 2015/04/26 15:15:20 mlelstv Exp $ */
+/*     $NetBSD: wd.c,v 1.421 2016/06/19 09:35:06 bouyer 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.420 2015/04/26 15:15:20 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.421 2016/06/19 09:35:06 bouyer Exp $");
 
 #include "opt_ata.h"
 
@@ -467,6 +467,8 @@
 
        bufq_free(sc->sc_q);
        sc->atabus->ata_killpending(sc->drvp);
+       if (flags & DETACH_POWEROFF)
+               wd_standby(sc, AT_POLL);
 
        splx(s);
 
diff -r 909e72437687 -r ed3c234af9bb sys/kern/subr_autoconf.c
--- a/sys/kern/subr_autoconf.c  Sun Jun 19 09:23:16 2016 +0000
+++ b/sys/kern/subr_autoconf.c  Sun Jun 19 09:35:06 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.241 2016/03/28 09:50:40 skrll Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.242 2016/06/19 09:35:06 bouyer Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.241 2016/03/28 09:50:40 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.242 2016/06/19 09:35:06 bouyer Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1876,14 +1876,20 @@
        static struct shutdown_state s;
        device_t curdev;
        bool progress = false;
+       int flags;
 
        if ((how & (RB_NOSYNC|RB_DUMP)) != 0)
                return false;
 
+       if ((how & RB_POWERDOWN) == RB_POWERDOWN)
+               flags = DETACH_SHUTDOWN | DETACH_POWEROFF;
+       else
+               flags = DETACH_SHUTDOWN;
+
        for (curdev = shutdown_first(&s); curdev != NULL;
             curdev = shutdown_next(&s)) {
                aprint_debug(" detaching %s, ", device_xname(curdev));
-               if (config_detach(curdev, DETACH_SHUTDOWN) == 0) {
+               if (config_detach(curdev, flags) == 0) {
                        progress = true;
                        aprint_debug("success.");
                } else
diff -r 909e72437687 -r ed3c234af9bb sys/sys/device.h
--- a/sys/sys/device.h  Sun Jun 19 09:23:16 2016 +0000
+++ b/sys/sys/device.h  Sun Jun 19 09:35:06 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: device.h,v 1.148 2015/12/07 11:38:46 pgoyette Exp $ */
+/* $NetBSD: device.h,v 1.149 2016/06/19 09:35:06 bouyer Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -349,6 +349,7 @@
 #define        DETACH_FORCE    0x01            /* force detachment; hardware gone */
 #define        DETACH_QUIET    0x02            /* don't print a notice */
 #define        DETACH_SHUTDOWN 0x04            /* detach because of system shutdown */
+#define        DETACH_POWEROFF 0x08            /* going to power off; power down devices */
 
 struct cfdriver {
        LIST_ENTRY(cfdriver) cd_list;   /* link on allcfdrivers */



Home | Main Index | Thread Index | Old Index