Lines Matching +full:ete +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0
11 #include <linux/coresight-pmu.h>
18 #include "cs-etm.h"
29 #include "../../../util/cs-etm.h"
93 u64 contextid = evsel->core.attr.config & in cs_etm_validate_context_id()
105 return -EINVAL; in cs_etm_validate_context_id()
116 * TRCIDR2.CIDSIZE, bit [9-5], indicates whether contextID in cs_etm_validate_context_id()
119 * 0b00100 Maximum of 32-bit Context ID size. in cs_etm_validate_context_id()
125 return -EINVAL; in cs_etm_validate_context_id()
141 return -EINVAL; in cs_etm_validate_context_id()
154 if (!(evsel->core.attr.config & in cs_etm_validate_timestamp()
161 return -EINVAL; in cs_etm_validate_timestamp()
170 * TRCIDR0.TSSIZE, bit [28-24], indicates whether global timestamping in cs_etm_validate_timestamp()
178 return -EINVAL; in cs_etm_validate_timestamp()
188 return ptr->cs_etm_pmu; in cs_etm_get_pmu()
202 struct perf_cpu_map *event_cpus = evsel->evlist->core.user_requested_cpus; in cs_etm_validate_config()
207 * Set option of each CPU we have. In per-cpu case, do the validation in cs_etm_validate_config()
208 * for CPUs to work with. In per-thread case, the CPU map has the "any" in cs_etm_validate_config()
225 return -EINVAL; in cs_etm_validate_config()
252 return -1; in cs_etm_parse_snapshot_options()
255 opts->auxtrace_snapshot_mode = true; in cs_etm_parse_snapshot_options()
256 opts->auxtrace_snapshot_size = snapshot_size; in cs_etm_parse_snapshot_options()
257 ptr->snapshot_size = snapshot_size; in cs_etm_parse_snapshot_options()
267 int ret = -EINVAL; in cs_etm_set_sink_attr()
270 if (evsel->core.attr.config2 & GENMASK(31, 0)) in cs_etm_set_sink_attr()
273 list_for_each_entry(term, &evsel->config_terms, list) { in cs_etm_set_sink_attr()
274 if (term->type != EVSEL__CONFIG_TERM_DRV_CFG) in cs_etm_set_sink_attr()
277 sink = term->val.str; in cs_etm_set_sink_attr()
281 if (ret != 1) { in cs_etm_set_sink_attr()
294 evsel->core.attr.config2 |= hash; in cs_etm_set_sink_attr()
299 * No sink was provided on the command line - allow the CoreSight in cs_etm_set_sink_attr()
312 struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu; in cs_etm_recording_options()
314 struct perf_cpu_map *cpus = evlist->core.user_requested_cpus; in cs_etm_recording_options()
315 bool privileged = perf_event_paranoid_check(-1); in cs_etm_recording_options()
319 if (evsel->core.attr.type == cs_etm_pmu->type) { in cs_etm_recording_options()
323 return -EINVAL; in cs_etm_recording_options()
333 ptr->evlist = evlist; in cs_etm_recording_options()
334 ptr->snapshot_mode = opts->auxtrace_snapshot_mode; in cs_etm_recording_options()
338 opts->record_switch_events = true; in cs_etm_recording_options()
340 cs_etm_evsel->needs_auxtrace_mmap = true; in cs_etm_recording_options()
341 opts->full_auxtrace = true; in cs_etm_recording_options()
347 if (opts->use_clockid) { in cs_etm_recording_options()
348 pr_err("Cannot use clockid (-k option) with %s\n", in cs_etm_recording_options()
350 return -EINVAL; in cs_etm_recording_options()
354 if (opts->auxtrace_snapshot_mode) { in cs_etm_recording_options()
356 * No size were given to '-S' or '-m,', so go with in cs_etm_recording_options()
359 if (!opts->auxtrace_snapshot_size && in cs_etm_recording_options()
360 !opts->auxtrace_mmap_pages) { in cs_etm_recording_options()
362 opts->auxtrace_mmap_pages = MiB(4) / page_size; in cs_etm_recording_options()
364 opts->auxtrace_mmap_pages = in cs_etm_recording_options()
366 if (opts->mmap_pages == UINT_MAX) in cs_etm_recording_options()
367 opts->mmap_pages = KiB(256) / page_size; in cs_etm_recording_options()
369 } else if (!opts->auxtrace_mmap_pages && !privileged && in cs_etm_recording_options()
370 opts->mmap_pages == UINT_MAX) { in cs_etm_recording_options()
371 opts->mmap_pages = KiB(256) / page_size; in cs_etm_recording_options()
375 * '-m,xyz' was specified but no snapshot size, so make the in cs_etm_recording_options()
378 if (!opts->auxtrace_snapshot_size) { in cs_etm_recording_options()
379 opts->auxtrace_snapshot_size = in cs_etm_recording_options()
380 opts->auxtrace_mmap_pages * (size_t)page_size; in cs_etm_recording_options()
384 * -Sxyz was specified but no auxtrace mmap area, so make the in cs_etm_recording_options()
388 if (!opts->auxtrace_mmap_pages) { in cs_etm_recording_options()
389 size_t sz = opts->auxtrace_snapshot_size; in cs_etm_recording_options()
392 opts->auxtrace_mmap_pages = roundup_pow_of_two(sz); in cs_etm_recording_options()
396 if (opts->auxtrace_snapshot_size > in cs_etm_recording_options()
397 opts->auxtrace_mmap_pages * (size_t)page_size) { in cs_etm_recording_options()
399 opts->auxtrace_snapshot_size, in cs_etm_recording_options()
400 opts->auxtrace_mmap_pages * (size_t)page_size); in cs_etm_recording_options()
401 return -EINVAL; in cs_etm_recording_options()
404 /* Something went wrong somewhere - this shouldn't happen */ in cs_etm_recording_options()
405 if (!opts->auxtrace_snapshot_size || in cs_etm_recording_options()
406 !opts->auxtrace_mmap_pages) { in cs_etm_recording_options()
408 return -EINVAL; in cs_etm_recording_options()
412 /* Buffer sizes weren't specified with '-m,xyz' so give some defaults */ in cs_etm_recording_options()
413 if (!opts->auxtrace_mmap_pages) { in cs_etm_recording_options()
415 opts->auxtrace_mmap_pages = MiB(4) / page_size; in cs_etm_recording_options()
417 opts->auxtrace_mmap_pages = KiB(128) / page_size; in cs_etm_recording_options()
418 if (opts->mmap_pages == UINT_MAX) in cs_etm_recording_options()
419 opts->mmap_pages = KiB(256) / page_size; in cs_etm_recording_options()
423 if (opts->auxtrace_snapshot_mode) in cs_etm_recording_options()
425 opts->auxtrace_snapshot_size); in cs_etm_recording_options()
434 * get the CPU on the sample - need it to associate trace ID in the in cs_etm_recording_options()
435 * AUX_OUTPUT_HW_ID event, and the AUX event for per-cpu mmaps. in cs_etm_recording_options()
440 * Also the case of per-cpu mmaps, need the contextID in order to be notified in cs_etm_recording_options()
445 "timestamp", 1); in cs_etm_recording_options()
447 "contextid", 1); in cs_etm_recording_options()
451 * When the option '--timestamp' or '-T' is enabled, the PERF_SAMPLE_TIME in cs_etm_recording_options()
455 if (opts->sample_time_set) in cs_etm_recording_options()
457 "timestamp", 1); in cs_etm_recording_options()
465 evsel->core.attr.freq = 0; in cs_etm_recording_options()
466 evsel->core.attr.sample_period = 1; in cs_etm_recording_options()
468 /* In per-cpu case, always need the time of mmap events etc */ in cs_etm_recording_options()
482 struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu; in cs_etm_get_config()
483 struct evlist *evlist = ptr->evlist; in cs_etm_get_config()
487 if (evsel->core.attr.type == cs_etm_pmu->type) { in cs_etm_get_config()
493 * drivers/hwtracing/coresight/coresight-perf.c for in cs_etm_get_config()
496 config = evsel->core.attr.config; in cs_etm_get_config()
505 #define BIT(N) (1UL << (N))
542 int etmv3 = 0, etmv4 = 0, ete = 0; in cs_etm_info_priv_size() local
543 struct perf_cpu_map *event_cpus = evlist->core.user_requested_cpus; in cs_etm_info_priv_size()
562 ete += v == CS_ETE; in cs_etm_info_priv_size()
569 (ete * CS_ETE_PRIV_SIZE) + in cs_etm_info_priv_size()
583 if (scan != 1) { in cs_etm_get_ro()
585 return -EINVAL; in cs_etm_get_ro()
602 if (scan != 1) { in cs_etm_get_ro_signed()
604 return -EINVAL; in cs_etm_get_ro_signed()
638 * ETE if ARCHVER is 5 (ARCHVER is 4 for ETM) and ARCHPART is 0xA13. in cs_etm_is_ete()
639 * See ETM_DEVARCH_ETE_ARCH in coresight-etm4x.h in cs_etm_is_ete()
653 struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu; in cs_etm_save_etmv4_header()
660 /* Get read-only information from sysFS */ in cs_etm_save_etmv4_header()
676 pr_debug3("[%03d] pmu file 'ts_source' not found. Fallback to safe value (-1)\n", in cs_etm_save_etmv4_header()
678 data[CS_ETMV4_TS_SOURCE] = (__u64) -1; in cs_etm_save_etmv4_header()
685 struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu; in cs_etm_save_ete_header()
692 /* Get read-only information from sysFS */ in cs_etm_save_ete_header()
699 /* ETE uses the same registers as ETMv4 plus TRCDEVARCH */ in cs_etm_save_ete_header()
707 pr_debug3("[%03d] pmu file 'ts_source' not found. Fallback to safe value (-1)\n", in cs_etm_save_ete_header()
709 data[CS_ETE_TS_SOURCE] = (__u64) -1; in cs_etm_save_ete_header()
725 cs_etm_save_ete_header(&info->priv[*offset], itr, cpu); in cs_etm_get_metadata()
729 nr_trc_params = CS_ETE_PRIV_MAX - CS_ETM_COMMON_BLK_MAX_V1; in cs_etm_get_metadata()
734 cs_etm_save_etmv4_header(&info->priv[*offset], itr, cpu); in cs_etm_get_metadata()
738 nr_trc_params = CS_ETMV4_PRIV_MAX - CS_ETMV4_TRCCONFIGR; in cs_etm_get_metadata()
744 info->priv[*offset + CS_ETM_ETMCR] = cs_etm_get_config(itr); in cs_etm_get_metadata()
746 info->priv[*offset + CS_ETM_ETMTRACEIDR] = cs_etm_get_legacy_trace_id(cpu); in cs_etm_get_metadata()
747 /* Get read-only information from sysFS */ in cs_etm_get_metadata()
749 &info->priv[*offset + CS_ETM_ETMCCER]); in cs_etm_get_metadata()
751 &info->priv[*offset + CS_ETM_ETMIDR]); in cs_etm_get_metadata()
755 nr_trc_params = CS_ETM_PRIV_MAX - CS_ETM_ETMCR; in cs_etm_get_metadata()
766 info->priv[*offset + CS_ETM_MAGIC] = magic; in cs_etm_get_metadata()
767 info->priv[*offset + CS_ETM_CPU] = cpu.cpu; in cs_etm_get_metadata()
768 info->priv[*offset + CS_ETM_NR_TRC_PARAMS] = nr_trc_params; in cs_etm_get_metadata()
782 struct perf_cpu_map *event_cpus = session->evlist->core.user_requested_cpus; in cs_etm_info_fill()
786 struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu; in cs_etm_info_fill()
789 if (priv_size != cs_etm_info_priv_size(itr, session->evlist)) in cs_etm_info_fill()
790 return -EINVAL; in cs_etm_info_fill()
792 if (!session->evlist->core.nr_mmaps) in cs_etm_info_fill()
793 return -EINVAL; in cs_etm_info_fill()
802 return -EINVAL; in cs_etm_info_fill()
810 type = cs_etm_pmu->type; in cs_etm_info_fill()
813 info->type = PERF_AUXTRACE_CS_ETM; in cs_etm_info_fill()
814 info->priv[CS_HEADER_VERSION] = CS_HEADER_CURRENT_VERSION; in cs_etm_info_fill()
815 info->priv[CS_PMU_TYPE_CPUS] = type << 32; in cs_etm_info_fill()
816 info->priv[CS_PMU_TYPE_CPUS] |= nr_cpu; in cs_etm_info_fill()
817 info->priv[CS_ETM_SNAPSHOT] = ptr->snapshot_mode; in cs_etm_info_fill()
819 offset = CS_ETM_SNAPSHOT + 1; in cs_etm_info_fill()
837 evlist__for_each_entry(ptr->evlist, evsel) { in cs_etm_snapshot_start()
838 if (evsel->core.attr.type == ptr->cs_etm_pmu->type) in cs_etm_snapshot_start()
841 return -EINVAL; in cs_etm_snapshot_start()
850 evlist__for_each_entry(ptr->evlist, evsel) { in cs_etm_snapshot_finish()
851 if (evsel->core.attr.type == ptr->cs_etm_pmu->type) in cs_etm_snapshot_finish()
854 return -EINVAL; in cs_etm_snapshot_finish()
879 *err = -EINVAL; in cs_etm_record_init()
885 *err = -ENOMEM; in cs_etm_record_init()
889 ptr->cs_etm_pmu = cs_etm_pmu; in cs_etm_record_init()
890 ptr->itr.parse_snapshot_options = cs_etm_parse_snapshot_options; in cs_etm_record_init()
891 ptr->itr.recording_options = cs_etm_recording_options; in cs_etm_record_init()
892 ptr->itr.info_priv_size = cs_etm_info_priv_size; in cs_etm_record_init()
893 ptr->itr.info_fill = cs_etm_info_fill; in cs_etm_record_init()
894 ptr->itr.snapshot_start = cs_etm_snapshot_start; in cs_etm_record_init()
895 ptr->itr.snapshot_finish = cs_etm_snapshot_finish; in cs_etm_record_init()
896 ptr->itr.reference = cs_etm_reference; in cs_etm_record_init()
897 ptr->itr.free = cs_etm_recording_free; in cs_etm_record_init()
898 ptr->itr.read_finish = auxtrace_record__read_finish; in cs_etm_record_init()
901 return &ptr->itr; in cs_etm_record_init()
915 attr->sample_period = 1; in cs_etm_get_default_config()