NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/46826: C-A-ESC to enter ddb with ukbd triggers uhci mutex_owned kassert



The following reply was made to PR kern/46826; it has been noted by GNATS.

From: David Holland <dholland-bugs%netbsd.org@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: kern/46826: C-A-ESC to enter ddb with ukbd triggers uhci
 mutex_owned kassert
Date: Sun, 6 Jan 2013 23:25:41 +0000

 (sent to the wrong address)
 
    ------
 
 From: Christos Zoulas <christos%astron.com@localhost>
 To: gnats%netbsd.org@localhost
 Subject: PR/46826
 Date: Sun,  6 Jan 2013 18:02:44 +0000 (UTC)
 
 
 The following patch avoids the KASSERTS, but the keyboard is unresponsive.
 
 christos
 
 Index: uhci.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/usb/uhci.c,v
 retrieving revision 1.251
 diff -u -p -u -r1.251 uhci.c
 --- uhci.c     5 Jan 2013 23:34:18 -0000       1.251
 +++ uhci.c     6 Jan 2013 17:50:30 -0000
 @@ -1503,14 +1503,14 @@ uhci_idone(uhci_intr_info_t *ii)
        u_int32_t status = 0, nstatus;
        int actlen;
  
 -      KASSERT(mutex_owned(&sc->sc_lock));
 +      KASSERT(sc->sc_bus.use_polling || mutex_owned(&sc->sc_lock));
  
        DPRINTFN(12, ("uhci_idone: ii=%p\n", ii));
  #ifdef DIAGNOSTIC
        {
                /* XXX SMP? */
                int s = splhigh();
 -              if (ii->isdone) {
 +              if (!sc->sc_bus.use_polling && ii->isdone) {
                        splx(s);
  #ifdef UHCI_DEBUG
                        printf("uhci_idone: ii is done!\n   ");
 @@ -1624,7 +1624,7 @@ uhci_idone(uhci_intr_info_t *ii)
  
   end:
        usb_transfer_complete(xfer);
 -      KASSERT(mutex_owned(&sc->sc_lock));
 +      KASSERT(sc->sc_bus.use_polling || mutex_owned(&sc->sc_lock));
        DPRINTFN(12, ("uhci_idone: ii=%p done\n", ii));
  }
  
 @@ -3007,6 +3007,8 @@ uhci_device_intr_done(usbd_xfer_handle x
  
        DPRINTFN(5, ("uhci_device_intr_done: length=%d\n", xfer->actlen));
  
 +      if (sc->sc_bus.use_polling)
 +              return;
        KASSERT(mutex_owned(&sc->sc_lock));
  
        npoll = upipe->u.intr.npoll;
 Index: usbdi.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/usb/usbdi.c,v
 retrieving revision 1.142
 diff -u -p -u -r1.142 usbdi.c
 --- usbdi.c    5 Jan 2013 23:34:20 -0000       1.142
 +++ usbdi.c    6 Jan 2013 17:50:30 -0000
 @@ -787,12 +787,11 @@ usb_transfer_complete(usbd_xfer_handle x
        int erred = xfer->status == USBD_CANCELLED ||
            xfer->status == USBD_TIMEOUT;
        int repeat, polling;
 +      kmutex_t *lock;
  
        DPRINTFN(5, ("usb_transfer_complete: pipe=%p xfer=%p status=%d "
                     "actlen=%d\n", pipe, xfer, xfer->status, xfer->actlen));
  
 -      KASSERT(pipe->device->bus->lock == NULL || 
mutex_owned(pipe->device->bus->lock));
 -
  #ifdef DIAGNOSTIC
        if (xfer->busy_free != XFER_ONQU) {
                printf("usb_transfer_complete: xfer=%p not busy 0x%08x\n",
 @@ -806,11 +805,17 @@ usb_transfer_complete(usbd_xfer_handle x
                return;
        }
  #endif
 -      repeat = pipe->repeat;
        polling = pipe->device->bus->use_polling;
        /* XXXX */
 -      if (polling)
 +      if (polling) {
                pipe->running = 0;
 +              lock = pipe->device->bus->lock;
 +              pipe->device->bus->lock = NULL;
 +      } else
 +              lock = NULL;
 +
 +      KASSERT(pipe->device->bus->lock == NULL || 
mutex_owned(pipe->device->bus->lock));
 +      repeat = pipe->repeat;
  
        if (!(xfer->flags & USBD_NO_COPY) && xfer->actlen != 0 &&
            usbd_xfer_isread(xfer)) {
 @@ -892,6 +897,8 @@ usb_transfer_complete(usbd_xfer_handle x
                else
                        usbd_start_next(pipe);
        }
 +      if (lock)
 +              pipe->device->bus->lock = lock;
  }
  
  /* Called with USB lock held. */
 


Home | Main Index | Thread Index | Old Index