blob: dc9a1ca70edf73ed4a8ebb653104dd2593d0816c [file] [log] [blame]
Thomas Gleixner1a59d1b82019-05-27 08:55:05 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * pmc.h
4 * Copyright (C) 2004 David Gibson, IBM Corporation
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 */
David Gibsonf7f6f4f2005-10-19 14:53:32 +10006#ifndef _POWERPC_PMC_H
7#define _POWERPC_PMC_H
Arnd Bergmann88ced032005-12-16 22:43:46 +01008#ifdef __KERNEL__
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
10#include <asm/ptrace.h>
11
12typedef void (*perf_irq_t)(struct pt_regs *);
Matt Portera31751e2005-11-08 21:34:38 -080013extern perf_irq_t perf_irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
15int reserve_pmc_hardware(perf_irq_t new_perf_irq);
16void release_pmc_hardware(void);
Paul Mackerrasa6dbf932009-09-09 01:26:03 +000017void ppc_enable_pmcs(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
Benjamin Herrenschmidtad085872009-09-12 16:08:08 +000019#ifdef CONFIG_PPC_BOOK3S_64
Paul Mackerrasa6dbf932009-09-09 01:26:03 +000020#include <asm/lppaca.h>
Nicholas Piggin8e0b634b2018-02-14 01:08:11 +100021#include <asm/firmware.h>
Paul Mackerrasa6dbf932009-09-09 01:26:03 +000022
23static inline void ppc_set_pmu_inuse(int inuse)
24{
Nicholas Piggin8e0b634b2018-02-14 01:08:11 +100025#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 Mackerrasa6dbf932009-09-09 01:26:03 +000036}
37
38extern void power4_enable_pmcs(void);
39
40#else /* CONFIG_PPC64 */
41
42static inline void ppc_set_pmu_inuse(int inuse) { }
43
David Gibsonf7f6f4f2005-10-19 14:53:32 +100044#endif
Michael Ellerman180a3362005-08-09 11:13:36 +100045
Arnd Bergmann88ced032005-12-16 22:43:46 +010046#endif /* __KERNEL__ */
David Gibsonf7f6f4f2005-10-19 14:53:32 +100047#endif /* _POWERPC_PMC_H */