From owner-freebsd-i386@FreeBSD.ORG Wed Jun 16 11:10:29 2004 Return-Path: Delivered-To: freebsd-i386@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 280F216A4CE for ; Wed, 16 Jun 2004 11:10:29 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0AF8643D45 for ; Wed, 16 Jun 2004 11:10:29 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i5GBAKX1023600 for ; Wed, 16 Jun 2004 11:10:20 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i5GBAKOP023599; Wed, 16 Jun 2004 11:10:20 GMT (envelope-from gnats) Date: Wed, 16 Jun 2004 11:10:20 GMT Message-Id: <200406161110.i5GBAKOP023599@freefall.freebsd.org> To: freebsd-i386@FreeBSD.org From: Dan Langille Subject: Re: i386/59806: [patch] Suspend/resume breaks em0 X-BeenThere: freebsd-i386@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Dan Langille List-Id: I386-specific issues for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jun 2004 11:10:29 -0000 The following reply was made to PR i386/59806; it has been noted by GNATS. From: Dan Langille 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) \