diff options
-rw-r--r-- | tools/perf/arch/arm/util/cs-etm.c | 58 | ||||
-rw-r--r-- | tools/perf/arch/arm/util/cs-etm.h | 3 | ||||
-rw-r--r-- | tools/perf/arch/arm/util/pmu.c | 2 |
3 files changed, 63 insertions, 0 deletions
diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index 829c479614f1..47d584da5819 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c | |||
@@ -27,12 +27,16 @@ | |||
27 | #include "../../util/auxtrace.h" | 27 | #include "../../util/auxtrace.h" |
28 | #include "../../util/cpumap.h" | 28 | #include "../../util/cpumap.h" |
29 | #include "../../util/evlist.h" | 29 | #include "../../util/evlist.h" |
30 | #include "../../util/evsel.h" | ||
30 | #include "../../util/pmu.h" | 31 | #include "../../util/pmu.h" |
31 | #include "../../util/thread_map.h" | 32 | #include "../../util/thread_map.h" |
32 | #include "../../util/cs-etm.h" | 33 | #include "../../util/cs-etm.h" |
33 | 34 | ||
34 | #include <stdlib.h> | 35 | #include <stdlib.h> |
35 | 36 | ||
37 | #define ENABLE_SINK_MAX 128 | ||
38 | #define CS_BUS_DEVICE_PATH "/bus/coresight/devices/" | ||
39 | |||
36 | struct cs_etm_recording { | 40 | struct cs_etm_recording { |
37 | struct auxtrace_record itr; | 41 | struct auxtrace_record itr; |
38 | struct perf_pmu *cs_etm_pmu; | 42 | struct perf_pmu *cs_etm_pmu; |
@@ -557,3 +561,57 @@ struct auxtrace_record *cs_etm_record_init(int *err) | |||
557 | out: | 561 | out: |
558 | return NULL; | 562 | return NULL; |
559 | } | 563 | } |
564 | |||
565 | static FILE *cs_device__open_file(const char *name) | ||
566 | { | ||
567 | struct stat st; | ||
568 | char path[PATH_MAX]; | ||
569 | const char *sysfs; | ||
570 | |||
571 | sysfs = sysfs__mountpoint(); | ||
572 | if (!sysfs) | ||
573 | return NULL; | ||
574 | |||
575 | snprintf(path, PATH_MAX, | ||
576 | "%s" CS_BUS_DEVICE_PATH "%s", sysfs, name); | ||
577 | |||
578 | printf("path: %s\n", path); | ||
579 | |||
580 | if (stat(path, &st) < 0) | ||
581 | return NULL; | ||
582 | |||
583 | return fopen(path, "w"); | ||
584 | |||
585 | } | ||
586 | |||
587 | static __attribute__((format(printf, 2, 3))) | ||
588 | int cs_device__print_file(const char *name, const char *fmt, ...) | ||
589 | { | ||
590 | va_list args; | ||
591 | FILE *file; | ||
592 | int ret = -EINVAL; | ||
593 | |||
594 | va_start(args, fmt); | ||
595 | file = cs_device__open_file(name); | ||
596 | if (file) { | ||
597 | ret = vfprintf(file, fmt, args); | ||
598 | fclose(file); | ||
599 | } | ||
600 | va_end(args); | ||
601 | return ret; | ||
602 | } | ||
603 | |||
604 | int cs_etm_set_drv_config(struct perf_evsel_config_term *term) | ||
605 | { | ||
606 | int ret; | ||
607 | char enable_sink[ENABLE_SINK_MAX]; | ||
608 | |||
609 | snprintf(enable_sink, ENABLE_SINK_MAX, "%s/%s", | ||
610 | term->val.drv_cfg, "enable_sink"); | ||
611 | |||
612 | ret = cs_device__print_file(enable_sink, "%d", 1); | ||
613 | if (ret < 0) | ||
614 | return ret; | ||
615 | |||
616 | return 0; | ||
617 | } | ||
diff --git a/tools/perf/arch/arm/util/cs-etm.h b/tools/perf/arch/arm/util/cs-etm.h index 909f486d02d1..5256741be549 100644 --- a/tools/perf/arch/arm/util/cs-etm.h +++ b/tools/perf/arch/arm/util/cs-etm.h | |||
@@ -18,6 +18,9 @@ | |||
18 | #ifndef INCLUDE__PERF_CS_ETM_H__ | 18 | #ifndef INCLUDE__PERF_CS_ETM_H__ |
19 | #define INCLUDE__PERF_CS_ETM_H__ | 19 | #define INCLUDE__PERF_CS_ETM_H__ |
20 | 20 | ||
21 | #include "../../util/evsel.h" | ||
22 | |||
21 | struct auxtrace_record *cs_etm_record_init(int *err); | 23 | struct auxtrace_record *cs_etm_record_init(int *err); |
24 | int cs_etm_set_drv_config(struct perf_evsel_config_term *term); | ||
22 | 25 | ||
23 | #endif | 26 | #endif |
diff --git a/tools/perf/arch/arm/util/pmu.c b/tools/perf/arch/arm/util/pmu.c index af9fb666b44f..98d67399a0d6 100644 --- a/tools/perf/arch/arm/util/pmu.c +++ b/tools/perf/arch/arm/util/pmu.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/coresight-pmu.h> | 19 | #include <linux/coresight-pmu.h> |
20 | #include <linux/perf_event.h> | 20 | #include <linux/perf_event.h> |
21 | 21 | ||
22 | #include "cs-etm.h" | ||
22 | #include "../../util/pmu.h" | 23 | #include "../../util/pmu.h" |
23 | 24 | ||
24 | struct perf_event_attr | 25 | struct perf_event_attr |
@@ -28,6 +29,7 @@ struct perf_event_attr | |||
28 | if (!strcmp(pmu->name, CORESIGHT_ETM_PMU_NAME)) { | 29 | if (!strcmp(pmu->name, CORESIGHT_ETM_PMU_NAME)) { |
29 | /* add ETM default config here */ | 30 | /* add ETM default config here */ |
30 | pmu->selectable = true; | 31 | pmu->selectable = true; |
32 | pmu->set_drv_config = cs_etm_set_drv_config; | ||
31 | } | 33 | } |
32 | #endif | 34 | #endif |
33 | return NULL; | 35 | return NULL; |