drivers/firmware/tegra/bpmp-debugfs.c
Source file repositories/reference/linux-study-clean/drivers/firmware/tegra/bpmp-debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firmware/tegra/bpmp-debugfs.c- Extension
.c- Size
- 17190 bytes
- Lines
- 840
- Domain
- Driver Families
- Bucket
- drivers/firmware
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/cleanup.hlinux/debugfs.hlinux/dma-mapping.hlinux/slab.hlinux/uaccess.hsoc/tegra/bpmp.hsoc/tegra/bpmp-abi.h
Detected Declarations
struct seqbuffunction seqbuf_initfunction seqbuf_availfunction seqbuf_statusfunction seqbuf_eoffunction seqbuf_readfunction seqbuf_read_u32function seqbuf_read_strfunction seqbuf_seekfunction mrq_debug_openfunction mrq_debug_closefunction mrq_debug_readfunction mrq_debug_writefunction bpmp_debug_showfunction bpmp_debug_storefunction bpmp_debug_openfunction bpmp_populate_debugfs_inbandfunction mrq_debugfs_readfunction mrq_debugfs_writefunction mrq_debugfs_dumpdirfunction debugfs_showfunction debugfs_openfunction debugfs_storefunction bpmp_populate_dirfunction bpmp_populate_debugfs_shmemfunction tegra_bpmp_init_debugfs
Annotated Snippet
static const struct file_operations bpmp_debug_fops = {
.open = bpmp_debug_open,
.read = seq_read,
.llseek = seq_lseek,
.write = bpmp_debug_store,
.release = single_release,
};
static int bpmp_populate_debugfs_inband(struct tegra_bpmp *bpmp,
struct dentry *parent,
char *ppath)
{
const size_t pathlen = SZ_256;
const size_t bufsize = SZ_16K;
struct dentry *dentry;
u32 dsize, attrs = 0;
struct seqbuf seqbuf;
char *buf, *pathbuf;
const char *name;
int err = 0;
if (!bpmp || !parent || !ppath)
return -EINVAL;
buf = kmalloc(bufsize, GFP_KERNEL);
if (!buf)
return -ENOMEM;
pathbuf = kzalloc(pathlen, GFP_KERNEL);
if (!pathbuf) {
kfree(buf);
return -ENOMEM;
}
err = mrq_debug_read(bpmp, ppath, buf, bufsize, &dsize);
if (err)
goto out;
seqbuf_init(&seqbuf, buf, dsize);
while (!seqbuf_eof(&seqbuf)) {
err = seqbuf_read_u32(&seqbuf, &attrs);
if (err)
goto out;
err = seqbuf_read_str(&seqbuf, &name);
if (err < 0)
goto out;
if (attrs & DEBUGFS_S_ISDIR) {
size_t len;
dentry = debugfs_create_dir(name, parent);
if (IS_ERR(dentry)) {
err = PTR_ERR(dentry);
goto out;
}
len = snprintf(pathbuf, pathlen, "%s%s/", ppath, name);
if (len >= pathlen) {
err = -EINVAL;
goto out;
}
err = bpmp_populate_debugfs_inband(bpmp, dentry,
pathbuf);
if (err < 0)
goto out;
} else {
umode_t mode;
mode = attrs & DEBUGFS_S_IRUSR ? 0400 : 0;
mode |= attrs & DEBUGFS_S_IWUSR ? 0200 : 0;
dentry = debugfs_create_file(name, mode, parent, bpmp,
&bpmp_debug_fops);
if (IS_ERR(dentry)) {
err = PTR_ERR(dentry);
goto out;
}
}
}
out:
kfree(pathbuf);
kfree(buf);
return err;
}
static int mrq_debugfs_read(struct tegra_bpmp *bpmp,
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/debugfs.h`, `linux/dma-mapping.h`, `linux/slab.h`, `linux/uaccess.h`, `soc/tegra/bpmp.h`, `soc/tegra/bpmp-abi.h`.
- Detected declarations: `struct seqbuf`, `function seqbuf_init`, `function seqbuf_avail`, `function seqbuf_status`, `function seqbuf_eof`, `function seqbuf_read`, `function seqbuf_read_u32`, `function seqbuf_read_str`, `function seqbuf_seek`, `function mrq_debug_open`.
- Atlas domain: Driver Families / drivers/firmware.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.