Lines Matching +full:free +full:- +full:running
1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <asm/intel-family.h>
6 #include <linux/io-64-nonatomic-lo-hi.h>
37 #define UNCORE_IGNORE_END -1
169 /* event config registers are 8-byte apart */
264 if (offset < box->pmu->type->mmio_map_size) in uncore_mmio_is_valid_offset()
268 offset, box->pmu->type->name); in uncore_mmio_is_valid_offset()
276 return box->pmu->type->box_ctl + in uncore_mmio_box_ctl()
277 box->pmu->type->mmio_offset * box->pmu->pmu_idx; in uncore_mmio_box_ctl()
282 return box->pmu->type->box_ctl; in uncore_pci_box_ctl()
287 return box->pmu->type->fixed_ctl; in uncore_pci_fixed_ctl()
292 return box->pmu->type->fixed_ctr; in uncore_pci_fixed_ctr()
298 if (test_bit(UNCORE_BOX_FLAG_CTL_OFFS8, &box->flags)) in uncore_pci_event_ctl()
299 return idx * 8 + box->pmu->type->event_ctl; in uncore_pci_event_ctl()
301 return idx * 4 + box->pmu->type->event_ctl; in uncore_pci_event_ctl()
307 return idx * 8 + box->pmu->type->perf_ctr; in uncore_pci_perf_ctr()
312 struct intel_uncore_pmu *pmu = box->pmu; in uncore_msr_box_offset()
313 return pmu->type->msr_offsets ? in uncore_msr_box_offset()
314 pmu->type->msr_offsets[pmu->pmu_idx] : in uncore_msr_box_offset()
315 pmu->type->msr_offset * pmu->pmu_idx; in uncore_msr_box_offset()
320 if (!box->pmu->type->box_ctl) in uncore_msr_box_ctl()
322 return box->pmu->type->box_ctl + uncore_msr_box_offset(box); in uncore_msr_box_ctl()
327 if (!box->pmu->type->fixed_ctl) in uncore_msr_fixed_ctl()
329 return box->pmu->type->fixed_ctl + uncore_msr_box_offset(box); in uncore_msr_fixed_ctl()
334 return box->pmu->type->fixed_ctr + uncore_msr_box_offset(box); in uncore_msr_fixed_ctr()
339 * In the uncore document, there is no event-code assigned to free running
340 * counters. Some events need to be defined to indicate the free running
341 * counters. The events are encoded as event-code + umask-code.
343 * The event-code for all free running counters is 0xff, which is the same as
346 * The umask-code is used to distinguish a fixed counter and a free running
347 * counter, and different types of free running counters.
348 * - For fixed counters, the umask-code is 0x0X.
350 * - For free running counters, the umask-code uses the rest of the space.
352 * X stands for the type of free running counters, which starts from 1.
353 * Y stands for the index of free running counters of same type, which
356 * For example, there are three types of IIO free running counters on Skylake
358 * The event-code for all the free running counters is 0xff.
360 * which umask-code starts from 0x10.
363 * the second type, which umask-code starts from 0x20.
375 return ((((config >> 8) - UNCORE_FREERUNNING_UMASK_START) >> 4) & 0xf); in uncore_freerunning_type()
382 unsigned int type = uncore_freerunning_type(event->hw.config); in uncore_freerunning_counter()
383 unsigned int idx = uncore_freerunning_idx(event->hw.config); in uncore_freerunning_counter()
384 struct intel_uncore_pmu *pmu = box->pmu; in uncore_freerunning_counter()
386 return pmu->type->freerunning[type].counter_base + in uncore_freerunning_counter()
387 pmu->type->freerunning[type].counter_offset * idx + in uncore_freerunning_counter()
388 (pmu->type->freerunning[type].box_offsets ? in uncore_freerunning_counter()
389 pmu->type->freerunning[type].box_offsets[pmu->pmu_idx] : in uncore_freerunning_counter()
390 pmu->type->freerunning[type].box_offset * pmu->pmu_idx); in uncore_freerunning_counter()
396 if (test_bit(UNCORE_BOX_FLAG_CFL8_CBOX_MSR_OFFS, &box->flags)) { in uncore_msr_event_ctl()
398 (box->pmu->type->pair_ctr_ctl ? 2 * idx : idx); in uncore_msr_event_ctl()
400 return box->pmu->type->event_ctl + in uncore_msr_event_ctl()
401 (box->pmu->type->pair_ctr_ctl ? 2 * idx : idx) + in uncore_msr_event_ctl()
409 if (test_bit(UNCORE_BOX_FLAG_CFL8_CBOX_MSR_OFFS, &box->flags)) { in uncore_msr_perf_ctr()
411 (box->pmu->type->pair_ctr_ctl ? 2 * idx : idx); in uncore_msr_perf_ctr()
413 return box->pmu->type->perf_ctr + in uncore_msr_perf_ctr()
414 (box->pmu->type->pair_ctr_ctl ? 2 * idx : idx) + in uncore_msr_perf_ctr()
422 if (box->pci_dev || box->io_addr) in uncore_fixed_ctl()
431 if (box->pci_dev || box->io_addr) in uncore_fixed_ctr()
440 if (box->pci_dev || box->io_addr) in uncore_event_ctl()
449 if (box->pci_dev || box->io_addr) in uncore_perf_ctr()
457 return box->pmu->type->perf_ctr_bits; in uncore_perf_ctr_bits()
462 return box->pmu->type->fixed_ctr_bits; in uncore_fixed_ctr_bits()
469 unsigned int type = uncore_freerunning_type(event->hw.config); in uncore_freerunning_bits()
471 return box->pmu->type->freerunning[type].bits; in uncore_freerunning_bits()
477 unsigned int type = uncore_freerunning_type(event->hw.config); in uncore_num_freerunning()
479 return box->pmu->type->freerunning[type].num_counters; in uncore_num_freerunning()
485 return box->pmu->type->num_freerunning_types; in uncore_num_freerunning_types()
491 unsigned int type = uncore_freerunning_type(event->hw.config); in check_valid_freerunning_event()
492 unsigned int idx = uncore_freerunning_idx(event->hw.config); in check_valid_freerunning_event()
500 return box->pmu->type->num_counters; in uncore_num_counters()
505 u64 cfg = event->attr.config; in is_freerunning_event()
518 return -EINVAL; in uncore_freerunning_hw_config()
524 box->pmu->type->ops->disable_event(box, event); in uncore_disable_event()
530 box->pmu->type->ops->enable_event(box, event); in uncore_enable_event()
536 return box->pmu->type->ops->read_counter(box, event); in uncore_read_counter()
541 if (!test_and_set_bit(UNCORE_BOX_FLAG_INITIATED, &box->flags)) { in uncore_box_init()
542 if (box->pmu->type->ops->init_box) in uncore_box_init()
543 box->pmu->type->ops->init_box(box); in uncore_box_init()
549 if (test_and_clear_bit(UNCORE_BOX_FLAG_INITIATED, &box->flags)) { in uncore_box_exit()
550 if (box->pmu->type->ops->exit_box) in uncore_box_exit()
551 box->pmu->type->ops->exit_box(box); in uncore_box_exit()
557 return (box->dieid < 0); in uncore_box_is_fake()
562 return container_of(event->pmu, struct intel_uncore_pmu, pmu); in uncore_event_to_pmu()
567 return event->pmu_private; in uncore_event_to_box()