Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Sep 2002 13:25:05 -0400 (EDT)
From:      John Baldwin <jhb@FreeBSD.org>
To:        Mark Santcroos <marks@ripe.net>
Cc:        mobile@freebsd.org
Subject:   RE: pccard re-attach after ACPI S1 resume
Message-ID:  <XFMail.20020912132505.jhb@FreeBSD.org>
In-Reply-To: <20020912125118.GA1343@laptop.6bone.nl>

next in thread | previous in thread | raw e-mail | index | archive | help

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 <jhb@FreeBSD.org>  <><  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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.20020912132505.jhb>