Lines Matching +full:attr +full:- +full:cnt +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0-only
16 #include <asm/hardware/cache-l2x0.h>
34 * We ensure that idx 0 -> Counter0, and idx1 -> Counter1.
48 return -1; in l2x0_pmu_find_idx()
54 int i, cnt = 0; in l2x0_pmu_num_active_counters() local
58 cnt++; in l2x0_pmu_num_active_counters()
61 return cnt; in l2x0_pmu_num_active_counters()
66 writel_relaxed(val, l2x0_base + L2X0_EVENT_CNT0_CFG - 4 * idx); in l2x0_pmu_counter_config_write()
71 return readl_relaxed(l2x0_base + L2X0_EVENT_CNT0_VAL - 4 * idx); in l2x0_pmu_counter_read()
76 writel_relaxed(val, l2x0_base + L2X0_EVENT_CNT0_VAL - 4 * idx); in l2x0_pmu_counter_write()
119 struct hw_perf_event *hw = &event->hw; in l2x0_pmu_event_read()
123 prev_count = local64_read(&hw->prev_count); in l2x0_pmu_event_read()
124 new_count = l2x0_pmu_counter_read(hw->idx); in l2x0_pmu_event_read()
125 } while (local64_xchg(&hw->prev_count, new_count) != prev_count); in l2x0_pmu_event_read()
128 local64_add((new_count - prev_count) & mask, &event->count); in l2x0_pmu_event_read()
135 struct hw_perf_event *hw = &event->hw; in l2x0_pmu_event_configure()
147 local64_set(&hw->prev_count, 0); in l2x0_pmu_event_configure()
148 l2x0_pmu_counter_write(hw->idx, 0); in l2x0_pmu_event_configure()
188 struct hw_perf_event *hw = &event->hw; in l2x0_pmu_event_start()
190 if (WARN_ON_ONCE(!(event->hw.state & PERF_HES_STOPPED))) in l2x0_pmu_event_start()
194 WARN_ON_ONCE(!(hw->state & PERF_HES_UPTODATE)); in l2x0_pmu_event_start()
198 hw->state = 0; in l2x0_pmu_event_start()
200 __l2x0_pmu_event_enable(hw->idx, hw->config_base); in l2x0_pmu_event_start()
214 struct hw_perf_event *hw = &event->hw; in l2x0_pmu_event_stop()
216 if (WARN_ON_ONCE(event->hw.state & PERF_HES_STOPPED)) in l2x0_pmu_event_stop()
219 __l2x0_pmu_event_disable(hw->idx); in l2x0_pmu_event_stop()
221 hw->state |= PERF_HES_STOPPED; in l2x0_pmu_event_stop()
225 hw->state |= PERF_HES_UPTODATE; in l2x0_pmu_event_stop()
231 struct hw_perf_event *hw = &event->hw; in l2x0_pmu_event_add()
234 if (idx == -1) in l2x0_pmu_event_add()
235 return -EAGAIN; in l2x0_pmu_event_add()
239 * event->cpu (this is the same one as presented in "cpumask" in l2x0_pmu_event_add()
247 hw->idx = idx; in l2x0_pmu_event_add()
251 hw->state = PERF_HES_STOPPED | PERF_HES_UPTODATE; in l2x0_pmu_event_add()
261 struct hw_perf_event *hw = &event->hw; in l2x0_pmu_event_del()
265 events[hw->idx] = NULL; in l2x0_pmu_event_del()
266 hw->idx = -1; in l2x0_pmu_event_del()
274 struct pmu *pmu = event->pmu; in l2x0_pmu_group_is_valid()
275 struct perf_event *leader = event->group_leader; in l2x0_pmu_group_is_valid()
279 if (leader->pmu == pmu) in l2x0_pmu_group_is_valid()
285 if (sibling->pmu == pmu) in l2x0_pmu_group_is_valid()
296 struct hw_perf_event *hw = &event->hw; in l2x0_pmu_event_init()
298 if (event->attr.type != l2x0_pmu->type) in l2x0_pmu_event_init()
299 return -ENOENT; in l2x0_pmu_event_init()
302 event->attach_state & PERF_ATTACH_TASK) in l2x0_pmu_event_init()
303 return -EINVAL; in l2x0_pmu_event_init()
305 if (event->cpu < 0) in l2x0_pmu_event_init()
306 return -EINVAL; in l2x0_pmu_event_init()
308 if (event->attr.config & ~L2X0_EVENT_CNT_CFG_SRC_MASK) in l2x0_pmu_event_init()
309 return -EINVAL; in l2x0_pmu_event_init()
311 hw->config_base = event->attr.config; in l2x0_pmu_event_init()
314 return -EINVAL; in l2x0_pmu_event_init()
316 event->cpu = cpumask_first(&pmu_cpu); in l2x0_pmu_event_init()
322 struct device_attribute attr; member
329 .attr = __ATTR(_name, S_IRUGO, l2x0_pmu_event_show, NULL), \
332 }})[0].attr.attr)
341 struct device_attribute *attr, char *buf) in l2x0_pmu_event_show() argument
345 lattr = container_of(attr, typeof(*lattr), attr); in l2x0_pmu_event_show()
346 return snprintf(buf, PAGE_SIZE, "config=0x%x\n", lattr->config); in l2x0_pmu_event_show()
350 struct attribute *attr, in l2x0_pmu_event_attr_is_visible() argument
357 lattr = container_of(attr, typeof(*lattr), attr.attr); in l2x0_pmu_event_attr_is_visible()
359 if (!lattr->pl310_only || strcmp("l2c_310", pmu->name) == 0) in l2x0_pmu_event_attr_is_visible()
360 return attr->mode; in l2x0_pmu_event_attr_is_visible()
385 .name = "events",
391 struct device_attribute *attr, char *buf) in l2x0_pmu_cpumask_show() argument
400 &l2x0_pmu_cpumask_attr.attr,
477 * Determine whether we support the PMU, and choose the name for sysfs. in l2x0_pmu_register()
486 * running, so just stash the name and base, and leave that to another in l2x0_pmu_register()
513 return -ENOMEM; in l2x0_pmu_init()
537 * quad-core test chip with cores clocked at 400MHz. Hopefully this in l2x0_pmu_init()
552 ret = perf_pmu_register(l2x0_pmu, l2x0_name, -1); in l2x0_pmu_init()