Lines Matching +full:risc +full:- +full:v
1 // SPDX-License-Identifier: GPL-2.0
3 * RISC-V performance counter support.
7 * This implementation is based on old RISC-V perf and ARM perf event code
22 struct perf_event_attr *attr = &event->attr; in pmu_legacy_ctr_get_idx()
24 if (event->attr.type != PERF_TYPE_HARDWARE) in pmu_legacy_ctr_get_idx()
25 return -EOPNOTSUPP; in pmu_legacy_ctr_get_idx()
26 if (attr->config == PERF_COUNT_HW_CPU_CYCLES) in pmu_legacy_ctr_get_idx()
28 else if (attr->config == PERF_COUNT_HW_INSTRUCTIONS) in pmu_legacy_ctr_get_idx()
31 return -EOPNOTSUPP; in pmu_legacy_ctr_get_idx()
42 struct hw_perf_event *hwc = &event->hw; in pmu_legacy_read_ctr()
43 int idx = hwc->idx; in pmu_legacy_read_ctr()
62 struct hw_perf_event *hwc = &event->hw; in pmu_legacy_ctr_start()
71 local64_set(&hwc->prev_count, initial_val); in pmu_legacy_ctr_start()
76 return event->hw.idx; in pmu_legacy_csr_index()
81 if (event->attr.config != PERF_COUNT_HW_CPU_CYCLES && in pmu_legacy_event_mapped()
82 event->attr.config != PERF_COUNT_HW_INSTRUCTIONS) in pmu_legacy_event_mapped()
85 event->hw.flags |= PERF_EVENT_FLAG_USER_READ_CNT; in pmu_legacy_event_mapped()
90 if (event->attr.config != PERF_COUNT_HW_CPU_CYCLES && in pmu_legacy_event_unmapped()
91 event->attr.config != PERF_COUNT_HW_INSTRUCTIONS) in pmu_legacy_event_unmapped()
94 event->hw.flags &= ~PERF_EVENT_FLAG_USER_READ_CNT; in pmu_legacy_event_unmapped()
99 * compatible with new RISC-V PMU driver framework.
108 pmu->cmask = BIT(RISCV_PMU_LEGACY_CYCLE) | in pmu_legacy_init()
110 pmu->ctr_start = pmu_legacy_ctr_start; in pmu_legacy_init()
111 pmu->ctr_stop = NULL; in pmu_legacy_init()
112 pmu->event_map = pmu_legacy_event_map; in pmu_legacy_init()
113 pmu->ctr_get_idx = pmu_legacy_ctr_get_idx; in pmu_legacy_init()
114 pmu->ctr_get_width = NULL; in pmu_legacy_init()
115 pmu->ctr_clear_idx = NULL; in pmu_legacy_init()
116 pmu->ctr_read = pmu_legacy_read_ctr; in pmu_legacy_init()
117 pmu->event_mapped = pmu_legacy_event_mapped; in pmu_legacy_init()
118 pmu->event_unmapped = pmu_legacy_event_unmapped; in pmu_legacy_init()
119 pmu->csr_index = pmu_legacy_csr_index; in pmu_legacy_init()
121 perf_pmu_register(&pmu->pmu, "cpu", PERF_TYPE_RAW); in pmu_legacy_init()
130 return -ENOMEM; in pmu_legacy_device_probe()
155 pdev = platform_device_register_simple(RISCV_PMU_LEGACY_PDEV_NAME, -1, NULL, 0); in riscv_pmu_legacy_devinit()