drivers/gpu/drm/gud/gud_drv.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/gud/gud_drv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/gud/gud_drv.c- Extension
.c- Size
- 18037 bytes
- Lines
- 708
- 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/dma-buf.hlinux/dma-mapping.hlinux/lz4.hlinux/module.hlinux/platform_device.hlinux/string_helpers.hlinux/usb.hlinux/vmalloc.hlinux/workqueue.hdrm/clients/drm_client_setup.hdrm/drm_atomic_helper.hdrm/drm_blend.hdrm/drm_crtc_helper.hdrm/drm_damage_helper.hdrm/drm_debugfs.hdrm/drm_drv.hdrm/drm_fbdev_shmem.hdrm/drm_fourcc.hdrm/drm_gem_atomic_helper.hdrm/drm_gem_framebuffer_helper.hdrm/drm_gem_shmem_helper.hdrm/drm_managed.hdrm/drm_print.hdrm/drm_probe_helper.hdrm/gud.hgud_internal.h
Detected Declarations
function gud_usb_control_msgfunction gud_get_display_descriptorfunction gud_status_to_errnofunction gud_usb_get_statusfunction gud_usb_transferfunction gud_usb_getfunction gud_usb_setfunction gud_usb_get_u8function gud_usb_set_u8function gud_plane_add_propertiesfunction gud_stats_debugfsfunction gud_alloc_bulk_bufferfunction gud_free_buffers_and_mutexfunction gud_probefunction gud_disconnectfunction gud_suspendfunction gud_resume
Annotated Snippet
if (status < 0) {
ret = status;
} else if (ret < 0) {
dev_err_once(gdrm->drm.dev,
"Unexpected status OK for failed transfer\n");
ret = -EPIPE;
}
}
if (ret < 0) {
drm_dbg(&gdrm->drm, "ret=%d\n", ret);
gdrm->stats_num_errors++;
}
mutex_unlock(&gdrm->ctrl_lock);
drm_dev_exit(idx);
return ret;
}
/*
* @buf cannot be allocated on the stack.
* Returns number of bytes received or negative error code on failure.
*/
int gud_usb_get(struct gud_device *gdrm, u8 request, u16 index, void *buf, size_t max_len)
{
return gud_usb_transfer(gdrm, true, request, index, buf, max_len);
}
/*
* @buf can be allocated on the stack or NULL.
* Returns zero on success or negative error code on failure.
*/
int gud_usb_set(struct gud_device *gdrm, u8 request, u16 index, void *buf, size_t len)
{
void *trbuf = NULL;
int ret;
if (buf && len) {
trbuf = kmemdup(buf, len, GFP_KERNEL);
if (!trbuf)
return -ENOMEM;
}
ret = gud_usb_transfer(gdrm, false, request, index, trbuf, len);
kfree(trbuf);
if (ret < 0)
return ret;
return ret != len ? -EIO : 0;
}
/*
* @val can be allocated on the stack.
* Returns zero on success or negative error code on failure.
*/
int gud_usb_get_u8(struct gud_device *gdrm, u8 request, u16 index, u8 *val)
{
u8 *buf;
int ret;
buf = kmalloc(sizeof(*val), GFP_KERNEL);
if (!buf)
return -ENOMEM;
ret = gud_usb_get(gdrm, request, index, buf, sizeof(*val));
*val = *buf;
kfree(buf);
if (ret < 0)
return ret;
return ret != sizeof(*val) ? -EIO : 0;
}
/* Returns zero on success or negative error code on failure. */
int gud_usb_set_u8(struct gud_device *gdrm, u8 request, u8 val)
{
return gud_usb_set(gdrm, request, 0, &val, sizeof(val));
}
static int gud_plane_add_properties(struct gud_device *gdrm)
{
struct gud_property_req *properties;
unsigned int i, num_properties;
int ret;
properties = kzalloc_objs(*properties, GUD_PROPERTIES_MAX_NUM);
if (!properties)
return -ENOMEM;
Annotation
- Immediate include surface: `linux/dma-buf.h`, `linux/dma-mapping.h`, `linux/lz4.h`, `linux/module.h`, `linux/platform_device.h`, `linux/string_helpers.h`, `linux/usb.h`, `linux/vmalloc.h`.
- Detected declarations: `function gud_usb_control_msg`, `function gud_get_display_descriptor`, `function gud_status_to_errno`, `function gud_usb_get_status`, `function gud_usb_transfer`, `function gud_usb_get`, `function gud_usb_set`, `function gud_usb_get_u8`, `function gud_usb_set_u8`, `function gud_plane_add_properties`.
- 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.