blob: 468f7799ab4fb13303aadc1652e2396082acf564 [file] [log] [blame]
Mathieu Poirierad0dfdf2018-05-09 12:06:04 -06001/* SPDX-License-Identifier: GPL-2.0 */
Mathieu Poirier0bcbf2e2016-02-17 17:52:01 -07002/*
3 * Copyright(C) 2015 Linaro Limited. All rights reserved.
4 * Author: Mathieu Poirier <mathieu.poirier@linaro.org>
Mathieu Poirier0bcbf2e2016-02-17 17:52:01 -07005 */
6
7#ifndef _CORESIGHT_ETM_PERF_H
8#define _CORESIGHT_ETM_PERF_H
9
Suzuki K Poulosed25054e2018-09-20 13:17:55 -060010#include <linux/percpu-defs.h>
Mathieu Poirierca878b12016-08-25 15:19:12 -060011#include "coresight-priv.h"
12
Mathieu Poirier0bcbf2e2016-02-17 17:52:01 -070013struct coresight_device;
Mike Leach94d2bac2021-08-18 13:40:15 -060014struct cscfg_config_desc;
Mathieu Poirier0bcbf2e2016-02-17 17:52:01 -070015
Mathieu Poirierca878b12016-08-25 15:19:12 -060016/*
17 * In both ETMv3 and v4 the maximum number of address comparator implentable
18 * is 8. The actual number is implementation specific and will be checked
19 * when filters are applied.
20 */
21#define ETM_ADDR_CMP_MAX 8
22
23/**
24 * struct etm_filter - single instruction range or start/stop configuration.
25 * @start_addr: The address to start tracing on.
26 * @stop_addr: The address to stop tracing on.
27 * @type: Is this a range or start/stop filter.
28 */
29struct etm_filter {
30 unsigned long start_addr;
31 unsigned long stop_addr;
32 enum etm_addr_type type;
33};
34
35/**
36 * struct etm_filters - set of filters for a session
37 * @etm_filter: All the filters for this session.
38 * @nr_filters: Number of filters
39 * @ssstatus: Status of the start/stop logic.
40 */
41struct etm_filters {
42 struct etm_filter etm_filter[ETM_ADDR_CMP_MAX];
43 unsigned int nr_filters;
44 bool ssstatus;
45};
46
Suzuki K Poulosed25054e2018-09-20 13:17:55 -060047/**
48 * struct etm_event_data - Coresight specifics associated to an event
49 * @work: Handle to free allocated memory outside IRQ context.
50 * @mask: Hold the CPU(s) this event was set for.
51 * @snk_config: The sink configuration.
Mike Leacha0114b42021-08-18 13:40:17 -060052 * @cfg_hash: The hash id of any coresight config selected.
Suzuki K Poulosed25054e2018-09-20 13:17:55 -060053 * @path: An array of path, each slot for one CPU.
54 */
55struct etm_event_data {
56 struct work_struct work;
57 cpumask_t mask;
58 void *snk_config;
Mike Leacha0114b42021-08-18 13:40:17 -060059 u32 cfg_hash;
Suzuki K Poulosed25054e2018-09-20 13:17:55 -060060 struct list_head * __percpu *path;
61};
Mathieu Poirierca878b12016-08-25 15:19:12 -060062
Kim Phillipsb8127112020-09-28 10:34:51 -060063#if IS_ENABLED(CONFIG_CORESIGHT)
Mathieu Poirier0bcbf2e2016-02-17 17:52:01 -070064int etm_perf_symlink(struct coresight_device *csdev, bool link);
Mathieu Poirierbb8e3702019-01-31 11:47:09 -070065int etm_perf_add_symlink_sink(struct coresight_device *csdev);
66void etm_perf_del_symlink_sink(struct coresight_device *csdev);
Suzuki K Poulosed25054e2018-09-20 13:17:55 -060067static inline void *etm_perf_sink_config(struct perf_output_handle *handle)
68{
69 struct etm_event_data *data = perf_get_aux(handle);
Mathieu Poirier0bcbf2e2016-02-17 17:52:01 -070070
Suzuki K Poulosed25054e2018-09-20 13:17:55 -060071 if (data)
72 return data->snk_config;
73 return NULL;
74}
Mike Leach94d2bac2021-08-18 13:40:15 -060075int etm_perf_add_symlink_cscfg(struct device *dev,
76 struct cscfg_config_desc *config_desc);
77void etm_perf_del_symlink_cscfg(struct cscfg_config_desc *config_desc);
Mathieu Poirier0bcbf2e2016-02-17 17:52:01 -070078#else
79static inline int etm_perf_symlink(struct coresight_device *csdev, bool link)
80{ return -EINVAL; }
Mathieu Poirierbb8e3702019-01-31 11:47:09 -070081int etm_perf_add_symlink_sink(struct coresight_device *csdev)
82{ return -EINVAL; }
83void etm_perf_del_symlink_sink(struct coresight_device *csdev) {}
Suzuki K Poulosed25054e2018-09-20 13:17:55 -060084static inline void *etm_perf_sink_config(struct perf_output_handle *handle)
85{
86 return NULL;
87}
Mike Leach94d2bac2021-08-18 13:40:15 -060088int etm_perf_add_symlink_cscfg(struct device *dev,
89 struct cscfg_config_desc *config_desc)
90{ return -EINVAL; }
91void etm_perf_del_symlink_cscfg(struct cscfg_config_desc *config_desc) {}
Suzuki K Poulosed25054e2018-09-20 13:17:55 -060092
Mathieu Poirier0bcbf2e2016-02-17 17:52:01 -070093#endif /* CONFIG_CORESIGHT */
94
Tingwei Zhang8e264c52020-09-28 10:35:12 -060095int __init etm_perf_init(void);
Mike Leach85e2414c2021-08-18 13:40:12 -060096void etm_perf_exit(void);
Tingwei Zhang8e264c52020-09-28 10:35:12 -060097
Mathieu Poirier0bcbf2e2016-02-17 17:52:01 -070098#endif