drivers/platform/mellanox/mlxbf-pmc.c
Source file repositories/reference/linux-study-clean/drivers/platform/mellanox/mlxbf-pmc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/mellanox/mlxbf-pmc.c- Extension
.c- Size
- 70861 bytes
- Lines
- 2372
- Domain
- Driver Families
- Bucket
- drivers/platform
- 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.
- 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/acpi.hlinux/arm-smccc.hlinux/bitfield.hlinux/errno.hlinux/hwmon.hlinux/platform_device.hlinux/string.hlinux/string_helpers.huapi/linux/psci.h
Detected Declarations
struct mlxbf_pmc_attributestruct mlxbf_pmc_block_infostruct mlxbf_pmc_contextstruct mlxbf_pmc_eventsfunction mlxbf_pmc_secure_readfunction mlxbf_pmc_readfunction mlxbf_pmc_readlfunction mlxbf_pmc_secure_writefunction mlxbf_pmc_writefunction mlxbf_pmc_valid_rangefunction mlxbf_pmc_event_supportedfunction mlxbf_pmc_get_event_numfunction mlxbf_pmc_config_l3_countersfunction mlxbf_pmc_program_l3_counterfunction mlxbf_pmc_program_crspace_counterfunction mlxbf_pmc_clear_crspace_counterfunction mlxbf_pmc_program_counterfunction mlxbf_pmc_read_l3_counterfunction mlxbf_pmc_read_crspace_counterfunction mlxbf_pmc_read_counterfunction mlxbf_pmc_read_l3_eventfunction mlxbf_pmc_read_crspace_eventfunction mlxbf_pmc_read_eventfunction mlxbf_pmc_read_regfunction mlxbf_pmc_write_regfunction mlxbf_pmc_counter_showfunction mlxbf_pmc_counter_storefunction mlxbf_pmc_event_showfunction mlxbf_pmc_event_storefunction mlxbf_pmc_event_list_showfunction mlxbf_pmc_enable_showfunction mlxbf_pmc_enable_storefunction mlxbf_pmc_count_clock_showfunction mlxbf_pmc_count_clock_storefunction mlxbf_pmc_init_perftype_counterfunction mlxbf_pmc_init_perftype_regfunction mlxbf_pmc_create_groupsfunction mlxbf_pmc_guid_matchfunction mlxbf_pmc_map_countersfunction mlxbf_pmc_probe
Annotated Snippet
struct mlxbf_pmc_attribute {
struct device_attribute dev_attr;
unsigned int index;
unsigned int nr;
};
/**
* struct mlxbf_pmc_block_info - Structure to hold info for each HW block
*
* @mmio_base: The VA at which the PMC block is mapped
* @blk_size: Size of each mapped region
* @counters: Number of counters in the block
* @type: Type of counters in the block
* @attr_counter: Attributes for "counter" sysfs files
* @attr_event: Attributes for "event" sysfs files
* @attr_event_list: Attributes for "event_list" sysfs files
* @attr_enable: Attributes for "enable" sysfs files
* @attr_count_clock: Attributes for "count_clock" sysfs files
* @block_attr: All attributes needed for the block
* @block_attr_grp: Attribute group for the block
*/
struct mlxbf_pmc_block_info {
void __iomem *mmio_base;
size_t blk_size;
size_t counters;
unsigned int type;
struct mlxbf_pmc_attribute *attr_counter;
struct mlxbf_pmc_attribute *attr_event;
struct mlxbf_pmc_attribute attr_event_list;
struct mlxbf_pmc_attribute attr_enable;
struct mlxbf_pmc_attribute attr_count_clock;
struct attribute *block_attr[MLXBF_PMC_MAX_ATTRS];
struct attribute_group block_attr_grp;
};
/**
* struct mlxbf_pmc_context - Structure to hold PMC context info
*
* @pdev: The kernel structure representing the device
* @total_blocks: Total number of blocks
* @tile_count: Number of tiles in the system
* @apt_enable: Info on enabled APTs
* @llt_enable: Info on enabled LLTs
* @mss_enable: Info on enabled MSSs
* @group_num: Group number assigned to each valid block
* @hwmon_dev: Hwmon device for bfperf
* @block_name: Block name
* @block: Block info
* @groups: Attribute groups from each block
* @svc_sreg_support: Whether SMCs are used to access performance registers
* @sreg_tbl_perf: Secure register access table number
* @event_set: Event set to use
*/
struct mlxbf_pmc_context {
struct platform_device *pdev;
u32 total_blocks;
u32 tile_count;
u8 apt_enable;
u8 llt_enable;
u8 mss_enable;
u32 group_num;
struct device *hwmon_dev;
const char *block_name[MLXBF_PMC_MAX_BLOCKS];
struct mlxbf_pmc_block_info block[MLXBF_PMC_MAX_BLOCKS];
const struct attribute_group *groups[MLXBF_PMC_MAX_BLOCKS];
bool svc_sreg_support;
u32 sreg_tbl_perf;
unsigned int event_set;
};
/**
* struct mlxbf_pmc_events - Structure to hold supported events for each block
* @evt_num: Event number used to program counters
* @evt_name: Name of the event
*/
struct mlxbf_pmc_events {
u32 evt_num;
char *evt_name;
};
static const struct mlxbf_pmc_events mlxbf_pmc_pcie_events[] = {
{ 0x0, "IN_P_PKT_CNT" },
{ 0x10, "IN_NP_PKT_CNT" },
{ 0x18, "IN_C_PKT_CNT" },
{ 0x20, "OUT_P_PKT_CNT" },
{ 0x28, "OUT_NP_PKT_CNT" },
{ 0x30, "OUT_C_PKT_CNT" },
{ 0x38, "IN_P_BYTE_CNT" },
{ 0x40, "IN_NP_BYTE_CNT" },
{ 0x48, "IN_C_BYTE_CNT" },
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/arm-smccc.h`, `linux/bitfield.h`, `linux/errno.h`, `linux/hwmon.h`, `linux/platform_device.h`, `linux/string.h`, `linux/string_helpers.h`.
- Detected declarations: `struct mlxbf_pmc_attribute`, `struct mlxbf_pmc_block_info`, `struct mlxbf_pmc_context`, `struct mlxbf_pmc_events`, `function mlxbf_pmc_secure_read`, `function mlxbf_pmc_read`, `function mlxbf_pmc_readl`, `function mlxbf_pmc_secure_write`, `function mlxbf_pmc_write`, `function mlxbf_pmc_valid_range`.
- Atlas domain: Driver Families / drivers/platform.
- 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.