Skip to content

Commit 7e52877

Browse files
James-A-ClarkSuzuki K Poulose
authored andcommitted
coresight: Expose map arguments in trace ID API
The trace ID API is currently hard coded to always use the global map. Add public versions that allow the map to be passed in so that Perf mode can use per-sink maps. Keep the non-map versions so that sysfs mode can continue to use the default global map. System ID functions are unchanged because they will always use the default map. Signed-off-by: James Clark <[email protected]> Reviewed-by: Mike Leach <[email protected]> Tested-by: Leo Yan <[email protected]> Signed-off-by: James Clark <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent acb0184 commit 7e52877

File tree

2 files changed

+45
-11
lines changed

2 files changed

+45
-11
lines changed

drivers/hwtracing/coresight/coresight-trace-id.c

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#include "coresight-trace-id.h"
1414

15-
/* Default trace ID map. Used on systems that don't require per sink mappings */
15+
/* Default trace ID map. Used in sysfs mode and for system sources */
1616
static struct coresight_trace_id_map id_map_default;
1717

1818
/* maintain a record of the mapping of IDs and pending releases per cpu */
@@ -47,7 +47,7 @@ static void coresight_trace_id_dump_table(struct coresight_trace_id_map *id_map,
4747
#endif
4848

4949
/* unlocked read of current trace ID value for given CPU */
50-
static int _coresight_trace_id_read_cpu_id(int cpu)
50+
static int _coresight_trace_id_read_cpu_id(int cpu, struct coresight_trace_id_map *id_map)
5151
{
5252
return atomic_read(&per_cpu(cpu_id, cpu));
5353
}
@@ -152,15 +152,15 @@ static void coresight_trace_id_release_all_pending(void)
152152
DUMP_ID_MAP(id_map);
153153
}
154154

155-
static int coresight_trace_id_map_get_cpu_id(int cpu, struct coresight_trace_id_map *id_map)
155+
static int _coresight_trace_id_get_cpu_id(int cpu, struct coresight_trace_id_map *id_map)
156156
{
157157
unsigned long flags;
158158
int id;
159159

160160
spin_lock_irqsave(&id_map_lock, flags);
161161

162162
/* check for existing allocation for this CPU */
163-
id = _coresight_trace_id_read_cpu_id(cpu);
163+
id = _coresight_trace_id_read_cpu_id(cpu, id_map);
164164
if (id)
165165
goto get_cpu_id_clr_pend;
166166

@@ -196,13 +196,13 @@ static int coresight_trace_id_map_get_cpu_id(int cpu, struct coresight_trace_id_
196196
return id;
197197
}
198198

199-
static void coresight_trace_id_map_put_cpu_id(int cpu, struct coresight_trace_id_map *id_map)
199+
static void _coresight_trace_id_put_cpu_id(int cpu, struct coresight_trace_id_map *id_map)
200200
{
201201
unsigned long flags;
202202
int id;
203203

204204
/* check for existing allocation for this CPU */
205-
id = _coresight_trace_id_read_cpu_id(cpu);
205+
id = _coresight_trace_id_read_cpu_id(cpu, id_map);
206206
if (!id)
207207
return;
208208

@@ -254,22 +254,40 @@ static void coresight_trace_id_map_put_system_id(struct coresight_trace_id_map *
254254

255255
int coresight_trace_id_get_cpu_id(int cpu)
256256
{
257-
return coresight_trace_id_map_get_cpu_id(cpu, &id_map_default);
257+
return _coresight_trace_id_get_cpu_id(cpu, &id_map_default);
258258
}
259259
EXPORT_SYMBOL_GPL(coresight_trace_id_get_cpu_id);
260260

261+
int coresight_trace_id_get_cpu_id_map(int cpu, struct coresight_trace_id_map *id_map)
262+
{
263+
return _coresight_trace_id_get_cpu_id(cpu, id_map);
264+
}
265+
EXPORT_SYMBOL_GPL(coresight_trace_id_get_cpu_id_map);
266+
261267
void coresight_trace_id_put_cpu_id(int cpu)
262268
{
263-
coresight_trace_id_map_put_cpu_id(cpu, &id_map_default);
269+
_coresight_trace_id_put_cpu_id(cpu, &id_map_default);
264270
}
265271
EXPORT_SYMBOL_GPL(coresight_trace_id_put_cpu_id);
266272

273+
void coresight_trace_id_put_cpu_id_map(int cpu, struct coresight_trace_id_map *id_map)
274+
{
275+
_coresight_trace_id_put_cpu_id(cpu, id_map);
276+
}
277+
EXPORT_SYMBOL_GPL(coresight_trace_id_put_cpu_id_map);
278+
267279
int coresight_trace_id_read_cpu_id(int cpu)
268280
{
269-
return _coresight_trace_id_read_cpu_id(cpu);
281+
return _coresight_trace_id_read_cpu_id(cpu, &id_map_default);
270282
}
271283
EXPORT_SYMBOL_GPL(coresight_trace_id_read_cpu_id);
272284

285+
int coresight_trace_id_read_cpu_id_map(int cpu, struct coresight_trace_id_map *id_map)
286+
{
287+
return _coresight_trace_id_read_cpu_id(cpu, id_map);
288+
}
289+
EXPORT_SYMBOL_GPL(coresight_trace_id_read_cpu_id_map);
290+
273291
int coresight_trace_id_get_system_id(void)
274292
{
275293
return coresight_trace_id_map_get_system_id(&id_map_default);

drivers/hwtracing/coresight/coresight-trace-id.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242
#define IS_VALID_CS_TRACE_ID(id) \
4343
((id > CORESIGHT_TRACE_ID_RES_0) && (id < CORESIGHT_TRACE_ID_RES_TOP))
4444

45-
/* Allocate and release IDs for a single default trace ID map */
46-
4745
/**
4846
* Read and optionally allocate a CoreSight trace ID and associate with a CPU.
4947
*
@@ -59,6 +57,12 @@
5957
*/
6058
int coresight_trace_id_get_cpu_id(int cpu);
6159

60+
/**
61+
* Version of coresight_trace_id_get_cpu_id() that allows the ID map to operate
62+
* on to be provided.
63+
*/
64+
int coresight_trace_id_get_cpu_id_map(int cpu, struct coresight_trace_id_map *id_map);
65+
6266
/**
6367
* Release an allocated trace ID associated with the CPU.
6468
*
@@ -72,6 +76,12 @@ int coresight_trace_id_get_cpu_id(int cpu);
7276
*/
7377
void coresight_trace_id_put_cpu_id(int cpu);
7478

79+
/**
80+
* Version of coresight_trace_id_put_cpu_id() that allows the ID map to operate
81+
* on to be provided.
82+
*/
83+
void coresight_trace_id_put_cpu_id_map(int cpu, struct coresight_trace_id_map *id_map);
84+
7585
/**
7686
* Read the current allocated CoreSight Trace ID value for the CPU.
7787
*
@@ -92,6 +102,12 @@ void coresight_trace_id_put_cpu_id(int cpu);
92102
*/
93103
int coresight_trace_id_read_cpu_id(int cpu);
94104

105+
/**
106+
* Version of coresight_trace_id_read_cpu_id() that allows the ID map to operate
107+
* on to be provided.
108+
*/
109+
int coresight_trace_id_read_cpu_id_map(int cpu, struct coresight_trace_id_map *id_map);
110+
95111
/**
96112
* Allocate a CoreSight trace ID for a system component.
97113
*

0 commit comments

Comments
 (0)