USB/TTY spl fix.

Bruce Evans bde at zeta.org.au
Sat Nov 6 04:38:26 PST 2004


On Fri, 5 Nov 2004, Julian Elischer wrote:

> Mike Tancsa wrote:
>
> > At 04:15 PM 05/11/2004, Julian Elischer wrote:
> >
> >> 1/ where are we?
> >>  I've seen USB commits recently from several people..
> >
> >
> > Not a commit, but a plea to have
> >
> > http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/72935
> >
> > reviewed / committed if possible :)
>
> *** uhid.c.orig Wed Oct 20 14:16:05 2004
> --- uhid.c      Wed Oct 20 14:16:56 2004
> ***************
> *** 411,416 ****
> --- 411,424 ----
>         if (sc->sc_dying)
>                 return (ENXIO);
>
> + /* KDW - test change to force class tty to include uhid */
> +       {
> +               int s = splhigh();
> +               tty_imask |= bio_imask;
> +               splx( s );
> +       }
> + /* end KDW */
> +
>         if (sc->sc_state & UHID_OPEN)
>                 return (EBUSY);
>         sc->sc_state |= UHID_OPEN;
>
>
> updated to.....
>
>          {
>                  int s = splhigh();
>                  tty_imask |= bio_imask;
>                  bio_imask |= tty_imask;
>                  update_intr_masks();
>                  splx( s );
>          }
>
> well, this probably solves the problem for static cases but it doesn't
> solve the
> case for someone plugging in a pccard modem.
> In that case the mask for tty_mask would change, and bio_mask would
> never be updated.
>
> My tbought is that we "ignore" this case for now and commit it as shown
> above. 5.x doesn't have this problem
> due to the completely different protection system.
>
> I'm CCing bde because he has general foo in this area.

It can't be much worse than for ppp and slip where we just ignore the
problem.  In fact it seems to be less worse since the above seems to
update the imasks for every device attach, but for ppp/slip the imasks
are only updated for module attach.

Perhaps non-static cases could at least be detected using spl*assert().
(The spl*assert() family proved to be so useful that it has never been
used in any committed code :-(.)

To get a robust but sub-optimal quick fix, edit iplfuncs.c to make
splbio() == splnet() == spltty() by ORing the imasks together in the
same way as for splvm().

Bruce


More information about the freebsd-usb mailing list