Lines Matching full:pmc
97 * @mmio_base: The VA at which the PMC block is mapped
122 * struct mlxbf_pmc_context - Structure to hold PMC context info
426 static struct mlxbf_pmc_context *pmc; variable
438 arm_smccc_smc(command, pmc->sreg_tbl_perf, (uintptr_t)addr, 0, 0, 0, 0, in mlxbf_pmc_secure_read()
462 if (pmc->svc_sreg_support) in mlxbf_pmc_read()
494 arm_smccc_smc(command, pmc->sreg_tbl_perf, value, (uintptr_t)addr, 0, 0, in mlxbf_pmc_secure_write()
514 if (pmc->svc_sreg_support) in mlxbf_pmc_write()
529 (offset + MLXBF_PMC_REG_SIZE <= pmc->block[blk_num].blk_size)) in mlxbf_pmc_valid_range()
530 return true; /* inside the mapped PMC space */ in mlxbf_pmc_valid_range()
551 switch (pmc->event_set) { in mlxbf_pmc_event_list()
637 return mlxbf_pmc_write(pmc->block[blk_num].mmio_base + in mlxbf_pmc_config_l3_counters()
659 pmcaddr = pmc->block[blk_num].mmio_base + in mlxbf_pmc_program_l3_counter()
664 pmcaddr = pmc->block[blk_num].mmio_base + in mlxbf_pmc_program_l3_counter()
715 if (cnt_num >= pmc->block[blk_num].counters) in mlxbf_pmc_program_counter()
736 if (mlxbf_pmc_write(pmc->block[blk_num].mmio_base + in mlxbf_pmc_program_counter()
750 if (mlxbf_pmc_write(pmc->block[blk_num].mmio_base + in mlxbf_pmc_program_counter()
761 if (mlxbf_pmc_write(pmc->block[blk_num].mmio_base + in mlxbf_pmc_program_counter()
777 status = mlxbf_pmc_readl(pmc->block[blk_num].mmio_base + in mlxbf_pmc_read_l3_counter()
785 status = mlxbf_pmc_readl(pmc->block[blk_num].mmio_base + in mlxbf_pmc_read_l3_counter()
809 if (cnt_num >= pmc->block[blk_num].counters) in mlxbf_pmc_read_counter()
817 pmc->block[blk_num].counters * MLXBF_PMC_REG_SIZE; in mlxbf_pmc_read_counter()
825 status = mlxbf_pmc_write(pmc->block[blk_num].mmio_base + perfcfg_offset, in mlxbf_pmc_read_counter()
832 return mlxbf_pmc_read(pmc->block[blk_num].mmio_base + perfval_offset, in mlxbf_pmc_read_counter()
848 pmcaddr = pmc->block[blk_num].mmio_base + in mlxbf_pmc_read_l3_event()
853 pmcaddr = pmc->block[blk_num].mmio_base + in mlxbf_pmc_read_l3_event()
897 if (cnt_num >= pmc->block[blk_num].counters) in mlxbf_pmc_read_event()
905 pmc->block[blk_num].counters * MLXBF_PMC_REG_SIZE; in mlxbf_pmc_read_event()
913 if (mlxbf_pmc_write(pmc->block[blk_num].mmio_base + perfcfg_offset, in mlxbf_pmc_read_event()
919 if (mlxbf_pmc_read(pmc->block[blk_num].mmio_base + perfval_offset, in mlxbf_pmc_read_event()
932 if (mlxbf_pmc_write(pmc->block[blk_num].mmio_base + perfcfg_offset, in mlxbf_pmc_read_event()
937 if (mlxbf_pmc_read(pmc->block[blk_num].mmio_base + perfval_offset, in mlxbf_pmc_read_event()
951 if (strstr(pmc->block_name[blk_num], "ecc")) { in mlxbf_pmc_read_reg()
952 if (mlxbf_pmc_readl(pmc->block[blk_num].mmio_base + offset, in mlxbf_pmc_read_reg()
961 return mlxbf_pmc_read(pmc->block[blk_num].mmio_base + offset, in mlxbf_pmc_read_reg()
970 if (strstr(pmc->block_name[blk_num], "ecc")) { in mlxbf_pmc_write_reg()
971 return mlxbf_pmc_write(pmc->block[blk_num].mmio_base + offset, in mlxbf_pmc_write_reg()
976 return mlxbf_pmc_write(pmc->block[blk_num].mmio_base + offset, in mlxbf_pmc_write_reg()
995 if (strstr(pmc->block_name[blk_num], "l3cache")) in mlxbf_pmc_counter_show()
998 if (pmc->block[blk_num].type == MLXBF_PMC_TYPE_COUNTER) { in mlxbf_pmc_counter_show()
1001 } else if (pmc->block[blk_num].type == MLXBF_PMC_TYPE_REGISTER) { in mlxbf_pmc_counter_show()
1002 offset = mlxbf_pmc_get_event_num(pmc->block_name[blk_num], in mlxbf_pmc_counter_show()
1033 if (!(strstr(pmc->block_name[blk_num], "ecc")) && data) in mlxbf_pmc_counter_store()
1037 if (strstr(pmc->block_name[blk_num], "l3cache")) in mlxbf_pmc_counter_store()
1040 if (pmc->block[blk_num].type == MLXBF_PMC_TYPE_COUNTER) { in mlxbf_pmc_counter_store()
1048 } else if (pmc->block[blk_num].type == MLXBF_PMC_TYPE_REGISTER) { in mlxbf_pmc_counter_store()
1049 offset = mlxbf_pmc_get_event_num(pmc->block_name[blk_num], in mlxbf_pmc_counter_store()
1076 if (strstr(pmc->block_name[blk_num], "l3cache")) in mlxbf_pmc_event_show()
1083 evt_name = mlxbf_pmc_get_event_name(pmc->block_name[blk_num], evt_num); in mlxbf_pmc_event_show()
1104 evt_num = mlxbf_pmc_get_event_num(pmc->block_name[blk_num], in mlxbf_pmc_event_store()
1114 if (strstr(pmc->block_name[blk_num], "l3cache")) in mlxbf_pmc_event_store()
1137 events = mlxbf_pmc_event_list(pmc->block_name[blk_num], &size); in mlxbf_pmc_event_list_show()
1164 if (mlxbf_pmc_readl(pmc->block[blk_num].mmio_base + in mlxbf_pmc_enable_show()
1213 attr = &pmc->block[blk_num].attr_event_list; in mlxbf_pmc_init_perftype_counter()
1218 pmc->block[blk_num].block_attr[i] = &attr->dev_attr.attr; in mlxbf_pmc_init_perftype_counter()
1222 if (strstr(pmc->block_name[blk_num], "l3cache")) { in mlxbf_pmc_init_perftype_counter()
1223 attr = &pmc->block[blk_num].attr_enable; in mlxbf_pmc_init_perftype_counter()
1230 pmc->block[blk_num].block_attr[++i] = &attr->dev_attr.attr; in mlxbf_pmc_init_perftype_counter()
1234 pmc->block[blk_num].attr_counter = devm_kcalloc( in mlxbf_pmc_init_perftype_counter()
1235 dev, pmc->block[blk_num].counters, in mlxbf_pmc_init_perftype_counter()
1237 if (!pmc->block[blk_num].attr_counter) in mlxbf_pmc_init_perftype_counter()
1240 pmc->block[blk_num].attr_event = devm_kcalloc( in mlxbf_pmc_init_perftype_counter()
1241 dev, pmc->block[blk_num].counters, in mlxbf_pmc_init_perftype_counter()
1243 if (!pmc->block[blk_num].attr_event) in mlxbf_pmc_init_perftype_counter()
1247 for (j = 0; j < pmc->block[blk_num].counters; ++j) { in mlxbf_pmc_init_perftype_counter()
1248 attr = &pmc->block[blk_num].attr_counter[j]; in mlxbf_pmc_init_perftype_counter()
1256 pmc->block[blk_num].block_attr[++i] = &attr->dev_attr.attr; in mlxbf_pmc_init_perftype_counter()
1259 attr = &pmc->block[blk_num].attr_event[j]; in mlxbf_pmc_init_perftype_counter()
1267 pmc->block[blk_num].block_attr[++i] = &attr->dev_attr.attr; in mlxbf_pmc_init_perftype_counter()
1281 events = mlxbf_pmc_event_list(pmc->block_name[blk_num], &j); in mlxbf_pmc_init_perftype_reg()
1285 pmc->block[blk_num].attr_event = devm_kcalloc( in mlxbf_pmc_init_perftype_reg()
1287 if (!pmc->block[blk_num].attr_event) in mlxbf_pmc_init_perftype_reg()
1292 attr = &pmc->block[blk_num].attr_event[j]; in mlxbf_pmc_init_perftype_reg()
1299 pmc->block[blk_num].block_attr[i] = &attr->dev_attr.attr; in mlxbf_pmc_init_perftype_reg()
1313 if (pmc->block[blk_num].type == MLXBF_PMC_TYPE_COUNTER) in mlxbf_pmc_create_groups()
1315 else if (pmc->block[blk_num].type == MLXBF_PMC_TYPE_REGISTER) in mlxbf_pmc_create_groups()
1324 pmc->block[blk_num].block_attr_grp.attrs = pmc->block[blk_num].block_attr; in mlxbf_pmc_create_groups()
1325 pmc->block[blk_num].block_attr_grp.name = devm_kasprintf( in mlxbf_pmc_create_groups()
1326 dev, GFP_KERNEL, pmc->block_name[blk_num]); in mlxbf_pmc_create_groups()
1327 pmc->groups[blk_num] = &pmc->block[blk_num].block_attr_grp; in mlxbf_pmc_create_groups()
1349 for (i = 0; i < pmc->total_blocks; ++i) { in mlxbf_pmc_map_counters()
1350 if (strstr(pmc->block_name[i], "tile")) { in mlxbf_pmc_map_counters()
1351 ret = sscanf(pmc->block_name[i], "tile%d", &tile_num); in mlxbf_pmc_map_counters()
1355 if (tile_num >= pmc->tile_count) in mlxbf_pmc_map_counters()
1358 ret = device_property_read_u64_array(dev, pmc->block_name[i], in mlxbf_pmc_map_counters()
1367 if (pmc->svc_sreg_support) in mlxbf_pmc_map_counters()
1368 pmc->block[i].mmio_base = (void __iomem *)info[0]; in mlxbf_pmc_map_counters()
1370 pmc->block[i].mmio_base = in mlxbf_pmc_map_counters()
1373 pmc->block[i].blk_size = info[1]; in mlxbf_pmc_map_counters()
1374 pmc->block[i].counters = info[2]; in mlxbf_pmc_map_counters()
1375 pmc->block[i].type = info[3]; in mlxbf_pmc_map_counters()
1377 if (!pmc->block[i].mmio_base) in mlxbf_pmc_map_counters()
1403 pmc = devm_kzalloc(dev, sizeof(struct mlxbf_pmc_context), GFP_KERNEL); in mlxbf_pmc_probe()
1404 if (!pmc) in mlxbf_pmc_probe()
1412 &pmc->sreg_tbl_perf); in mlxbf_pmc_probe()
1414 pmc->svc_sreg_support = false; in mlxbf_pmc_probe()
1419 * them in the pmc struct. in mlxbf_pmc_probe()
1425 pmc->svc_sreg_support = true; in mlxbf_pmc_probe()
1431 pmc->event_set = MLXBF_PMC_EVENT_SET_BF1; in mlxbf_pmc_probe()
1433 pmc->event_set = MLXBF_PMC_EVENT_SET_BF2; in mlxbf_pmc_probe()
1437 ret = device_property_read_u32(dev, "block_num", &pmc->total_blocks); in mlxbf_pmc_probe()
1442 pmc->block_name, in mlxbf_pmc_probe()
1443 pmc->total_blocks); in mlxbf_pmc_probe()
1444 if (ret != pmc->total_blocks) in mlxbf_pmc_probe()
1447 ret = device_property_read_u32(dev, "tile_num", &pmc->tile_count); in mlxbf_pmc_probe()
1451 pmc->pdev = pdev; in mlxbf_pmc_probe()
1457 pmc->hwmon_dev = devm_hwmon_device_register_with_groups( in mlxbf_pmc_probe()
1458 dev, "bfperf", pmc, pmc->groups); in mlxbf_pmc_probe()
1459 platform_set_drvdata(pdev, pmc); in mlxbf_pmc_probe()
1470 .driver = { .name = "mlxbf-pmc",
1478 MODULE_DESCRIPTION("Mellanox PMC driver");