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/sd.c | |
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/sd.c')
-rw-r--r-- | sys/scsi/sd.c | 52 |
1 files changed, 6 insertions, 46 deletions
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 */ |