Subject: new patch, was: Re: test pmfified ex(4) please
To: None <current-users@netbsd.org>
From: S.P.Zeidler <spz@serpens.de>
List: current-users
Date: 12/22/2007 22:29:06
--SLDf9lqlvOQaIe6s
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi,
In lists.netbsd.current-users you write:
>On Thu, Dec 20, 2007 at 03:55:23PM +0100, S.P.Zeidler wrote:
>> @@ -474,6 +479,11 @@
>> if (sc->sc_powerhook == NULL)
>> aprint_error("%s: WARNING: unable to establish power hook\n",
>> sc->sc_dev.dv_xname);
>> +#endif
>> + if (!pmf_device_register(&(sc->sc_dev), ex_suspend, ex_resume))
> NULL, NULL
>The powerhandler does nothing, the network class handler doesn't already
>do.
Right, even the Cardbus sc->power on resume gets called via ex_init
calling ex_enable.
I feel like I'm in a maze of twisty little passages all opening up onto
each other at unexpected turns :P
Ifdeffing out what becomes obviously useless with pmf gives the attached
patch. Re-tests would be nice. :)
I can suspend/resume in single user and ex will continue working; in
multi-user my machine doesn't yet resume, but that's not necessarily due
to the if_ex (graphics are still massively messed up so I don't see what's
happening).
regards,
spz
--
spz@serpens.de (S.P.Zeidler)
--SLDf9lqlvOQaIe6s
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="ex.diff"
Index: cardbus/if_ex_cardbus.c
===================================================================
RCS file: /cvsroot/src/sys/dev/cardbus/if_ex_cardbus.c,v
retrieving revision 1.41
diff -u -r1.41 if_ex_cardbus.c
--- cardbus/if_ex_cardbus.c 9 Dec 2007 20:27:56 -0000 1.41
+++ cardbus/if_ex_cardbus.c 22 Dec 2007 20:25:25 -0000
@@ -90,7 +90,9 @@
int ex_cardbus_enable(struct ex_softc *);
void ex_cardbus_disable(struct ex_softc *);
+#if oldpowerhook
void ex_cardbus_power(struct ex_softc *, int);
+#endif
struct ex_cardbus_softc {
struct ex_softc sc_softc;
@@ -290,7 +292,9 @@
/* Power management hooks. */
sc->enable = ex_cardbus_enable;
sc->disable = ex_cardbus_disable;
+#if oldpowerhook
sc->power = ex_cardbus_power;
+#endif
/*
* Handle power management nonsense and
@@ -389,6 +393,7 @@
}
+#if oldpowerhook
void
ex_cardbus_power(sc, why)
struct ex_softc *sc;
@@ -408,6 +413,7 @@
ex_cardbus_setup(csc);
}
}
+#endif
void
ex_cardbus_setup(csc)
Index: ic/elinkxl.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/elinkxl.c,v
retrieving revision 1.99
diff -u -r1.99 elinkxl.c
--- ic/elinkxl.c 19 Oct 2007 11:59:51 -0000 1.99
+++ ic/elinkxl.c 22 Dec 2007 20:25:27 -0000
@@ -105,14 +105,18 @@
void ex_printstats(struct ex_softc *);
void ex_tick(void *);
+#if oldpowerhook
void ex_power(int, void *);
+#endif
static int ex_eeprom_busy(struct ex_softc *);
static int ex_add_rxbuf(struct ex_softc *, struct ex_rxdesc *);
static void ex_init_txdescs(struct ex_softc *);
static void ex_setup_tx(struct ex_softc *);
+#if oldpowerhook
static void ex_shutdown(void *);
+#endif
static void ex_start(struct ifnet *);
static void ex_txstat(struct ex_softc *);
@@ -462,6 +466,7 @@
RND_TYPE_NET, 0);
#endif
+#if oldpowerhook
/* Establish callback to reset card when we reboot. */
sc->sc_sdhook = shutdownhook_establish(ex_shutdown, sc);
if (sc->sc_sdhook == NULL)
@@ -474,6 +479,11 @@
if (sc->sc_powerhook == NULL)
aprint_error("%s: WARNING: unable to establish power hook\n",
sc->sc_dev.dv_xname);
+#endif
+ if (!pmf_device_register(&(sc->sc_dev), NULL, NULL))
+ aprint_error_dev(&(sc->sc_dev), "couldn't establish power handler\n");
+ else
+ pmf_class_network_register(&(sc->sc_dev), &sc->sc_ethercom.ec_if);
/* The attach is successful. */
sc->ex_flags |= EX_FLAGS_ATTACHED;
@@ -1796,12 +1806,16 @@
EX_NUPD * sizeof (struct ex_upd));
bus_dmamem_free(sc->sc_dmat, &sc->sc_useg, sc->sc_urseg);
+#if oldpowerhook
shutdownhook_disestablish(sc->sc_sdhook);
powerhook_disestablish(sc->sc_powerhook);
+#endif
+ pmf_device_deregister((device_t) sc);
return (0);
}
+#if oldpowerhook
/*
* Before reboots, reset card completely.
*/
@@ -1818,6 +1832,7 @@
*/
(void) ex_enable(sc);
}
+#endif
/*
* Read EEPROM data.
@@ -2052,6 +2067,7 @@
}
}
+#if oldpowerhook
void
ex_power(why, arg)
int why;
@@ -2083,3 +2099,4 @@
}
splx(s);
}
+#endif
Index: ic/elinkxlvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/elinkxlvar.h,v
retrieving revision 1.18
diff -u -r1.18 elinkxlvar.h
--- ic/elinkxlvar.h 4 Mar 2007 06:01:54 -0000 1.18
+++ ic/elinkxlvar.h 22 Dec 2007 20:25:27 -0000
@@ -126,14 +126,18 @@
/* power management hooks */
int (*enable)(struct ex_softc *);
void (*disable)(struct ex_softc *);
+#if oldpowerhook
void (*power)(struct ex_softc *, int);
+#endif
int enabled;
/* interrupt acknowledge hook */
void (*intr_ack)(struct ex_softc *);
+#if oldpowerhook
void *sc_sdhook;
void *sc_powerhook;
+#endif
bus_dma_segment_t sc_useg, sc_dseg;
int sc_urseg, sc_drseg;
--SLDf9lqlvOQaIe6s--