tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
Source file repositories/reference/linux-study-clean/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
File Facts
- System
- Linux kernel
- Corpus path
tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c- Extension
.c- Size
- 8630 bytes
- Lines
- 335
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdio.hstdlib.hstdint.htime.hstring.hpci/pci.hidle_monitor/cpupower-monitor.hhelpers/helpers.h
Detected Declarations
enum amd_fam14h_statesfunction amd_fam14h_get_pci_infofunction amd_fam14h_initfunction amd_fam14h_disablefunction fam14h_nbp1_countfunction fam14h_get_count_percentfunction amd_fam14h_startfunction amd_fam14h_stopfunction is_nbp1_capablefunction amd_fam14h_unregister
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* (C) 2010,2011 Thomas Renninger <trenn@suse.de>, Novell Inc.
*
* PCI initialization based on example code from:
* Andreas Herrmann <andreas.herrmann3@amd.com>
*/
#if defined(__i386__) || defined(__x86_64__)
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <time.h>
#include <string.h>
#include <pci/pci.h>
#include "idle_monitor/cpupower-monitor.h"
#include "helpers/helpers.h"
#define PCI_NON_PC0_OFFSET 0xb0
#define PCI_PC1_OFFSET 0xb4
#define PCI_PC6_OFFSET 0xb8
#define PCI_MONITOR_ENABLE_REG 0xe0
#define PCI_NON_PC0_ENABLE_BIT 0
#define PCI_PC1_ENABLE_BIT 1
#define PCI_PC6_ENABLE_BIT 2
#define PCI_NBP1_STAT_OFFSET 0x98
#define PCI_NBP1_ACTIVE_BIT 2
#define PCI_NBP1_ENTERED_BIT 1
#define PCI_NBP1_CAP_OFFSET 0x90
#define PCI_NBP1_CAPABLE_BIT 31
#define OVERFLOW_MS 343597 /* 32 bit register filled at 12500 HZ
(1 tick per 80ns) */
enum amd_fam14h_states {NON_PC0 = 0, PC1, PC6, NBP1,
AMD_FAM14H_STATE_NUM};
static int fam14h_get_count_percent(unsigned int self_id, double *percent,
unsigned int cpu);
static int fam14h_nbp1_count(unsigned int id, unsigned long long *count,
unsigned int cpu);
static cstate_t amd_fam14h_cstates[AMD_FAM14H_STATE_NUM] = {
{
.name = "!PC0",
.desc = N_("Package in sleep state (PC1 or deeper)"),
.id = NON_PC0,
.range = RANGE_PACKAGE,
.get_count_percent = fam14h_get_count_percent,
},
{
.name = "PC1",
.desc = N_("Processor Package C1"),
.id = PC1,
.range = RANGE_PACKAGE,
.get_count_percent = fam14h_get_count_percent,
},
{
.name = "PC6",
.desc = N_("Processor Package C6"),
.id = PC6,
.range = RANGE_PACKAGE,
.get_count_percent = fam14h_get_count_percent,
},
{
.name = "NBP1",
.desc = N_("North Bridge P1 boolean counter (returns 0 or 1)"),
.id = NBP1,
.range = RANGE_PACKAGE,
.get_count = fam14h_nbp1_count,
},
};
static struct pci_access *pci_acc;
static struct pci_dev *amd_fam14h_pci_dev;
static int nbp1_entered;
static struct timespec start_time;
static unsigned long long timediff;
#ifdef DEBUG
struct timespec dbg_time;
long dbg_timediff;
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `stdint.h`, `time.h`, `string.h`, `pci/pci.h`, `idle_monitor/cpupower-monitor.h`, `helpers/helpers.h`.
- Detected declarations: `enum amd_fam14h_states`, `function amd_fam14h_get_pci_info`, `function amd_fam14h_init`, `function amd_fam14h_disable`, `function fam14h_nbp1_count`, `function fam14h_get_count_percent`, `function amd_fam14h_start`, `function amd_fam14h_stop`, `function is_nbp1_capable`, `function amd_fam14h_unregister`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.