diff options
author | 2012-10-08 21:47:45 +0000 | |
---|---|---|
committer | 2012-10-08 21:47:45 +0000 | |
commit | 1e4b376cc93a4177cfbe219c9001277edc699d6c (patch) | |
tree | 3a10a5466f2dc80a042bbdf6dadcba6f503a8dee /sys/dev/pci | |
parent | disk space is cheap but we still want to limit the default size of a body (diff) | |
download | wireguard-openbsd-1e4b376cc93a4177cfbe219c9001277edc699d6c.tar.xz wireguard-openbsd-1e4b376cc93a4177cfbe219c9001277edc699d6c.zip |
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/dev/pci')
-rw-r--r-- | sys/dev/pci/ahci.c | 5 | ||||
-rw-r--r-- | sys/dev/pci/ehci_pci.c | 33 | ||||
-rw-r--r-- | sys/dev/pci/glxpcib.c | 5 | ||||
-rw-r--r-- | sys/dev/pci/pccbb.c | 8 | ||||
-rw-r--r-- | sys/dev/pci/pci.c | 30 | ||||
-rw-r--r-- | sys/dev/pci/pciide.c | 5 | ||||
-rw-r--r-- | sys/dev/pci/ppb.c | 7 | ||||
-rw-r--r-- | sys/dev/pci/sdhc_pci.c | 7 | ||||
-rw-r--r-- | sys/dev/pci/sili_pci.c | 5 | ||||
-rw-r--r-- | sys/dev/pci/vga_pci.c | 5 |
10 files changed, 72 insertions, 38 deletions
diff --git a/sys/dev/pci/ahci.c b/sys/dev/pci/ahci.c index 7bda90956ce..edd071050df 100644 --- a/sys/dev/pci/ahci.c +++ b/sys/dev/pci/ahci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ahci.c,v 1.193 2012/08/11 13:52:27 jmatthew Exp $ */ +/* $OpenBSD: ahci.c,v 1.194 2012/10/08 21:47:50 deraadt Exp $ */ /* * Copyright (c) 2006 David Gwynne <dlg@openbsd.org> @@ -985,6 +985,9 @@ ahci_pci_activate(struct device *self, int act) break; case DVACT_SUSPEND: rv = config_activate_children(self, act); + break; + case DVACT_POWERDOWN: + rv = config_activate_children(self, act); for (i = 0; i < AHCI_MAX_PORTS; i++) { if (sc->sc_ports[i] != NULL) ahci_port_stop(sc->sc_ports[i], 1); diff --git a/sys/dev/pci/ehci_pci.c b/sys/dev/pci/ehci_pci.c index 6f46a987f55..11565cf2531 100644 --- a/sys/dev/pci/ehci_pci.c +++ b/sys/dev/pci/ehci_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ehci_pci.c,v 1.23 2011/04/26 00:37:34 deraadt Exp $ */ +/* $OpenBSD: ehci_pci.c,v 1.24 2012/10/08 21:47:50 deraadt Exp $ */ /* $NetBSD: ehci_pci.c,v 1.15 2004/04/23 21:13:06 itojun Exp $ */ /* @@ -75,9 +75,10 @@ int ehci_pci_match(struct device *, void *, void *); void ehci_pci_attach(struct device *, struct device *, void *); int ehci_pci_detach(struct device *, int); int ehci_pci_activate(struct device *, int); +#if 0 void ehci_pci_givecontroller(struct ehci_pci_softc *); +#endif void ehci_pci_takecontroller(struct ehci_pci_softc *, int); -void ehci_pci_shutdown(void *); struct cfattach ehci_pci_ca = { sizeof(struct ehci_pci_softc), ehci_pci_match, ehci_pci_attach, @@ -215,7 +216,6 @@ ehci_pci_attach(struct device *parent, struct device *self, void *aux) goto disestablish_ret; } - sc->sc.sc_shutdownhook = shutdownhook_establish(ehci_pci_shutdown, sc); splx(s); /* Attach usb device. */ @@ -235,15 +235,24 @@ int ehci_pci_activate(struct device *self, int act) { struct ehci_pci_softc *sc = (struct ehci_pci_softc *)self; + int rv; - /* On resume, take ownership from the BIOS */ switch (act) { case DVACT_RESUME: ehci_pci_takecontroller(sc, 1); break; } - return ehci_activate(self, act); + rv = ehci_activate(self, act); + +#if 0 + switch (act) { + case DVACT_POWERDOWN: + ehci_pci_givecontroller(sc); + break; + } +#endif + return (rv); } int @@ -266,7 +275,7 @@ ehci_pci_detach(struct device *self, int flags) return (0); } -#if 0 /* not used */ +#if 0 void ehci_pci_givecontroller(struct ehci_pci_softc *sc) { @@ -319,18 +328,6 @@ ehci_pci_takecontroller(struct ehci_pci_softc *sc, int silent) } } -void -ehci_pci_shutdown(void *v) -{ - struct ehci_pci_softc *sc = (struct ehci_pci_softc *)v; - - ehci_shutdown(&sc->sc); -#if 0 - /* best not to do this anymore; BIOS SMM spins? */ - ehci_pci_givecontroller(sc); -#endif -} - int ehci_sb700_match(struct pci_attach_args *pa) { diff --git a/sys/dev/pci/glxpcib.c b/sys/dev/pci/glxpcib.c index fa1ccaeb16e..30a4dcde277 100644 --- a/sys/dev/pci/glxpcib.c +++ b/sys/dev/pci/glxpcib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: glxpcib.c,v 1.5 2012/03/06 12:57:36 mikeb Exp $ */ +/* $OpenBSD: glxpcib.c,v 1.6 2012/10/08 21:47:50 deraadt Exp $ */ /* * Copyright (c) 2007 Marc Balmer <mbalmer@openbsd.org> @@ -426,6 +426,9 @@ glxpcib_activate(struct device *self, int act) #endif break; + case DVACT_POWERDOWN: + rv = config_activate_children(self, act); + break; case DVACT_RESUME: #ifndef SMALL_KERNEL if (sc->sc_wdog) diff --git a/sys/dev/pci/pccbb.c b/sys/dev/pci/pccbb.c index fd37b407280..e2d233d766e 100644 --- a/sys/dev/pci/pccbb.c +++ b/sys/dev/pci/pccbb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pccbb.c,v 1.87 2010/12/08 20:22:49 miod Exp $ */ +/* $OpenBSD: pccbb.c,v 1.88 2012/10/08 21:47:50 deraadt Exp $ */ /* $NetBSD: pccbb.c,v 1.96 2004/03/28 09:49:31 nakayama Exp $ */ /* @@ -457,8 +457,6 @@ pccbbattach(struct device *parent, struct device *self, void *aux) printf("\n"); - shutdownhook_establish(pccbb_shutdown, sc); - /* Disable legacy register mapping. */ pccbb_legacy_disable(sc); @@ -2841,6 +2839,10 @@ pccbbactivate(struct device *self, int act) sc->sc_iobase[1] = pci_conf_read(pc, tag, PCI_CB_IOBASE1); sc->sc_iolimit[1] = pci_conf_read(pc, tag, PCI_CB_IOLIMIT1); break; + case DVACT_POWERDOWN: + rv = config_activate_children(self, act); + pccbb_shutdown(self); + break; case DVACT_RESUME: /* Restore the registers saved above. */ pci_conf_write(pc, tag, PCI_BHLC_REG, sc->sc_bhlcr); diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index a19420b7d18..6bd03cb39dd 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci.c,v 1.96 2012/09/19 23:01:21 kettenis Exp $ */ +/* $OpenBSD: pci.c,v 1.97 2012/10/08 21:47:50 deraadt Exp $ */ /* $NetBSD: pci.c,v 1.31 1997/06/06 23:48:04 thorpej Exp $ */ /* @@ -51,6 +51,7 @@ void pciattach(struct device *, struct device *, void *); int pcidetach(struct device *, int); int pciactivate(struct device *, int); void pci_suspend(struct pci_softc *); +void pci_powerdown(struct pci_softc *); void pci_resume(struct pci_softc *); #define NMAPREG ((PCI_MAPREG_END - PCI_MAPREG_START) / \ @@ -215,6 +216,10 @@ pciactivate(struct device *self, int act) rv = config_activate_children(self, act); pci_suspend((struct pci_softc *)self); break; + case DVACT_POWERDOWN: + rv = config_activate_children(self, act); + pci_powerdown((struct pci_softc *)self); + break; case DVACT_RESUME: pci_resume((struct pci_softc *)self); rv = config_activate_children(self, act); @@ -266,6 +271,24 @@ pci_suspend(struct pci_softc *sc) } pd->pd_msi_mc = reg; } + } +} + +void +pci_powerdown(struct pci_softc *sc) +{ + struct pci_dev *pd; + pcireg_t bhlc; + + LIST_FOREACH(pd, &sc->sc_devs, pd_next) { + /* + * Only handle header type 0 here; PCI-PCI bridges and + * CardBus bridges need special handling, which will + * be done in their specific drivers. + */ + bhlc = pci_conf_read(sc->sc_pc, pd->pd_tag, PCI_BHLC_REG); + if (PCI_HDRTYPE_TYPE(bhlc) != 0) + continue; if (pci_dopm) { /* @@ -297,11 +320,10 @@ pci_resume(struct pci_softc *sc) if (PCI_HDRTYPE_TYPE(bhlc) != 0) continue; - if (pci_dopm) { - /* Restore power. */ + /* Restore power. */ + if (pci_dopm) pci_set_powerstate(sc->sc_pc, pd->pd_tag, pd->pd_pmcsr_state); - } /* Restore the registers saved above. */ for (i = 0; i < NMAPREG; i++) diff --git a/sys/dev/pci/pciide.c b/sys/dev/pci/pciide.c index 34976ae11a6..45f112c53ea 100644 --- a/sys/dev/pci/pciide.c +++ b/sys/dev/pci/pciide.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pciide.c,v 1.339 2012/04/22 14:22:28 miod Exp $ */ +/* $OpenBSD: pciide.c,v 1.340 2012/10/08 21:47:50 deraadt Exp $ */ /* $NetBSD: pciide.c,v 1.127 2001/08/03 01:31:08 tsutsui Exp $ */ /* @@ -1489,6 +1489,9 @@ pciide_activate(struct device *self, int act) sc->sc_tag, NFORCE_UDMATIM); } break; + case DVACT_POWERDOWN: + rv = config_activate_children(self, act); + break; case DVACT_RESUME: for (i = 0; i < nitems(sc->sc_save); i++) pci_conf_write(sc->sc_pc, sc->sc_tag, diff --git a/sys/dev/pci/ppb.c b/sys/dev/pci/ppb.c index 32dfce9523e..c9a7f9cca53 100644 --- a/sys/dev/pci/ppb.c +++ b/sys/dev/pci/ppb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ppb.c,v 1.54 2012/09/07 19:26:48 kettenis Exp $ */ +/* $OpenBSD: ppb.c,v 1.55 2012/10/08 21:47:50 deraadt Exp $ */ /* $NetBSD: ppb.c,v 1.16 1997/06/06 23:48:05 thorpej Exp $ */ /* @@ -389,7 +389,10 @@ ppbactivate(struct device *self, int act) } sc->sc_msi_mc = reg; } - + break; + case DVACT_POWERDOWN: + rv = config_activate_children(self, act); + if (pci_dopm) { /* * Place the bridge into the lowest possible diff --git a/sys/dev/pci/sdhc_pci.c b/sys/dev/pci/sdhc_pci.c index eac6107992a..5abe511d84e 100644 --- a/sys/dev/pci/sdhc_pci.c +++ b/sys/dev/pci/sdhc_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sdhc_pci.c,v 1.12 2011/12/23 21:58:47 kettenis Exp $ */ +/* $OpenBSD: sdhc_pci.c,v 1.13 2012/10/08 21:47:50 deraadt Exp $ */ /* * Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org> @@ -172,11 +172,6 @@ sdhc_pci_attach(struct device *parent, struct device *self, void *aux) printf("%s at 0x%x: can't initialize host\n", sc->sc.sc_dev.dv_xname, reg); } - - /* - * Establish shutdown hooks. - */ - (void)shutdownhook_establish(sdhc_shutdown, &sc->sc); } void diff --git a/sys/dev/pci/sili_pci.c b/sys/dev/pci/sili_pci.c index 2be1405924d..d4f0b6510df 100644 --- a/sys/dev/pci/sili_pci.c +++ b/sys/dev/pci/sili_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sili_pci.c,v 1.12 2010/08/31 17:13:44 deraadt Exp $ */ +/* $OpenBSD: sili_pci.c,v 1.13 2012/10/08 21:47:50 deraadt Exp $ */ /* * Copyright (c) 2007 David Gwynne <dlg@openbsd.org> @@ -212,6 +212,9 @@ sili_pci_activate(struct device *self, int act) case DVACT_SUSPEND: rv = config_activate_children(self, act); break; + case DVACT_POWERDOWN: + rv = config_activate_children(self, act); + break; case DVACT_RESUME: sili_resume(sc); rv = config_activate_children(self, act); diff --git a/sys/dev/pci/vga_pci.c b/sys/dev/pci/vga_pci.c index 595483c23c9..56f977a1b93 100644 --- a/sys/dev/pci/vga_pci.c +++ b/sys/dev/pci/vga_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vga_pci.c,v 1.68 2012/08/22 20:58:30 mpi Exp $ */ +/* $OpenBSD: vga_pci.c,v 1.69 2012/10/08 21:47:50 deraadt Exp $ */ /* $NetBSD: vga_pci.c,v 1.3 1998/06/08 06:55:58 thorpej Exp $ */ /* @@ -336,6 +336,9 @@ vga_pci_activate(struct device *self, int act) #endif rv = config_activate_children(self, act); break; + case DVACT_POWERDOWN: + rv = config_activate_children(self, act); + break; } return (rv); |