summaryrefslogtreecommitdiff
path: root/drivers/hwtracing/coresight/coresight-etm-perf.h
blob: 24d929428633f56f24a114d5bb93b8ac4799ca11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright(C) 2015 Linaro Limited. All rights reserved.
 * Author: Mathieu Poirier <mathieu.poirier@linaro.org>
 */

#ifndef _CORESIGHT_ETM_PERF_H
#define _CORESIGHT_ETM_PERF_H

#include <linux/percpu-defs.h>
#include "coresight-priv.h"

struct coresight_device;
struct cscfg_config_desc;

/*
 * In both ETMv3 and v4 the maximum number of address comparator implentable
 * is 8.  The actual number is implementation specific and will be checked
 * when filters are applied.
 */
#define ETM_ADDR_CMP_MAX	8

#define ATTR_CFG_FLD_preset_CFG			config
#define ATTR_CFG_FLD_preset_LO			0
#define ATTR_CFG_FLD_preset_HI			3
#define ATTR_CFG_FLD_timestamp_CFG		config
#define ATTR_CFG_FLD_timestamp_LO		4
#define ATTR_CFG_FLD_timestamp_HI		7
#define ATTR_CFG_FLD_branch_broadcast_CFG	config
#define ATTR_CFG_FLD_branch_broadcast_LO	8
#define ATTR_CFG_FLD_branch_broadcast_HI	8
#define ATTR_CFG_FLD_cycacc_CFG			config
#define ATTR_CFG_FLD_cycacc_LO			12
#define ATTR_CFG_FLD_cycacc_HI			12
#define ATTR_CFG_FLD_contextid1_CFG		config
#define ATTR_CFG_FLD_contextid1_LO		14
#define ATTR_CFG_FLD_contextid1_HI		14
#define ATTR_CFG_FLD_contextid2_CFG		config
#define ATTR_CFG_FLD_contextid2_LO		15
#define ATTR_CFG_FLD_contextid2_HI		15
/*
 * Old position of 'timestamp' and not published in sysfs. Remove at a later
 * date if necessary.
 */
#define ATTR_CFG_FLD_deprecated_timestamp_CFG	config
#define ATTR_CFG_FLD_deprecated_timestamp_LO	28
#define ATTR_CFG_FLD_deprecated_timestamp_HI	28
#define ATTR_CFG_FLD_retstack_CFG		config
#define ATTR_CFG_FLD_retstack_LO		29
#define ATTR_CFG_FLD_retstack_HI		29
#define ATTR_CFG_FLD_sinkid_CFG			config2
#define ATTR_CFG_FLD_sinkid_LO			0
#define ATTR_CFG_FLD_sinkid_HI			31
#define ATTR_CFG_FLD_configid_CFG		config2
#define ATTR_CFG_FLD_configid_LO		32
#define ATTR_CFG_FLD_configid_HI		63
#define ATTR_CFG_FLD_cc_threshold_CFG		config3
#define ATTR_CFG_FLD_cc_threshold_LO		0
#define ATTR_CFG_FLD_cc_threshold_HI		11

/**
 * struct etm_filter - single instruction range or start/stop configuration.
 * @start_addr:	The address to start tracing on.
 * @stop_addr:	The address to stop tracing on.
 * @type:	Is this a range or start/stop filter.
 */
struct etm_filter {
	unsigned long start_addr;
	unsigned long stop_addr;
	enum etm_addr_type type;
};

/**
 * struct etm_filters - set of filters for a session
 * @etm_filter:	All the filters for this session.
 * @nr_filters:	Number of filters
 * @ssstatus:	Status of the start/stop logic.
 */
struct etm_filters {
	struct etm_filter	etm_filter[ETM_ADDR_CMP_MAX];
	unsigned int		nr_filters;
	bool			ssstatus;
};

/**
 * struct etm_event_data - Coresight specifics associated to an event
 * @work:		Handle to free allocated memory outside IRQ context.
 * @mask:		Hold the CPU(s) this event was set for.
 * @aux_hwid_done:	Whether a CPU has emitted the TraceID packet or not.
 * @snk_config:		The sink configuration.
 * @cfg_hash:		The hash id of any coresight config selected.
 * @path:		An array of path, each slot for one CPU.
 */
struct etm_event_data {
	struct work_struct work;
	cpumask_t mask;
	cpumask_t aux_hwid_done;
	void *snk_config;
	u32 cfg_hash;
	struct coresight_path * __percpu *path;
};

int etm_perf_symlink(struct coresight_device *csdev, bool link);
int etm_perf_add_symlink_sink(struct coresight_device *csdev);
void etm_perf_del_symlink_sink(struct coresight_device *csdev);
static inline void *etm_perf_sink_config(struct perf_output_handle *handle)
{
	struct etm_event_data *data = perf_get_aux(handle);

	if (data)
		return data->snk_config;
	return NULL;
}
int etm_perf_add_symlink_cscfg(struct device *dev,
			       struct cscfg_config_desc *config_desc);
void etm_perf_del_symlink_cscfg(struct cscfg_config_desc *config_desc);
int __init etm_perf_init(void);
void etm_perf_exit(void);

#endif