Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: xhci: move ring initialization

Move ring initialization from xhci_ring_alloc() to xhci_ring_init().
Call xhci_ring_init() after xhci_ring_alloc(); in the future,
it can also be used to re-initialize the ring during resume.

Additionally, remove xhci_dbg_trace() from xhci_mem_init(). The command
ring's first segment DMA address is now printed during the trace call in
xhci_ring_init().

This refactoring lays also the groundwork for eventually replacing:
* xhci_dbc_ring_init()
* xhci_clear_command_ring()

Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://patch.msgid.link/20260402131342.2628648-9-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Niklas Neronin and committed by
Greg Kroah-Hartman
e4573f49 b1ebf192

+18 -5
+14 -5
drivers/usb/host/xhci-mem.c
··· 129 129 ring->last_seg->trbs[TRBS_PER_SEGMENT - 1].link.control |= cpu_to_le32(LINK_TOGGLE); 130 130 } 131 131 132 + void xhci_ring_init(struct xhci_hcd *xhci, struct xhci_ring *ring) 133 + { 134 + xhci_initialize_ring_segments(xhci, ring); 135 + xhci_initialize_ring_info(ring); 136 + trace_xhci_ring_alloc(ring); 137 + } 138 + 132 139 /* 133 140 * Link the src ring segments to the dst ring. 134 141 * Set Toggle Cycle for the new ring if needed. ··· 396 389 if (ret) 397 390 goto fail; 398 391 399 - xhci_initialize_ring_segments(xhci, ring); 400 - xhci_initialize_ring_info(ring); 401 - trace_xhci_ring_alloc(ring); 402 392 return ring; 403 393 404 394 fail: ··· 672 668 cur_ring = stream_info->stream_rings[cur_stream]; 673 669 if (!cur_ring) 674 670 goto cleanup_rings; 671 + 672 + xhci_ring_init(xhci, cur_ring); 675 673 cur_ring->stream_id = cur_stream; 676 674 cur_ring->trb_address_map = &stream_info->trb_address_map; 677 675 /* Set deq ptr, cycle bit, and stream context type */ ··· 1016 1010 dev->eps[0].ring = xhci_ring_alloc(xhci, 2, TYPE_CTRL, 0, flags); 1017 1011 if (!dev->eps[0].ring) 1018 1012 goto fail; 1013 + 1014 + xhci_ring_init(xhci, dev->eps[0].ring); 1019 1015 1020 1016 dev->udev = udev; 1021 1017 ··· 1500 1492 1501 1493 virt_dev->eps[ep_index].skip = false; 1502 1494 ep_ring = virt_dev->eps[ep_index].new_ring; 1495 + xhci_ring_init(xhci, ep_ring); 1503 1496 1504 1497 /* Fill the endpoint context */ 1505 1498 ep_ctx->ep_info = cpu_to_le32(EP_MAX_ESIT_PAYLOAD_HI(max_esit_payload) | ··· 2379 2370 if (!ir) 2380 2371 return NULL; 2381 2372 2373 + xhci_ring_init(xhci, ir->event_ring); 2374 + 2382 2375 spin_lock_irq(&xhci->lock); 2383 2376 if (!intr_num) { 2384 2377 /* Find available secondary interrupter, interrupter 0 is reserved for primary */ ··· 2493 2482 goto fail; 2494 2483 2495 2484 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Allocated command ring at %p", xhci->cmd_ring); 2496 - xhci_dbg_trace(xhci, trace_xhci_dbg_init, "First segment DMA is 0x%pad", 2497 - &xhci->cmd_ring->first_seg->dma); 2498 2485 2499 2486 /* Allocate and set up primary interrupter 0 with an event ring. */ 2500 2487 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Allocating primary event ring");
+3
drivers/usb/host/xhci.c
··· 564 564 /* Set the Number of Device Slots Enabled to the maximum supported value */ 565 565 xhci_enable_max_dev_slots(xhci); 566 566 567 + /* Initialize the Command ring */ 568 + xhci_ring_init(xhci, xhci->cmd_ring); 567 569 /* 568 570 * Reserve one command ring TRB for disabling LPM. 569 571 * Since the USB core grabs the shared usb_bus bandwidth mutex before ··· 585 583 xhci_set_dev_notifications(xhci); 586 584 587 585 /* Initialize the Primary interrupter */ 586 + xhci_ring_init(xhci, xhci->interrupters[0]->event_ring); 588 587 xhci_add_interrupter(xhci, 0); 589 588 xhci->interrupters[0]->isoc_bei_interval = AVOID_BEI_INTERVAL_MAX; 590 589
+1
drivers/usb/host/xhci.h
··· 1824 1824 int xhci_ring_expansion(struct xhci_hcd *xhci, struct xhci_ring *ring, 1825 1825 unsigned int num_trbs, gfp_t flags); 1826 1826 void xhci_initialize_ring_info(struct xhci_ring *ring); 1827 + void xhci_ring_init(struct xhci_hcd *xhci, struct xhci_ring *ring); 1827 1828 void xhci_free_endpoint_ring(struct xhci_hcd *xhci, 1828 1829 struct xhci_virt_device *virt_dev, 1829 1830 unsigned int ep_index);