hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/perf/arm-ccn.c
....@@ -1,12 +1,5 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
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.
103 *
114 * Copyright (C) 2014 ARM Limited
125 */
....@@ -167,7 +160,7 @@
167160
168161 struct hrtimer hrtimer;
169162
170
- cpumask_t cpu;
163
+ unsigned int cpu;
171164 struct hlist_node node;
172165
173166 struct pmu pmu;
....@@ -335,15 +328,15 @@
335328 struct arm_ccn_pmu_event, attr);
336329 ssize_t res;
337330
338
- res = snprintf(buf, PAGE_SIZE, "type=0x%x", event->type);
331
+ res = scnprintf(buf, PAGE_SIZE, "type=0x%x", event->type);
339332 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",
341334 event->event);
342335 if (event->def)
343
- res += snprintf(buf + res, PAGE_SIZE - res, ",%s",
336
+ res += scnprintf(buf + res, PAGE_SIZE - res, ",%s",
344337 event->def);
345338 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",
347340 event->mask);
348341
349342 /* Arguments required by an event */
....@@ -351,25 +344,25 @@
351344 case CCN_TYPE_CYCLES:
352345 break;
353346 case CCN_TYPE_XP:
354
- res += snprintf(buf + res, PAGE_SIZE - res,
347
+ res += scnprintf(buf + res, PAGE_SIZE - res,
355348 ",xp=?,vc=?");
356349 if (event->event == CCN_EVENT_WATCHPOINT)
357
- res += snprintf(buf + res, PAGE_SIZE - res,
350
+ res += scnprintf(buf + res, PAGE_SIZE - res,
358351 ",port=?,dir=?,cmp_l=?,cmp_h=?,mask=?");
359352 else
360
- res += snprintf(buf + res, PAGE_SIZE - res,
353
+ res += scnprintf(buf + res, PAGE_SIZE - res,
361354 ",bus=?");
362355
363356 break;
364357 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);
366359 break;
367360 default:
368
- res += snprintf(buf + res, PAGE_SIZE - res, ",node=?");
361
+ res += scnprintf(buf + res, PAGE_SIZE - res, ",node=?");
369362 break;
370363 }
371364
372
- res += snprintf(buf + res, PAGE_SIZE - res, "\n");
365
+ res += scnprintf(buf + res, PAGE_SIZE - res, "\n");
373366
374367 return res;
375368 }
....@@ -559,7 +552,7 @@
559552 {
560553 struct arm_ccn *ccn = pmu_to_arm_ccn(dev_get_drvdata(dev));
561554
562
- return cpumap_print_to_pagebuf(true, buf, &ccn->dt.cpu);
555
+ return cpumap_print_to_pagebuf(true, buf, cpumask_of(ccn->dt.cpu));
563556 }
564557
565558 static struct device_attribute arm_ccn_pmu_cpumask_attr =
....@@ -741,10 +734,7 @@
741734 return -EOPNOTSUPP;
742735 }
743736
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)) {
748738 dev_dbg(ccn->dev, "Can't exclude execution levels!\n");
749739 return -EINVAL;
750740 }
....@@ -762,7 +752,7 @@
762752 * mitigate this, we enforce CPU assignment to one, selected
763753 * processor (the one described in the "cpumask" attribute).
764754 */
765
- event->cpu = cpumask_first(&ccn->dt.cpu);
755
+ event->cpu = ccn->dt.cpu;
766756
767757 node_xp = CCN_CONFIG_NODE(event->attr.config);
768758 type = CCN_CONFIG_TYPE(event->attr.config);
....@@ -1218,15 +1208,15 @@
12181208 struct arm_ccn *ccn = container_of(dt, struct arm_ccn, dt);
12191209 unsigned int target;
12201210
1221
- if (!cpumask_test_and_clear_cpu(cpu, &dt->cpu))
1211
+ if (cpu != dt->cpu)
12221212 return 0;
12231213 target = cpumask_any_but(cpu_online_mask, cpu);
12241214 if (target >= nr_cpu_ids)
12251215 return 0;
12261216 perf_pmu_migrate_context(&dt->pmu, cpu, target);
1227
- cpumask_set_cpu(target, &dt->cpu);
1217
+ dt->cpu = target;
12281218 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)));
12301220 return 0;
12311221 }
12321222
....@@ -1290,6 +1280,7 @@
12901280 .read = arm_ccn_pmu_event_read,
12911281 .pmu_enable = arm_ccn_pmu_enable,
12921282 .pmu_disable = arm_ccn_pmu_disable,
1283
+ .capabilities = PERF_PMU_CAP_NO_EXCLUDE,
12931284 };
12941285
12951286 /* No overflow interrupt? Have to use a timer instead. */
....@@ -1301,29 +1292,30 @@
13011292 }
13021293
13031294 /* 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();
13051296
13061297 /* Also make sure that the overflow interrupt is handled by this CPU */
13071298 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));
13091300 if (err) {
13101301 dev_err(ccn->dev, "Failed to set interrupt affinity!\n");
13111302 goto error_set_affinity;
13121303 }
13131304 }
13141305
1306
+ cpuhp_state_add_instance_nocalls(CPUHP_AP_PERF_ARM_CCN_ONLINE,
1307
+ &ccn->dt.node);
1308
+
13151309 err = perf_pmu_register(&ccn->dt.pmu, name, -1);
13161310 if (err)
13171311 goto error_pmu_register;
13181312
1319
- cpuhp_state_add_instance_nocalls(CPUHP_AP_PERF_ARM_CCN_ONLINE,
1320
- &ccn->dt.node);
1321
- put_cpu();
13221313 return 0;
13231314
13241315 error_pmu_register:
1316
+ cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_CCN_ONLINE,
1317
+ &ccn->dt.node);
13251318 error_set_affinity:
1326
- put_cpu();
13271319 error_choose_name:
13281320 ida_simple_remove(&arm_ccn_pmu_ida, ccn->dt.id);
13291321 for (i = 0; i < ccn->num_xps; i++)
....@@ -1412,7 +1404,7 @@
14121404 break;
14131405 case CCN_TYPE_SBAS:
14141406 ccn->sbas_present = 1;
1415
- /* Fall-through */
1407
+ fallthrough;
14161408 default:
14171409 component = &ccn->node[id];
14181410 break;
....@@ -1485,8 +1477,7 @@
14851477 ccn->dev = &pdev->dev;
14861478 platform_set_drvdata(pdev, ccn);
14871479
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);
14901481 if (IS_ERR(ccn->base))
14911482 return PTR_ERR(ccn->base);
14921483
....@@ -1545,6 +1536,7 @@
15451536 static const struct of_device_id arm_ccn_match[] = {
15461537 { .compatible = "arm,ccn-502", },
15471538 { .compatible = "arm,ccn-504", },
1539
+ { .compatible = "arm,ccn-512", },
15481540 {},
15491541 };
15501542 MODULE_DEVICE_TABLE(of, arm_ccn_match);
....@@ -1553,6 +1545,7 @@
15531545 .driver = {
15541546 .name = "arm-ccn",
15551547 .of_match_table = arm_ccn_match,
1548
+ .suppress_bind_attrs = true,
15561549 },
15571550 .probe = arm_ccn_probe,
15581551 .remove = arm_ccn_remove,