Date: Fri, 17 Nov 2006 14:12:34 -0500 From: John Baldwin <john@baldwin.cx> To: freebsd-acpi@freebsd.org, Stepan Zastupov <redchrom@gmail.com> Cc: current@freebsd.org Subject: Re: Add suspend/resume support for the bfe driver Message-ID: <200611171412.35214.john@baldwin.cx> In-Reply-To: <20061117172102.GA836@stepan.ispsystem.net> References: <20061117172102.GA836@stepan.ispsystem.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Friday 17 November 2006 12:21, Stepan Zastupov wrote: > A couple of weeks ago I wrote patch which added suspend/resume support > for the bfe driver. It just attach/deattach device when suspend/resume > as it done in Linux driver. In pr I wrote that it dosen'y help but now I > know that it dose! Just need to stop devd before suspend, I do it from > the /etc/rc.suspend and start from /etc/rc.resume. I hope somebody > commit the patch into kernel tree. > Here is the pr http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/104652 Usually drivers don't detach on suspend. How about this patch instead: Index: if_bfe.c =================================================================== RCS file: /usr/cvs/src/sys/dev/bfe/if_bfe.c,v retrieving revision 1.40 diff -u -r1.40 if_bfe.c --- if_bfe.c 28 May 2006 20:35:39 -0000 1.40 +++ if_bfe.c 17 Nov 2006 19:11:47 -0000 @@ -87,6 +87,8 @@ static int bfe_probe (device_t); static int bfe_attach (device_t); static int bfe_detach (device_t); +static int bfe_suspend (device_t); +static int bfe_resume (device_t); static void bfe_release_resources (struct bfe_softc *); static void bfe_intr (void *); static void bfe_start (struct ifnet *); @@ -136,6 +138,8 @@ DEVMETHOD(device_attach, bfe_attach), DEVMETHOD(device_detach, bfe_detach), DEVMETHOD(device_shutdown, bfe_shutdown), + DEVMETHOD(device_suspend, bfe_suspend), + DEVMETHOD(device_resume, bfe_resume), /* bus interface */ DEVMETHOD(bus_print_child, bus_generic_print_child), @@ -480,6 +484,39 @@ } static int +bfe_suspend(device_t dev) +{ + struct bfe_softc *sc; + + sc = device_get_softc(dev); + BFE_LOCK(sc); + bfe_stop(sc); + BFE_UNLOCK(sc); + + return (0); +} + +static int +bfe_resume(device_t dev) +{ + struct bfe_softc *sc; + struct ifnet *ifp; + + sc = device_get_softc(dev); + ifp = sc->bfe_ifp; + BFE_LOCK(sc); + if (ifp->if_flags & IFF_UP) { + bfe_init_locked(sc); + if (ifp->if_drv_flags & IFF_DRV_RUNNING && + !IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + bfe_start_locked(ifp); + } + BFE_UNLOCK(sc); + + return (0); +} + +static int bfe_miibus_readreg(device_t dev, int phy, int reg) { struct bfe_softc *sc; -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200611171412.35214.john>