drivers/usb/host/xhci-debugfs.c
Source file repositories/reference/linux-study-clean/drivers/usb/host/xhci-debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/host/xhci-debugfs.c- Extension
.c- Size
- 22033 bytes
- Lines
- 855
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/slab.hlinux/uaccess.hxhci.hxhci-debugfs.h
Detected Declarations
function xhci_debugfs_free_regsetfunction xhci_debugfs_regsetfunction xhci_debugfs_extcap_regsetfunction xhci_ring_enqueue_showfunction xhci_ring_dequeue_showfunction xhci_ring_cycle_showfunction xhci_ring_dump_segmentfunction xhci_ring_trb_showfunction xhci_ring_openfunction xhci_slot_context_showfunction xhci_endpoint_context_showfunction xhci_device_name_showfunction xhci_context_openfunction xhci_portsc_showfunction xhci_port_openfunction xhci_port_writefunction xhci_portli_showfunction xhci_portli_openfunction xhci_debugfs_create_filesfunction xhci_debugfs_create_context_filesfunction xhci_debugfs_create_endpointfunction xhci_debugfs_remove_endpointfunction xhci_stream_id_showfunction xhci_stream_id_openfunction xhci_stream_id_writefunction xhci_stream_context_array_showfunction xhci_debugfs_create_stream_filesfunction xhci_debugfs_create_slotfunction xhci_debugfs_remove_slotfunction xhci_debugfs_create_portsfunction xhci_port_bw_showfunction xhci_ss_bw_showfunction xhci_hs_bw_showfunction xhci_fs_bw_showfunction bw_context_openfunction xhci_debugfs_create_bandwidthfunction xhci_debugfs_initfunction xhci_debugfs_exitfunction xhci_debugfs_create_rootfunction xhci_debugfs_remove_root
Annotated Snippet
static const struct file_operations xhci_ring_fops = {
.open = xhci_ring_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static int xhci_slot_context_show(struct seq_file *s, void *unused)
{
struct xhci_hcd *xhci;
struct xhci_slot_ctx *slot_ctx;
struct xhci_slot_priv *priv = s->private;
struct xhci_virt_device *dev = priv->dev;
char str[XHCI_MSG_MAX];
xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus));
slot_ctx = xhci_get_slot_ctx(xhci, dev->out_ctx);
seq_printf(s, "%pad: %s\n", &dev->out_ctx->dma,
xhci_decode_slot_context(str,
le32_to_cpu(slot_ctx->dev_info),
le32_to_cpu(slot_ctx->dev_info2),
le32_to_cpu(slot_ctx->tt_info),
le32_to_cpu(slot_ctx->dev_state)));
return 0;
}
static int xhci_endpoint_context_show(struct seq_file *s, void *unused)
{
int ep_index;
dma_addr_t dma;
struct xhci_hcd *xhci;
struct xhci_ep_ctx *ep_ctx;
struct xhci_slot_priv *priv = s->private;
struct xhci_virt_device *dev = priv->dev;
char str[XHCI_MSG_MAX];
xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus));
for (ep_index = 0; ep_index < 31; ep_index++) {
ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, ep_index);
dma = dev->out_ctx->dma + (ep_index + 1) * CTX_SIZE(xhci->hcc_params);
seq_printf(s, "%pad: %s, virt_state:%#x\n", &dma,
xhci_decode_ep_context(str,
le32_to_cpu(ep_ctx->ep_info),
le32_to_cpu(ep_ctx->ep_info2),
le64_to_cpu(ep_ctx->deq),
le32_to_cpu(ep_ctx->tx_info)),
dev->eps[ep_index].ep_state);
}
return 0;
}
static int xhci_device_name_show(struct seq_file *s, void *unused)
{
struct xhci_slot_priv *priv = s->private;
struct xhci_virt_device *dev = priv->dev;
seq_printf(s, "%s\n", dev_name(&dev->udev->dev));
return 0;
}
static struct xhci_file_map context_files[] = {
{"name", xhci_device_name_show, },
{"slot-context", xhci_slot_context_show, },
{"ep-context", xhci_endpoint_context_show, },
};
static int xhci_context_open(struct inode *inode, struct file *file)
{
const struct xhci_file_map *f_map = debugfs_get_aux(file);
return single_open(file, f_map->show, inode->i_private);
}
static const struct file_operations xhci_context_fops = {
.open = xhci_context_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static int xhci_portsc_show(struct seq_file *s, void *unused)
{
struct xhci_port *port = s->private;
u32 portsc;
Annotation
- Immediate include surface: `linux/slab.h`, `linux/uaccess.h`, `xhci.h`, `xhci-debugfs.h`.
- Detected declarations: `function xhci_debugfs_free_regset`, `function xhci_debugfs_regset`, `function xhci_debugfs_extcap_regset`, `function xhci_ring_enqueue_show`, `function xhci_ring_dequeue_show`, `function xhci_ring_cycle_show`, `function xhci_ring_dump_segment`, `function xhci_ring_trb_show`, `function xhci_ring_open`, `function xhci_slot_context_show`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.