On Sat, Nov 10, 2012 at 03:52:37AM +0100, Mike Belopuhov wrote:
> On Tue, Nov 06, 2012 at 12:15 +0100, Stefan Sperling wrote:
> > It seems more appropriate to handle this problem entirely within
> > the USB-specific layer of the driver, rather than within dev/ic/athn.c.
> > 
> > If loading the firmware fails, athn_usb_attachhook() doesn't even
> > call athn_attach(). This is what your fix is compensating for. I believe
> > athn_usb_detach() shouldn't be calling athn_detach() unconditionally.
> > 
> > I fixed a similar problem for acx(4) cardbus cards once, where ejecting
> > a card that had failed to attach half way through paniced the kernel.
> > This was in r1.12 of dev/cardbus/if_acx_cardbus.c, which looked like this:
> > 
> 
> works for me. ok?

Yes!
 
> Index: dev/usb/if_athn_usb.c
> ===================================================================
> RCS file: /home/cvs/src/sys/dev/usb/if_athn_usb.c,v
> retrieving revision 1.8
> diff -u -p -r1.8 if_athn_usb.c
> --- dev/usb/if_athn_usb.c     3 Jul 2011 15:47:17 -0000       1.8
> +++ dev/usb/if_athn_usb.c     10 Nov 2012 02:04:12 -0000
> @@ -289,7 +289,8 @@ athn_usb_detach(struct device *self, int
>       struct athn_usb_softc *usc = (struct athn_usb_softc *)self;
>       struct athn_softc *sc = &usc->sc_sc;
>  
> -     athn_detach(sc);
> +     if (usc->sc_athn_attached)
> +             athn_detach(sc);
>  
>       /* Wait for all async commands to complete. */
>       athn_usb_wait_async(usc);
> @@ -347,6 +348,7 @@ athn_usb_attachhook(void *xsc)
>               splx(s);
>               return;
>       }
> +     usc->sc_athn_attached = 1;
>       /* Override some operations for USB. */
>       ifp->if_ioctl = athn_usb_ioctl;
>       ifp->if_start = athn_usb_start;
> Index: dev/usb/if_athn_usb.h
> ===================================================================
> RCS file: /home/cvs/src/sys/dev/usb/if_athn_usb.h,v
> retrieving revision 1.2
> diff -u -p -r1.2 if_athn_usb.h
> --- dev/usb/if_athn_usb.h     8 Jan 2011 15:18:01 -0000       1.2
> +++ dev/usb/if_athn_usb.h     10 Nov 2012 02:04:33 -0000
> @@ -417,6 +417,7 @@ struct athn_usb_host_cmd_ring {
>  struct athn_usb_softc {
>       struct athn_softc               sc_sc;
>  #define usb_dev      sc_sc.sc_dev
> +     int                             sc_athn_attached;
>  
>       /* USB specific goo. */
>       usbd_device_handle              sc_udev;

Reply via email to