Lines Matching refs:ccn
333 struct arm_ccn *ccn = pmu_to_arm_ccn(dev_get_drvdata(dev)); in arm_ccn_pmu_event_show() local
365 res += snprintf(buf + res, PAGE_SIZE - res, ",node=%d", ccn->mn_id); in arm_ccn_pmu_event_show()
381 struct arm_ccn *ccn = pmu_to_arm_ccn(dev_get_drvdata(dev)); in arm_ccn_pmu_events_is_visible() local
387 if (event->type == CCN_TYPE_SBAS && !ccn->sbas_present) in arm_ccn_pmu_events_is_visible()
389 if (event->type == CCN_TYPE_SBSX && !ccn->sbsx_present) in arm_ccn_pmu_events_is_visible()
462 static u64 *arm_ccn_pmu_get_cmp_mask(struct arm_ccn *ccn, const char *name) in arm_ccn_pmu_get_cmp_mask() argument
472 return &ccn->dt.cmp_mask[i].l; in arm_ccn_pmu_get_cmp_mask()
474 return &ccn->dt.cmp_mask[i].h; in arm_ccn_pmu_get_cmp_mask()
483 struct arm_ccn *ccn = pmu_to_arm_ccn(dev_get_drvdata(dev)); in arm_ccn_pmu_cmp_mask_show() local
484 u64 *mask = arm_ccn_pmu_get_cmp_mask(ccn, attr->attr.name); in arm_ccn_pmu_cmp_mask_show()
492 struct arm_ccn *ccn = pmu_to_arm_ccn(dev_get_drvdata(dev)); in arm_ccn_pmu_cmp_mask_store() local
493 u64 *mask = arm_ccn_pmu_get_cmp_mask(ccn, attr->attr.name); in arm_ccn_pmu_cmp_mask_store()
560 struct arm_ccn *ccn = pmu_to_arm_ccn(dev_get_drvdata(dev)); in arm_ccn_pmu_cpumask_show() local
562 return cpumap_print_to_pagebuf(true, buf, &ccn->dt.cpu); in arm_ccn_pmu_cpumask_show()
645 struct arm_ccn *ccn = pmu_to_arm_ccn(event->pmu); in arm_ccn_pmu_event_alloc() local
658 ccn->dt.pmu_counters_mask)) in arm_ccn_pmu_event_alloc()
662 ccn->dt.pmu_counters[CCN_IDX_PMU_CYCLE_COUNTER].event = event; in arm_ccn_pmu_event_alloc()
668 hw->idx = arm_ccn_pmu_alloc_bit(ccn->dt.pmu_counters_mask, in arm_ccn_pmu_event_alloc()
671 dev_dbg(ccn->dev, "No more counters available!\n"); in arm_ccn_pmu_event_alloc()
676 source = &ccn->xp[node_xp]; in arm_ccn_pmu_event_alloc()
678 source = &ccn->node[node_xp]; in arm_ccn_pmu_event_alloc()
679 ccn->dt.pmu_counters[hw->idx].source = source; in arm_ccn_pmu_event_alloc()
689 dev_dbg(ccn->dev, "No more event sources/watchpoints on node/XP %d!\n", in arm_ccn_pmu_event_alloc()
691 clear_bit(hw->idx, ccn->dt.pmu_counters_mask); in arm_ccn_pmu_event_alloc()
696 ccn->dt.pmu_counters[hw->idx].event = event; in arm_ccn_pmu_event_alloc()
703 struct arm_ccn *ccn = pmu_to_arm_ccn(event->pmu); in arm_ccn_pmu_event_release() local
707 clear_bit(CCN_IDX_PMU_CYCLE_COUNTER, ccn->dt.pmu_counters_mask); in arm_ccn_pmu_event_release()
710 ccn->dt.pmu_counters[hw->idx].source; in arm_ccn_pmu_event_release()
718 clear_bit(hw->idx, ccn->dt.pmu_counters_mask); in arm_ccn_pmu_event_release()
721 ccn->dt.pmu_counters[hw->idx].source = NULL; in arm_ccn_pmu_event_release()
722 ccn->dt.pmu_counters[hw->idx].event = NULL; in arm_ccn_pmu_event_release()
727 struct arm_ccn *ccn; in arm_ccn_pmu_event_init() local
737 ccn = pmu_to_arm_ccn(event->pmu); in arm_ccn_pmu_event_init()
740 dev_dbg(ccn->dev, "Sampling not supported!\n"); in arm_ccn_pmu_event_init()
748 dev_dbg(ccn->dev, "Can't exclude execution levels!\n"); in arm_ccn_pmu_event_init()
753 dev_dbg(ccn->dev, "Can't provide per-task data!\n"); in arm_ccn_pmu_event_init()
765 event->cpu = cpumask_first(&ccn->dt.cpu); in arm_ccn_pmu_event_init()
774 if (node_xp != ccn->mn_id) { in arm_ccn_pmu_event_init()
775 dev_dbg(ccn->dev, "Invalid MN ID %d!\n", node_xp); in arm_ccn_pmu_event_init()
780 if (node_xp >= ccn->num_xps) { in arm_ccn_pmu_event_init()
781 dev_dbg(ccn->dev, "Invalid XP ID %d!\n", node_xp); in arm_ccn_pmu_event_init()
788 if (node_xp >= ccn->num_nodes) { in arm_ccn_pmu_event_init()
789 dev_dbg(ccn->dev, "Invalid node ID %d!\n", node_xp); in arm_ccn_pmu_event_init()
792 if (!arm_ccn_pmu_type_eq(type, ccn->node[node_xp].type)) { in arm_ccn_pmu_event_init()
793 dev_dbg(ccn->dev, "Invalid type 0x%x for node %d!\n", in arm_ccn_pmu_event_init()
812 dev_dbg(ccn->dev, "Invalid port %d for node/XP %d!\n", in arm_ccn_pmu_event_init()
817 dev_dbg(ccn->dev, "Invalid vc %d for node/XP %d!\n", in arm_ccn_pmu_event_init()
824 dev_dbg(ccn->dev, "Invalid event 0x%x for node/XP %d!\n", in arm_ccn_pmu_event_init()
859 static u64 arm_ccn_pmu_read_counter(struct arm_ccn *ccn, int idx) in arm_ccn_pmu_read_counter() argument
865 res = readq(ccn->dt.base + CCN_DT_PMCCNTR); in arm_ccn_pmu_read_counter()
868 writel(0x1, ccn->dt.base + CCN_DT_PMSR_REQ); in arm_ccn_pmu_read_counter()
869 while (!(readl(ccn->dt.base + CCN_DT_PMSR) & 0x1)) in arm_ccn_pmu_read_counter()
871 writel(0x1, ccn->dt.base + CCN_DT_PMSR_CLR); in arm_ccn_pmu_read_counter()
872 res = readl(ccn->dt.base + CCN_DT_PMCCNTRSR + 4) & 0xff; in arm_ccn_pmu_read_counter()
874 res |= readl(ccn->dt.base + CCN_DT_PMCCNTRSR); in arm_ccn_pmu_read_counter()
877 res = readl(ccn->dt.base + CCN_DT_PMEVCNT(idx)); in arm_ccn_pmu_read_counter()
885 struct arm_ccn *ccn = pmu_to_arm_ccn(event->pmu); in arm_ccn_pmu_event_update() local
891 new_count = arm_ccn_pmu_read_counter(ccn, hw->idx); in arm_ccn_pmu_event_update()
901 struct arm_ccn *ccn = pmu_to_arm_ccn(event->pmu); in arm_ccn_pmu_xp_dt_config() local
911 xp = &ccn->xp[CCN_CONFIG_XP(event->attr.config)]; in arm_ccn_pmu_xp_dt_config()
913 xp = &ccn->xp[arm_ccn_node_to_xp( in arm_ccn_pmu_xp_dt_config()
921 spin_lock(&ccn->dt.config_lock); in arm_ccn_pmu_xp_dt_config()
929 spin_unlock(&ccn->dt.config_lock); in arm_ccn_pmu_xp_dt_config()
934 struct arm_ccn *ccn = pmu_to_arm_ccn(event->pmu); in arm_ccn_pmu_event_start() local
938 arm_ccn_pmu_read_counter(ccn, hw->idx)); in arm_ccn_pmu_event_start()
960 struct arm_ccn *ccn = pmu_to_arm_ccn(event->pmu); in arm_ccn_pmu_xp_watchpoint_config() local
963 ccn->dt.pmu_counters[hw->idx].source; in arm_ccn_pmu_xp_watchpoint_config()
968 u64 mask_l = ccn->dt.cmp_mask[CCN_CONFIG_MASK(event->attr.config)].l; in arm_ccn_pmu_xp_watchpoint_config()
969 u64 mask_h = ccn->dt.cmp_mask[CCN_CONFIG_MASK(event->attr.config)].h; in arm_ccn_pmu_xp_watchpoint_config()
1008 struct arm_ccn *ccn = pmu_to_arm_ccn(event->pmu); in arm_ccn_pmu_xp_event_config() local
1011 ccn->dt.pmu_counters[hw->idx].source; in arm_ccn_pmu_xp_event_config()
1029 struct arm_ccn *ccn = pmu_to_arm_ccn(event->pmu); in arm_ccn_pmu_node_event_config() local
1032 ccn->dt.pmu_counters[hw->idx].source; in arm_ccn_pmu_node_event_config()
1066 struct arm_ccn *ccn = pmu_to_arm_ccn(event->pmu); in arm_ccn_pmu_event_config() local
1079 spin_lock(&ccn->dt.config_lock); in arm_ccn_pmu_event_config()
1083 val = readl(ccn->dt.base + CCN_DT_ACTIVE_DSM + offset); in arm_ccn_pmu_event_config()
1087 writel(val, ccn->dt.base + CCN_DT_ACTIVE_DSM + offset); in arm_ccn_pmu_event_config()
1099 spin_unlock(&ccn->dt.config_lock); in arm_ccn_pmu_event_config()
1102 static int arm_ccn_pmu_active_counters(struct arm_ccn *ccn) in arm_ccn_pmu_active_counters() argument
1104 return bitmap_weight(ccn->dt.pmu_counters_mask, in arm_ccn_pmu_active_counters()
1112 struct arm_ccn *ccn = pmu_to_arm_ccn(event->pmu); in arm_ccn_pmu_event_add() local
1123 if (!ccn->irq && arm_ccn_pmu_active_counters(ccn) == 1) in arm_ccn_pmu_event_add()
1124 hrtimer_start(&ccn->dt.hrtimer, arm_ccn_pmu_timer_period(), in arm_ccn_pmu_event_add()
1139 struct arm_ccn *ccn = pmu_to_arm_ccn(event->pmu); in arm_ccn_pmu_event_del() local
1145 if (!ccn->irq && arm_ccn_pmu_active_counters(ccn) == 0) in arm_ccn_pmu_event_del()
1146 hrtimer_cancel(&ccn->dt.hrtimer); in arm_ccn_pmu_event_del()
1156 struct arm_ccn *ccn = pmu_to_arm_ccn(pmu); in arm_ccn_pmu_enable() local
1158 u32 val = readl(ccn->dt.base + CCN_DT_PMCR); in arm_ccn_pmu_enable()
1160 writel(val, ccn->dt.base + CCN_DT_PMCR); in arm_ccn_pmu_enable()
1165 struct arm_ccn *ccn = pmu_to_arm_ccn(pmu); in arm_ccn_pmu_disable() local
1167 u32 val = readl(ccn->dt.base + CCN_DT_PMCR); in arm_ccn_pmu_disable()
1169 writel(val, ccn->dt.base + CCN_DT_PMCR); in arm_ccn_pmu_disable()
1218 struct arm_ccn *ccn = container_of(dt, struct arm_ccn, dt); in arm_ccn_pmu_offline_cpu() local
1228 if (ccn->irq) in arm_ccn_pmu_offline_cpu()
1229 WARN_ON(irq_set_affinity_hint(ccn->irq, &dt->cpu) != 0); in arm_ccn_pmu_offline_cpu()
1235 static int arm_ccn_pmu_init(struct arm_ccn *ccn) in arm_ccn_pmu_init() argument
1242 ccn->dt.base = ccn->base + CCN_REGION_SIZE; in arm_ccn_pmu_init()
1243 spin_lock_init(&ccn->dt.config_lock); in arm_ccn_pmu_init()
1244 writel(CCN_DT_PMOVSR_CLR__MASK, ccn->dt.base + CCN_DT_PMOVSR_CLR); in arm_ccn_pmu_init()
1245 writel(CCN_DT_CTL__DT_EN, ccn->dt.base + CCN_DT_CTL); in arm_ccn_pmu_init()
1247 ccn->dt.base + CCN_DT_PMCR); in arm_ccn_pmu_init()
1248 writel(0x1, ccn->dt.base + CCN_DT_PMSR_CLR); in arm_ccn_pmu_init()
1249 for (i = 0; i < ccn->num_xps; i++) { in arm_ccn_pmu_init()
1250 writel(0, ccn->xp[i].base + CCN_XP_DT_CONFIG); in arm_ccn_pmu_init()
1256 ccn->xp[i].base + CCN_XP_DT_CONTROL); in arm_ccn_pmu_init()
1258 ccn->dt.cmp_mask[CCN_IDX_MASK_ANY].l = ~0; in arm_ccn_pmu_init()
1259 ccn->dt.cmp_mask[CCN_IDX_MASK_ANY].h = ~0; in arm_ccn_pmu_init()
1260 ccn->dt.cmp_mask[CCN_IDX_MASK_EXACT].l = 0; in arm_ccn_pmu_init()
1261 ccn->dt.cmp_mask[CCN_IDX_MASK_EXACT].h = 0; in arm_ccn_pmu_init()
1262 ccn->dt.cmp_mask[CCN_IDX_MASK_ORDER].l = ~0; in arm_ccn_pmu_init()
1263 ccn->dt.cmp_mask[CCN_IDX_MASK_ORDER].h = ~(0x1 << 15); in arm_ccn_pmu_init()
1264 ccn->dt.cmp_mask[CCN_IDX_MASK_OPCODE].l = ~0; in arm_ccn_pmu_init()
1265 ccn->dt.cmp_mask[CCN_IDX_MASK_OPCODE].h = ~(0x1f << 9); in arm_ccn_pmu_init()
1268 ccn->dt.id = ida_simple_get(&arm_ccn_pmu_ida, 0, 0, GFP_KERNEL); in arm_ccn_pmu_init()
1269 if (ccn->dt.id == 0) { in arm_ccn_pmu_init()
1272 name = devm_kasprintf(ccn->dev, GFP_KERNEL, "ccn_%d", in arm_ccn_pmu_init()
1273 ccn->dt.id); in arm_ccn_pmu_init()
1281 ccn->dt.pmu = (struct pmu) { in arm_ccn_pmu_init()
1296 if (!ccn->irq) { in arm_ccn_pmu_init()
1297 dev_info(ccn->dev, "No access to interrupts, using timer.\n"); in arm_ccn_pmu_init()
1298 hrtimer_init(&ccn->dt.hrtimer, CLOCK_MONOTONIC, in arm_ccn_pmu_init()
1300 ccn->dt.hrtimer.function = arm_ccn_pmu_timer_handler; in arm_ccn_pmu_init()
1304 cpumask_set_cpu(get_cpu(), &ccn->dt.cpu); in arm_ccn_pmu_init()
1307 if (ccn->irq) { in arm_ccn_pmu_init()
1308 err = irq_set_affinity_hint(ccn->irq, &ccn->dt.cpu); in arm_ccn_pmu_init()
1310 dev_err(ccn->dev, "Failed to set interrupt affinity!\n"); in arm_ccn_pmu_init()
1315 err = perf_pmu_register(&ccn->dt.pmu, name, -1); in arm_ccn_pmu_init()
1320 &ccn->dt.node); in arm_ccn_pmu_init()
1328 ida_simple_remove(&arm_ccn_pmu_ida, ccn->dt.id); in arm_ccn_pmu_init()
1329 for (i = 0; i < ccn->num_xps; i++) in arm_ccn_pmu_init()
1330 writel(0, ccn->xp[i].base + CCN_XP_DT_CONTROL); in arm_ccn_pmu_init()
1331 writel(0, ccn->dt.base + CCN_DT_PMCR); in arm_ccn_pmu_init()
1335 static void arm_ccn_pmu_cleanup(struct arm_ccn *ccn) in arm_ccn_pmu_cleanup() argument
1340 &ccn->dt.node); in arm_ccn_pmu_cleanup()
1341 if (ccn->irq) in arm_ccn_pmu_cleanup()
1342 irq_set_affinity_hint(ccn->irq, NULL); in arm_ccn_pmu_cleanup()
1343 for (i = 0; i < ccn->num_xps; i++) in arm_ccn_pmu_cleanup()
1344 writel(0, ccn->xp[i].base + CCN_XP_DT_CONTROL); in arm_ccn_pmu_cleanup()
1345 writel(0, ccn->dt.base + CCN_DT_PMCR); in arm_ccn_pmu_cleanup()
1346 perf_pmu_unregister(&ccn->dt.pmu); in arm_ccn_pmu_cleanup()
1347 ida_simple_remove(&arm_ccn_pmu_ida, ccn->dt.id); in arm_ccn_pmu_cleanup()
1350 static int arm_ccn_for_each_valid_region(struct arm_ccn *ccn, in arm_ccn_for_each_valid_region() argument
1351 int (*callback)(struct arm_ccn *ccn, int region, in arm_ccn_for_each_valid_region() argument
1361 val = readl(ccn->base + CCN_MN_OLY_COMP_LIST_63_0 + in arm_ccn_for_each_valid_region()
1366 base = ccn->base + region * CCN_REGION_SIZE; in arm_ccn_for_each_valid_region()
1373 err = callback(ccn, region, base, type, id); in arm_ccn_for_each_valid_region()
1381 static int arm_ccn_get_nodes_num(struct arm_ccn *ccn, int region, in arm_ccn_get_nodes_num() argument
1385 if (type == CCN_TYPE_XP && id >= ccn->num_xps) in arm_ccn_get_nodes_num()
1386 ccn->num_xps = id + 1; in arm_ccn_get_nodes_num()
1387 else if (id >= ccn->num_nodes) in arm_ccn_get_nodes_num()
1388 ccn->num_nodes = id + 1; in arm_ccn_get_nodes_num()
1393 static int arm_ccn_init_nodes(struct arm_ccn *ccn, int region, in arm_ccn_init_nodes() argument
1398 dev_dbg(ccn->dev, "Region %d: id=%u, type=0x%02x\n", region, id, type); in arm_ccn_init_nodes()
1402 ccn->mn_id = id; in arm_ccn_init_nodes()
1407 component = &ccn->xp[id]; in arm_ccn_init_nodes()
1410 ccn->sbsx_present = 1; in arm_ccn_init_nodes()
1411 component = &ccn->node[id]; in arm_ccn_init_nodes()
1414 ccn->sbas_present = 1; in arm_ccn_init_nodes()
1417 component = &ccn->node[id]; in arm_ccn_init_nodes()
1428 static irqreturn_t arm_ccn_error_handler(struct arm_ccn *ccn, in arm_ccn_error_handler() argument
1432 dev_err(ccn->dev, "Error reported in %08x%08x%08x%08x%08x%08x.\n", in arm_ccn_error_handler()
1435 dev_err(ccn->dev, "Disabling interrupt generation for all errors.\n"); in arm_ccn_error_handler()
1437 ccn->base + CCN_MN_ERRINT_STATUS); in arm_ccn_error_handler()
1446 struct arm_ccn *ccn = dev_id; in arm_ccn_irq_handler() local
1452 err_or = err_sig_val[0] = readl(ccn->base + CCN_MN_ERR_SIG_VAL_63_0); in arm_ccn_irq_handler()
1455 res = arm_ccn_pmu_overflow_handler(&ccn->dt); in arm_ccn_irq_handler()
1460 err_sig_val[i] = readl(ccn->base + in arm_ccn_irq_handler()
1465 res |= arm_ccn_error_handler(ccn, err_sig_val); in arm_ccn_irq_handler()
1469 ccn->base + CCN_MN_ERRINT_STATUS); in arm_ccn_irq_handler()
1477 struct arm_ccn *ccn; in arm_ccn_probe() local
1482 ccn = devm_kzalloc(&pdev->dev, sizeof(*ccn), GFP_KERNEL); in arm_ccn_probe()
1483 if (!ccn) in arm_ccn_probe()
1485 ccn->dev = &pdev->dev; in arm_ccn_probe()
1486 platform_set_drvdata(pdev, ccn); in arm_ccn_probe()
1489 ccn->base = devm_ioremap_resource(ccn->dev, res); in arm_ccn_probe()
1490 if (IS_ERR(ccn->base)) in arm_ccn_probe()
1491 return PTR_ERR(ccn->base); in arm_ccn_probe()
1500 ccn->base + CCN_MN_ERRINT_STATUS); in arm_ccn_probe()
1501 if (readl(ccn->base + CCN_MN_ERRINT_STATUS) & in arm_ccn_probe()
1505 ccn->base + CCN_MN_ERRINT_STATUS); in arm_ccn_probe()
1506 err = devm_request_irq(ccn->dev, irq, arm_ccn_irq_handler, in arm_ccn_probe()
1508 dev_name(ccn->dev), ccn); in arm_ccn_probe()
1512 ccn->irq = irq; in arm_ccn_probe()
1518 err = arm_ccn_for_each_valid_region(ccn, arm_ccn_get_nodes_num); in arm_ccn_probe()
1522 ccn->node = devm_kcalloc(ccn->dev, ccn->num_nodes, sizeof(*ccn->node), in arm_ccn_probe()
1524 ccn->xp = devm_kcalloc(ccn->dev, ccn->num_xps, sizeof(*ccn->node), in arm_ccn_probe()
1526 if (!ccn->node || !ccn->xp) in arm_ccn_probe()
1529 err = arm_ccn_for_each_valid_region(ccn, arm_ccn_init_nodes); in arm_ccn_probe()
1533 return arm_ccn_pmu_init(ccn); in arm_ccn_probe()
1538 struct arm_ccn *ccn = platform_get_drvdata(pdev); in arm_ccn_remove() local
1540 arm_ccn_pmu_cleanup(ccn); in arm_ccn_remove()