drivers/usb/gadget/udc/aspeed-vhub/epn.c
Source file repositories/reference/linux-study-clean/drivers/usb/gadget/udc/aspeed-vhub/epn.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/gadget/udc/aspeed-vhub/epn.c- Extension
.c- Size
- 23071 bytes
- Lines
- 855
- 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/module.hlinux/platform_device.hlinux/delay.hlinux/ioport.hlinux/slab.hlinux/errno.hlinux/list.hlinux/interrupt.hlinux/proc_fs.hlinux/prefetch.hlinux/clk.hlinux/usb/gadget.hlinux/of.hlinux/regmap.hlinux/dma-mapping.hvhub.h
Detected Declarations
function ast_vhub_epn_kickfunction ast_vhub_epn_handle_ackfunction ast_vhub_count_free_descsfunction ast_vhub_epn_kick_descfunction ast_vhub_epn_handle_ack_descfunction ast_vhub_epn_ack_irqfunction ast_vhub_epn_queuefunction modefunction ast_vhub_stop_active_reqfunction ast_vhub_epn_dequeuefunction ast_vhub_update_epn_stallfunction ast_vhub_set_halt_and_wedgefunction ast_vhub_epn_set_haltfunction ast_vhub_epn_set_wedgefunction ast_vhub_epn_disablefunction ast_vhub_epn_enablefunction ast_vhub_epn_dispose
Annotated Snippet
if (ep->epn.is_in) {
memcpy(ep->buf, req->req.buf + act, chunk);
vhub_dma_workaround(ep->buf);
}
writel(ep->buf_dma, ep->epn.regs + AST_VHUB_EP_DESC_BASE);
} else {
if (ep->epn.is_in)
vhub_dma_workaround(req->req.buf);
writel(req->req.dma + act, ep->epn.regs + AST_VHUB_EP_DESC_BASE);
}
/* Start DMA */
req->active = true;
writel(VHUB_EP_DMA_SET_TX_SIZE(chunk),
ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
writel(VHUB_EP_DMA_SET_TX_SIZE(chunk) | VHUB_EP_DMA_SINGLE_KICK,
ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
}
static void ast_vhub_epn_handle_ack(struct ast_vhub_ep *ep)
{
struct ast_vhub_req *req;
unsigned int len;
int status = 0;
u32 stat;
/* Read EP status */
stat = readl(ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
/* Grab current request if any */
req = list_first_entry_or_null(&ep->queue, struct ast_vhub_req, queue);
EPVDBG(ep, "ACK status=%08x is_in=%d, req=%p (active=%d)\n",
stat, ep->epn.is_in, req, req ? req->active : 0);
/* In absence of a request, bail out, must have been dequeued */
if (!req)
return;
/*
* Request not active, move on to processing queue, active request
* was probably dequeued
*/
if (!req->active)
goto next_chunk;
/* Check if HW has moved on */
if (VHUB_EP_DMA_RPTR(stat) != 0) {
EPDBG(ep, "DMA read pointer not 0 !\n");
return;
}
/* No current DMA ongoing */
req->active = false;
/* Grab length out of HW */
len = VHUB_EP_DMA_TX_SIZE(stat);
/* If not using DMA, copy data out if needed */
if (!req->req.dma && !ep->epn.is_in && len) {
if (req->req.actual + len > req->req.length) {
req->last_desc = 1;
status = -EOVERFLOW;
goto done;
} else {
memcpy(req->req.buf + req->req.actual, ep->buf, len);
}
}
/* Adjust size */
req->req.actual += len;
/* Check for short packet */
if (len < ep->ep.maxpacket)
req->last_desc = 1;
done:
/* That's it ? complete the request and pick a new one */
if (req->last_desc >= 0) {
ast_vhub_done(ep, req, status);
req = list_first_entry_or_null(&ep->queue, struct ast_vhub_req,
queue);
/*
* Due to lock dropping inside "done" the next request could
* already be active, so check for that and bail if needed.
*/
if (!req || req->active)
return;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/platform_device.h`, `linux/delay.h`, `linux/ioport.h`, `linux/slab.h`, `linux/errno.h`, `linux/list.h`.
- Detected declarations: `function ast_vhub_epn_kick`, `function ast_vhub_epn_handle_ack`, `function ast_vhub_count_free_descs`, `function ast_vhub_epn_kick_desc`, `function ast_vhub_epn_handle_ack_desc`, `function ast_vhub_epn_ack_irq`, `function ast_vhub_epn_queue`, `function mode`, `function ast_vhub_stop_active_req`, `function ast_vhub_epn_dequeue`.
- 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.