Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 #include <asm/io.h>
0003 #include <asm/hvcall.h>
0004 
0005 #include "hv-gpci.h"
0006 #include "hv-common.h"
0007 
0008 unsigned long hv_perf_caps_get(struct hv_perf_caps *caps)
0009 {
0010     unsigned long r;
0011     struct p {
0012         struct hv_get_perf_counter_info_params params;
0013         struct hv_gpci_system_performance_capabilities caps;
0014     } __packed __aligned(sizeof(uint64_t));
0015 
0016     struct p arg = {
0017         .params = {
0018             .counter_request = cpu_to_be32(
0019                 HV_GPCI_system_performance_capabilities),
0020             .starting_index = cpu_to_be32(-1),
0021             .counter_info_version_in = 0,
0022         }
0023     };
0024 
0025     r = plpar_hcall_norets(H_GET_PERF_COUNTER_INFO,
0026                    virt_to_phys(&arg), sizeof(arg));
0027 
0028     if (r)
0029         return r;
0030 
0031     pr_devel("capability_mask: 0x%x\n", arg.caps.capability_mask);
0032 
0033     caps->version = arg.params.counter_info_version_out;
0034     caps->collect_privileged = !!arg.caps.perf_collect_privileged;
0035     caps->ga = !!(arg.caps.capability_mask & HV_GPCI_CM_GA);
0036     caps->expanded = !!(arg.caps.capability_mask & HV_GPCI_CM_EXPANDED);
0037     caps->lab = !!(arg.caps.capability_mask & HV_GPCI_CM_LAB);
0038 
0039     return r;
0040 }