drivers/gpu/drm/msm/msm_rd.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/msm/msm_rd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/msm/msm_rd.c- Extension
.c- Size
- 10081 bytes
- Lines
- 437
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/circ_buf.hlinux/debugfs.hlinux/kfifo.hlinux/uaccess.hlinux/wait.hdrm/drm_file.hmsm_drv.hmsm_gpu.hmsm_gem.h
Detected Declarations
struct msm_rd_stateenum rd_sect_typefunction rd_writefunction rd_write_sectionfunction rd_readfunction rd_openfunction rd_releasefunction rd_cleanupfunction msm_rd_debugfs_initfunction msm_rd_debugfs_cleanupfunction snapshot_buffunction msm_rd_dump_submitfunction drm_gpuvm_for_each_vafunction rd_write_section
Annotated Snippet
static const struct file_operations rd_debugfs_fops = {
.owner = THIS_MODULE,
.open = rd_open,
.read = rd_read,
.release = rd_release,
};
static void rd_cleanup(struct msm_rd_state *rd)
{
if (!rd)
return;
mutex_destroy(&rd->read_lock);
mutex_destroy(&rd->write_lock);
kfree(rd);
}
static struct msm_rd_state *rd_init(struct drm_minor *minor, const char *name)
{
struct msm_rd_state *rd;
rd = kzalloc_obj(*rd);
if (!rd)
return ERR_PTR(-ENOMEM);
rd->dev = minor->dev;
rd->fifo.buf = rd->buf;
mutex_init(&rd->read_lock);
mutex_init(&rd->write_lock);
init_waitqueue_head(&rd->fifo_event);
debugfs_create_file(name, S_IFREG | S_IRUGO, minor->debugfs_root, rd,
&rd_debugfs_fops);
return rd;
}
int msm_rd_debugfs_init(struct drm_minor *minor)
{
struct msm_drm_private *priv = minor->dev->dev_private;
struct msm_rd_state *rd;
int ret;
if (!priv->gpu_pdev)
return 0;
/* only create on first minor: */
if (priv->rd)
return 0;
rd = rd_init(minor, "rd");
if (IS_ERR(rd)) {
ret = PTR_ERR(rd);
goto fail;
}
priv->rd = rd;
rd = rd_init(minor, "hangrd");
if (IS_ERR(rd)) {
ret = PTR_ERR(rd);
goto fail;
}
priv->hangrd = rd;
return 0;
fail:
msm_rd_debugfs_cleanup(priv);
return ret;
}
void msm_rd_debugfs_cleanup(struct msm_drm_private *priv)
{
rd_cleanup(priv->rd);
priv->rd = NULL;
rd_cleanup(priv->hangrd);
priv->hangrd = NULL;
}
static void snapshot_buf(struct msm_rd_state *rd, struct drm_gem_object *obj,
uint64_t iova, bool full, size_t offset, size_t size)
{
const char *buf;
Annotation
- Immediate include surface: `linux/circ_buf.h`, `linux/debugfs.h`, `linux/kfifo.h`, `linux/uaccess.h`, `linux/wait.h`, `drm/drm_file.h`, `msm_drv.h`, `msm_gpu.h`.
- Detected declarations: `struct msm_rd_state`, `enum rd_sect_type`, `function rd_write`, `function rd_write_section`, `function rd_read`, `function rd_open`, `function rd_release`, `function rd_cleanup`, `function msm_rd_debugfs_init`, `function msm_rd_debugfs_cleanup`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.