drivers/usb/host/ehci-sched.c
Source file repositories/reference/linux-study-clean/drivers/usb/host/ehci-sched.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/host/ehci-sched.c- Extension
.c- Size
- 65222 bytes
- Lines
- 2491
- 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.
- 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
- No C-style include directives detected by the generator.
Detected Declarations
function periodic_next_shadowfunction shadow_next_periodicfunction periodic_unlinkfunction drop_ttfunction bandwidth_dbgfunction reserve_release_intr_bandwidthfunction compute_tt_budgetfunction same_ttfunction carryover_tt_bandwidthfunction lengthfunction tt_no_collisionfunction enable_periodicfunction disable_periodicfunction qh_link_periodicfunction qh_unlink_periodicfunction cancel_unlink_wait_intrfunction start_unlink_intrfunction completefunction end_unlink_intrfunction check_periodfunction check_intr_schedulefunction qh_schedulefunction intr_submitfunction scan_intrfunction list_for_each_entry_safefunction iso_stream_allocfunction iso_stream_initfunction iso_stream_findfunction iso_sched_allocfunction itd_sched_initfunction iso_sched_freefunction itd_urb_transactionfunction reserve_release_iso_bandwidthfunction itd_slot_okfunction sitd_slot_okfunction iso_stream_schedulefunction ehci_to_hcdfunction itd_initfunction itd_patchfunction itd_linkfunction itd_link_urbfunction assumingfunction itd_submitfunction sitd_sched_initfunction sitd_urb_transactionfunction INfunction sitd_patchfunction sitd_link
Annotated Snippet
if (!tt_index) { /* Create the index array */
tt_index = kzalloc_objs(*tt_index, utt->hub->maxchild,
GFP_ATOMIC);
if (!tt_index)
return ERR_PTR(-ENOMEM);
utt->hcpriv = tt_index;
allocated_index = true;
}
port = udev->ttport - 1;
ptt = &tt_index[port];
} else {
port = 0;
ptt = (struct ehci_tt **) &utt->hcpriv;
}
tt = *ptt;
if (!tt) { /* Create the ehci_tt */
struct ehci_hcd *ehci =
hcd_to_ehci(bus_to_hcd(udev->bus));
tt = kzalloc_obj(*tt, GFP_ATOMIC);
if (!tt) {
if (allocated_index) {
utt->hcpriv = NULL;
kfree(tt_index);
}
return ERR_PTR(-ENOMEM);
}
list_add_tail(&tt->tt_list, &ehci->tt_list);
INIT_LIST_HEAD(&tt->ps_list);
tt->usb_tt = utt;
tt->tt_port = port;
*ptt = tt;
}
return tt;
}
/* Release the TT above udev, if it's not in use */
static void drop_tt(struct usb_device *udev)
{
struct usb_tt *utt = udev->tt;
struct ehci_tt *tt, **tt_index, **ptt;
int cnt, i;
if (!utt || !utt->hcpriv)
return; /* Not below a TT, or never allocated */
cnt = 0;
if (utt->multi) {
tt_index = utt->hcpriv;
ptt = &tt_index[udev->ttport - 1];
/* How many entries are left in tt_index? */
for (i = 0; i < utt->hub->maxchild; ++i)
cnt += !!tt_index[i];
} else {
tt_index = NULL;
ptt = (struct ehci_tt **) &utt->hcpriv;
}
tt = *ptt;
if (!tt || !list_empty(&tt->ps_list))
return; /* never allocated, or still in use */
list_del(&tt->tt_list);
*ptt = NULL;
kfree(tt);
if (cnt == 1) {
utt->hcpriv = NULL;
kfree(tt_index);
}
}
static void bandwidth_dbg(struct ehci_hcd *ehci, int sign, char *type,
struct ehci_per_sched *ps)
{
dev_dbg(&ps->udev->dev,
"ep %02x: %s %s @ %u+%u (%u.%u+%u) [%u/%u us] mask %04x\n",
ps->ep->desc.bEndpointAddress,
(sign >= 0 ? "reserve" : "release"), type,
(ps->bw_phase << 3) + ps->phase_uf, ps->bw_uperiod,
ps->phase, ps->phase_uf, ps->period,
ps->usecs, ps->c_usecs, ps->cs_mask);
}
static void reserve_release_intr_bandwidth(struct ehci_hcd *ehci,
struct ehci_qh *qh, int sign)
{
unsigned start_uf;
Annotation
- Detected declarations: `function periodic_next_shadow`, `function shadow_next_periodic`, `function periodic_unlink`, `function drop_tt`, `function bandwidth_dbg`, `function reserve_release_intr_bandwidth`, `function compute_tt_budget`, `function same_tt`, `function carryover_tt_bandwidth`, `function length`.
- 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.
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.