hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/arch/powerpc/perf/mpc7450-pmu.c
....@@ -1,12 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Performance counter support for MPC7450-family processors.
34 *
45 * Copyright 2008-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.
106 */
117 #include <linux/string.h>
128 #include <linux/perf_event.h>
....@@ -261,7 +257,7 @@
261257 * Compute MMCR0/1/2 values for a set of events.
262258 */
263259 static int mpc7450_compute_mmcr(u64 event[], int n_ev, unsigned int hwc[],
264
- unsigned long mmcr[],
260
+ struct mmcr_regs *mmcr,
265261 struct perf_event *pevents[])
266262 {
267263 u8 event_index[N_CLASSES][N_COUNTER];
....@@ -325,9 +321,16 @@
325321 mmcr0 |= MMCR0_PMCnCE;
326322
327323 /* Return MMCRx values */
328
- mmcr[0] = mmcr0;
329
- mmcr[1] = mmcr1;
330
- mmcr[2] = mmcr2;
324
+ mmcr->mmcr0 = mmcr0;
325
+ mmcr->mmcr1 = mmcr1;
326
+ mmcr->mmcr2 = mmcr2;
327
+ /*
328
+ * 32-bit doesn't have an MMCRA and uses SPRN_MMCR2 to define
329
+ * SPRN_MMCRA. So assign mmcra of cpu_hw_events with `mmcr2`
330
+ * value to ensure that any write to this SPRN_MMCRA will
331
+ * use mmcr2 value.
332
+ */
333
+ mmcr->mmcra = mmcr2;
331334 return 0;
332335 }
333336
....@@ -335,12 +338,12 @@
335338 * Disable counting by a PMC.
336339 * Note that the pmc argument is 0-based here, not 1-based.
337340 */
338
-static void mpc7450_disable_pmc(unsigned int pmc, unsigned long mmcr[])
341
+static void mpc7450_disable_pmc(unsigned int pmc, struct mmcr_regs *mmcr)
339342 {
340343 if (pmc <= 1)
341
- mmcr[0] &= ~(pmcsel_mask[pmc] << pmcsel_shift[pmc]);
344
+ mmcr->mmcr0 &= ~(pmcsel_mask[pmc] << pmcsel_shift[pmc]);
342345 else
343
- mmcr[1] &= ~(pmcsel_mask[pmc] << pmcsel_shift[pmc]);
346
+ mmcr->mmcr1 &= ~(pmcsel_mask[pmc] << pmcsel_shift[pmc]);
344347 }
345348
346349 static int mpc7450_generic_events[] = {
....@@ -358,7 +361,7 @@
358361 * 0 means not supported, -1 means nonsensical, other values
359362 * are event codes.
360363 */
361
-static int mpc7450_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
364
+static u64 mpc7450_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
362365 [C(L1D)] = { /* RESULT_ACCESS RESULT_MISS */
363366 [C(OP_READ)] = { 0, 0x225 },
364367 [C(OP_WRITE)] = { 0, 0x227 },