drivers/gpu/drm/v3d/v3d_sysfs.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/v3d/v3d_sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/v3d/v3d_sysfs.c- Extension
.c- Size
- 1668 bytes
- Lines
- 67
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/sched/clock.hlinux/sysfs.hv3d_drv.h
Detected Declarations
function gpu_stats_showfunction v3d_sysfs_initfunction v3d_sysfs_destroy
Annotated Snippet
// SPDX-License-Identifier: MIT
/*
* Copyright © 2023 Igalia S.L.
*/
#include <linux/sched/clock.h>
#include <linux/sysfs.h>
#include "v3d_drv.h"
static ssize_t
gpu_stats_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct drm_device *drm = dev_get_drvdata(dev);
struct v3d_dev *v3d = to_v3d_dev(drm);
enum v3d_queue queue;
u64 timestamp = local_clock();
ssize_t len = 0;
len += sysfs_emit(buf, "queue\ttimestamp\tjobs\truntime\n");
for (queue = 0; queue < V3D_MAX_QUEUES; queue++) {
struct v3d_stats *stats = v3d->queue[queue].stats;
u64 active_runtime, jobs_completed;
v3d_get_stats(stats, timestamp, &active_runtime, &jobs_completed);
/* Each line will display the queue name, timestamp, the number
* of jobs sent to that queue and the runtime, as can be seem here:
*
* queue timestamp jobs runtime
* bin 239043069420 22620 17438164056
* render 239043069420 22619 27284814161
* tfu 239043069420 8763 394592566
* csd 239043069420 3168 10787905530
* cache_clean 239043069420 6127 237375940
*/
len += sysfs_emit_at(buf, len, "%s\t%llu\t%llu\t%llu\n",
v3d_queue_to_string(queue),
timestamp, jobs_completed, active_runtime);
}
return len;
}
static DEVICE_ATTR_RO(gpu_stats);
static struct attribute *v3d_sysfs_entries[] = {
&dev_attr_gpu_stats.attr,
NULL,
};
static struct attribute_group v3d_sysfs_attr_group = {
.attrs = v3d_sysfs_entries,
};
int
v3d_sysfs_init(struct device *dev)
{
return sysfs_create_group(&dev->kobj, &v3d_sysfs_attr_group);
}
void
v3d_sysfs_destroy(struct device *dev)
{
return sysfs_remove_group(&dev->kobj, &v3d_sysfs_attr_group);
}
Annotation
- Immediate include surface: `linux/sched/clock.h`, `linux/sysfs.h`, `v3d_drv.h`.
- Detected declarations: `function gpu_stats_show`, `function v3d_sysfs_init`, `function v3d_sysfs_destroy`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
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.