drivers/usb/host/fhci-sched.c
Source file repositories/reference/linux-study-clean/drivers/usb/host/fhci-sched.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/host/fhci-sched.c- Extension
.c- Size
- 24007 bytes
- Lines
- 892
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/types.hlinux/spinlock.hlinux/delay.hlinux/errno.hlinux/list.hlinux/interrupt.hlinux/io.hlinux/usb.hlinux/usb/hcd.hsoc/fsl/qe/qe.hasm/fsl_gtm.hfhci.h
Detected Declarations
function Copyrightfunction fhci_transaction_confirmfunction transactionfunction fhci_flush_all_transmissionsfunction add_packetfunction move_head_to_tailfunction scan_ed_listfunction list_for_each_entryfunction rotate_framesfunction fhci_schedule_transactionsfunction sof_interruptfunction fhci_device_disconnected_interruptfunction fhci_device_connected_interruptfunction fhci_frame_limit_timer_irqfunction abort_transmissionfunction fhci_irqfunction completionsfunction fhci_transfer_confirm_callbackfunction fhci_queue_urb
Annotated Snippet
if (ed->td_list.next->next != &ed->td_list) {
struct td *td_next =
list_entry(ed->td_list.next->next, struct td,
node);
td_next->start_frame = usb->actual_frame->frame_num;
}
td->actual_len = trans_len;
td_done = true;
} else if ((td->status & USB_TD_ERROR) &&
!(td->status & USB_TD_TX_ER_NAK)) {
/*
* There was an error on the transaction (but not NAK).
* If it is fatal error (data underrun, stall, bad pid or 3
* errors exceeded), mark this TD as done.
*/
if ((td->status & USB_TD_RX_DATA_UNDERUN) ||
(td->status & USB_TD_TX_ER_STALL) ||
(td->status & USB_TD_RX_ER_PID) ||
(++td->error_cnt >= 3)) {
ed->state = FHCI_ED_HALTED;
td_done = true;
if (td->status & USB_TD_RX_DATA_UNDERUN) {
fhci_dbg(usb->fhci, "td err fu\n");
td->toggle = !td->toggle;
td->actual_len += trans_len;
} else {
fhci_dbg(usb->fhci, "td err f!u\n");
}
} else {
fhci_dbg(usb->fhci, "td err !f\n");
/* it is not a fatal error -retry this transaction */
td->nak_cnt = 0;
td->error_cnt++;
td->status = USB_TD_OK;
}
} else if (td->status & USB_TD_TX_ER_NAK) {
/* there was a NAK response */
fhci_vdbg(usb->fhci, "td nack\n");
td->nak_cnt++;
td->error_cnt = 0;
td->status = USB_TD_OK;
} else {
/* there was no error on transaction */
td->error_cnt = 0;
td->nak_cnt = 0;
td->toggle = !td->toggle;
td->actual_len += trans_len;
if (td->len == td->actual_len)
td_done = true;
}
if (td_done)
fhci_move_td_from_ed_to_done_list(usb, ed);
}
/*
* Flush all transmitted packets from BDs
* This routine is called when disabling the USB port to flush all
* transmissions that are already scheduled in the BDs
*/
void fhci_flush_all_transmissions(struct fhci_usb *usb)
{
u8 mode;
struct td *td;
mode = in_8(&usb->fhci->regs->usb_usmod);
clrbits8(&usb->fhci->regs->usb_usmod, USB_MODE_EN);
fhci_flush_bds(usb);
while ((td = fhci_peek_td_from_frame(usb->actual_frame)) != NULL) {
struct packet *pkt = td->pkt;
pkt->status = USB_TD_TX_ER_TIMEOUT;
fhci_transaction_confirm(usb, pkt);
}
usb->actual_frame->frame_status = FRAME_END_TRANSMISSION;
/* reset the event register */
out_be16(&usb->fhci->regs->usb_usber, 0xffff);
/* enable the USB controller */
out_8(&usb->fhci->regs->usb_usmod, mode | USB_MODE_EN);
}
/*
* This function forms the packet and transmit the packet. This function
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/types.h`, `linux/spinlock.h`, `linux/delay.h`, `linux/errno.h`, `linux/list.h`, `linux/interrupt.h`, `linux/io.h`.
- Detected declarations: `function Copyright`, `function fhci_transaction_confirm`, `function transaction`, `function fhci_flush_all_transmissions`, `function add_packet`, `function move_head_to_tail`, `function scan_ed_list`, `function list_for_each_entry`, `function rotate_frames`, `function fhci_schedule_transactions`.
- 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.