diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2012-10-08 21:47:52 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2012-10-08 21:47:52 +0000 |
commit | 4a7a1f17c7d6f8e79f29d4fde2ba5faf09b7f5a8 (patch) | |
tree | fdc5670bf4d0a8cd810fe846698cb565f1f51cb9 /sys/scsi | |
parent | c7f240fd53223122e6fe8cee52bb76b460263763 (diff) |
Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin
Diffstat (limited to 'sys/scsi')
-rw-r--r-- | sys/scsi/scsiconf.c | 3 | ||||
-rw-r--r-- | sys/scsi/sd.c | 52 | ||||
-rw-r--r-- | sys/scsi/sdvar.h | 3 |
3 files changed, 9 insertions, 49 deletions
diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c index 7ab9a02d207..c503a5a10ef 100644 --- a/sys/scsi/scsiconf.c +++ b/sys/scsi/scsiconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.c,v 1.182 2011/09/22 21:36:00 jsing Exp $ */ +/* $OpenBSD: scsiconf.c,v 1.183 2012/10/08 21:47:51 deraadt Exp $ */ /* $NetBSD: scsiconf.c,v 1.57 1996/05/02 01:09:01 neil Exp $ */ /* @@ -251,6 +251,7 @@ scsi_activate_lun(struct scsibus_softc *sc, int target, int lun, int act) case DVACT_QUIESCE: case DVACT_SUSPEND: case DVACT_RESUME: + case DVACT_POWERDOWN: config_suspend(dev, act); break; case DVACT_DEACTIVATE: diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index 0cb8b51a30a..3b3aeeab7aa 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd.c,v 1.242 2012/07/09 12:58:01 krw Exp $ */ +/* $OpenBSD: sd.c,v 1.243 2012/10/08 21:47:51 deraadt Exp $ */ /* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */ /*- @@ -87,7 +87,6 @@ int sddetach(struct device *, int); void sdminphys(struct buf *); int sdgetdisklabel(dev_t, struct sd_softc *, struct disklabel *, int); void sdstart(struct scsi_xfer *); -void sd_shutdown(void *); int sd_interpret_sense(struct scsi_xfer *); int sd_read_cap_10(struct sd_softc *, int); int sd_read_cap_16(struct sd_softc *, int); @@ -260,19 +259,6 @@ sdattach(struct device *parent, struct device *self, void *aux) sd_ioctl_cache(sc, DIOCSCACHE, &dkc); } - /* - * Establish a shutdown hook so that we can ensure that - * our data has actually made it onto the platter at - * shutdown time. Note that this relies on the fact - * that the shutdown hook code puts us at the head of - * the list (thus guaranteeing that our hook runs before - * our ancestors'). - */ - if ((sc->sc_sdhook = - shutdownhook_establish(sd_shutdown, sc)) == NULL) - printf("%s: WARNING: unable to establish shutdown hook\n", - sc->sc_dev.dv_xname); - /* Attach disk. */ disk_attach(&sc->sc_dev, &sc->sc_dk); } @@ -285,6 +271,8 @@ sdactivate(struct device *self, int act) switch (act) { case DVACT_SUSPEND: + break; + case DVACT_POWERDOWN: /* * Stop the disk. Stopping the disk should flush the * cache, but we are paranoid so we flush the cache @@ -292,8 +280,9 @@ sdactivate(struct device *self, int act) */ if ((sc->flags & SDF_DIRTY) != 0) sd_flush(sc, SCSI_AUTOCONF); - scsi_start(sc->sc_link, SSS_STOP, - SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_AUTOCONF); + if (boothowto & RB_POWERDOWN) + scsi_start(sc->sc_link, SSS_STOP, + SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_AUTOCONF); break; case DVACT_RESUME: scsi_start(sc->sc_link, SSS_START, @@ -316,10 +305,6 @@ sddetach(struct device *self, int flags) disk_gone(sdopen, self->dv_unit); - /* Get rid of the shutdown hook. */ - if (sc->sc_sdhook != NULL) - shutdownhook_disestablish(sc->sc_sdhook); - /* Detach disk. */ bufq_destroy(&sc->sc_bufq); disk_detach(&sc->sc_dk); @@ -1118,31 +1103,6 @@ sdgetdisklabel(dev_t dev, struct sd_softc *sc, struct disklabel *lp, return readdisklabel(DISKLABELDEV(dev), sdstrategy, lp, spoofonly); } - -void -sd_shutdown(void *arg) -{ - struct sd_softc *sc = (struct sd_softc *)arg; - - /* - * If the disk cache needs to be flushed, and the disk supports - * it, flush it. We're cold at this point, so we poll for - * completion. - */ - if ((sc->flags & SDF_DIRTY) != 0) - sd_flush(sc, SCSI_AUTOCONF); - if (boothowto & RB_POWERDOWN) - scsi_start(sc->sc_link, SSS_STOP, - SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_AUTOCONF); - - /* - * There should be no outstanding IO at this point, but lets stop - * it just in case. - */ - timeout_del(&sc->sc_timeout); - scsi_xsh_del(&sc->sc_xsh); -} - /* * Check Errors */ diff --git a/sys/scsi/sdvar.h b/sys/scsi/sdvar.h index f723a7e9729..4e2accdfde1 100644 --- a/sys/scsi/sdvar.h +++ b/sys/scsi/sdvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sdvar.h,v 1.38 2011/07/11 06:26:09 dlg Exp $ */ +/* $OpenBSD: sdvar.h,v 1.39 2012/10/08 21:47:51 deraadt Exp $ */ /* $NetBSD: sdvar.h,v 1.7 1998/08/17 00:49:03 mycroft Exp $ */ /*- @@ -69,7 +69,6 @@ struct sd_softc { u_int32_t unmap_sectors; /* maximum sectors/unmap */ u_int32_t unmap_descs; /* maximum descriptors/unmap */ } params; - void *sc_sdhook; /* our shutdown hook */ struct timeout sc_timeout; struct scsi_xshandler sc_xsh; |