hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/arch/powerpc/perf/hv-gpci.c
....@@ -72,7 +72,7 @@
7272
7373 static struct attribute_group event_group = {
7474 .name = "events",
75
- .attrs = hv_gpci_event_attrs,
75
+ /* .attrs is set in init */
7676 };
7777
7878 #define HV_CAPS_ATTR(_name, _format) \
....@@ -330,6 +330,7 @@
330330 int r;
331331 unsigned long hret;
332332 struct hv_perf_caps caps;
333
+ struct hv_gpci_request_buffer *arg;
333334
334335 hv_gpci_assert_offsets_correct();
335336
....@@ -353,6 +354,36 @@
353354 /* sampling not supported */
354355 h_gpci_pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT;
355356
357
+ arg = (void *)get_cpu_var(hv_gpci_reqb);
358
+ memset(arg, 0, HGPCI_REQ_BUFFER_SIZE);
359
+
360
+ /*
361
+ * hcall H_GET_PERF_COUNTER_INFO populates the output
362
+ * counter_info_version value based on the system hypervisor.
363
+ * Pass the counter request 0x10 corresponds to request type
364
+ * 'Dispatch_timebase_by_processor', to get the supported
365
+ * counter_info_version.
366
+ */
367
+ arg->params.counter_request = cpu_to_be32(0x10);
368
+
369
+ r = plpar_hcall_norets(H_GET_PERF_COUNTER_INFO,
370
+ virt_to_phys(arg), HGPCI_REQ_BUFFER_SIZE);
371
+ if (r) {
372
+ pr_devel("hcall failed, can't get supported counter_info_version: 0x%x\n", r);
373
+ arg->params.counter_info_version_out = 0x8;
374
+ }
375
+
376
+ /*
377
+ * Use counter_info_version_out value to assign
378
+ * required hv-gpci event list.
379
+ */
380
+ if (arg->params.counter_info_version_out >= 0x8)
381
+ event_group.attrs = hv_gpci_event_attrs;
382
+ else
383
+ event_group.attrs = hv_gpci_event_attrs_v6;
384
+
385
+ put_cpu_var(hv_gpci_reqb);
386
+
356387 r = perf_pmu_register(&h_gpci_pmu, h_gpci_pmu.name, -1);
357388 if (r)
358389 return r;