drivers/soc/qcom/rpm_master_stats.c
Source file repositories/reference/linux-study-clean/drivers/soc/qcom/rpm_master_stats.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/qcom/rpm_master_stats.c- Extension
.c- Size
- 4808 bytes
- Lines
- 168
- Domain
- Driver Families
- Bucket
- drivers/soc
- 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/debugfs.hlinux/io.hlinux/module.hlinux/of.hlinux/of_address.hlinux/platform_device.h
Detected Declarations
struct master_stats_datastruct rpm_master_statsfunction master_stats_showfunction master_stats_probefunction master_stats_remove
Annotated Snippet
struct master_stats_data {
void __iomem *base;
const char *label;
};
struct rpm_master_stats {
u32 active_cores;
u32 num_shutdowns;
u64 shutdown_req;
u64 wakeup_idx;
u64 bringup_req;
u64 bringup_ack;
u32 wakeup_reason; /* 0 = "rude wakeup", 1 = scheduled wakeup */
u32 last_sleep_trans_dur;
u32 last_wake_trans_dur;
/* Per-subsystem (*not necessarily* SoC-wide) XO shutdown stats */
u32 xo_count;
u64 xo_last_enter;
u64 last_exit;
u64 xo_total_dur;
} __packed;
static int master_stats_show(struct seq_file *s, void *unused)
{
struct master_stats_data *data = s->private;
struct rpm_master_stats stat;
memcpy_fromio(&stat, data->base, sizeof(stat));
seq_printf(s, "%s:\n", data->label);
seq_printf(s, "\tLast shutdown @ %llu\n", stat.shutdown_req);
seq_printf(s, "\tLast bringup req @ %llu\n", stat.bringup_req);
seq_printf(s, "\tLast bringup ack @ %llu\n", stat.bringup_ack);
seq_printf(s, "\tLast wakeup idx: %llu\n", stat.wakeup_idx);
seq_printf(s, "\tLast XO shutdown enter @ %llu\n", stat.xo_last_enter);
seq_printf(s, "\tLast XO shutdown exit @ %llu\n", stat.last_exit);
seq_printf(s, "\tXO total duration: %llu\n", stat.xo_total_dur);
seq_printf(s, "\tLast sleep transition duration: %u\n", stat.last_sleep_trans_dur);
seq_printf(s, "\tLast wake transition duration: %u\n", stat.last_wake_trans_dur);
seq_printf(s, "\tXO shutdown count: %u\n", stat.xo_count);
seq_printf(s, "\tWakeup reason: 0x%x\n", stat.wakeup_reason);
seq_printf(s, "\tShutdown count: %u\n", stat.num_shutdowns);
seq_printf(s, "\tActive cores bitmask: 0x%x\n", stat.active_cores);
return 0;
}
DEFINE_SHOW_ATTRIBUTE(master_stats);
static int master_stats_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct master_stats_data *data;
struct device_node *msgram_np;
struct dentry *dent, *root;
struct resource res;
int count, i, ret;
count = of_property_count_strings(dev->of_node, "qcom,master-names");
if (count < 0)
return count;
data = devm_kcalloc(dev, count, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
root = debugfs_create_dir("qcom_rpm_master_stats", NULL);
platform_set_drvdata(pdev, root);
for (i = 0; i < count; i++) {
msgram_np = of_parse_phandle(dev->of_node, "qcom,rpm-msg-ram", i);
if (!msgram_np) {
debugfs_remove_recursive(root);
return dev_err_probe(dev, -ENODEV,
"Couldn't parse MSG RAM phandle idx %d", i);
}
/*
* Purposefully skip devm_platform helpers as we're using a
* shared resource.
*/
ret = of_address_to_resource(msgram_np, 0, &res);
of_node_put(msgram_np);
if (ret < 0) {
debugfs_remove_recursive(root);
return ret;
}
data[i].base = devm_ioremap(dev, res.start, resource_size(&res));
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/io.h`, `linux/module.h`, `linux/of.h`, `linux/of_address.h`, `linux/platform_device.h`.
- Detected declarations: `struct master_stats_data`, `struct rpm_master_stats`, `function master_stats_show`, `function master_stats_probe`, `function master_stats_remove`.
- Atlas domain: Driver Families / drivers/soc.
- 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.