[BACK]Return to ehci.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / dev / usb

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/dev/usb/ehci.c between version 1.296 and 1.297

version 1.296, 2021/12/22 21:36:40 version 1.297, 2021/12/22 21:45:02
Line 489  ehci_init(ehci_softc_t *sc)
Line 489  ehci_init(ehci_softc_t *sc)
         sc->sc_bus.ub_usedma = true;          sc->sc_bus.ub_usedma = true;
         sc->sc_bus.ub_dmaflags = USBMALLOC_MULTISEG;          sc->sc_bus.ub_dmaflags = USBMALLOC_MULTISEG;
   
           /*
            * The bus attachment code will possibly provide a 64bit DMA
            * tag which we now limit to the bottom 4G range as
            *
            * - that's as much as ehci can address in its QH, TD, iTD, and siTD
            *   structures; and
            * - the driver doesn't currently set EHCI_CTRLDSSEGMENT to anything
            *   other than 0.
            */
           bus_dma_tag_t ntag;
           sc->sc_dmatag = sc->sc_bus.ub_dmatag;
           err = bus_dmatag_subregion(sc->sc_bus.ub_dmatag, 0, UINT32_MAX,
               &ntag, 0);
           if (err == 0) {
                   sc->sc_dmatag = ntag;
                   aprint_normal_dev(sc->sc_dev, "Using DMA subregion for control"
                       " data structures\n");
           }
   
         /* Reset the controller */          /* Reset the controller */
         DPRINTF("resetting", 0, 0, 0, 0);          DPRINTF("resetting", 0, 0, 0, 0);
         EOWRITE4(sc, EHCI_USBCMD, 0);   /* Halt controller */          EOWRITE4(sc, EHCI_USBCMD, 0);   /* Halt controller */
Line 501  ehci_init(ehci_softc_t *sc)
Line 520  ehci_init(ehci_softc_t *sc)
                         break;                          break;
         }          }
         if (hcr) {          if (hcr) {
                 aprint_error("%s: reset timeout\n", device_xname(sc->sc_dev));                  aprint_error_dev(sc->sc_dev, "reset timeout\n");
                 return EIO;                  err = EIO;
                   goto fail1;
         }          }
         if (sc->sc_vendor_init)          if (sc->sc_vendor_init)
                 sc->sc_vendor_init(sc);                  sc->sc_vendor_init(sc);
Line 515  ehci_init(ehci_softc_t *sc)
Line 535  ehci_init(ehci_softc_t *sc)
         case 0: sc->sc_flsize = 1024; break;          case 0: sc->sc_flsize = 1024; break;
         case 1: sc->sc_flsize = 512; break;          case 1: sc->sc_flsize = 512; break;
         case 2: sc->sc_flsize = 256; break;          case 2: sc->sc_flsize = 256; break;
         case 3: return EIO;          case 3:
                   err = EIO;
                   goto fail1;
         }          }
         err = usb_allocmem(sc->sc_bus.ub_dmatag,          err = usb_allocmem(sc->sc_bus.ub_dmatag,
             sc->sc_flsize * sizeof(ehci_link_t),              sc->sc_flsize * sizeof(ehci_link_t),
             EHCI_FLALIGN_ALIGN, USBMALLOC_COHERENT, &sc->sc_fldma);              EHCI_FLALIGN_ALIGN, USBMALLOC_COHERENT, &sc->sc_fldma);
         if (err)          if (err) {
                 return err;                  aprint_error_dev(sc->sc_dev, "failed to allocate frame list\n");
                   goto fail1;
           }
         DPRINTF("flsize=%jd", sc->sc_flsize, 0, 0, 0);          DPRINTF("flsize=%jd", sc->sc_flsize, 0, 0, 0);
         sc->sc_flist = KERNADDR(&sc->sc_fldma, 0);          sc->sc_flist = KERNADDR(&sc->sc_fldma, 0);
   
Line 529  ehci_init(ehci_softc_t *sc)
Line 553  ehci_init(ehci_softc_t *sc)
                 sc->sc_flist[i] = EHCI_NULL;                  sc->sc_flist[i] = EHCI_NULL;
         }          }
   
         EOWRITE4(sc, EHCI_PERIODICLISTBASE, DMAADDR(&sc->sc_fldma, 0));          KASSERT(BUS_ADDR_HI32(DMAADDR(&sc->sc_fldma, 0)) == 0);
           uint32_t lo32 = BUS_ADDR_LO32(DMAADDR(&sc->sc_fldma, 0));
   
           EOWRITE4(sc, EHCI_PERIODICLISTBASE, lo32);
   
         sc->sc_softitds = kmem_zalloc(sc->sc_flsize * sizeof(ehci_soft_itd_t *),          sc->sc_softitds = kmem_zalloc(sc->sc_flsize * sizeof(ehci_soft_itd_t *),
             KM_SLEEP);              KM_SLEEP);
Line 547  ehci_init(ehci_softc_t *sc)
Line 574  ehci_init(ehci_softc_t *sc)
          * Allocate the interrupt dummy QHs. These are arranged to give poll           * Allocate the interrupt dummy QHs. These are arranged to give poll
          * intervals that are powers of 2 times 1ms.           * intervals that are powers of 2 times 1ms.
          */           */
           memset(sc->sc_islots, 0, sizeof(sc->sc_islots));
         for (i = 0; i < EHCI_INTRQHS; i++) {          for (i = 0; i < EHCI_INTRQHS; i++) {
                 sqh = ehci_alloc_sqh(sc);                  sqh = ehci_alloc_sqh(sc);
                 if (sqh == NULL) {                  if (sqh == NULL) {
                         err = ENOMEM;                          err = ENOMEM;
                         goto bad1;                          goto fail2;
                 }                  }
                 sc->sc_islots[i].sqh = sqh;                  sc->sc_islots[i].sqh = sqh;
         }          }
Line 594  ehci_init(ehci_softc_t *sc)
Line 622  ehci_init(ehci_softc_t *sc)
         sqh = ehci_alloc_sqh(sc);          sqh = ehci_alloc_sqh(sc);
         if (sqh == NULL) {          if (sqh == NULL) {
                 err = ENOMEM;                  err = ENOMEM;
                 goto bad1;                  goto fail2;
         }          }
         /* Fill the QH */          /* Fill the QH */
         sqh->qh.qh_endp =          sqh->qh.qh_endp =
Line 641  ehci_init(ehci_softc_t *sc)
Line 669  ehci_init(ehci_softc_t *sc)
         }          }
         if (hcr) {          if (hcr) {
                 aprint_error("%s: run timeout\n", device_xname(sc->sc_dev));                  aprint_error("%s: run timeout\n", device_xname(sc->sc_dev));
                 return EIO;                  err = EIO;
                   goto fail3;
         }          }
   
         /* Enable interrupts */          /* Enable interrupts */
Line 650  ehci_init(ehci_softc_t *sc)
Line 679  ehci_init(ehci_softc_t *sc)
   
         return 0;          return 0;
   
 #if 0  fail3:
  bad2:  
         ehci_free_sqh(sc, sc->sc_async_head);          ehci_free_sqh(sc, sc->sc_async_head);
 #endif  
  bad1:  fail2:
           for (i = 0; i < EHCI_INTRQHS; i++) {
                   sqh = sc->sc_islots[i].sqh;
                   if (sqh)
                           ehci_free_sqh(sc, sqh);
           }
   
           kmem_free(sc->sc_softitds, sc->sc_flsize * sizeof(ehci_soft_itd_t *));
         usb_freemem(&sc->sc_fldma);          usb_freemem(&sc->sc_fldma);
   
   fail1:
           softint_disestablish(sc->sc_doorbell_si);
           softint_disestablish(sc->sc_pcd_si);
           mutex_destroy(&sc->sc_lock);
           mutex_destroy(&sc->sc_intr_lock);
   
         return err;          return err;
 }  }
   
Line 2000  ehci_open(struct usbd_pipe *pipe)
Line 2042  ehci_open(struct usbd_pipe *pipe)
   
         switch (xfertype) {          switch (xfertype) {
         case UE_CONTROL:          case UE_CONTROL:
                   /* we can use 64bit DMA for the reqdma buffer */
                 err = usb_allocmem(sc->sc_bus.ub_dmatag,                  err = usb_allocmem(sc->sc_bus.ub_dmatag,
                     sizeof(usb_device_request_t), 0, USBMALLOC_COHERENT,                      sizeof(usb_device_request_t), 0, USBMALLOC_COHERENT,
                     &epipe->ctrl.reqdma);                      &epipe->ctrl.reqdma);
Line 2798  ehci_alloc_sqh(ehci_softc_t *sc)
Line 2841  ehci_alloc_sqh(ehci_softc_t *sc)
                 mutex_exit(&sc->sc_lock);                  mutex_exit(&sc->sc_lock);
   
                 usb_dma_t dma;                  usb_dma_t dma;
                 int err = usb_allocmem(sc->sc_bus.ub_dmatag,                  int err = usb_allocmem(sc->sc_dmatag,
                     EHCI_SQH_SIZE * EHCI_SQH_CHUNK,                      EHCI_SQH_SIZE * EHCI_SQH_CHUNK,
                     EHCI_PAGE_SIZE, USBMALLOC_COHERENT, &dma);                      EHCI_PAGE_SIZE, USBMALLOC_COHERENT, &dma);
   
Line 2854  ehci_alloc_sqtd(ehci_softc_t *sc)
Line 2897  ehci_alloc_sqtd(ehci_softc_t *sc)
                 mutex_exit(&sc->sc_lock);                  mutex_exit(&sc->sc_lock);
   
                 usb_dma_t dma;                  usb_dma_t dma;
                 int err = usb_allocmem(sc->sc_bus.ub_dmatag,                  int err = usb_allocmem(sc->sc_dmatag,
                     EHCI_SQTD_SIZE * EHCI_SQTD_CHUNK,                      EHCI_SQTD_SIZE * EHCI_SQTD_CHUNK,
                     EHCI_PAGE_SIZE, USBMALLOC_COHERENT, &dma);                      EHCI_PAGE_SIZE, USBMALLOC_COHERENT, &dma);
   
Line 3114  ehci_alloc_itd(ehci_softc_t *sc)
Line 3157  ehci_alloc_itd(ehci_softc_t *sc)
                 mutex_exit(&sc->sc_lock);                  mutex_exit(&sc->sc_lock);
   
                 usb_dma_t dma;                  usb_dma_t dma;
                 int err = usb_allocmem(sc->sc_bus.ub_dmatag,                  int err = usb_allocmem(sc->sc_dmatag,
                     EHCI_ITD_SIZE * EHCI_ITD_CHUNK,                      EHCI_ITD_SIZE * EHCI_ITD_CHUNK,
                     EHCI_PAGE_SIZE, USBMALLOC_COHERENT, &dma);                      EHCI_PAGE_SIZE, USBMALLOC_COHERENT, &dma);
   

Legend:
Removed from v.1.296  
changed lines
  Added in v.1.297

CVSweb <webmaster@jp.NetBSD.org>