drivers/usb/host/xhci-mtk-sch.c
Source file repositories/reference/linux-study-clean/drivers/usb/host/xhci-mtk-sch.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/host/xhci-mtk-sch.c- Extension
.c- Size
- 25953 bytes
- Lines
- 1056
- 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.
- 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/kernel.hlinux/module.hlinux/slab.hxhci.hxhci-mtk.h
Detected Declarations
function Copyrightfunction is_fs_or_lsfunction decode_epfunction get_bw_boundaryfunction get_bw_infofunction get_esitfunction drop_ttfunction create_sch_epfunction setup_sch_infofunction get_max_bwfunction get_fs_bwfunction update_bus_bwfunction check_ls_budget_microframesfunction check_fs_budget_microframesfunction check_fs_budget_framesfunction check_fs_bus_bwfunction check_ss_and_csfunction check_isoc_ss_overlapfunction check_sch_tt_budgetfunction alloc_sch_portion_of_framefunction update_sch_ttfunction load_ep_bwfunction alloc_sch_microframesfunction check_sch_bwfunction destroy_sch_epfunction need_bw_schfunction xhci_mtk_sch_initfunction xhci_mtk_sch_exitfunction add_ep_quirkfunction drop_ep_quirkfunction hash_for_each_possible_safefunction xhci_mtk_check_bandwidthfunction list_for_each_entryfunction xhci_mtk_reset_bandwidthfunction xhci_mtk_add_epfunction xhci_mtk_drop_ep
Annotated Snippet
if (!tt_index) { /* Create the index array */
tt_index = kzalloc_objs(*tt_index, utt->hub->maxchild);
if (!tt_index)
return ERR_PTR(-ENOMEM);
utt->hcpriv = tt_index;
allocated_index = true;
}
ptt = &tt_index[udev->ttport - 1];
} else {
ptt = (struct mu3h_sch_tt **) &utt->hcpriv;
}
tt = *ptt;
if (!tt) { /* Create the mu3h_sch_tt */
tt = kzalloc_obj(*tt);
if (!tt) {
if (allocated_index) {
utt->hcpriv = NULL;
kfree(tt_index);
}
return ERR_PTR(-ENOMEM);
}
INIT_LIST_HEAD(&tt->ep_list);
*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 mu3h_sch_tt *tt, **tt_index, **ptt;
int i, cnt;
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 mu3h_sch_tt **)&utt->hcpriv;
}
tt = *ptt;
if (!tt || !list_empty(&tt->ep_list))
return; /* never allocated , or still in use*/
*ptt = NULL;
kfree(tt);
if (cnt == 1) {
utt->hcpriv = NULL;
kfree(tt_index);
}
}
static struct mu3h_sch_ep_info *
create_sch_ep(struct xhci_hcd_mtk *mtk, struct usb_device *udev,
struct usb_host_endpoint *ep, struct xhci_ep_ctx *ep_ctx)
{
struct mu3h_sch_ep_info *sch_ep;
struct mu3h_sch_bw_info *bw_info;
struct mu3h_sch_tt *tt = NULL;
u32 len;
bw_info = get_bw_info(mtk, udev, ep);
if (!bw_info)
return ERR_PTR(-ENODEV);
if (is_fs_or_ls(udev->speed))
len = TT_MICROFRAMES_MAX;
else if ((udev->speed >= USB_SPEED_SUPER) &&
usb_endpoint_xfer_isoc(&ep->desc))
len = get_esit(ep_ctx);
else
len = 1;
sch_ep = kzalloc_flex(*sch_ep, bw_budget_table, len);
if (!sch_ep)
return ERR_PTR(-ENOMEM);
if (is_fs_or_ls(udev->speed)) {
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `xhci.h`, `xhci-mtk.h`.
- Detected declarations: `function Copyright`, `function is_fs_or_ls`, `function decode_ep`, `function get_bw_boundary`, `function get_bw_info`, `function get_esit`, `function drop_tt`, `function create_sch_ep`, `function setup_sch_info`, `function get_max_bw`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
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.