From: deraadt Date: Sat, 7 Aug 2010 06:10:04 +0000 (+0000) Subject: On resume, re-activate the host RNG on the host bridges that need it. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=75ba69865bfe4115dc0abd89e7116dfe99868537;p=openbsd On resume, re-activate the host RNG on the host bridges that need it. ok kettenis --- diff --git a/sys/arch/amd64/pci/pchb.c b/sys/arch/amd64/pci/pchb.c index f42b042f042..e715e3097c4 100644 --- a/sys/arch/amd64/pci/pchb.c +++ b/sys/arch/amd64/pci/pchb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pchb.c,v 1.34 2010/06/24 00:06:57 kettenis Exp $ */ +/* $OpenBSD: pchb.c,v 1.35 2010/08/07 06:10:04 deraadt Exp $ */ /* $NetBSD: pchb.c,v 1.1 2003/04/26 18:39:50 fvdl Exp $ */ /* * Copyright (c) 2000 Michael Shalayeff @@ -108,6 +108,7 @@ struct pchb_softc { bus_space_handle_t sc_bh; /* rng stuff */ + int sc_rng_active; int sc_rng_ax; int sc_rng_i; struct timeout sc_rng_to; @@ -115,10 +116,11 @@ struct pchb_softc { int pchbmatch(struct device *, void *, void *); void pchbattach(struct device *, struct device *, void *); +int pchbactivate(struct device *, int); struct cfattach pchb_ca = { sizeof(struct pchb_softc), pchbmatch, pchbattach, NULL, - config_activate_children + pchbactivate }; struct cfdriver pchb_cd = { @@ -202,6 +204,7 @@ pchbattach(struct device *parent, struct device *self, void *aux) timeout_set(&sc->sc_rng_to, pchb_rnd, sc); sc->sc_rng_i = 4; pchb_rnd(sc); + sc->sc_rng_active = 1; break; } printf("\n"); @@ -269,6 +272,29 @@ pchbattach(struct device *parent, struct device *self, void *aux) config_found(self, &pba, pchb_print); } +int +pchbactivate(struct device *self, int act) +{ + struct pchb_softc *sc = (struct pchb_softc *)self; + + switch (act) { + case DVACT_SUSPEND: + config_activate_children(self, act); + break; + case DVACT_RESUME: + /* re-enable RNG, if we have it */ + if (sc->sc_rng_active) + bus_space_write_1(sc->sc_bt, sc->sc_bh, + I82802_RNG_HWST, + bus_space_read_1(sc->sc_bt, sc->sc_bh, + I82802_RNG_HWST) | I82802_RNG_HWST_ENABLE); + config_activate_children(self, act); + break; + } + return (0); +} + + int pchb_print(void *aux, const char *pnp) { diff --git a/sys/arch/i386/pci/pchb.c b/sys/arch/i386/pci/pchb.c index c2839350918..3b594a5a269 100644 --- a/sys/arch/i386/pci/pchb.c +++ b/sys/arch/i386/pci/pchb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pchb.c,v 1.82 2010/06/24 00:06:57 kettenis Exp $ */ +/* $OpenBSD: pchb.c,v 1.83 2010/08/07 06:10:06 deraadt Exp $ */ /* $NetBSD: pchb.c,v 1.65 2007/08/15 02:26:13 markd Exp $ */ /* @@ -120,6 +120,7 @@ struct pchb_softc { bus_space_handle_t sc_bh; /* rng stuff */ + int sc_rng_active; int sc_rng_ax; int sc_rng_i; struct timeout sc_rng_to; @@ -127,10 +128,11 @@ struct pchb_softc { int pchbmatch(struct device *, void *, void *); void pchbattach(struct device *, struct device *, void *); +int pchbactivate(struct device *, int); struct cfattach pchb_ca = { sizeof(struct pchb_softc), pchbmatch, pchbattach, NULL, - config_activate_children + pchbactivate }; struct cfdriver pchb_cd = { @@ -345,6 +347,7 @@ pchbattach(struct device *parent, struct device *self, void *aux) timeout_set(&sc->sc_rng_to, pchb_rnd, sc); sc->sc_rng_i = 4; pchb_rnd(sc); + sc->sc_rng_active = 1; break; } printf("\n"); @@ -412,6 +415,29 @@ pchbattach(struct device *parent, struct device *self, void *aux) config_found(self, &pba, pchb_print); } +int +pchbactivate(struct device *self, int act) +{ + struct pchb_softc *sc = (struct pchb_softc *)self; + + switch (act) { + case DVACT_SUSPEND: + config_activate_children(self, act); + break; + case DVACT_RESUME: + /* re-enable RNG, if we have it */ + if (sc->sc_rng_active) + bus_space_write_1(sc->sc_bt, sc->sc_bh, + I82802_RNG_HWST, + bus_space_read_1(sc->sc_bt, sc->sc_bh, + I82802_RNG_HWST) | I82802_RNG_HWST_ENABLE); + config_activate_children(self, act); + break; + } + return (0); +} + + int pchb_print(void *aux, const char *pnp) {