[BACK]Return to xhci.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/xhci.c between version 1.136 and 1.137

version 1.136, 2020/12/22 01:07:23 version 1.137, 2021/01/02 12:39:33
Line 1087  xhci_init(struct xhci_softc *sc)
Line 1087  xhci_init(struct xhci_softc *sc)
         if (sc->sc_maxspbuf != 0) {          if (sc->sc_maxspbuf != 0) {
                 err = usb_allocmem(&sc->sc_bus,                  err = usb_allocmem(&sc->sc_bus,
                     sizeof(uint64_t) * sc->sc_maxspbuf, sizeof(uint64_t),                      sizeof(uint64_t) * sc->sc_maxspbuf, sizeof(uint64_t),
                     USBMALLOC_COHERENT, &sc->sc_spbufarray_dma);                      USBMALLOC_COHERENT | USBMALLOC_ZERO,
                       &sc->sc_spbufarray_dma);
                 if (err) {                  if (err) {
                         aprint_error_dev(sc->sc_dev,                          aprint_error_dev(sc->sc_dev,
                             "spbufarray init fail, err %d\n", err);                              "spbufarray init fail, err %d\n", err);
Line 1101  xhci_init(struct xhci_softc *sc)
Line 1102  xhci_init(struct xhci_softc *sc)
                         usb_dma_t * const dma = &sc->sc_spbuf_dma[i];                          usb_dma_t * const dma = &sc->sc_spbuf_dma[i];
                         /* allocate contexts */                          /* allocate contexts */
                         err = usb_allocmem(&sc->sc_bus, sc->sc_pgsz,                          err = usb_allocmem(&sc->sc_bus, sc->sc_pgsz,
                             sc->sc_pgsz, USBMALLOC_COHERENT, dma);                              sc->sc_pgsz, USBMALLOC_COHERENT | USBMALLOC_ZERO,
                               dma);
                         if (err) {                          if (err) {
                                 aprint_error_dev(sc->sc_dev,                                  aprint_error_dev(sc->sc_dev,
                                     "spbufarray_dma init fail, err %d\n", err);                                      "spbufarray_dma init fail, err %d\n", err);
Line 1149  xhci_init(struct xhci_softc *sc)
Line 1151  xhci_init(struct xhci_softc *sc)
             XHCI_EVENT_RING_SEGMENT_TABLE_ALIGN);              XHCI_EVENT_RING_SEGMENT_TABLE_ALIGN);
         KASSERTMSG(size <= (512 * 1024), "eventst size %zu too large", size);          KASSERTMSG(size <= (512 * 1024), "eventst size %zu too large", size);
         align = XHCI_EVENT_RING_SEGMENT_TABLE_ALIGN;          align = XHCI_EVENT_RING_SEGMENT_TABLE_ALIGN;
         err = usb_allocmem(&sc->sc_bus, size, align, USBMALLOC_COHERENT, dma);          err = usb_allocmem(&sc->sc_bus, size, align,
               USBMALLOC_COHERENT | USBMALLOC_ZERO, dma);
         if (err) {          if (err) {
                 aprint_error_dev(sc->sc_dev, "eventst init fail, err %d\n",                  aprint_error_dev(sc->sc_dev, "eventst init fail, err %d\n",
                     err);                      err);
Line 1157  xhci_init(struct xhci_softc *sc)
Line 1160  xhci_init(struct xhci_softc *sc)
                 goto bad3;                  goto bad3;
         }          }
   
         memset(KERNADDR(dma, 0), 0, size);  
         usb_syncmem(dma, 0, size, BUS_DMASYNC_PREWRITE);  
         aprint_debug_dev(sc->sc_dev, "eventst: 0x%016jx %p %zx\n",          aprint_debug_dev(sc->sc_dev, "eventst: 0x%016jx %p %zx\n",
             (uintmax_t)DMAADDR(&sc->sc_eventst_dma, 0),              (uintmax_t)DMAADDR(&sc->sc_eventst_dma, 0),
             KERNADDR(&sc->sc_eventst_dma, 0),              KERNADDR(&sc->sc_eventst_dma, 0),
Line 1168  xhci_init(struct xhci_softc *sc)
Line 1169  xhci_init(struct xhci_softc *sc)
         size = (1 + sc->sc_maxslots) * sizeof(uint64_t);          size = (1 + sc->sc_maxslots) * sizeof(uint64_t);
         KASSERTMSG(size <= 2048, "dcbaa size %zu too large", size);          KASSERTMSG(size <= 2048, "dcbaa size %zu too large", size);
         align = XHCI_DEVICE_CONTEXT_BASE_ADDRESS_ARRAY_ALIGN;          align = XHCI_DEVICE_CONTEXT_BASE_ADDRESS_ARRAY_ALIGN;
         err = usb_allocmem(&sc->sc_bus, size, align, USBMALLOC_COHERENT, dma);          err = usb_allocmem(&sc->sc_bus, size, align,
               USBMALLOC_COHERENT | USBMALLOC_ZERO, dma);
         if (err) {          if (err) {
                 aprint_error_dev(sc->sc_dev, "dcbaa init fail, err %d\n", err);                  aprint_error_dev(sc->sc_dev, "dcbaa init fail, err %d\n", err);
                 rv = ENOMEM;                  rv = ENOMEM;
Line 1179  xhci_init(struct xhci_softc *sc)
Line 1181  xhci_init(struct xhci_softc *sc)
             KERNADDR(&sc->sc_dcbaa_dma, 0),              KERNADDR(&sc->sc_dcbaa_dma, 0),
             sc->sc_dcbaa_dma.udma_block->size);              sc->sc_dcbaa_dma.udma_block->size);
   
         memset(KERNADDR(dma, 0), 0, size);  
         if (sc->sc_maxspbuf != 0) {          if (sc->sc_maxspbuf != 0) {
                 /*                  /*
                  * DCBA entry 0 hold the scratchbuf array pointer.                   * DCBA entry 0 hold the scratchbuf array pointer.
                  */                   */
                 *(uint64_t *)KERNADDR(dma, 0) =                  *(uint64_t *)KERNADDR(dma, 0) =
                     htole64(DMAADDR(&sc->sc_spbufarray_dma, 0));                      htole64(DMAADDR(&sc->sc_spbufarray_dma, 0));
                   usb_syncmem(dma, 0, size, BUS_DMASYNC_PREWRITE);
         }          }
         usb_syncmem(dma, 0, size, BUS_DMASYNC_PREWRITE);  
   
         sc->sc_slots = kmem_zalloc(sizeof(*sc->sc_slots) * sc->sc_maxslots,          sc->sc_slots = kmem_zalloc(sizeof(*sc->sc_slots) * sc->sc_maxslots,
             KM_SLEEP);              KM_SLEEP);
Line 2580  xhci_ring_init(struct xhci_softc * const
Line 2581  xhci_ring_init(struct xhci_softc * const
         xr = kmem_zalloc(sizeof(struct xhci_ring), KM_SLEEP);          xr = kmem_zalloc(sizeof(struct xhci_ring), KM_SLEEP);
         DPRINTFN(1, "ring %#jx", (uintptr_t)xr, 0, 0, 0);          DPRINTFN(1, "ring %#jx", (uintptr_t)xr, 0, 0, 0);
   
         err = usb_allocmem(&sc->sc_bus, size, align, USBMALLOC_COHERENT,          err = usb_allocmem(&sc->sc_bus, size, align,
             &xr->xr_dma);              USBMALLOC_COHERENT | USBMALLOC_ZERO, &xr->xr_dma);
         if (err) {          if (err) {
                 kmem_free(xr, sizeof(struct xhci_ring));                  kmem_free(xr, sizeof(struct xhci_ring));
                 DPRINTFN(1, "alloc xr_dma failed %jd", err, 0, 0, 0);                  DPRINTFN(1, "alloc xr_dma failed %jd", err, 0, 0, 0);
Line 3020  xhci_init_slot(struct usbd_device *dev, 
Line 3021  xhci_init_slot(struct usbd_device *dev, 
   
         /* allocate contexts */          /* allocate contexts */
         err = usb_allocmem(&sc->sc_bus, sc->sc_pgsz, sc->sc_pgsz,          err = usb_allocmem(&sc->sc_bus, sc->sc_pgsz, sc->sc_pgsz,
             USBMALLOC_COHERENT, &xs->xs_dc_dma);              USBMALLOC_COHERENT | USBMALLOC_ZERO, &xs->xs_dc_dma);
         if (err) {          if (err) {
                 DPRINTFN(1, "failed to allocmem output device context %jd",                  DPRINTFN(1, "failed to allocmem output device context %jd",
                     err, 0, 0, 0);                      err, 0, 0, 0);
                 return err;                  return err;
         }          }
         memset(KERNADDR(&xs->xs_dc_dma, 0), 0, sc->sc_pgsz);  
   
         err = usb_allocmem(&sc->sc_bus, sc->sc_pgsz, sc->sc_pgsz,          err = usb_allocmem(&sc->sc_bus, sc->sc_pgsz, sc->sc_pgsz,
             USBMALLOC_COHERENT, &xs->xs_ic_dma);              USBMALLOC_COHERENT | USBMALLOC_ZERO, &xs->xs_ic_dma);
         if (err) {          if (err) {
                 DPRINTFN(1, "failed to allocmem input device context %jd",                  DPRINTFN(1, "failed to allocmem input device context %jd",
                     err, 0, 0, 0);                      err, 0, 0, 0);
                 goto bad1;                  goto bad1;
         }          }
         memset(KERNADDR(&xs->xs_ic_dma, 0), 0, sc->sc_pgsz);  
   
         memset(&xs->xs_xr[0], 0, sizeof(xs->xs_xr));          memset(&xs->xs_xr[0], 0, sizeof(xs->xs_xr));
         xs->xs_idx = slot;          xs->xs_idx = slot;

Legend:
Removed from v.1.136  
changed lines
  Added in v.1.137

CVSweb <webmaster@jp.NetBSD.org>