drivers/gpu/drm/udl/udl_main.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/udl/udl_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/udl/udl_main.c- Extension
.c- Size
- 8903 bytes
- Lines
- 387
- Domain
- Driver Families
- Bucket
- drivers/gpu
- 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
linux/unaligned.hdrm/drm.hdrm/drm_print.hdrm/drm_probe_helper.hudl_drv.h
Detected Declarations
function udl_parse_vendor_descriptorfunction udl_select_std_channelfunction udl_urb_completionfunction udl_free_urb_listfunction udl_alloc_urb_listfunction udl_submit_urbfunction udl_sync_pending_urbsfunction udl_initfunction udl_drop_usb
Annotated Snippet
if (!urb) {
kfree(unode);
break;
}
unode->urb = urb;
buf = usb_alloc_coherent(udev, size, GFP_KERNEL,
&urb->transfer_dma);
if (!buf) {
kfree(unode);
usb_free_urb(urb);
if (size > PAGE_SIZE) {
size /= 2;
udl_free_urb_list(udl);
goto retry;
}
break;
}
/* urb->transfer_buffer_length set to actual before submit */
usb_fill_bulk_urb(urb, udev, usb_sndbulkpipe(udev, 1),
buf, size, udl_urb_completion, unode);
urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
list_add_tail(&unode->entry, &udl->urbs.list);
udl->urbs.count++;
udl->urbs.available++;
}
DRM_DEBUG("allocated %d %d byte urbs\n", udl->urbs.count, (int) size);
return udl->urbs.count;
}
static struct urb *udl_get_urb_locked(struct udl_device *udl, long timeout)
{
struct urb_node *unode;
assert_spin_locked(&udl->urbs.lock);
/* Wait for an in-flight buffer to complete and get re-queued */
if (!wait_event_lock_irq_timeout(udl->urbs.sleep,
!udl->urbs.count ||
!list_empty(&udl->urbs.list),
udl->urbs.lock, timeout)) {
DRM_INFO("wait for urb interrupted: available: %d\n",
udl->urbs.available);
return NULL;
}
if (!udl->urbs.count)
return NULL;
unode = list_first_entry(&udl->urbs.list, struct urb_node, entry);
list_del_init(&unode->entry);
udl->urbs.available--;
return unode->urb;
}
struct urb *udl_get_urb(struct udl_device *udl)
{
struct urb *urb;
spin_lock_irq(&udl->urbs.lock);
urb = udl_get_urb_locked(udl, HZ * 2);
spin_unlock_irq(&udl->urbs.lock);
return urb;
}
int udl_submit_urb(struct udl_device *udl, struct urb *urb, size_t len)
{
int ret;
if (WARN_ON(len > udl->urbs.size)) {
ret = -EINVAL;
goto error;
}
urb->transfer_buffer_length = len; /* set to actual payload len */
ret = usb_submit_urb(urb, GFP_ATOMIC);
error:
if (ret) {
udl_urb_completion(urb); /* because no one else will */
DRM_ERROR("usb_submit_urb error %x\n", ret);
}
return ret;
}
/* wait until all pending URBs have been processed */
Annotation
- Immediate include surface: `linux/unaligned.h`, `drm/drm.h`, `drm/drm_print.h`, `drm/drm_probe_helper.h`, `udl_drv.h`.
- Detected declarations: `function udl_parse_vendor_descriptor`, `function udl_select_std_channel`, `function udl_urb_completion`, `function udl_free_urb_list`, `function udl_alloc_urb_list`, `function udl_submit_urb`, `function udl_sync_pending_urbs`, `function udl_init`, `function udl_drop_usb`.
- Atlas domain: Driver Families / drivers/gpu.
- 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.