.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Performance counter support for POWER7 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 POWER7 |
---|
.. | .. |
---|
238 | 236 | case 6: |
---|
239 | 237 | if (psel == 0x64) |
---|
240 | 238 | return pmc >= 3; |
---|
| 239 | + break; |
---|
241 | 240 | case 8: |
---|
242 | 241 | return unit == 0xd; |
---|
243 | 242 | } |
---|
.. | .. |
---|
245 | 244 | } |
---|
246 | 245 | |
---|
247 | 246 | static int power7_compute_mmcr(u64 event[], int n_ev, |
---|
248 | | - unsigned int hwc[], unsigned long mmcr[], struct perf_event *pevents[]) |
---|
| 247 | + unsigned int hwc[], struct mmcr_regs *mmcr, |
---|
| 248 | + struct perf_event *pevents[]) |
---|
249 | 249 | { |
---|
250 | 250 | unsigned long mmcr1 = 0; |
---|
251 | 251 | unsigned long mmcra = MMCRA_SDAR_DCACHE_MISS | MMCRA_SDAR_ERAT_MISS; |
---|
.. | .. |
---|
301 | 301 | } |
---|
302 | 302 | |
---|
303 | 303 | /* Return MMCRx values */ |
---|
304 | | - mmcr[0] = 0; |
---|
| 304 | + mmcr->mmcr0 = 0; |
---|
305 | 305 | if (pmc_inuse & 1) |
---|
306 | | - mmcr[0] = MMCR0_PMC1CE; |
---|
| 306 | + mmcr->mmcr0 = MMCR0_PMC1CE; |
---|
307 | 307 | if (pmc_inuse & 0x3e) |
---|
308 | | - mmcr[0] |= MMCR0_PMCjCE; |
---|
309 | | - mmcr[1] = mmcr1; |
---|
310 | | - mmcr[2] = mmcra; |
---|
| 308 | + mmcr->mmcr0 |= MMCR0_PMCjCE; |
---|
| 309 | + mmcr->mmcr1 = mmcr1; |
---|
| 310 | + mmcr->mmcra = mmcra; |
---|
311 | 311 | return 0; |
---|
312 | 312 | } |
---|
313 | 313 | |
---|
314 | | -static void power7_disable_pmc(unsigned int pmc, unsigned long mmcr[]) |
---|
| 314 | +static void power7_disable_pmc(unsigned int pmc, struct mmcr_regs *mmcr) |
---|
315 | 315 | { |
---|
316 | 316 | if (pmc <= 3) |
---|
317 | | - mmcr[1] &= ~(0xffUL << MMCR1_PMCSEL_SH(pmc)); |
---|
| 317 | + mmcr->mmcr1 &= ~(0xffUL << MMCR1_PMCSEL_SH(pmc)); |
---|
318 | 318 | } |
---|
319 | 319 | |
---|
320 | 320 | static int power7_generic_events[] = { |
---|
.. | .. |
---|
335 | 335 | * 0 means not supported, -1 means nonsensical, other values |
---|
336 | 336 | * are event codes. |
---|
337 | 337 | */ |
---|
338 | | -static int power7_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = { |
---|
| 338 | +static u64 power7_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = { |
---|
339 | 339 | [C(L1D)] = { /* RESULT_ACCESS RESULT_MISS */ |
---|
340 | 340 | [C(OP_READ)] = { 0xc880, 0x400f0 }, |
---|
341 | 341 | [C(OP_WRITE)] = { 0, 0x300f0 }, |
---|
.. | .. |
---|
444 | 444 | .cache_events = &power7_cache_events, |
---|
445 | 445 | }; |
---|
446 | 446 | |
---|
447 | | -static int __init init_power7_pmu(void) |
---|
| 447 | +int init_power7_pmu(void) |
---|
448 | 448 | { |
---|
449 | 449 | if (!cur_cpu_spec->oprofile_cpu_type || |
---|
450 | 450 | strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power7")) |
---|
.. | .. |
---|
455 | 455 | |
---|
456 | 456 | return register_power_pmu(&power7_pmu); |
---|
457 | 457 | } |
---|
458 | | - |
---|
459 | | -early_initcall(init_power7_pmu); |
---|