drivers/soc/qcom/qcom_stats.c
Source file repositories/reference/linux-study-clean/drivers/soc/qcom/qcom_stats.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/qcom/qcom_stats.c- Extension
.c- Size
- 11697 bytes
- Lines
- 431
- 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/bitfield.hlinux/debugfs.hlinux/device.hlinux/io.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/seq_file.hlinux/soc/qcom/qcom_aoss.hlinux/soc/qcom/smem.hclocksource/arm_arch_timer.h
Detected Declarations
struct subsystem_datastruct stats_configstruct ddr_stats_entrystruct stats_datastruct sleep_statsstruct appended_statsfunction qcom_print_statsfunction qcom_subsystem_sleep_stats_showfunction qcom_soc_sleep_stats_showfunction qcom_ddr_stats_printfunction statfunction qcom_ddr_stats_showfunction qcom_create_ddr_stat_filesfunction qcom_create_soc_sleep_stat_filesfunction qcom_create_subsystem_stat_filesfunction qcom_stats_probefunction qcom_stats_removefunction qcom_stats_initfunction qcom_stats_exit
Annotated Snippet
struct subsystem_data {
const char *name;
u32 smem_item;
u32 pid;
};
static const struct subsystem_data subsystems[] = {
{ "modem", 605, 1 },
{ "wpss", 605, 13 },
{ "adsp", 606, 2 },
{ "cdsp", 607, 5 },
{ "cdsp1", 607, 12 },
{ "gpdsp0", 607, 17 },
{ "gpdsp1", 607, 18 },
{ "slpi", 608, 3 },
{ "gpu", 609, 0 },
{ "display", 610, 0 },
{ "adsp_island", 613, 2 },
{ "slpi_island", 613, 3 },
{ "apss", 631, QCOM_SMEM_HOST_ANY },
};
struct stats_config {
size_t stats_offset;
size_t ddr_stats_offset;
size_t num_records;
bool appended_stats_avail;
bool dynamic_offset;
bool subsystem_stats_in_smem;
};
struct ddr_stats_entry {
u32 name;
u32 count;
u64 duration;
};
struct stats_data {
bool appended_stats_avail;
void __iomem *base;
};
struct sleep_stats {
u32 stat_type;
u32 count;
u64 last_entered_at;
u64 last_exited_at;
u64 accumulated;
};
struct appended_stats {
u32 client_votes;
u32 reserved[3];
};
static void qcom_print_stats(struct seq_file *s, const struct sleep_stats *stat)
{
u64 accumulated = stat->accumulated;
/*
* If a subsystem is in sleep when reading the sleep stats adjust
* the accumulated sleep duration to show actual sleep time.
*/
if (stat->last_entered_at > stat->last_exited_at)
accumulated += arch_timer_read_counter() - stat->last_entered_at;
seq_printf(s, "Count: %u\n", stat->count);
seq_printf(s, "Last Entered At: %llu\n", stat->last_entered_at);
seq_printf(s, "Last Exited At: %llu\n", stat->last_exited_at);
seq_printf(s, "Accumulated Duration: %llu\n", accumulated);
}
static int qcom_subsystem_sleep_stats_show(struct seq_file *s, void *unused)
{
struct subsystem_data *subsystem = s->private;
struct sleep_stats *stat;
/* Items are allocated lazily, so lookup pointer each time */
stat = qcom_smem_get(subsystem->pid, subsystem->smem_item, NULL);
if (IS_ERR(stat))
return 0;
qcom_print_stats(s, stat);
return 0;
}
static int qcom_soc_sleep_stats_show(struct seq_file *s, void *unused)
{
struct stats_data *d = s->private;
void __iomem *reg = d->base;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/debugfs.h`, `linux/device.h`, `linux/io.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/seq_file.h`.
- Detected declarations: `struct subsystem_data`, `struct stats_config`, `struct ddr_stats_entry`, `struct stats_data`, `struct sleep_stats`, `struct appended_stats`, `function qcom_print_stats`, `function qcom_subsystem_sleep_stats_show`, `function qcom_soc_sleep_stats_show`, `function qcom_ddr_stats_print`.
- 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.