hv-common.c 1.0 KB

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