powerpc/perf: Update cpu_hw_event to use struct
for storing MMCR registers
core-book3s currently uses array to store the MMCR registers as part of per-cpu `cpu_hw_events`. This patch does a clean up to use `struct` to store mmcr regs instead of array. This will make code easier to read and reduces chance of any subtle bug that may come in the future, say when new registers are added. Patch updates all relevant code that was using MMCR array ( cpuhw->mmcr[x]) to use newly introduced `struct`. This includes the PMU driver code for supported platforms (power5 to power9) and ISA macros for counter support functions. Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/1594996707-3727-2-git-send-email-atrajeev@linux.vnet.ibm.com
This commit is contained in:

committed by
Michael Ellerman

parent
3c9450c053
commit
78d76819e6
@@ -363,7 +363,7 @@ int isa207_get_constraint(u64 event, unsigned long *maskp, unsigned long *valp)
|
||||
}
|
||||
|
||||
int isa207_compute_mmcr(u64 event[], int n_ev,
|
||||
unsigned int hwc[], unsigned long mmcr[],
|
||||
unsigned int hwc[], struct mmcr_regs *mmcr,
|
||||
struct perf_event *pevents[])
|
||||
{
|
||||
unsigned long mmcra, mmcr1, mmcr2, unit, combine, psel, cache, val;
|
||||
@@ -464,30 +464,30 @@ int isa207_compute_mmcr(u64 event[], int n_ev,
|
||||
}
|
||||
|
||||
/* Return MMCRx values */
|
||||
mmcr[0] = 0;
|
||||
mmcr->mmcr0 = 0;
|
||||
|
||||
/* pmc_inuse is 1-based */
|
||||
if (pmc_inuse & 2)
|
||||
mmcr[0] = MMCR0_PMC1CE;
|
||||
mmcr->mmcr0 = MMCR0_PMC1CE;
|
||||
|
||||
if (pmc_inuse & 0x7c)
|
||||
mmcr[0] |= MMCR0_PMCjCE;
|
||||
mmcr->mmcr0 |= MMCR0_PMCjCE;
|
||||
|
||||
/* If we're not using PMC 5 or 6, freeze them */
|
||||
if (!(pmc_inuse & 0x60))
|
||||
mmcr[0] |= MMCR0_FC56;
|
||||
mmcr->mmcr0 |= MMCR0_FC56;
|
||||
|
||||
mmcr[1] = mmcr1;
|
||||
mmcr[2] = mmcra;
|
||||
mmcr[3] = mmcr2;
|
||||
mmcr->mmcr1 = mmcr1;
|
||||
mmcr->mmcra = mmcra;
|
||||
mmcr->mmcr2 = mmcr2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void isa207_disable_pmc(unsigned int pmc, unsigned long mmcr[])
|
||||
void isa207_disable_pmc(unsigned int pmc, struct mmcr_regs *mmcr)
|
||||
{
|
||||
if (pmc <= 3)
|
||||
mmcr[1] &= ~(0xffUL << MMCR1_PMCSEL_SHIFT(pmc + 1));
|
||||
mmcr->mmcr1 &= ~(0xffUL << MMCR1_PMCSEL_SHIFT(pmc + 1));
|
||||
}
|
||||
|
||||
static int find_alternative(u64 event, const unsigned int ev_alt[][MAX_ALT], int size)
|
||||
|
Reference in New Issue
Block a user