Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Replace shutdownhook_establish(9) with pmf_device...



details:   https://anonhg.NetBSD.org/src/rev/254676dff8d6
branches:  trunk
changeset: 747106:254676dff8d6
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Wed Sep 02 16:38:17 2009 +0000

description:
Replace shutdownhook_establish(9) with pmf_device_register1(9).
Untested, but mostly copied from ahc(4).

This may fix reboot failure problem on ahd(4) after pmf(9) merge:
http://mail-index.NetBSD.org/current-users/2007/12/10/0008.html
which was also seen on old ahc(4):
http://mail-index.NetBSD.org/port-sgimips/2008/01/05/msg000003.html

diffstat:

 sys/dev/ic/aic79xx.c     |   7 +----
 sys/dev/ic/aic79xx_osm.c |  50 +++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 49 insertions(+), 8 deletions(-)

diffs (118 lines):

diff -r 12803fb33754 -r 254676dff8d6 sys/dev/ic/aic79xx.c
--- a/sys/dev/ic/aic79xx.c      Wed Sep 02 15:45:10 2009 +0000
+++ b/sys/dev/ic/aic79xx.c      Wed Sep 02 16:38:17 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aic79xx.c,v 1.41 2009/03/18 16:00:18 cegger Exp $      */
+/*     $NetBSD: aic79xx.c,v 1.42 2009/09/02 16:38:17 tsutsui Exp $     */
 
 /*
  * Core routines and tables shareable across OS platforms.
@@ -49,7 +49,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aic79xx.c,v 1.41 2009/03/18 16:00:18 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aic79xx.c,v 1.42 2009/09/02 16:38:17 tsutsui Exp $");
 
 #include <dev/ic/aic79xx_osm.h>
 #include <dev/ic/aic79xx_inline.h>
@@ -6177,9 +6177,6 @@
        ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US,
                        ahd_stat_timer, ahd);
 
-       /* We have to wait until after any system dumps... */
-       ahd->shutdown_hook = shutdownhook_establish(ahd_shutdown, ahd);
-
        return (0);
 }
 
diff -r 12803fb33754 -r 254676dff8d6 sys/dev/ic/aic79xx_osm.c
--- a/sys/dev/ic/aic79xx_osm.c  Wed Sep 02 15:45:10 2009 +0000
+++ b/sys/dev/ic/aic79xx_osm.c  Wed Sep 02 16:38:17 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aic79xx_osm.c,v 1.21 2009/05/12 14:25:17 cegger Exp $  */
+/*     $NetBSD: aic79xx_osm.c,v 1.22 2009/09/02 16:38:17 tsutsui Exp $ */
 
 /*
  * Bus independent NetBSD shim for the aic7xxx based adaptec SCSI controllers
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aic79xx_osm.c,v 1.21 2009/05/12 14:25:17 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aic79xx_osm.c,v 1.22 2009/09/02 16:38:17 tsutsui Exp $");
 
 #include <dev/ic/aic79xx_osm.h>
 #include <dev/ic/aic79xx_inline.h>
@@ -64,6 +64,10 @@
 static void    ahd_set_recoveryscb(struct ahd_softc *ahd, struct scb *scb);
 #endif
 
+static bool    ahd_pmf_suspend(device_t PMF_FN_PROTO);
+static bool    ahd_pmf_resume(device_t PMF_FN_PROTO);
+static bool    ahd_pmf_shutdown(device_t, int);
+
 /*
  * Attach all the sub-devices we can find
  */
@@ -103,11 +107,51 @@
        if (ahd->flags & AHD_RESET_BUS_A)
                ahd_reset_channel(ahd, 'A', TRUE);
 
+       if (!pmf_device_register1(&ahd->sc_dev,
+           ahd_pmf_suspend, ahd_pmf_resume, ahd_pmf_shutdown))
+               aprint_error_dev(&ahd->sc_dev,
+                   "couldn't establish power handler\n");
+
         ahd_unlock(ahd, &s);
 
        return (1);
 }
 
+static bool
+ahd_pmf_suspend(device_t dev PMF_FN_ARGS)
+{
+       struct ahd_softc *sc = device_private(dev);
+#if 0
+       return (ahd_suspend(sc) == 0);
+#else
+       ahd_shutdown(sc);
+       return true;
+#endif
+}
+
+static bool
+ahd_pmf_resume(device_t dev PMF_FN_ARGS)
+{
+#if 0
+       struct ahd_softc *sc = device_private(dev);
+
+       return (ahd_resume(sc) == 0);
+#else
+       return true;
+#endif
+}
+
+static bool
+ahd_pmf_shutdown(device_t dev, int howto)
+{
+       struct ahd_softc *sc = device_private(dev);
+
+       /* Disable all interrupt sources by resetting the controller */
+       ahd_shutdown(sc);
+
+       return true;
+}
+
 static int
 ahd_ioctl(struct scsipi_channel *channel, u_long cmd,
          void *addr, int flag, struct proc *p)
@@ -766,7 +810,7 @@
        if (ahd->sc_child != NULL)
                rv = config_detach((void *)ahd->sc_child, flags);
 
-       shutdownhook_disestablish(ahd->shutdown_hook);
+       pmf_device_deregister(&ahd->sc_dev);
 
        ahd_free(ahd);
 



Home | Main Index | Thread Index | Old Index