From owner-freebsd-mobile Thu Sep 12 10:25:13 2002 Delivered-To: freebsd-mobile@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6211837B400 for ; Thu, 12 Sep 2002 10:25:08 -0700 (PDT) Received: from mail.speakeasy.net (mail13.speakeasy.net [216.254.0.213]) by mx1.FreeBSD.org (Postfix) with ESMTP id E877D43E65 for ; Thu, 12 Sep 2002 10:25:07 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Received: (qmail 20912 invoked from network); 12 Sep 2002 17:25:06 -0000 Received: from unknown (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) by mail13.speakeasy.net (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 12 Sep 2002 17:25:06 -0000 Received: from laptop.baldwin.cx (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.12.5/8.12.5) with ESMTP id g8CHP5Bv039478; Thu, 12 Sep 2002 13:25:05 -0400 (EDT) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.5.2 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20020912125118.GA1343@laptop.6bone.nl> Date: Thu, 12 Sep 2002 13:25:05 -0400 (EDT) From: John Baldwin To: Mark Santcroos Subject: RE: pccard re-attach after ACPI S1 resume Cc: mobile@freebsd.org Sender: owner-freebsd-mobile@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On 12-Sep-2002 Mark Santcroos wrote: > This patch fixes the re-attaching of pccards after suspending(S1) with > ACPI on my laptop. > > Although it is tested it might not be the most clean solution. The same > thing could be done for cardbus also, but I don't have any hardware to > test that. > > Please let me know if this should be fixed differently. > > Mark > > > diff -u -r /usr/src/sys/dev/pccard/pccard.c ./pccard.c > --- /usr/src/sys/dev/pccard/pccard.c Thu Sep 12 12:46:13 2002 > +++ ./pccard.c Thu Sep 12 14:05:10 2002 > @@ -155,6 +155,8 @@ > device_t child; > int i; > > + sc->suspended = 0; /* XXX initialize, maybe not here */ > + > /* > * this is here so that when socket_enable calls gettype, trt happens > */ This part you don't need because softc's are zero'd when they are allocated. What if you just had pccard_resume() always call pccard_attach_card(self), does that work? If not, you do have one bug, you should clear sc_suspended after the pccard_attach_card() in pccard_resume(). > @@ -251,6 +253,7 @@ > return (0); > } > > +#define PCCARD_DETACH_FOR_SUSPEND 0x01 > static int > pccard_detach_card(device_t dev, int flags) > { > @@ -265,8 +268,11 @@ > STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) { > int state = device_get_state(pf->dev); > > - if (state == DS_ATTACHED || state == DS_BUSY) > + if (state == DS_ATTACHED || state == DS_BUSY) { > device_detach(pf->dev); > + if(flags & PCCARD_DETACH_FOR_SUSPEND) > + sc->suspended = 1; > + } > if (pf->cfe != NULL) > pccard_function_disable(pf); > pccard_function_free(pf); > @@ -776,14 +782,18 @@ > static int > pccard_suspend(device_t self) > { > - pccard_detach_card(self, 0); > + pccard_detach_card(self, PCCARD_DETACH_FOR_SUSPEND); > return (0); > } > > static > int > -pccard_resume(device_t self) > +pccard_resume(device_t dev) > { > + struct pccard_softc *sc = PCCARD_SOFTC(dev); > + > + if (sc->suspended == 1) > + pccard_attach_card(dev); > return (0); > } > > diff -u -r /usr/src/sys/dev/pccard/pccardvar.h ./pccardvar.h > --- /usr/src/sys/dev/pccard/pccardvar.h Wed Jul 17 07:20:43 2002 > +++ ./pccardvar.h Thu Sep 12 14:06:42 2002 > @@ -205,6 +205,8 @@ > /* this stuff is for the card */ > struct pccard_card card; > int sc_enabled_count; /* num functions enabled */ > + /* was there a device active on time of suspension */ > + int suspended; > }; > > void > > > -- > Mark Santcroos RIPE Network Coordination Centre > http://www.ripe.net/home/mark/ New Projects Group/TTM -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-mobile" in the body of the message