From owner-freebsd-current@FreeBSD.ORG Fri Nov 17 19:12:57 2006 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 88A7416A4F0; Fri, 17 Nov 2006 19:12:57 +0000 (UTC) (envelope-from john@baldwin.cx) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id 912D443D45; Fri, 17 Nov 2006 19:12:56 +0000 (GMT) (envelope-from john@baldwin.cx) Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.6/8.13.6) with ESMTP id kAHJCn3L051885; Fri, 17 Nov 2006 14:12:50 -0500 (EST) (envelope-from john@baldwin.cx) From: John Baldwin To: freebsd-acpi@freebsd.org, Stepan Zastupov Date: Fri, 17 Nov 2006 14:12:34 -0500 User-Agent: KMail/1.9.1 References: <20061117172102.GA836@stepan.ispsystem.net> In-Reply-To: <20061117172102.GA836@stepan.ispsystem.net> MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200611171412.35214.john@baldwin.cx> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Fri, 17 Nov 2006 14:12:50 -0500 (EST) X-Virus-Scanned: ClamAV 0.88.3/2201/Fri Nov 17 07:16:33 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx X-Mailman-Approved-At: Fri, 17 Nov 2006 20:55:46 +0000 Cc: current@freebsd.org Subject: Re: Add suspend/resume support for the bfe driver X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Nov 2006 19:12:57 -0000 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