xref: /linux/arch/powerpc/include/asm/pmc.h (revision 762f99f4f3cb41a775b5157dd761217beba65873)
11a59d1b8SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2b8b572e1SStephen Rothwell /*
3b8b572e1SStephen Rothwell  * pmc.h
4b8b572e1SStephen Rothwell  * Copyright (C) 2004  David Gibson, IBM Corporation
5b8b572e1SStephen Rothwell  */
6b8b572e1SStephen Rothwell #ifndef _POWERPC_PMC_H
7b8b572e1SStephen Rothwell #define _POWERPC_PMC_H
8b8b572e1SStephen Rothwell #ifdef __KERNEL__
9b8b572e1SStephen Rothwell 
10b8b572e1SStephen Rothwell #include <asm/ptrace.h>
11b8b572e1SStephen Rothwell 
12b8b572e1SStephen Rothwell typedef void (*perf_irq_t)(struct pt_regs *);
13b8b572e1SStephen Rothwell extern perf_irq_t perf_irq;
14b8b572e1SStephen Rothwell 
15b8b572e1SStephen Rothwell int reserve_pmc_hardware(perf_irq_t new_perf_irq);
16b8b572e1SStephen Rothwell void release_pmc_hardware(void);
17a6dbf93aSPaul Mackerras void ppc_enable_pmcs(void);
18b8b572e1SStephen Rothwell 
19ad08587eSBenjamin Herrenschmidt #ifdef CONFIG_PPC_BOOK3S_64
20a6dbf93aSPaul Mackerras #include <asm/lppaca.h>
218e0b634bSNicholas Piggin #include <asm/firmware.h>
22a6dbf93aSPaul Mackerras 
ppc_set_pmu_inuse(int inuse)23a6dbf93aSPaul Mackerras static inline void ppc_set_pmu_inuse(int inuse)
24a6dbf93aSPaul Mackerras {
258e0b634bSNicholas Piggin #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_KVM_BOOK3S_HV_POSSIBLE)
268e0b634bSNicholas Piggin 	if (firmware_has_feature(FW_FEATURE_LPAR)) {
278e0b634bSNicholas Piggin #ifdef CONFIG_PPC_PSERIES
28a6dbf93aSPaul Mackerras 		get_lppaca()->pmcregs_in_use = inuse;
298e0b634bSNicholas Piggin #endif
3028d2a6e6SSuraj Jitindar Singh 	}
318e0b634bSNicholas Piggin #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
328e0b634bSNicholas Piggin 	get_paca()->pmcregs_in_use = inuse;
338e0b634bSNicholas Piggin #endif
348e0b634bSNicholas Piggin #endif
35a6dbf93aSPaul Mackerras }
36a6dbf93aSPaul Mackerras 
37*17826638SNicholas Piggin #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
ppc_get_pmu_inuse(void)38*17826638SNicholas Piggin static inline int ppc_get_pmu_inuse(void)
39*17826638SNicholas Piggin {
40*17826638SNicholas Piggin 	return get_paca()->pmcregs_in_use;
41*17826638SNicholas Piggin }
42*17826638SNicholas Piggin #endif
43*17826638SNicholas Piggin 
44a6dbf93aSPaul Mackerras extern void power4_enable_pmcs(void);
45a6dbf93aSPaul Mackerras 
46a6dbf93aSPaul Mackerras #else /* CONFIG_PPC64 */
47a6dbf93aSPaul Mackerras 
ppc_set_pmu_inuse(int inuse)48a6dbf93aSPaul Mackerras static inline void ppc_set_pmu_inuse(int inuse) { }
49a6dbf93aSPaul Mackerras 
50b8b572e1SStephen Rothwell #endif
51b8b572e1SStephen Rothwell 
52b8b572e1SStephen Rothwell #endif /* __KERNEL__ */
53b8b572e1SStephen Rothwell #endif /* _POWERPC_PMC_H */
54