hv-common.c 1019 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <asm/io.h>
  2. #include <asm/hvcall.h>
  3. #include "hv-gpci.h"
  4. #include "hv-common.h"
  5. unsigned long hv_perf_caps_get(struct hv_perf_caps *caps)
  6. {
  7. unsigned long r;
  8. struct p {
  9. struct hv_get_perf_counter_info_params params;
  10. struct hv_gpci_system_performance_capabilities caps;
  11. } __packed __aligned(sizeof(uint64_t));
  12. struct p arg = {
  13. .params = {
  14. .counter_request = cpu_to_be32(
  15. HV_GPCI_system_performance_capabilities),
  16. .starting_index = cpu_to_be32(-1),
  17. .counter_info_version_in = 0,
  18. }
  19. };
  20. r = plpar_hcall_norets(H_GET_PERF_COUNTER_INFO,
  21. virt_to_phys(&arg), sizeof(arg));
  22. if (r)
  23. return r;
  24. pr_devel("capability_mask: 0x%x\n", arg.caps.capability_mask);
  25. caps->version = arg.params.counter_info_version_out;
  26. caps->collect_privileged = !!arg.caps.perf_collect_privileged;
  27. caps->ga = !!(arg.caps.capability_mask & HV_GPCI_CM_GA);
  28. caps->expanded = !!(arg.caps.capability_mask & HV_GPCI_CM_EXPANDED);
  29. caps->lab = !!(arg.caps.capability_mask & HV_GPCI_CM_LAB);
  30. return r;
  31. }