Thomas Gleixner | 1a59d1b8 | 2019-05-27 08:55:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * pmc.h |
| 4 | * Copyright (C) 2004 David Gibson, IBM Corporation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | */ |
David Gibson | f7f6f4f | 2005-10-19 14:53:32 +1000 | [diff] [blame] | 6 | #ifndef _POWERPC_PMC_H |
| 7 | #define _POWERPC_PMC_H |
Arnd Bergmann | 88ced03 | 2005-12-16 22:43:46 +0100 | [diff] [blame] | 8 | #ifdef __KERNEL__ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
| 10 | #include <asm/ptrace.h> |
| 11 | |
| 12 | typedef void (*perf_irq_t)(struct pt_regs *); |
Matt Porter | a31751e | 2005-11-08 21:34:38 -0800 | [diff] [blame] | 13 | extern perf_irq_t perf_irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
| 15 | int reserve_pmc_hardware(perf_irq_t new_perf_irq); |
| 16 | void release_pmc_hardware(void); |
Paul Mackerras | a6dbf93 | 2009-09-09 01:26:03 +0000 | [diff] [blame] | 17 | void ppc_enable_pmcs(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
Benjamin Herrenschmidt | ad08587 | 2009-09-12 16:08:08 +0000 | [diff] [blame] | 19 | #ifdef CONFIG_PPC_BOOK3S_64 |
Paul Mackerras | a6dbf93 | 2009-09-09 01:26:03 +0000 | [diff] [blame] | 20 | #include <asm/lppaca.h> |
Nicholas Piggin | 8e0b634b | 2018-02-14 01:08:11 +1000 | [diff] [blame] | 21 | #include <asm/firmware.h> |
Paul Mackerras | a6dbf93 | 2009-09-09 01:26:03 +0000 | [diff] [blame] | 22 | |
| 23 | static inline void ppc_set_pmu_inuse(int inuse) |
| 24 | { |
Nicholas Piggin | 8e0b634b | 2018-02-14 01:08:11 +1000 | [diff] [blame] | 25 | #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_KVM_BOOK3S_HV_POSSIBLE) |
| 26 | if (firmware_has_feature(FW_FEATURE_LPAR)) { |
| 27 | #ifdef CONFIG_PPC_PSERIES |
| 28 | get_lppaca()->pmcregs_in_use = inuse; |
| 29 | #endif |
| 30 | } else { |
| 31 | #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE |
| 32 | get_paca()->pmcregs_in_use = inuse; |
| 33 | #endif |
| 34 | } |
| 35 | #endif |
Paul Mackerras | a6dbf93 | 2009-09-09 01:26:03 +0000 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | extern void power4_enable_pmcs(void); |
| 39 | |
| 40 | #else /* CONFIG_PPC64 */ |
| 41 | |
| 42 | static inline void ppc_set_pmu_inuse(int inuse) { } |
| 43 | |
David Gibson | f7f6f4f | 2005-10-19 14:53:32 +1000 | [diff] [blame] | 44 | #endif |
Michael Ellerman | 180a336 | 2005-08-09 11:13:36 +1000 | [diff] [blame] | 45 | |
Arnd Bergmann | 88ced03 | 2005-12-16 22:43:46 +0100 | [diff] [blame] | 46 | #endif /* __KERNEL__ */ |
David Gibson | f7f6f4f | 2005-10-19 14:53:32 +1000 | [diff] [blame] | 47 | #endif /* _POWERPC_PMC_H */ |