.. | .. |
---|
| 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+ (POWER5 GS) and POWER5++ (POWER5 GS DD3) |
---|
.. | .. |
---|
452 | 450 | } |
---|
453 | 451 | |
---|
454 | 452 | static int power5p_compute_mmcr(u64 event[], int n_ev, |
---|
455 | | - unsigned int hwc[], unsigned long mmcr[], struct perf_event *pevents[]) |
---|
| 453 | + unsigned int hwc[], struct mmcr_regs *mmcr, |
---|
| 454 | + struct perf_event *pevents[]) |
---|
456 | 455 | { |
---|
457 | 456 | unsigned long mmcr1 = 0; |
---|
458 | 457 | unsigned long mmcra = 0; |
---|
.. | .. |
---|
590 | 589 | } |
---|
591 | 590 | |
---|
592 | 591 | /* Return MMCRx values */ |
---|
593 | | - mmcr[0] = 0; |
---|
| 592 | + mmcr->mmcr0 = 0; |
---|
594 | 593 | if (pmc_inuse & 1) |
---|
595 | | - mmcr[0] = MMCR0_PMC1CE; |
---|
| 594 | + mmcr->mmcr0 = MMCR0_PMC1CE; |
---|
596 | 595 | if (pmc_inuse & 0x3e) |
---|
597 | | - mmcr[0] |= MMCR0_PMCjCE; |
---|
598 | | - mmcr[1] = mmcr1; |
---|
599 | | - mmcr[2] = mmcra; |
---|
| 596 | + mmcr->mmcr0 |= MMCR0_PMCjCE; |
---|
| 597 | + mmcr->mmcr1 = mmcr1; |
---|
| 598 | + mmcr->mmcra = mmcra; |
---|
600 | 599 | return 0; |
---|
601 | 600 | } |
---|
602 | 601 | |
---|
603 | | -static void power5p_disable_pmc(unsigned int pmc, unsigned long mmcr[]) |
---|
| 602 | +static void power5p_disable_pmc(unsigned int pmc, struct mmcr_regs *mmcr) |
---|
604 | 603 | { |
---|
605 | 604 | if (pmc <= 3) |
---|
606 | | - mmcr[1] &= ~(0x7fUL << MMCR1_PMCSEL_SH(pmc)); |
---|
| 605 | + mmcr->mmcr1 &= ~(0x7fUL << MMCR1_PMCSEL_SH(pmc)); |
---|
607 | 606 | } |
---|
608 | 607 | |
---|
609 | 608 | static int power5p_generic_events[] = { |
---|
.. | .. |
---|
622 | 621 | * 0 means not supported, -1 means nonsensical, other values |
---|
623 | 622 | * are event codes. |
---|
624 | 623 | */ |
---|
625 | | -static int power5p_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = { |
---|
| 624 | +static u64 power5p_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = { |
---|
626 | 625 | [C(L1D)] = { /* RESULT_ACCESS RESULT_MISS */ |
---|
627 | 626 | [C(OP_READ)] = { 0x1c10a8, 0x3c1088 }, |
---|
628 | 627 | [C(OP_WRITE)] = { 0x2c10a8, 0xc10c3 }, |
---|
.. | .. |
---|
677 | 676 | .cache_events = &power5p_cache_events, |
---|
678 | 677 | }; |
---|
679 | 678 | |
---|
680 | | -static int __init init_power5p_pmu(void) |
---|
| 679 | +int init_power5p_pmu(void) |
---|
681 | 680 | { |
---|
682 | 681 | if (!cur_cpu_spec->oprofile_cpu_type || |
---|
683 | 682 | (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5+") |
---|
.. | .. |
---|
686 | 685 | |
---|
687 | 686 | return register_power_pmu(&power5p_pmu); |
---|
688 | 687 | } |
---|
689 | | - |
---|
690 | | -early_initcall(init_power5p_pmu); |
---|