drivers/virtio/virtio_debug.c
Source file repositories/reference/linux-study-clean/drivers/virtio/virtio_debug.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/virtio/virtio_debug.c- Extension
.c- Size
- 3381 bytes
- Lines
- 118
- Domain
- Driver Families
- Bucket
- drivers/virtio
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/virtio.hlinux/virtio_config.hlinux/debugfs.h
Detected Declarations
function virtio_debug_device_features_showfunction virtio_debug_filter_features_showfunction virtio_debug_filter_features_clearfunction virtio_debug_filter_feature_addfunction virtio_debug_filter_feature_delfunction virtio_debug_device_initfunction virtio_debug_device_filter_featuresfunction virtio_debug_device_exitfunction virtio_debug_initfunction virtio_debug_exitexport virtio_debug_device_initexport virtio_debug_device_filter_featuresexport virtio_debug_device_exitexport virtio_debug_initexport virtio_debug_exit
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
#include <linux/virtio.h>
#include <linux/virtio_config.h>
#include <linux/debugfs.h>
static struct dentry *virtio_debugfs_dir;
static int virtio_debug_device_features_show(struct seq_file *s, void *data)
{
u64 device_features[VIRTIO_FEATURES_U64S];
struct virtio_device *dev = s->private;
unsigned int i;
virtio_get_features(dev, device_features);
for (i = 0; i < VIRTIO_FEATURES_BITS; i++) {
if (virtio_features_test_bit(device_features, i))
seq_printf(s, "%u\n", i);
}
return 0;
}
DEFINE_SHOW_ATTRIBUTE(virtio_debug_device_features);
static int virtio_debug_filter_features_show(struct seq_file *s, void *data)
{
struct virtio_device *dev = s->private;
unsigned int i;
for (i = 0; i < VIRTIO_FEATURES_BITS; i++) {
if (virtio_features_test_bit(dev->debugfs_filter_features, i))
seq_printf(s, "%u\n", i);
}
return 0;
}
DEFINE_SHOW_ATTRIBUTE(virtio_debug_filter_features);
static int virtio_debug_filter_features_clear(void *data, u64 val)
{
struct virtio_device *dev = data;
if (val == 1)
virtio_features_zero(dev->debugfs_filter_features);
return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(virtio_debug_filter_features_clear_fops, NULL,
virtio_debug_filter_features_clear, "%llu\n");
static int virtio_debug_filter_feature_add(void *data, u64 val)
{
struct virtio_device *dev = data;
if (val >= VIRTIO_FEATURES_BITS)
return -EINVAL;
virtio_features_set_bit(dev->debugfs_filter_features, val);
return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(virtio_debug_filter_feature_add_fops, NULL,
virtio_debug_filter_feature_add, "%llu\n");
static int virtio_debug_filter_feature_del(void *data, u64 val)
{
struct virtio_device *dev = data;
if (val >= VIRTIO_FEATURES_BITS)
return -EINVAL;
virtio_features_clear_bit(dev->debugfs_filter_features, val);
return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(virtio_debug_filter_feature_del_fops, NULL,
virtio_debug_filter_feature_del, "%llu\n");
void virtio_debug_device_init(struct virtio_device *dev)
{
dev->debugfs_dir = debugfs_create_dir(dev_name(&dev->dev),
virtio_debugfs_dir);
debugfs_create_file("device_features", 0400, dev->debugfs_dir, dev,
&virtio_debug_device_features_fops);
debugfs_create_file("filter_features", 0400, dev->debugfs_dir, dev,
&virtio_debug_filter_features_fops);
debugfs_create_file("filter_features_clear", 0200, dev->debugfs_dir, dev,
&virtio_debug_filter_features_clear_fops);
debugfs_create_file("filter_feature_add", 0200, dev->debugfs_dir, dev,
&virtio_debug_filter_feature_add_fops);
debugfs_create_file("filter_feature_del", 0200, dev->debugfs_dir, dev,
&virtio_debug_filter_feature_del_fops);
Annotation
- Immediate include surface: `linux/virtio.h`, `linux/virtio_config.h`, `linux/debugfs.h`.
- Detected declarations: `function virtio_debug_device_features_show`, `function virtio_debug_filter_features_show`, `function virtio_debug_filter_features_clear`, `function virtio_debug_filter_feature_add`, `function virtio_debug_filter_feature_del`, `function virtio_debug_device_init`, `function virtio_debug_device_filter_features`, `function virtio_debug_device_exit`, `function virtio_debug_init`, `function virtio_debug_exit`.
- Atlas domain: Driver Families / drivers/virtio.
- Implementation status: integration 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.