From owner-freebsd-mobile Thu Sep 12 5:51:28 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 0402B37B400 for ; Thu, 12 Sep 2002 05:51:22 -0700 (PDT) Received: from birch.ripe.net (birch.ripe.net [193.0.1.96]) by mx1.FreeBSD.org (Postfix) with ESMTP id C943643E3B for ; Thu, 12 Sep 2002 05:51:20 -0700 (PDT) (envelope-from marks@ripe.net) Received: from laptop.6bone.nl (cow.ripe.net [193.0.1.239]) by birch.ripe.net (8.12.5/8.11.6) with SMTP id g8CCpJKu030017 for ; Thu, 12 Sep 2002 14:51:19 +0200 Received: (nullmailer pid 1503 invoked by uid 1000); Thu, 12 Sep 2002 12:51:18 -0000 Date: Thu, 12 Sep 2002 14:51:18 +0200 From: Mark Santcroos To: mobile@freebsd.org Subject: pccard re-attach after ACPI S1 resume Message-ID: <20020912125118.GA1343@laptop.6bone.nl> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="jRHKVT23PllUwdXP" Content-Disposition: inline User-Agent: Mutt/1.4i X-Handles: MS6-6BONE, MS18417-RIPE X-RIPE-Spam-Status: NONE ; -994 X-RIPE-Spam-Level: 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 --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 */ @@ -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 --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="pccard_resume.diff" 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 */ @@ -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 --jRHKVT23PllUwdXP-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-mobile" in the body of the message