.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Performance counter support for POWER5 (not POWER5++) processors. |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright 2009 Paul Mackerras, IBM Corporation. |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or |
---|
7 | | - * modify it under the terms of the GNU General Public License |
---|
8 | | - * as published by the Free Software Foundation; either version |
---|
9 | | - * 2 of the License, or (at your option) any later version. |
---|
10 | 6 | */ |
---|
11 | 7 | #include <linux/kernel.h> |
---|
12 | 8 | #include <linux/perf_event.h> |
---|
13 | 9 | #include <linux/string.h> |
---|
14 | 10 | #include <asm/reg.h> |
---|
15 | 11 | #include <asm/cputable.h> |
---|
| 12 | + |
---|
| 13 | +#include "internal.h" |
---|
16 | 14 | |
---|
17 | 15 | /* |
---|
18 | 16 | * Bits in event code for POWER5 (not POWER5++) |
---|
.. | .. |
---|
383 | 381 | } |
---|
384 | 382 | |
---|
385 | 383 | static int power5_compute_mmcr(u64 event[], int n_ev, |
---|
386 | | - unsigned int hwc[], unsigned long mmcr[], struct perf_event *pevents[]) |
---|
| 384 | + unsigned int hwc[], struct mmcr_regs *mmcr, |
---|
| 385 | + struct perf_event *pevents[]) |
---|
387 | 386 | { |
---|
388 | 387 | unsigned long mmcr1 = 0; |
---|
389 | 388 | unsigned long mmcra = MMCRA_SDAR_DCACHE_MISS | MMCRA_SDAR_ERAT_MISS; |
---|
.. | .. |
---|
532 | 531 | } |
---|
533 | 532 | |
---|
534 | 533 | /* Return MMCRx values */ |
---|
535 | | - mmcr[0] = 0; |
---|
| 534 | + mmcr->mmcr0 = 0; |
---|
536 | 535 | if (pmc_inuse & 1) |
---|
537 | | - mmcr[0] = MMCR0_PMC1CE; |
---|
| 536 | + mmcr->mmcr0 = MMCR0_PMC1CE; |
---|
538 | 537 | if (pmc_inuse & 0x3e) |
---|
539 | | - mmcr[0] |= MMCR0_PMCjCE; |
---|
540 | | - mmcr[1] = mmcr1; |
---|
541 | | - mmcr[2] = mmcra; |
---|
| 538 | + mmcr->mmcr0 |= MMCR0_PMCjCE; |
---|
| 539 | + mmcr->mmcr1 = mmcr1; |
---|
| 540 | + mmcr->mmcra = mmcra; |
---|
542 | 541 | return 0; |
---|
543 | 542 | } |
---|
544 | 543 | |
---|
545 | | -static void power5_disable_pmc(unsigned int pmc, unsigned long mmcr[]) |
---|
| 544 | +static void power5_disable_pmc(unsigned int pmc, struct mmcr_regs *mmcr) |
---|
546 | 545 | { |
---|
547 | 546 | if (pmc <= 3) |
---|
548 | | - mmcr[1] &= ~(0x7fUL << MMCR1_PMCSEL_SH(pmc)); |
---|
| 547 | + mmcr->mmcr1 &= ~(0x7fUL << MMCR1_PMCSEL_SH(pmc)); |
---|
549 | 548 | } |
---|
550 | 549 | |
---|
551 | 550 | static int power5_generic_events[] = { |
---|
.. | .. |
---|
564 | 563 | * 0 means not supported, -1 means nonsensical, other values |
---|
565 | 564 | * are event codes. |
---|
566 | 565 | */ |
---|
567 | | -static int power5_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = { |
---|
| 566 | +static u64 power5_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = { |
---|
568 | 567 | [C(L1D)] = { /* RESULT_ACCESS RESULT_MISS */ |
---|
569 | 568 | [C(OP_READ)] = { 0x4c1090, 0x3c1088 }, |
---|
570 | 569 | [C(OP_WRITE)] = { 0x3c1090, 0xc10c3 }, |
---|
.. | .. |
---|
618 | 617 | .flags = PPMU_HAS_SSLOT, |
---|
619 | 618 | }; |
---|
620 | 619 | |
---|
621 | | -static int __init init_power5_pmu(void) |
---|
| 620 | +int init_power5_pmu(void) |
---|
622 | 621 | { |
---|
623 | 622 | if (!cur_cpu_spec->oprofile_cpu_type || |
---|
624 | 623 | strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5")) |
---|
.. | .. |
---|
626 | 625 | |
---|
627 | 626 | return register_power_pmu(&power5_pmu); |
---|
628 | 627 | } |
---|
629 | | - |
---|
630 | | -early_initcall(init_power5_pmu); |
---|