| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
/* |
| 3 |
* Copyright(C) 2015 Linaro Limited. All rights reserved. |
| 4 |
* Author: Mathieu Poirier <[email protected]> |
| 5 |
*/ |
| 6 |
|
| 7 |
#ifndef _CORESIGHT_ETM_PERF_H |
| 8 |
#define _CORESIGHT_ETM_PERF_H |
| 9 |
|
| 10 |
#include <linux/percpu-defs.h> |
| 11 |
#include "coresight-priv.h" |
| 12 |
|
| 13 |
struct coresight_device; |
| 14 |
struct cscfg_config_desc; |
| 15 |
|
| 16 |
/* |
| 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 |
#define ATTR_CFG_FLD_preset_CFG config |
| 24 |
#define ATTR_CFG_FLD_preset_LO 0 |
| 25 |
#define ATTR_CFG_FLD_preset_HI 3 |
| 26 |
#define ATTR_CFG_FLD_timestamp_CFG config |
| 27 |
#define ATTR_CFG_FLD_timestamp_LO 4 |
| 28 |
#define ATTR_CFG_FLD_timestamp_HI 7 |
| 29 |
#define ATTR_CFG_FLD_branch_broadcast_CFG config |
| 30 |
#define ATTR_CFG_FLD_branch_broadcast_LO 8 |
| 31 |
#define ATTR_CFG_FLD_branch_broadcast_HI 8 |
| 32 |
#define ATTR_CFG_FLD_cycacc_CFG config |
| 33 |
#define ATTR_CFG_FLD_cycacc_LO 12 |
| 34 |
#define ATTR_CFG_FLD_cycacc_HI 12 |
| 35 |
#define ATTR_CFG_FLD_contextid1_CFG config |
| 36 |
#define ATTR_CFG_FLD_contextid1_LO 14 |
| 37 |
#define ATTR_CFG_FLD_contextid1_HI 14 |
| 38 |
#define ATTR_CFG_FLD_contextid2_CFG config |
| 39 |
#define ATTR_CFG_FLD_contextid2_LO 15 |
| 40 |
#define ATTR_CFG_FLD_contextid2_HI 15 |
| 41 |
/* |
| 42 |
* Old position of 'timestamp' and not published in sysfs. Remove at a later |
| 43 |
* date if necessary. |
| 44 |
*/ |
| 45 |
#define ATTR_CFG_FLD_deprecated_timestamp_CFG config |
| 46 |
#define ATTR_CFG_FLD_deprecated_timestamp_LO 28 |
| 47 |
#define ATTR_CFG_FLD_deprecated_timestamp_HI 28 |
| 48 |
#define ATTR_CFG_FLD_retstack_CFG config |
| 49 |
#define ATTR_CFG_FLD_retstack_LO 29 |
| 50 |
#define ATTR_CFG_FLD_retstack_HI 29 |
| 51 |
#define ATTR_CFG_FLD_sinkid_CFG config2 |
| 52 |
#define ATTR_CFG_FLD_sinkid_LO 0 |
| 53 |
#define ATTR_CFG_FLD_sinkid_HI 31 |
| 54 |
#define ATTR_CFG_FLD_configid_CFG config2 |
| 55 |
#define ATTR_CFG_FLD_configid_LO 32 |
| 56 |
#define ATTR_CFG_FLD_configid_HI 63 |
| 57 |
#define ATTR_CFG_FLD_cc_threshold_CFG config3 |
| 58 |
#define ATTR_CFG_FLD_cc_threshold_LO 0 |
| 59 |
#define ATTR_CFG_FLD_cc_threshold_HI 11 |
| 60 |
|
| 61 |
/** |
| 62 |
* struct etm_filter - single instruction range or start/stop configuration. |
| 63 |
* @start_addr: The address to start tracing on. |
| 64 |
* @stop_addr: The address to stop tracing on. |
| 65 |
* @type: Is this a range or start/stop filter. |
| 66 |
*/ |
| 67 |
struct etm_filter { |
| 68 |
unsigned long start_addr; |
| 69 |
unsigned long stop_addr; |
| 70 |
enum etm_addr_type type; |
| 71 |
}; |
| 72 |
|
| 73 |
/** |
| 74 |
* struct etm_filters - set of filters for a session |
| 75 |
* @etm_filter: All the filters for this session. |
| 76 |
* @nr_filters: Number of filters |
| 77 |
* @ssstatus: Status of the start/stop logic. |
| 78 |
*/ |
| 79 |
struct etm_filters { |
| 80 |
struct etm_filter etm_filter[ETM_ADDR_CMP_MAX]; |
| 81 |
unsigned int nr_filters; |
| 82 |
bool ssstatus; |
| 83 |
}; |
| 84 |
|
| 85 |
/** |
| 86 |
* struct etm_event_data - Coresight specifics associated to an event |
| 87 |
* @work: Handle to free allocated memory outside IRQ context. |
| 88 |
* @mask: Hold the CPU(s) this event was set for. |
| 89 |
* @aux_hwid_done: Whether a CPU has emitted the TraceID packet or not. |
| 90 |
* @snk_config: The sink configuration. |
| 91 |
* @cfg_hash: The hash id of any coresight config selected. |
| 92 |
* @path: An array of path, each slot for one CPU. |
| 93 |
*/ |
| 94 |
struct etm_event_data { |
| 95 |
struct work_struct work; |
| 96 |
cpumask_t mask; |
| 97 |
cpumask_t aux_hwid_done; |
| 98 |
void *snk_config; |
| 99 |
u32 cfg_hash; |
| 100 |
struct coresight_path * __percpu *path; |
| 101 |
}; |
| 102 |
|
| 103 |
int etm_perf_symlink(struct coresight_device *csdev, bool link); |
| 104 |
int etm_perf_add_symlink_sink(struct coresight_device *csdev); |
| 105 |
void etm_perf_del_symlink_sink(struct coresight_device *csdev); |
| 106 |
static inline void *etm_perf_sink_config(struct perf_output_handle *handle) |
| 107 |
{ |
| 108 |
struct etm_event_data *data = perf_get_aux(handle); |
| 109 |
|
| 110 |
if (data) |
| 111 |
return data->snk_config; |
| 112 |
return NULL; |
| 113 |
} |
| 114 |
int etm_perf_add_symlink_cscfg(struct device *dev, |
| 115 |
struct cscfg_config_desc *config_desc); |
| 116 |
void etm_perf_del_symlink_cscfg(struct cscfg_config_desc *config_desc); |
| 117 |
int __init etm_perf_init(void); |
| 118 |
void etm_perf_exit(void); |
| 119 |
|
| 120 |
#endif |