drivers/usb/host/xhci-hub.c
Source file repositories/reference/linux-study-clean/drivers/usb/host/xhci-hub.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/host/xhci-hub.c- Extension
.c- Size
- 57468 bytes
- Lines
- 1969
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/slab.hlinux/unaligned.hlinux/bitfield.hlinux/pci.hxhci.hxhci-trace.h
Detected Declarations
function xhci_create_usb3x_bos_descfunction xhci_common_hub_descriptorfunction xhci_usb2_hub_descriptorfunction xhci_usb3_hub_descriptorfunction xhci_hub_descriptorfunction xhci_port_speedfunction Zerofunction xhci_stop_devicefunction xhci_ring_devicefunction xhci_disable_portfunction xhci_clear_port_change_bitfunction xhci_set_port_powerfunction xhci_port_set_test_modefunction xhci_enter_test_modefunction xhci_exit_test_modefunction xhci_port_is_tunneledfunction xhci_set_link_statefunction xhci_set_remote_wake_maskfunction xhci_test_and_clear_bitfunction xhci_hub_report_usb3_link_statefunction xhci_del_comp_mod_timerfunction xhci_handle_usb2_port_link_resumefunction xhci_get_ext_port_statusfunction xhci_get_usb3_port_statusfunction xhci_get_usb2_port_statusfunction xhci_get_port_statusfunction xhci_hub_controlfunction Enabledfunction xhci_hub_status_datafunction xhci_bus_suspendfunction Statusfunction xhci_bus_resumefunction for_each_set_bitfunction xhci_get_resuming_portsexport xhci_port_state_to_neutralexport xhci_hub_control
Annotated Snippet
if (i == 0 || bcdUSB < rev) {
bcdUSB = rev;
port_cap = &xhci->port_caps[i];
}
}
if (bcdUSB >= 0x0310) {
if (port_cap->psi_count) {
u8 num_sym_ssa = 0;
for (i = 0; i < port_cap->psi_count; i++) {
if ((port_cap->psi[i] & PLT_MASK) == PLT_SYM)
num_sym_ssa++;
}
ssac = port_cap->psi_count + num_sym_ssa - 1;
ssic = port_cap->psi_uid_count - 1;
} else {
if (bcdUSB >= 0x0320)
ssac = 7;
else
ssac = 3;
ssic = (ssac + 1) / 2 - 1;
}
bos->bNumDeviceCaps++;
bos->wTotalLength = cpu_to_le16(USB_DT_BOS_SIZE +
USB_DT_USB_SS_CAP_SIZE +
USB_DT_USB_SSP_CAP_SIZE(ssac));
}
if (wLength < USB_DT_BOS_SIZE + USB_DT_USB_SS_CAP_SIZE)
return wLength;
/* SuperSpeed USB Device Capability */
ss_cap = (struct usb_ss_cap_descriptor *)&buf[USB_DT_BOS_SIZE];
ss_cap->bLength = USB_DT_USB_SS_CAP_SIZE;
ss_cap->bDescriptorType = USB_DT_DEVICE_CAPABILITY;
ss_cap->bDevCapabilityType = USB_SS_CAP_TYPE;
ss_cap->bmAttributes = 0; /* set later */
ss_cap->wSpeedSupported = cpu_to_le16(USB_5GBPS_OPERATION);
ss_cap->bFunctionalitySupport = USB_LOW_SPEED_OPERATION;
ss_cap->bU1devExitLat = 0; /* set later */
ss_cap->bU2DevExitLat = 0; /* set later */
reg = readl(&xhci->cap_regs->hcc_params);
if (reg & HCC_LTC)
ss_cap->bmAttributes |= USB_LTM_SUPPORT;
if ((xhci->quirks & XHCI_LPM_SUPPORT)) {
reg = readl(&xhci->cap_regs->hcs_params3);
ss_cap->bU1devExitLat = HCS_U1_LATENCY(reg);
ss_cap->bU2DevExitLat = cpu_to_le16(HCS_U2_LATENCY(reg));
}
if (wLength < le16_to_cpu(bos->wTotalLength))
return wLength;
if (bcdUSB < 0x0310)
return le16_to_cpu(bos->wTotalLength);
ssp_cap = (struct usb_ssp_cap_descriptor *)&buf[USB_DT_BOS_SIZE +
USB_DT_USB_SS_CAP_SIZE];
ssp_cap->bLength = USB_DT_USB_SSP_CAP_SIZE(ssac);
ssp_cap->bDescriptorType = USB_DT_DEVICE_CAPABILITY;
ssp_cap->bDevCapabilityType = USB_SSP_CAP_TYPE;
ssp_cap->bReserved = 0;
ssp_cap->wReserved = 0;
ssp_cap->bmAttributes =
cpu_to_le32(FIELD_PREP(USB_SSP_SUBLINK_SPEED_ATTRIBS, ssac) |
FIELD_PREP(USB_SSP_SUBLINK_SPEED_IDS, ssic));
if (!port_cap->psi_count) {
for (i = 0; i < ssac + 1; i++)
ssp_cap->bmSublinkSpeedAttr[i] =
cpu_to_le32(ssp_cap_default_ssa[i]);
min_ssid = 4;
goto out;
}
offset = 0;
for (i = 0; i < port_cap->psi_count; i++) {
u32 psi;
u32 attr;
u8 ssid;
u8 lp;
u8 lse;
u8 psie;
Annotation
- Immediate include surface: `linux/slab.h`, `linux/unaligned.h`, `linux/bitfield.h`, `linux/pci.h`, `xhci.h`, `xhci-trace.h`.
- Detected declarations: `function xhci_create_usb3x_bos_desc`, `function xhci_common_hub_descriptor`, `function xhci_usb2_hub_descriptor`, `function xhci_usb3_hub_descriptor`, `function xhci_hub_descriptor`, `function xhci_port_speed`, `function Zero`, `function xhci_stop_device`, `function xhci_ring_device`, `function xhci_disable_port`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.