usb: host: xhci: delete sp_dma_buffers for scratchpad
[platform/kernel/linux-starfive.git] / drivers / usb / host / xhci-mem.c
index 032a702..f80bd03 100644 (file)
@@ -288,6 +288,8 @@ void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring)
        if (!ring)
                return;
 
+       trace_xhci_ring_free(ring);
+
        if (ring->first_seg) {
                if (ring->type == TYPE_STREAM)
                        xhci_remove_stream_mapping(ring);
@@ -313,9 +315,6 @@ static void xhci_initialize_ring_info(struct xhci_ring *ring,
         * handling ring expansion, set the cycle state equal to the old ring.
         */
        ring->cycle_state = cycle_state;
-       /* Not necessary for new rings, but needed for re-initialized rings */
-       ring->enq_updates = 0;
-       ring->deq_updates = 0;
 
        /*
         * Each segment has a link TRB, and leave an extra TRB for SW
@@ -400,6 +399,7 @@ static struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci,
                        cpu_to_le32(LINK_TOGGLE);
        }
        xhci_initialize_ring_info(ring, cycle_state);
+       trace_xhci_ring_alloc(ring);
        return ring;
 
 fail:
@@ -504,6 +504,7 @@ int xhci_ring_expansion(struct xhci_hcd *xhci, struct xhci_ring *ring,
        }
 
        xhci_link_rings(xhci, ring, first, last, num_segs);
+       trace_xhci_ring_expansion(ring);
        xhci_dbg_trace(xhci, trace_xhci_dbg_ring_expansion,
                        "ring expansion succeed, now has %d segments",
                        ring->num_segs);
@@ -1502,6 +1503,17 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
         */
        max_esit_payload = xhci_get_max_esit_payload(udev, ep);
        interval = xhci_get_endpoint_interval(udev, ep);
+
+       /* Periodic endpoint bInterval limit quirk */
+       if (usb_endpoint_xfer_int(&ep->desc) ||
+           usb_endpoint_xfer_isoc(&ep->desc)) {
+               if ((xhci->quirks & XHCI_LIMIT_ENDPOINT_INTERVAL_7) &&
+                   udev->speed >= USB_SPEED_HIGH &&
+                   interval >= 7) {
+                       interval = 6;
+               }
+       }
+
        mult = xhci_get_endpoint_mult(udev, ep);
        max_packet = usb_endpoint_maxp(&ep->desc);
        max_burst = xhci_get_endpoint_max_burst(udev, ep);
@@ -1709,36 +1721,27 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
        if (!xhci->scratchpad->sp_buffers)
                goto fail_sp3;
 
-       xhci->scratchpad->sp_dma_buffers =
-               kzalloc(sizeof(dma_addr_t) * num_sp, flags);
-
-       if (!xhci->scratchpad->sp_dma_buffers)
-               goto fail_sp4;
-
        xhci->dcbaa->dev_context_ptrs[0] = cpu_to_le64(xhci->scratchpad->sp_dma);
        for (i = 0; i < num_sp; i++) {
                dma_addr_t dma;
                void *buf = dma_alloc_coherent(dev, xhci->page_size, &dma,
                                flags);
                if (!buf)
-                       goto fail_sp5;
+                       goto fail_sp4;
 
                xhci->scratchpad->sp_array[i] = dma;
                xhci->scratchpad->sp_buffers[i] = buf;
-               xhci->scratchpad->sp_dma_buffers[i] = dma;
        }
 
        return 0;
 
- fail_sp5:
+ fail_sp4:
        for (i = i - 1; i >= 0; i--) {
                dma_free_coherent(dev, xhci->page_size,
                                    xhci->scratchpad->sp_buffers[i],
-                                   xhci->scratchpad->sp_dma_buffers[i]);
+                                   xhci->scratchpad->sp_array[i]);
        }
-       kfree(xhci->scratchpad->sp_dma_buffers);
 
- fail_sp4:
        kfree(xhci->scratchpad->sp_buffers);
 
  fail_sp3:
@@ -1768,9 +1771,8 @@ static void scratchpad_free(struct xhci_hcd *xhci)
        for (i = 0; i < num_sp; i++) {
                dma_free_coherent(dev, xhci->page_size,
                                    xhci->scratchpad->sp_buffers[i],
-                                   xhci->scratchpad->sp_dma_buffers[i]);
+                                   xhci->scratchpad->sp_array[i]);
        }
-       kfree(xhci->scratchpad->sp_dma_buffers);
        kfree(xhci->scratchpad->sp_buffers);
        dma_free_coherent(dev, num_sp * sizeof(u64),
                            xhci->scratchpad->sp_array,
@@ -2419,7 +2421,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
        writel(val, &xhci->op_regs->config_reg);
 
        /*
-        * Section 5.4.8 - doorbell array must be
+        * xHCI section 5.4.6 - doorbell array must be
         * "physically contiguous and 64-byte (cache line) aligned".
         */
        xhci->dcbaa = dma_alloc_coherent(dev, sizeof(*xhci->dcbaa), &dma,
@@ -2601,7 +2603,6 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
        return 0;
 
 fail:
-       xhci_warn(xhci, "Couldn't initialize memory\n");
        xhci_halt(xhci);
        xhci_reset(xhci);
        xhci_mem_cleanup(xhci);