From owner-freebsd-current Mon Dec 10 1:47:36 2001 Delivered-To: freebsd-current@freebsd.org Received: from mgo.iij.ad.jp (mgo.iij.ad.jp [202.232.15.6]) by hub.freebsd.org (Postfix) with ESMTP id 6703637B417; Mon, 10 Dec 2001 01:47:17 -0800 (PST) Received: from ns.iij.ad.jp (ns.iij.ad.jp [192.168.2.8]) by mgo.iij.ad.jp (8.8.8/MGO1.0) with ESMTP id SAA07128; Mon, 10 Dec 2001 18:47:16 +0900 (JST) Received: from fs.iij.ad.jp (root@fs.iij.ad.jp [192.168.2.9]) by ns.iij.ad.jp (8.8.5/3.5Wpl7) with ESMTP id SAA13196; Mon, 10 Dec 2001 18:47:16 +0900 (JST) Received: from localhost (shigeru@mercury.iij.ad.jp [192.168.4.89]) by fs.iij.ad.jp (8.8.5/3.5Wpl7) with ESMTP id SAA24819; Mon, 10 Dec 2001 18:47:16 +0900 (JST) Date: Mon, 10 Dec 2001 18:47:15 +0900 (JST) Message-Id: <20011210.184715.99986520.shigeru@iij.ad.jp> To: freebsd-mobile@FreeBSD.ORG, freebsd-current@FreeBSD.ORG Subject: Re: 2 patches for NEWCARD From: YAMAMOTO Shigeru In-Reply-To: <200111200454.fAK4sb780192@harmony.village.org> References: <20011119.171129.72757009.shigeru@iij.ad.jp> <200111200454.fAK4sb780192@harmony.village.org> X-Mailer: Mew version 2.0 pre1 on Emacs 20.7 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Mon_Dec_10_18:47:15_2001_070)--" Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG ----Next_Part(Mon_Dec_10_18:47:15_2001_070)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit >>>>> "Warner" == Warner Losh writes: Warner> Hmmm. Something about this patch looks incorrect. Wouldn't it Warner> delete the actual bus (eg pccard/cardbus)? I'd think that we'd want Warner> to delete the children's children. I will have to look at the code Warner> more closely to see if I might be mistaken. I re-write a patch for NEWCARD. New patch is, - detach children of cardbus/pccard devices at suspend time - probe and attach children of cardbus/pccard devices at resume time - pccbb devices are suspend/resume - cardbus and pccard devices are suspend/resume instead of detach/attach Currently, I'm using this fixes on my NotePC and there is no problem. ------- YAMAMOTO Shigeru ----Next_Part(Mon_Dec_10_18:47:15_2001_070)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="newcard.diff" Index: cardbus/cardbus.c =================================================================== RCS file: /share/cvsup/FreeBSD/current/usr/src/sys/dev/cardbus/cardbus.c,v retrieving revision 1.12 diff -u -r1.12 cardbus.c --- cardbus/cardbus.c 27 Aug 2001 00:09:34 -0000 1.12 +++ cardbus/cardbus.c 9 Dec 2001 15:51:50 -0000 @@ -163,6 +163,24 @@ return 0; } +static +int +cardbus_suspend(device_t self) { + int error = 0; + + cardbus_detach_card(self, DETACH_FORCE); + + return(error); +} + +static +int +cardbus_resume(device_t self) { + int error = 0; + + return(error); +} + /************************************************************************/ /* Attach/Detach card */ /************************************************************************/ @@ -1199,8 +1217,8 @@ DEVMETHOD(device_attach, cardbus_attach), DEVMETHOD(device_detach, cardbus_detach), DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), + DEVMETHOD(device_suspend, cardbus_suspend), + DEVMETHOD(device_resume, cardbus_resume), /* Bus interface */ DEVMETHOD(bus_print_child, cardbus_print_child), Index: pccard/pccard.c =================================================================== RCS file: /share/cvsup/FreeBSD/current/usr/src/sys/dev/pccard/pccard.c,v retrieving revision 1.48 diff -u -r1.48 pccard.c --- pccard/pccard.c 26 Nov 2001 07:14:00 -0000 1.48 +++ pccard/pccard.c 9 Dec 2001 15:50:43 -0000 @@ -807,6 +807,25 @@ return 0; } +static +int +pccard_suspend(device_t self) { + int error = 0; + struct pccard_softc* sc = PCCARD_SOFTC(self); + + pccard_detach_card(self, 0); + + return(error); +} + +static +int +pccard_resume(device_t self) { + int error = 0; + + return(error); +} + static void pccard_print_resources(struct resource_list *rl, const char *name, int type, int count, const char *format) @@ -1200,8 +1219,8 @@ DEVMETHOD(device_attach, pccard_attach), DEVMETHOD(device_detach, pccard_detach), DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), + DEVMETHOD(device_suspend, pccard_suspend), + DEVMETHOD(device_resume, pccard_resume), /* Bus interface */ DEVMETHOD(bus_print_child, pccard_print_child), Index: pccbb/pccbb.c =================================================================== RCS file: /share/cvsup/FreeBSD/current/usr/src/sys/dev/pccbb/pccbb.c,v retrieving revision 1.31 diff -u -r1.31 pccbb.c --- pccbb/pccbb.c 26 Nov 2001 07:17:09 -0000 1.31 +++ pccbb/pccbb.c 9 Dec 2001 15:50:04 -0000 @@ -2096,14 +2096,78 @@ b, s, f, reg, val, width); } +static +int +pccbb_suspend(device_t self) { + int error = 0; + struct pccbb_softc* sc = device_get_softc(self); + int numdevs; + device_t* devlist; + int tmp; + + bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intrhand); + + bus_generic_suspend(self); + + return(error); +} + +static +int +pccbb_resume(device_t self) +{ + int error = 0; + struct pccbb_softc *sc = (struct pccbb_softc *)device_get_softc(self); + + pci_write_config(self, PCCBBR_SOCKBASE, + rman_get_start(sc->sc_base_res), 4); + DEVPRINTF((self, "PCI Memory allocated: %08lx\n", + rman_get_start(sc->sc_base_res))); + + pccbb_chipinit(sc); + + /* CSC Interrupt: Card detect interrupt on */ + sc->sc_socketreg->socket_mask |= PCCBB_SOCKET_MASK_CD; + + /* reset interrupt */ + { + u_int32_t tmp; + + tmp = sc->sc_socketreg->socket_event; + sc->sc_socketreg->socket_event = tmp; + } + + /* establish the interrupt. */ + if (bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO, pccbb_intr, sc, + &(sc->sc_intrhand))) { + device_printf(self, "couldn't establish interrupt"); + bus_release_resource(self, SYS_RES_IRQ, 0, sc->sc_irq_res); + bus_release_resource(self, SYS_RES_MEMORY, PCCBBR_SOCKBASE, + sc->sc_base_res); + mtx_destroy(&sc->sc_mtx); + error = ENOMEM; + } + + bus_generic_resume(self); + + /* wakeup thread */ + if (!error) { + mtx_lock(&sc->sc_mtx); + wakeup(sc); + mtx_unlock(&sc->sc_mtx); + } + + return(error); +} + static device_method_t pccbb_methods[] = { /* Device interface */ DEVMETHOD(device_probe, pccbb_probe), DEVMETHOD(device_attach, pccbb_attach), DEVMETHOD(device_detach, pccbb_detach), DEVMETHOD(device_shutdown, pccbb_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), + DEVMETHOD(device_suspend, pccbb_suspend), + DEVMETHOD(device_resume, pccbb_resume), /* bus methods */ DEVMETHOD(bus_print_child, bus_generic_print_child), ----Next_Part(Mon_Dec_10_18:47:15_2001_070)---- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message