Module Name: src Committed By: tsutsui Date: Wed Sep 2 16:38:17 UTC 2009
Modified Files: src/sys/dev/ic: aic79xx.c aic79xx_osm.c Log Message: 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 To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/dev/ic/aic79xx.c cvs rdiff -u -r1.21 -r1.22 src/sys/dev/ic/aic79xx_osm.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/ic/aic79xx.c diff -u src/sys/dev/ic/aic79xx.c:1.41 src/sys/dev/ic/aic79xx.c:1.42 --- src/sys/dev/ic/aic79xx.c:1.41 Wed Mar 18 16:00:18 2009 +++ src/sys/dev/ic/aic79xx.c Wed Sep 2 16:38:17 2009 @@ -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); } Index: src/sys/dev/ic/aic79xx_osm.c diff -u src/sys/dev/ic/aic79xx_osm.c:1.21 src/sys/dev/ic/aic79xx_osm.c:1.22 --- src/sys/dev/ic/aic79xx_osm.c:1.21 Tue May 12 14:25:17 2009 +++ src/sys/dev/ic/aic79xx_osm.c Wed Sep 2 16:38:17 2009 @@ -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);