drivers/gpu/drm/lima/lima_drv.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/lima/lima_drv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/lima/lima_drv.c- Extension
.c- Size
- 12325 bytes
- Lines
- 504
- 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.
- 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/module.hlinux/of.hlinux/platform_device.hlinux/uaccess.hlinux/slab.hlinux/pm_runtime.hdrm/drm_ioctl.hdrm/drm_drv.hdrm/drm_prime.hdrm/lima_drm.hlima_device.hlima_drv.hlima_gem.hlima_vm.h
Detected Declarations
struct lima_block_readerfunction lima_ioctl_get_paramfunction lima_ioctl_gem_createfunction lima_ioctl_gem_infofunction lima_ioctl_gem_submitfunction lima_ioctl_gem_waitfunction lima_ioctl_ctx_createfunction lima_ioctl_ctx_freefunction lima_drm_driver_openfunction lima_drm_driver_postclosefunction lima_read_blockfunction lima_error_state_readfunction lima_error_state_writefunction list_for_each_entry_safefunction lima_pdev_probefunction lima_pdev_remove
Annotated Snippet
struct lima_block_reader {
void *dst;
size_t base;
size_t count;
size_t off;
ssize_t read;
};
static bool lima_read_block(struct lima_block_reader *reader,
void *src, size_t src_size)
{
size_t max_off = reader->base + src_size;
if (reader->off < max_off) {
size_t size = min_t(size_t, max_off - reader->off,
reader->count);
memcpy(reader->dst, src + (reader->off - reader->base), size);
reader->dst += size;
reader->off += size;
reader->read += size;
reader->count -= size;
}
reader->base = max_off;
return !!reader->count;
}
static ssize_t lima_error_state_read(struct file *filp, struct kobject *kobj,
const struct bin_attribute *attr, char *buf,
loff_t off, size_t count)
{
struct device *dev = kobj_to_dev(kobj);
struct lima_device *ldev = dev_get_drvdata(dev);
struct lima_sched_error_task *et;
struct lima_block_reader reader = {
.dst = buf,
.count = count,
.off = off,
};
mutex_lock(&ldev->error_task_list_lock);
if (lima_read_block(&reader, &ldev->dump, sizeof(ldev->dump))) {
list_for_each_entry(et, &ldev->error_task_list, list) {
if (!lima_read_block(&reader, et->data, et->size))
break;
}
}
mutex_unlock(&ldev->error_task_list_lock);
return reader.read;
}
static ssize_t lima_error_state_write(struct file *file, struct kobject *kobj,
const struct bin_attribute *attr, char *buf,
loff_t off, size_t count)
{
struct device *dev = kobj_to_dev(kobj);
struct lima_device *ldev = dev_get_drvdata(dev);
struct lima_sched_error_task *et, *tmp;
mutex_lock(&ldev->error_task_list_lock);
list_for_each_entry_safe(et, tmp, &ldev->error_task_list, list) {
list_del(&et->list);
kvfree(et);
}
ldev->dump.size = 0;
ldev->dump.num_tasks = 0;
mutex_unlock(&ldev->error_task_list_lock);
return count;
}
static const struct bin_attribute lima_error_state_attr = {
.attr.name = "error",
.attr.mode = 0600,
.size = 0,
.read = lima_error_state_read,
.write = lima_error_state_write,
};
static int lima_pdev_probe(struct platform_device *pdev)
{
struct lima_device *ldev;
Annotation
- Immediate include surface: `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/uaccess.h`, `linux/slab.h`, `linux/pm_runtime.h`, `drm/drm_ioctl.h`, `drm/drm_drv.h`.
- Detected declarations: `struct lima_block_reader`, `function lima_ioctl_get_param`, `function lima_ioctl_gem_create`, `function lima_ioctl_gem_info`, `function lima_ioctl_gem_submit`, `function lima_ioctl_gem_wait`, `function lima_ioctl_ctx_create`, `function lima_ioctl_ctx_free`, `function lima_drm_driver_open`, `function lima_drm_driver_postclose`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source 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.