pmu.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * linux/arch/arm/include/asm/pmu.h
  3. *
  4. * Copyright (C) 2009 picoChip Designs Ltd, Jamie Iles
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. */
  11. #ifndef __ARM_PMU_H__
  12. #define __ARM_PMU_H__
  13. #ifdef CONFIG_CPU_HAS_PMU
  14. struct pmu_irqs {
  15. const int *irqs;
  16. int num_irqs;
  17. };
  18. /**
  19. * reserve_pmu() - reserve the hardware performance counters
  20. *
  21. * Reserve the hardware performance counters in the system for exclusive use.
  22. * The 'struct pmu_irqs' for the system is returned on success, ERR_PTR()
  23. * encoded error on failure.
  24. */
  25. extern const struct pmu_irqs *
  26. reserve_pmu(void);
  27. /**
  28. * release_pmu() - Relinquish control of the performance counters
  29. *
  30. * Release the performance counters and allow someone else to use them.
  31. * Callers must have disabled the counters and released IRQs before calling
  32. * this. The 'struct pmu_irqs' returned from reserve_pmu() must be passed as
  33. * a cookie.
  34. */
  35. extern int
  36. release_pmu(const struct pmu_irqs *irqs);
  37. /**
  38. * init_pmu() - Initialise the PMU.
  39. *
  40. * Initialise the system ready for PMU enabling. This should typically set the
  41. * IRQ affinity and nothing else. The users (oprofile/perf events etc) will do
  42. * the actual hardware initialisation.
  43. */
  44. extern int
  45. init_pmu(void);
  46. #else /* CONFIG_CPU_HAS_PMU */
  47. static inline const struct pmu_irqs *
  48. reserve_pmu(void)
  49. {
  50. return ERR_PTR(-ENODEV);
  51. }
  52. static inline int
  53. release_pmu(const struct pmu_irqs *irqs)
  54. {
  55. return -ENODEV;
  56. }
  57. static inline int
  58. init_pmu(void)
  59. {
  60. return -ENODEV;
  61. }
  62. #endif /* CONFIG_CPU_HAS_PMU */
  63. #endif /* __ARM_PMU_H__ */