drivers/usb/cdns3/cdns3-gadget.c
Source file repositories/reference/linux-study-clean/drivers/usb/cdns3/cdns3-gadget.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/cdns3/cdns3-gadget.c- Extension
.c- Size
- 96066 bytes
- Lines
- 3525
- 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.
- 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/dma-mapping.hlinux/usb/gadget.hlinux/module.hlinux/dmapool.hlinux/iopoll.hlinux/property.hcore.hgadget-export.hcdns3-gadget.hcdns3-trace.hdrd.h
Detected Declarations
function cdns3_clear_register_bitfunction cdns3_set_register_bitfunction cdns3_ep_addr_to_indexfunction cdns3_get_dma_posfunction cdns3_select_epfunction cdns3_get_tdlfunction cdns3_trb_virt_to_dmafunction cdns3_free_trb_poolfunction cdns3_allocate_trb_poolfunction cdns3_ep_stall_flushfunction cdns3_hw_reset_eps_configfunction cdns3_ep_inc_trbfunction cdns3_ep_inc_enqfunction cdns3_ep_inc_deqfunction cdns3_allow_enable_l1function cdns3_get_speedfunction cdns3_start_all_requestfunction __cdns3_descmiss_copy_datafunction cdns3_wa2_descmiss_copy_datafunction cdns3_wa2_gadget_ep_queuefunction cdns3_wa2_remove_old_requestfunction cdns3_wa2_descmissing_packetfunction cdns3_wa2_reset_tdlfunction cdns3_wa2_check_outq_statusfunction cdns3_gadget_givebackfunction cdns3_wa1_restore_cycle_bitfunction cdns3_free_aligned_request_buffunction list_for_each_entry_safefunction cdns3_prepare_aligned_request_buffunction cdns3_wa1_update_guardfunction cdns3_wa1_tray_restore_cycle_bitfunction cdns3_ep_run_stream_transferfunction cdns3_rearm_drdy_if_neededfunction cdns3_ep_run_transferfunction disabledfunction cdns3_set_hw_configurationfunction list_for_each_entryfunction cdns3_trb_handledfunction cdns3_transfer_completedfunction cdns3_rearm_transferfunction cdns3_reprogram_tdlfunction cdns3_check_ep_interrupt_proceedfunction cdns3_disconnect_gadgetfunction cdns3_check_usb_interrupt_proceedfunction cdns3_device_irq_handlerfunction cdns3_device_thread_irq_handlerfunction for_each_set_bitfunction cdns3_ep_onchip_buffer_reserve
Annotated Snippet
if (!priv_ep->use_streams) {
ret = cdns3_ep_run_transfer(priv_ep, request);
} else {
priv_ep->stream_sg_idx = 0;
ret = cdns3_ep_run_stream_transfer(priv_ep, request);
}
if (ret)
return ret;
list_move_tail(&request->list, &priv_ep->pending_req_list);
if (request->stream_id != 0 || (priv_ep->flags & EP_TDLCHK_EN))
break;
}
priv_ep->flags &= ~EP_RING_FULL;
return ret;
}
/*
* WA2: Set flag for all not ISOC OUT endpoints. If this flag is set
* driver try to detect whether endpoint need additional internal
* buffer for unblocking on-chip FIFO buffer. This flag will be cleared
* if before first DESCMISS interrupt the DMA will be armed.
*/
#define cdns3_wa2_enable_detection(priv_dev, priv_ep, reg) do { \
if (!priv_ep->dir && priv_ep->type != USB_ENDPOINT_XFER_ISOC) { \
priv_ep->flags |= EP_QUIRK_EXTRA_BUF_DET; \
(reg) |= EP_STS_EN_DESCMISEN; \
} } while (0)
static void __cdns3_descmiss_copy_data(struct usb_request *request,
struct usb_request *descmiss_req)
{
int length = request->actual + descmiss_req->actual;
struct scatterlist *s = request->sg;
if (!s) {
if (length <= request->length) {
memcpy(&((u8 *)request->buf)[request->actual],
descmiss_req->buf,
descmiss_req->actual);
request->actual = length;
} else {
/* It should never occures */
request->status = -ENOMEM;
}
} else {
if (length <= sg_dma_len(s)) {
void *p = phys_to_virt(sg_dma_address(s));
memcpy(&((u8 *)p)[request->actual],
descmiss_req->buf,
descmiss_req->actual);
request->actual = length;
} else {
request->status = -ENOMEM;
}
}
}
/**
* cdns3_wa2_descmiss_copy_data - copy data from internal requests to
* request queued by class driver.
* @priv_ep: extended endpoint object
* @request: request object
*/
static void cdns3_wa2_descmiss_copy_data(struct cdns3_endpoint *priv_ep,
struct usb_request *request)
{
struct usb_request *descmiss_req;
struct cdns3_request *descmiss_priv_req;
while (!list_empty(&priv_ep->wa2_descmiss_req_list)) {
int chunk_end;
descmiss_priv_req =
cdns3_next_priv_request(&priv_ep->wa2_descmiss_req_list);
descmiss_req = &descmiss_priv_req->request;
/* driver can't touch pending request */
if (descmiss_priv_req->flags & REQUEST_PENDING)
break;
chunk_end = descmiss_priv_req->flags & REQUEST_INTERNAL_CH;
request->status = descmiss_req->status;
__cdns3_descmiss_copy_data(request, descmiss_req);
list_del_init(&descmiss_priv_req->list);
kfree(descmiss_req->buf);
cdns3_gadget_ep_free_request(&priv_ep->endpoint, descmiss_req);
--priv_ep->wa2_counter;
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `linux/usb/gadget.h`, `linux/module.h`, `linux/dmapool.h`, `linux/iopoll.h`, `linux/property.h`, `core.h`, `gadget-export.h`.
- Detected declarations: `function cdns3_clear_register_bit`, `function cdns3_set_register_bit`, `function cdns3_ep_addr_to_index`, `function cdns3_get_dma_pos`, `function cdns3_select_ep`, `function cdns3_get_tdl`, `function cdns3_trb_virt_to_dma`, `function cdns3_free_trb_pool`, `function cdns3_allocate_trb_pool`, `function cdns3_ep_stall_flush`.
- 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.