.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | | - * This program is free software; you can redistribute it and/or modify |
---|
3 | | - * it under the terms of the GNU General Public License version 2 as |
---|
4 | | - * published by the Free Software Foundation. |
---|
5 | | - * |
---|
6 | | - * This program is distributed in the hope that it will be useful, |
---|
7 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
8 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
9 | | - * GNU General Public License for more details. |
---|
10 | 3 | * |
---|
11 | 4 | * Copyright (C) 2014 ARM Limited |
---|
12 | 5 | */ |
---|
.. | .. |
---|
167 | 160 | |
---|
168 | 161 | struct hrtimer hrtimer; |
---|
169 | 162 | |
---|
170 | | - cpumask_t cpu; |
---|
| 163 | + unsigned int cpu; |
---|
171 | 164 | struct hlist_node node; |
---|
172 | 165 | |
---|
173 | 166 | struct pmu pmu; |
---|
.. | .. |
---|
335 | 328 | struct arm_ccn_pmu_event, attr); |
---|
336 | 329 | ssize_t res; |
---|
337 | 330 | |
---|
338 | | - res = snprintf(buf, PAGE_SIZE, "type=0x%x", event->type); |
---|
| 331 | + res = scnprintf(buf, PAGE_SIZE, "type=0x%x", event->type); |
---|
339 | 332 | if (event->event) |
---|
340 | | - res += snprintf(buf + res, PAGE_SIZE - res, ",event=0x%x", |
---|
| 333 | + res += scnprintf(buf + res, PAGE_SIZE - res, ",event=0x%x", |
---|
341 | 334 | event->event); |
---|
342 | 335 | if (event->def) |
---|
343 | | - res += snprintf(buf + res, PAGE_SIZE - res, ",%s", |
---|
| 336 | + res += scnprintf(buf + res, PAGE_SIZE - res, ",%s", |
---|
344 | 337 | event->def); |
---|
345 | 338 | if (event->mask) |
---|
346 | | - res += snprintf(buf + res, PAGE_SIZE - res, ",mask=0x%x", |
---|
| 339 | + res += scnprintf(buf + res, PAGE_SIZE - res, ",mask=0x%x", |
---|
347 | 340 | event->mask); |
---|
348 | 341 | |
---|
349 | 342 | /* Arguments required by an event */ |
---|
.. | .. |
---|
351 | 344 | case CCN_TYPE_CYCLES: |
---|
352 | 345 | break; |
---|
353 | 346 | case CCN_TYPE_XP: |
---|
354 | | - res += snprintf(buf + res, PAGE_SIZE - res, |
---|
| 347 | + res += scnprintf(buf + res, PAGE_SIZE - res, |
---|
355 | 348 | ",xp=?,vc=?"); |
---|
356 | 349 | if (event->event == CCN_EVENT_WATCHPOINT) |
---|
357 | | - res += snprintf(buf + res, PAGE_SIZE - res, |
---|
| 350 | + res += scnprintf(buf + res, PAGE_SIZE - res, |
---|
358 | 351 | ",port=?,dir=?,cmp_l=?,cmp_h=?,mask=?"); |
---|
359 | 352 | else |
---|
360 | | - res += snprintf(buf + res, PAGE_SIZE - res, |
---|
| 353 | + res += scnprintf(buf + res, PAGE_SIZE - res, |
---|
361 | 354 | ",bus=?"); |
---|
362 | 355 | |
---|
363 | 356 | break; |
---|
364 | 357 | case CCN_TYPE_MN: |
---|
365 | | - res += snprintf(buf + res, PAGE_SIZE - res, ",node=%d", ccn->mn_id); |
---|
| 358 | + res += scnprintf(buf + res, PAGE_SIZE - res, ",node=%d", ccn->mn_id); |
---|
366 | 359 | break; |
---|
367 | 360 | default: |
---|
368 | | - res += snprintf(buf + res, PAGE_SIZE - res, ",node=?"); |
---|
| 361 | + res += scnprintf(buf + res, PAGE_SIZE - res, ",node=?"); |
---|
369 | 362 | break; |
---|
370 | 363 | } |
---|
371 | 364 | |
---|
372 | | - res += snprintf(buf + res, PAGE_SIZE - res, "\n"); |
---|
| 365 | + res += scnprintf(buf + res, PAGE_SIZE - res, "\n"); |
---|
373 | 366 | |
---|
374 | 367 | return res; |
---|
375 | 368 | } |
---|
.. | .. |
---|
559 | 552 | { |
---|
560 | 553 | struct arm_ccn *ccn = pmu_to_arm_ccn(dev_get_drvdata(dev)); |
---|
561 | 554 | |
---|
562 | | - return cpumap_print_to_pagebuf(true, buf, &ccn->dt.cpu); |
---|
| 555 | + return cpumap_print_to_pagebuf(true, buf, cpumask_of(ccn->dt.cpu)); |
---|
563 | 556 | } |
---|
564 | 557 | |
---|
565 | 558 | static struct device_attribute arm_ccn_pmu_cpumask_attr = |
---|
.. | .. |
---|
741 | 734 | return -EOPNOTSUPP; |
---|
742 | 735 | } |
---|
743 | 736 | |
---|
744 | | - if (has_branch_stack(event) || event->attr.exclude_user || |
---|
745 | | - event->attr.exclude_kernel || event->attr.exclude_hv || |
---|
746 | | - event->attr.exclude_idle || event->attr.exclude_host || |
---|
747 | | - event->attr.exclude_guest) { |
---|
| 737 | + if (has_branch_stack(event)) { |
---|
748 | 738 | dev_dbg(ccn->dev, "Can't exclude execution levels!\n"); |
---|
749 | 739 | return -EINVAL; |
---|
750 | 740 | } |
---|
.. | .. |
---|
762 | 752 | * mitigate this, we enforce CPU assignment to one, selected |
---|
763 | 753 | * processor (the one described in the "cpumask" attribute). |
---|
764 | 754 | */ |
---|
765 | | - event->cpu = cpumask_first(&ccn->dt.cpu); |
---|
| 755 | + event->cpu = ccn->dt.cpu; |
---|
766 | 756 | |
---|
767 | 757 | node_xp = CCN_CONFIG_NODE(event->attr.config); |
---|
768 | 758 | type = CCN_CONFIG_TYPE(event->attr.config); |
---|
.. | .. |
---|
1218 | 1208 | struct arm_ccn *ccn = container_of(dt, struct arm_ccn, dt); |
---|
1219 | 1209 | unsigned int target; |
---|
1220 | 1210 | |
---|
1221 | | - if (!cpumask_test_and_clear_cpu(cpu, &dt->cpu)) |
---|
| 1211 | + if (cpu != dt->cpu) |
---|
1222 | 1212 | return 0; |
---|
1223 | 1213 | target = cpumask_any_but(cpu_online_mask, cpu); |
---|
1224 | 1214 | if (target >= nr_cpu_ids) |
---|
1225 | 1215 | return 0; |
---|
1226 | 1216 | perf_pmu_migrate_context(&dt->pmu, cpu, target); |
---|
1227 | | - cpumask_set_cpu(target, &dt->cpu); |
---|
| 1217 | + dt->cpu = target; |
---|
1228 | 1218 | if (ccn->irq) |
---|
1229 | | - WARN_ON(irq_set_affinity_hint(ccn->irq, &dt->cpu) != 0); |
---|
| 1219 | + WARN_ON(irq_set_affinity_hint(ccn->irq, cpumask_of(dt->cpu))); |
---|
1230 | 1220 | return 0; |
---|
1231 | 1221 | } |
---|
1232 | 1222 | |
---|
.. | .. |
---|
1290 | 1280 | .read = arm_ccn_pmu_event_read, |
---|
1291 | 1281 | .pmu_enable = arm_ccn_pmu_enable, |
---|
1292 | 1282 | .pmu_disable = arm_ccn_pmu_disable, |
---|
| 1283 | + .capabilities = PERF_PMU_CAP_NO_EXCLUDE, |
---|
1293 | 1284 | }; |
---|
1294 | 1285 | |
---|
1295 | 1286 | /* No overflow interrupt? Have to use a timer instead. */ |
---|
.. | .. |
---|
1301 | 1292 | } |
---|
1302 | 1293 | |
---|
1303 | 1294 | /* Pick one CPU which we will use to collect data from CCN... */ |
---|
1304 | | - cpumask_set_cpu(get_cpu(), &ccn->dt.cpu); |
---|
| 1295 | + ccn->dt.cpu = raw_smp_processor_id(); |
---|
1305 | 1296 | |
---|
1306 | 1297 | /* Also make sure that the overflow interrupt is handled by this CPU */ |
---|
1307 | 1298 | if (ccn->irq) { |
---|
1308 | | - err = irq_set_affinity_hint(ccn->irq, &ccn->dt.cpu); |
---|
| 1299 | + err = irq_set_affinity_hint(ccn->irq, cpumask_of(ccn->dt.cpu)); |
---|
1309 | 1300 | if (err) { |
---|
1310 | 1301 | dev_err(ccn->dev, "Failed to set interrupt affinity!\n"); |
---|
1311 | 1302 | goto error_set_affinity; |
---|
1312 | 1303 | } |
---|
1313 | 1304 | } |
---|
1314 | 1305 | |
---|
| 1306 | + cpuhp_state_add_instance_nocalls(CPUHP_AP_PERF_ARM_CCN_ONLINE, |
---|
| 1307 | + &ccn->dt.node); |
---|
| 1308 | + |
---|
1315 | 1309 | err = perf_pmu_register(&ccn->dt.pmu, name, -1); |
---|
1316 | 1310 | if (err) |
---|
1317 | 1311 | goto error_pmu_register; |
---|
1318 | 1312 | |
---|
1319 | | - cpuhp_state_add_instance_nocalls(CPUHP_AP_PERF_ARM_CCN_ONLINE, |
---|
1320 | | - &ccn->dt.node); |
---|
1321 | | - put_cpu(); |
---|
1322 | 1313 | return 0; |
---|
1323 | 1314 | |
---|
1324 | 1315 | error_pmu_register: |
---|
| 1316 | + cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_CCN_ONLINE, |
---|
| 1317 | + &ccn->dt.node); |
---|
1325 | 1318 | error_set_affinity: |
---|
1326 | | - put_cpu(); |
---|
1327 | 1319 | error_choose_name: |
---|
1328 | 1320 | ida_simple_remove(&arm_ccn_pmu_ida, ccn->dt.id); |
---|
1329 | 1321 | for (i = 0; i < ccn->num_xps; i++) |
---|
.. | .. |
---|
1412 | 1404 | break; |
---|
1413 | 1405 | case CCN_TYPE_SBAS: |
---|
1414 | 1406 | ccn->sbas_present = 1; |
---|
1415 | | - /* Fall-through */ |
---|
| 1407 | + fallthrough; |
---|
1416 | 1408 | default: |
---|
1417 | 1409 | component = &ccn->node[id]; |
---|
1418 | 1410 | break; |
---|
.. | .. |
---|
1485 | 1477 | ccn->dev = &pdev->dev; |
---|
1486 | 1478 | platform_set_drvdata(pdev, ccn); |
---|
1487 | 1479 | |
---|
1488 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
---|
1489 | | - ccn->base = devm_ioremap_resource(ccn->dev, res); |
---|
| 1480 | + ccn->base = devm_platform_ioremap_resource(pdev, 0); |
---|
1490 | 1481 | if (IS_ERR(ccn->base)) |
---|
1491 | 1482 | return PTR_ERR(ccn->base); |
---|
1492 | 1483 | |
---|
.. | .. |
---|
1545 | 1536 | static const struct of_device_id arm_ccn_match[] = { |
---|
1546 | 1537 | { .compatible = "arm,ccn-502", }, |
---|
1547 | 1538 | { .compatible = "arm,ccn-504", }, |
---|
| 1539 | + { .compatible = "arm,ccn-512", }, |
---|
1548 | 1540 | {}, |
---|
1549 | 1541 | }; |
---|
1550 | 1542 | MODULE_DEVICE_TABLE(of, arm_ccn_match); |
---|
.. | .. |
---|
1553 | 1545 | .driver = { |
---|
1554 | 1546 | .name = "arm-ccn", |
---|
1555 | 1547 | .of_match_table = arm_ccn_match, |
---|
| 1548 | + .suppress_bind_attrs = true, |
---|
1556 | 1549 | }, |
---|
1557 | 1550 | .probe = arm_ccn_probe, |
---|
1558 | 1551 | .remove = arm_ccn_remove, |
---|