Date: Wed, 16 Jun 2004 11:10:20 GMT From: Dan Langille <dan@langille.org> To: freebsd-i386@FreeBSD.org Subject: Re: i386/59806: [patch] Suspend/resume breaks em0 Message-ID: <200406161110.i5GBAKOP023599@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR i386/59806; it has been noted by GNATS.
From: Dan Langille <dan@langille.org>
To: freebsd-gnats-submit@FreeBSD.org, peter.schuller@infidyne.com
Cc: dan@langille.org
Subject: Re: i386/59806: [patch] Suspend/resume breaks em0
Date: Wed, 16 Jun 2004 07:08:17 -0400 (EDT)
Is there any reason not to commit this PR?
I have a slightly amended patch [I think it's from the Originator of this
PR]. I have tested it and found it to work well on my IBM ThinkPad T41.
Any else eager to test this patch?
--- /usr/src/sys/dev/em/if_em.c Sun Dec 7 11:53:50 2003
+++ if_em.c Tue Jun 15 12:18:17 2004
@@ -125,6 +125,8 @@
static void em_init(void *);
static void em_init_locked(struct adapter *);
static void em_stop(void *);
+static int em_suspend(device_t);
+static int em_resume(device_t);
static void em_media_status(struct ifnet *, struct ifmediareq *);
static int em_media_change(struct ifnet *);
static void em_identify_hardware(struct adapter *);
@@ -192,6 +194,8 @@
DEVMETHOD(device_probe, em_probe),
DEVMETHOD(device_attach, em_attach),
DEVMETHOD(device_detach, em_detach),
+ DEVMETHOD(device_suspend, em_suspend),
+ DEVMETHOD(device_resume, em_resume),
DEVMETHOD(device_shutdown, em_shutdown),
{0, 0}
};
@@ -1619,6 +1623,53 @@
ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
return;
+}
+
+/*********************************************************************
+ *
+ * Prepares the interface for suspend by stopping it.
+ *
+ *********************************************************************/
+
+static int
+em_suspend(device_t dev)
+{
+ int i;
+ struct adapter *adapter = device_get_softc(dev);
+
+ EM_LOCK(adapter);
+ em_stop(adapter);
+
+ /* bulk copy pci regs for fixy TKTKTK */
+ for (i = 0; i < 28; i++) {
+ adapter->pci_backup[i] = pci_read_config(dev, i, 1);
+ }
+
+ EM_UNLOCK(adapter);
+ return(0);
+}
+
+/*********************************************************************
+ *
+ * Reinit the interface when resuming.
+ *
+ *********************************************************************/
+
+static int
+em_resume(device_t dev)
+{
+ int i;
+ struct adapter *adapter = device_get_softc(dev);
+ EM_LOCK(adapter);
+
+ /* bulk copy pci regs back for fixy TKTKTK */
+ for (i = 0; i < 28; i++) {
+ pci_write_config(dev, i, adapter->pci_backup[i], 1);
+ }
+
+ em_init_locked(adapter);
+ EM_UNLOCK(adapter);
+ return(0);
}
--- /usr/src/sys/dev/em/if_em.h Fri Nov 14 13:02:24 2003
+++ if_em.h Tue Jun 15 12:18:17 2004
@@ -424,6 +424,8 @@
#endif
struct em_hw_stats stats;
+
+ u_int8_t pci_backup[28];
};
#define EM_LOCK_INIT(_sc, _name) \
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200406161110.i5GBAKOP023599>
