arch/mips/sibyte/common/sb_tbprof.c
Source file repositories/reference/linux-study-clean/arch/mips/sibyte/common/sb_tbprof.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/sibyte/common/sb_tbprof.c- Extension
.c- Size
- 15560 bytes
- Lines
- 594
- Domain
- Architecture Layer
- Bucket
- arch/mips
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- 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/device.hlinux/module.hlinux/kernel.hlinux/types.hlinux/init.hlinux/interrupt.hlinux/sched.hlinux/vmalloc.hlinux/fs.hlinux/errno.hlinux/wait.hasm/io.hasm/sibyte/sb1250.hasm/sibyte/bcm1480_regs.hasm/sibyte/bcm1480_scd.hasm/sibyte/bcm1480_int.hasm/sibyte/sb1250_regs.hasm/sibyte/sb1250_scd.hasm/sibyte/sb1250_int.hlinux/uaccess.h
Detected Declarations
struct sbprof_tbenum open_statusfunction arm_tbfunction sbprof_tb_intrfunction sbprof_pc_intrfunction sbprof_zbprof_startfunction sbprof_zbprof_stopfunction sbprof_tb_openfunction sbprof_tb_releasefunction sbprof_tb_readfunction sbprof_tb_ioctlfunction sbprof_tb_initfunction sbprof_tb_cleanupmodule init sbprof_tb_init
Annotated Snippet
static const struct file_operations sbprof_tb_fops = {
.owner = THIS_MODULE,
.open = sbprof_tb_open,
.release = sbprof_tb_release,
.read = sbprof_tb_read,
.unlocked_ioctl = sbprof_tb_ioctl,
.compat_ioctl = sbprof_tb_ioctl,
.mmap = NULL,
.llseek = default_llseek,
};
static const struct class tb_class = {
.name = "sb_tracebuffer",
};
static struct device *tb_dev;
static int __init sbprof_tb_init(void)
{
struct device *dev;
int err;
if (register_chrdev(SBPROF_TB_MAJOR, DEVNAME, &sbprof_tb_fops)) {
printk(KERN_WARNING DEVNAME ": initialization failed (dev %d)\n",
SBPROF_TB_MAJOR);
return -EIO;
}
err = class_register(&tb_class);
if (err)
goto out_chrdev;
dev = device_create(&tb_class, NULL, MKDEV(SBPROF_TB_MAJOR, 0), NULL, "tb");
if (IS_ERR(dev)) {
err = PTR_ERR(dev);
goto out_class;
}
tb_dev = dev;
sbp.open = SB_CLOSED;
wmb();
tb_period = zbbus_mhz * 10000LL;
pr_info(DEVNAME ": initialized - tb_period = %lld\n",
(long long) tb_period);
return 0;
out_class:
class_unregister(&tb_class);
out_chrdev:
unregister_chrdev(SBPROF_TB_MAJOR, DEVNAME);
return err;
}
static void __exit sbprof_tb_cleanup(void)
{
device_destroy(&tb_class, MKDEV(SBPROF_TB_MAJOR, 0));
unregister_chrdev(SBPROF_TB_MAJOR, DEVNAME);
class_unregister(&tb_class);
}
module_init(sbprof_tb_init);
module_exit(sbprof_tb_cleanup);
MODULE_ALIAS_CHARDEV_MAJOR(SBPROF_TB_MAJOR);
MODULE_AUTHOR("Ralf Baechle <ralf@linux-mips.org>");
MODULE_DESCRIPTION("Support for ZBbus profiling");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/device.h`, `linux/module.h`, `linux/kernel.h`, `linux/types.h`, `linux/init.h`, `linux/interrupt.h`, `linux/sched.h`, `linux/vmalloc.h`.
- Detected declarations: `struct sbprof_tb`, `enum open_status`, `function arm_tb`, `function sbprof_tb_intr`, `function sbprof_pc_intr`, `function sbprof_zbprof_start`, `function sbprof_zbprof_stop`, `function sbprof_tb_open`, `function sbprof_tb_release`, `function sbprof_tb_read`.
- Atlas domain: Architecture Layer / arch/mips.
- 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.