drivers/usb/host/xhci-dbgcap.c
Source file repositories/reference/linux-study-clean/drivers/usb/host/xhci-dbgcap.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/host/xhci-dbgcap.c- Extension
.c- Size
- 36132 bytes
- Lines
- 1561
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bug.hlinux/device.hlinux/dma-mapping.hlinux/errno.hlinux/kstrtox.hlinux/list.hlinux/nls.hlinux/pm_runtime.hlinux/slab.hlinux/spinlock.hlinux/string.hlinux/sysfs.hlinux/types.hlinux/workqueue.hlinux/io-64-nonatomic-lo-hi.hasm/byteorder.hxhci.hxhci-trace.hxhci-dbgcap.h
Detected Declarations
function dbc_free_ctxfunction dbc_ring_freefunction xhci_dbc_init_ep_contextsfunction get_str_desc_lenfunction dbc_prepare_info_context_str_lenfunction xhci_dbc_populate_str_descfunction xhci_dbc_populate_str_descsfunction xhci_dbc_init_contextsfunction xhci_dbc_givebackfunction trb_to_noopfunction xhci_dbc_flush_single_requestfunction xhci_dbc_flush_endpoint_requestsfunction xhci_dbc_flush_requestsfunction dbc_alloc_requestfunction dbc_free_requestfunction xhci_dbc_queue_trbfunction xhci_dbc_queue_bulk_txfunction dbc_ep_do_queuefunction dbc_ep_queuefunction xhci_dbc_do_eps_initfunction xhci_dbc_eps_initfunction xhci_dbc_eps_exitfunction dbc_erst_allocfunction dbc_erst_freefunction dbc_alloc_ctxfunction xhci_dbc_ring_initfunction xhci_dbc_reinit_ep_ringsfunction xhci_dbc_ring_allocfunction xhci_dbc_mem_initfunction xhci_dbc_mem_cleanupfunction xhci_do_dbc_startfunction xhci_do_dbc_stopfunction xhci_dbc_startfunction xhci_dbc_stopfunction handle_ep_halt_changesfunction dbc_handle_port_statusfunction dbc_handle_xfer_eventfunction ClearFeaturefunction inc_evt_deqfunction xhci_dbc_do_handle_eventsfunction xhci_dbc_handle_eventsfunction dbc_showfunction dbc_storefunction dbc_idVendor_showfunction dbc_idVendor_storefunction dbc_idProduct_showfunction dbc_idProduct_storefunction dbc_bcdDevice_show
Annotated Snippet
if (r->trb_dma == event->trans_event.buffer) {
req = r;
break;
}
if (r->status == -COMP_STALL_ERROR) {
dev_warn(dbc->dev, "Give back stale stalled req\n");
ring->num_trbs_free++;
xhci_dbc_giveback(r, 0);
}
}
if (!req) {
dev_warn(dbc->dev, "no matched request\n");
return;
}
trace_xhci_dbc_handle_transfer(ring, &req->trb->generic, req->trb_dma);
switch (comp_code) {
case COMP_SUCCESS:
remain_length = 0;
fallthrough;
case COMP_SHORT_PACKET:
status = 0;
break;
case COMP_TRB_ERROR:
case COMP_BABBLE_DETECTED_ERROR:
case COMP_USB_TRANSACTION_ERROR:
dev_warn(dbc->dev, "tx error %d detected\n", comp_code);
status = -comp_code;
break;
case COMP_STALL_ERROR:
dev_warn(dbc->dev, "Stall error at bulk TRB %llx, remaining %zu, ep deq %llx\n",
event->trans_event.buffer, remain_length, ep_ctx->deq);
status = 0;
dep->halted = 1;
/*
* xHC DbC may trigger a STALL bulk xfer event when host sends a
* ClearFeature(ENDPOINT_HALT) request even if there wasn't an
* active bulk transfer.
*
* Don't give back this transfer request as hardware will later
* start processing TRBs starting from this 'STALLED' TRB,
* causing TRBs and requests to be out of sync.
*
* If STALL event shows some bytes were transferred then assume
* it's an actual transfer issue and give back the request.
* In this case mark the TRB as No-Op to avoid hw from using the
* TRB again.
*/
if ((ep_ctx->deq & ~TRB_CYCLE) == event->trans_event.buffer) {
dev_dbg(dbc->dev, "Ep stopped on Stalled TRB\n");
if (remain_length == req->length) {
dev_dbg(dbc->dev, "Spurious stall event, keep req\n");
req->status = -COMP_STALL_ERROR;
req->actual = 0;
return;
}
dev_dbg(dbc->dev, "Give back stalled req, but turn TRB to No-op\n");
trb_to_noop(req->trb);
}
break;
default:
dev_err(dbc->dev, "unknown tx error %d\n", comp_code);
status = -comp_code;
break;
}
ring->num_trbs_free++;
req->actual = req->length - remain_length;
xhci_dbc_giveback(req, status);
}
static void inc_evt_deq(struct xhci_ring *ring)
{
/* If on the last TRB of the segment go back to the beginning */
if (ring->dequeue == &ring->deq_seg->trbs[TRBS_PER_SEGMENT - 1]) {
ring->cycle_state ^= 1;
ring->dequeue = ring->deq_seg->trbs;
return;
}
ring->dequeue++;
}
static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc)
{
dma_addr_t deq;
Annotation
- Immediate include surface: `linux/bug.h`, `linux/device.h`, `linux/dma-mapping.h`, `linux/errno.h`, `linux/kstrtox.h`, `linux/list.h`, `linux/nls.h`, `linux/pm_runtime.h`.
- Detected declarations: `function dbc_free_ctx`, `function dbc_ring_free`, `function xhci_dbc_init_ep_contexts`, `function get_str_desc_len`, `function dbc_prepare_info_context_str_len`, `function xhci_dbc_populate_str_desc`, `function xhci_dbc_populate_str_descs`, `function xhci_dbc_init_contexts`, `function xhci_dbc_giveback`, `function trb_to_noop`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.