summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2010-08-27 20:06:40 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2010-08-27 20:06:40 +0000
commite783a220ecb726af815b850ba3dbdea6026f811c (patch)
tree22c948c770a7e130c812462719b5e0c3ed5b3219 /sys
parent01a046408f59847748eab2250c9a21f537961806 (diff)
Massage the powerhook function into an activate function, and since we do
not neccessarily have a working filesystem for the firmware yet, use a workq to postpone resume. Then make the powerhook function call the activate function. There remains some questions about the sc_power functions... ok kettenis
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/cardbus/if_pgt_cardbus.c3
-rw-r--r--sys/dev/ic/pgt.c68
-rw-r--r--sys/dev/ic/pgtvar.h5
-rw-r--r--sys/dev/pci/if_pgt_pci.c5
4 files changed, 50 insertions, 31 deletions
diff --git a/sys/dev/cardbus/if_pgt_cardbus.c b/sys/dev/cardbus/if_pgt_cardbus.c
index 88ffd78b3b4..5c3f6d4c4f1 100644
--- a/sys/dev/cardbus/if_pgt_cardbus.c
+++ b/sys/dev/cardbus/if_pgt_cardbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pgt_cardbus.c,v 1.11 2010/03/27 21:40:13 jsg Exp $ */
+/* $OpenBSD: if_pgt_cardbus.c,v 1.12 2010/08/27 20:06:38 deraadt Exp $ */
/*
* Copyright (c) 2006 Marcus Glocker <mglocker@openbsd.org>
@@ -31,6 +31,7 @@
#include <sys/malloc.h>
#include <sys/timeout.h>
#include <sys/device.h>
+#include <sys/workq.h>
#include <machine/bus.h>
#include <machine/intr.h>
diff --git a/sys/dev/ic/pgt.c b/sys/dev/ic/pgt.c
index 4df90aed28b..3b16908a013 100644
--- a/sys/dev/ic/pgt.c
+++ b/sys/dev/ic/pgt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pgt.c,v 1.63 2010/08/27 17:08:00 jsg Exp $ */
+/* $OpenBSD: pgt.c,v 1.64 2010/08/27 20:06:39 deraadt Exp $ */
/*
* Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org>
@@ -59,6 +59,7 @@
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/device.h>
+#include <sys/workq.h>
#include <machine/bus.h>
#include <machine/endian.h>
@@ -192,7 +193,8 @@ int pgt_dma_alloc_queue(struct pgt_softc *sc, enum pgt_queue pq);
void pgt_dma_free(struct pgt_softc *);
void pgt_dma_free_queue(struct pgt_softc *sc, enum pgt_queue pq);
void pgt_shutdown(void *);
-void pgt_power(int, void *);
+void pgt_powerhook(int, void *);
+void pgt_resume(void *, void *);
void
pgt_write_memory_barrier(struct pgt_softc *sc)
@@ -2034,7 +2036,7 @@ pgt_net_attach(struct pgt_softc *sc)
if (sc->sc_shutdown_hook == NULL)
printf("%s: WARNING: unable to establish shutdown hook\n",
sc->sc_dev.dv_xname);
- sc->sc_power_hook = powerhook_establish(pgt_power, sc);
+ sc->sc_power_hook = powerhook_establish(pgt_powerhook, sc);
if (sc->sc_power_hook == NULL)
printf("%s: WARNING: unable to establish power hook\n",
sc->sc_dev.dv_xname);
@@ -3312,39 +3314,51 @@ pgt_shutdown(void *arg)
pgt_stop(sc, SC_DYING);
}
-void
-pgt_power(int why, void *arg)
+int
+pgt_activate(struct device *self, int act)
{
- struct pgt_softc *sc = arg;
+ struct pgt_softc *sc = (struct pgt_softc *)self;
struct ifnet *ifp = &sc->sc_ic.ic_if;
- int s;
DPRINTF(("%s: %s(%d)\n", sc->sc_dev.dv_xname, __func__, why));
- s = splnet();
-
- switch (why) {
- case PWR_SUSPEND:
- pgt_stop(sc, SC_NEEDS_RESET);
- pgt_update_hw_from_sw(sc, 0, 0);
-
+ switch (act) {
+ case DVACT_SUSPEND:
+ if (ifp->if_flags & IFF_RUNNING) {
+ pgt_stop(sc, SC_NEEDS_RESET);
+ pgt_update_hw_from_sw(sc, 0, 0);
+ }
if (sc->sc_power != NULL)
- (*sc->sc_power)(sc, why);
+ (*sc->sc_power)(sc, act);
break;
- case PWR_RESUME:
- if (sc->sc_power != NULL)
- (*sc->sc_power)(sc, why);
+ case DVACT_RESUME:
+ workq_queue_task(NULL, &sc->sc_resume_wqt, 0,
+ pgt_resume, sc, NULL);
+ break;
+ }
+ return 0;
+}
- pgt_stop(sc, SC_NEEDS_RESET);
- pgt_update_hw_from_sw(sc, 0, 0);
+void
+pgt_resume(void *arg1, void *arg2)
+{
+ struct pgt_softc *sc = arg1;
+ struct ifnet *ifp = &sc->sc_ic.ic_if;
- if ((ifp->if_flags & IFF_UP) &&
- !(ifp->if_flags & IFF_RUNNING)) {
- pgt_init(ifp);
- pgt_update_hw_from_sw(sc, 0, 0);
- }
- break;
+ if (sc->sc_power != NULL)
+ (*sc->sc_power)(sc, DVACT_RESUME);
+
+ pgt_stop(sc, SC_NEEDS_RESET);
+ pgt_update_hw_from_sw(sc, 0, 0);
+
+ if (ifp->if_flags & IFF_UP) {
+ pgt_init(ifp);
+ pgt_update_hw_from_sw(sc, 0, 0);
}
+}
- splx(s);
+void
+pgt_powerhook(int why, void *arg)
+{
+ pgt_activate(arg, why);
}
diff --git a/sys/dev/ic/pgtvar.h b/sys/dev/ic/pgtvar.h
index 622b02e32f3..cb44228bf62 100644
--- a/sys/dev/ic/pgtvar.h
+++ b/sys/dev/ic/pgtvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pgtvar.h,v 1.11 2006/10/09 21:04:05 mglocker Exp $ */
+/* $OpenBSD: pgtvar.h,v 1.12 2010/08/27 20:06:39 deraadt Exp $ */
/*
* Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org>
@@ -210,11 +210,14 @@ struct pgt_softc {
#define sc_txtap sc_txtapu.th
int sc_txtap_len;
#endif
+
+ struct workq_task sc_resume_wqt;
};
int pgt_intr(void *);
void pgt_attach(void *);
int pgt_detach(struct pgt_softc *);
+int pgt_activate(struct device *, int);
static __inline int
pgt_queue_is_rx(enum pgt_queue pq)
diff --git a/sys/dev/pci/if_pgt_pci.c b/sys/dev/pci/if_pgt_pci.c
index 7fb29bdc460..567ad03570c 100644
--- a/sys/dev/pci/if_pgt_pci.c
+++ b/sys/dev/pci/if_pgt_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pgt_pci.c,v 1.12 2010/08/07 16:16:18 kettenis Exp $ */
+/* $OpenBSD: if_pgt_pci.c,v 1.13 2010/08/27 20:06:39 deraadt Exp $ */
/*
* Copyright (c) 2006 Marcus Glocker <mglocker@openbsd.org>
@@ -31,6 +31,7 @@
#include <sys/malloc.h>
#include <sys/timeout.h>
#include <sys/device.h>
+#include <sys/workq.h>
#include <machine/bus.h>
#include <machine/intr.h>
@@ -69,7 +70,7 @@ struct pgt_pci_softc {
struct cfattach pgt_pci_ca = {
sizeof(struct pgt_pci_softc), pgt_pci_match, pgt_pci_attach,
- pgt_pci_detach
+ pgt_pci_detach, pgt_activate
};
const struct pci_matchid pgt_pci_devices[] = {