18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * pmc.h 48c2ecf20Sopenharmony_ci * Copyright (C) 2004 David Gibson, IBM Corporation 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci#ifndef _POWERPC_PMC_H 78c2ecf20Sopenharmony_ci#define _POWERPC_PMC_H 88c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <asm/ptrace.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_citypedef void (*perf_irq_t)(struct pt_regs *); 138c2ecf20Sopenharmony_ciextern perf_irq_t perf_irq; 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciint reserve_pmc_hardware(perf_irq_t new_perf_irq); 168c2ecf20Sopenharmony_civoid release_pmc_hardware(void); 178c2ecf20Sopenharmony_civoid ppc_enable_pmcs(void); 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_BOOK3S_64 208c2ecf20Sopenharmony_ci#include <asm/lppaca.h> 218c2ecf20Sopenharmony_ci#include <asm/firmware.h> 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_cistatic inline void ppc_set_pmu_inuse(int inuse) 248c2ecf20Sopenharmony_ci{ 258c2ecf20Sopenharmony_ci#if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_KVM_BOOK3S_HV_POSSIBLE) 268c2ecf20Sopenharmony_ci if (firmware_has_feature(FW_FEATURE_LPAR)) { 278c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_PSERIES 288c2ecf20Sopenharmony_ci get_lppaca()->pmcregs_in_use = inuse; 298c2ecf20Sopenharmony_ci#endif 308c2ecf20Sopenharmony_ci } 318c2ecf20Sopenharmony_ci#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE 328c2ecf20Sopenharmony_ci get_paca()->pmcregs_in_use = inuse; 338c2ecf20Sopenharmony_ci#endif 348c2ecf20Sopenharmony_ci#endif 358c2ecf20Sopenharmony_ci} 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE 388c2ecf20Sopenharmony_cistatic inline int ppc_get_pmu_inuse(void) 398c2ecf20Sopenharmony_ci{ 408c2ecf20Sopenharmony_ci return get_paca()->pmcregs_in_use; 418c2ecf20Sopenharmony_ci} 428c2ecf20Sopenharmony_ci#endif 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ciextern void power4_enable_pmcs(void); 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#else /* CONFIG_PPC64 */ 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cistatic inline void ppc_set_pmu_inuse(int inuse) { } 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#endif 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */ 538c2ecf20Sopenharmony_ci#endif /* _POWERPC_PMC_H */ 54