Skip to content

Commit 85e2414

Browse files
mikel-armbbgregkh
authored andcommitted
coresight: syscfg: Initial coresight system configuration
Creates an system management API to allow complex configurations and features to be programmed into a CoreSight infrastructure. A feature is defined as a programming set for a device or class of devices. A configuration is a set of features across the system that are enabled for a trace session. The API will manage system wide configuration, and allow complex programmed features to be added to individual device instances, and provide for system wide configuration selection on trace capture operations. This patch creates the initial data object and the initial API for loading configurations and features. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mike Leach <[email protected]> Signed-off-by: Mathieu Poirier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e6d468d commit 85e2414

File tree

7 files changed

+401
-4
lines changed

7 files changed

+401
-4
lines changed

drivers/hwtracing/coresight/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
obj-$(CONFIG_CORESIGHT) += coresight.o
66
coresight-y := coresight-core.o coresight-etm-perf.o coresight-platform.o \
7-
coresight-sysfs.o
7+
coresight-sysfs.o coresight-syscfg.o
88
obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o
99
coresight-tmc-y := coresight-tmc-core.o coresight-tmc-etf.o \
1010
coresight-tmc-etr.o
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright (c) 2020 Linaro Limited, All rights reserved.
4+
* Author: Mike Leach <[email protected]>
5+
*/
6+
7+
#ifndef _CORESIGHT_CORESIGHT_CONFIG_H
8+
#define _CORESIGHT_CORESIGHT_CONFIG_H
9+
10+
#include <linux/coresight.h>
11+
#include <linux/types.h>
12+
13+
/* CoreSight Configuration Management - component and system wide configuration */
14+
15+
/*
16+
* Register type flags for register value descriptor:
17+
* describe how the value is interpreted, and handled.
18+
*/
19+
#define CS_CFG_REG_TYPE_STD 0x80 /* reg is standard reg */
20+
#define CS_CFG_REG_TYPE_RESOURCE 0x40 /* reg is a resource */
21+
#define CS_CFG_REG_TYPE_VAL_PARAM 0x08 /* reg value uses param */
22+
#define CS_CFG_REG_TYPE_VAL_MASK 0x04 /* reg value bit masked */
23+
#define CS_CFG_REG_TYPE_VAL_64BIT 0x02 /* reg value 64 bit */
24+
#define CS_CFG_REG_TYPE_VAL_SAVE 0x01 /* reg value save on disable */
25+
26+
/*
27+
* flags defining what device class a feature will match to when processing a
28+
* system configuration - used by config data and devices.
29+
*/
30+
#define CS_CFG_MATCH_CLASS_SRC_ALL 0x0001 /* match any source */
31+
#define CS_CFG_MATCH_CLASS_SRC_ETM4 0x0002 /* match any ETMv4 device */
32+
33+
/* flags defining device instance matching - used in config match desc data. */
34+
#define CS_CFG_MATCH_INST_ANY 0x80000000 /* any instance of a class */
35+
36+
/*
37+
* Limit number of presets in a configuration
38+
* This is related to the number of bits (4) we use to select the preset on
39+
* the perf command line. Preset 0 is always none selected.
40+
* See PMU_FORMAT_ATTR(preset, "config:0-3") in coresight-etm-perf.c
41+
*/
42+
#define CS_CFG_CONFIG_PRESET_MAX 15
43+
44+
/**
45+
* Parameter descriptor for a device feature.
46+
*
47+
* @name: Name of parameter.
48+
* @value: Initial or default value.
49+
*/
50+
struct cscfg_parameter_desc {
51+
const char *name;
52+
u64 value;
53+
};
54+
55+
/**
56+
* Representation of register value and a descriptor of register usage.
57+
*
58+
* Used as a descriptor in the feature descriptors.
59+
* Used as a value in when in a feature loading into a csdev.
60+
*
61+
* Supports full 64 bit register value, or 32 bit value with optional mask
62+
* value.
63+
*
64+
* @type: define register usage and interpretation.
65+
* @offset: the address offset for register in the hardware device (per device specification).
66+
* @hw_info: optional hardware device type specific information. (ETM / CTI specific etc)
67+
* @val64: 64 bit value.
68+
* @val32: 32 bit value.
69+
* @mask32: 32 bit mask when using 32 bit value to access device register - if mask type.
70+
* @param_idx: parameter index value into parameter array if param type.
71+
*/
72+
struct cscfg_regval_desc {
73+
struct {
74+
u32 type:8;
75+
u32 offset:12;
76+
u32 hw_info:12;
77+
};
78+
union {
79+
u64 val64;
80+
struct {
81+
u32 val32;
82+
u32 mask32;
83+
};
84+
u32 param_idx;
85+
};
86+
};
87+
88+
/**
89+
* Device feature descriptor - combination of registers and parameters to
90+
* program a device to implement a specific complex function.
91+
*
92+
* @name: feature name.
93+
* @description: brief description of the feature.
94+
* @item: List entry.
95+
* @match_flags: matching information if loading into a device
96+
* @nr_params: number of parameters used.
97+
* @params_desc: array of parameters used.
98+
* @nr_regs: number of registers used.
99+
* @regs_desc: array of registers used.
100+
*/
101+
struct cscfg_feature_desc {
102+
const char *name;
103+
const char *description;
104+
struct list_head item;
105+
u32 match_flags;
106+
int nr_params;
107+
struct cscfg_parameter_desc *params_desc;
108+
int nr_regs;
109+
struct cscfg_regval_desc *regs_desc;
110+
};
111+
112+
/**
113+
* Configuration descriptor - describes selectable system configuration.
114+
*
115+
* A configuration describes device features in use, and may provide preset
116+
* values for the parameters in those features.
117+
*
118+
* A single set of presets is the sum of the parameters declared by
119+
* all the features in use - this value is @nr_total_params.
120+
*
121+
* @name: name of the configuration - used for selection.
122+
* @description: description of the purpose of the configuration.
123+
* @item: list entry.
124+
* @nr_feat_refs: Number of features used in this configuration.
125+
* @feat_ref_names: references to features used in this configuration.
126+
* @nr_presets: Number of sets of presets supplied by this configuration.
127+
* @nr_total_params: Sum of all parameters declared by used features
128+
* @presets: Array of preset values.
129+
*
130+
*/
131+
struct cscfg_config_desc {
132+
const char *name;
133+
const char *description;
134+
struct list_head item;
135+
int nr_feat_refs;
136+
const char **feat_ref_names;
137+
int nr_presets;
138+
int nr_total_params;
139+
const u64 *presets; /* nr_presets * nr_total_params */
140+
};
141+
142+
#endif /* _CORESIGHT_CORESIGHT_CONFIG_H */

drivers/hwtracing/coresight/coresight-core.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "coresight-etm-perf.h"
2323
#include "coresight-priv.h"
24+
#include "coresight-syscfg.h"
2425

2526
static DEFINE_MUTEX(coresight_mutex);
2627
static DEFINE_PER_CPU(struct coresight_device *, csdev_sink);
@@ -1763,13 +1764,22 @@ static int __init coresight_init(void)
17631764

17641765
ret = etm_perf_init();
17651766
if (ret)
1766-
bus_unregister(&coresight_bustype);
1767+
goto exit_bus_unregister;
17671768

1769+
/* initialise the coresight syscfg API */
1770+
ret = cscfg_init();
1771+
if (!ret)
1772+
return 0;
1773+
1774+
etm_perf_exit();
1775+
exit_bus_unregister:
1776+
bus_unregister(&coresight_bustype);
17681777
return ret;
17691778
}
17701779

17711780
static void __exit coresight_exit(void)
17721781
{
1782+
cscfg_exit();
17731783
etm_perf_exit();
17741784
bus_unregister(&coresight_bustype);
17751785
}

drivers/hwtracing/coresight/coresight-etm-perf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ int __init etm_perf_init(void)
748748
return ret;
749749
}
750750

751-
void __exit etm_perf_exit(void)
751+
void etm_perf_exit(void)
752752
{
753753
perf_pmu_unregister(&etm_pmu);
754754
}

drivers/hwtracing/coresight/coresight-etm-perf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@ static inline void *etm_perf_sink_config(struct perf_output_handle *handle)
8383
#endif /* CONFIG_CORESIGHT */
8484

8585
int __init etm_perf_init(void);
86-
void __exit etm_perf_exit(void);
86+
void etm_perf_exit(void);
8787

8888
#endif

0 commit comments

Comments
 (0)