Skip to content

Commit a0f08a6

Browse files
mathieupoiriergregkh
authored andcommitted
coresight: Communicate perf event to sink buffer allocation functions
Make struct perf_event available to sink buffer allocation functions in order to use the pid they carry to allocate and free buffer memory along with regimenting access to what source a sink can collect data for. Signed-off-by: Mathieu Poirier <[email protected]> Tested-by: Leo Yan <[email protected]> Tested-by: Robert Walker <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f5200aa commit a0f08a6

File tree

5 files changed

+22
-17
lines changed

5 files changed

+22
-17
lines changed

drivers/hwtracing/coresight/coresight-etb10.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,11 @@ static int etb_disable(struct coresight_device *csdev)
343343
return 0;
344344
}
345345

346-
static void *etb_alloc_buffer(struct coresight_device *csdev, int cpu,
347-
void **pages, int nr_pages, bool overwrite)
346+
static void *etb_alloc_buffer(struct coresight_device *csdev,
347+
struct perf_event *event, void **pages,
348+
int nr_pages, bool overwrite)
348349
{
349-
int node;
350+
int node, cpu = event->cpu;
350351
struct cs_buffers *buf;
351352

352353
if (cpu == -1)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
277277

278278
/* Allocate the sink buffer for this session */
279279
event_data->snk_config =
280-
sink_ops(sink)->alloc_buffer(sink, cpu, pages,
280+
sink_ops(sink)->alloc_buffer(sink, event, pages,
281281
nr_pages, overwrite);
282282
if (!event_data->snk_config)
283283
goto err;

drivers/hwtracing/coresight/coresight-tmc-etf.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,11 @@ static void tmc_disable_etf_link(struct coresight_device *csdev,
350350
dev_dbg(drvdata->dev, "TMC-ETF disabled\n");
351351
}
352352

353-
static void *tmc_alloc_etf_buffer(struct coresight_device *csdev, int cpu,
354-
void **pages, int nr_pages, bool overwrite)
353+
static void *tmc_alloc_etf_buffer(struct coresight_device *csdev,
354+
struct perf_event *event, void **pages,
355+
int nr_pages, bool overwrite)
355356
{
356-
int node;
357+
int node, cpu = event->cpu;
357358
struct cs_buffers *buf;
358359

359360
if (cpu == -1)

drivers/hwtracing/coresight/coresight-tmc-etr.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,13 +1167,18 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev)
11671167
* reaches a minimum limit (1M), beyond which we give up.
11681168
*/
11691169
static struct etr_perf_buffer *
1170-
tmc_etr_setup_perf_buf(struct tmc_drvdata *drvdata, int node, int nr_pages,
1171-
void **pages, bool snapshot)
1170+
tmc_etr_setup_perf_buf(struct tmc_drvdata *drvdata, struct perf_event *event,
1171+
int nr_pages, void **pages, bool snapshot)
11721172
{
1173+
int node, cpu = event->cpu;
11731174
struct etr_buf *etr_buf;
11741175
struct etr_perf_buffer *etr_perf;
11751176
unsigned long size;
11761177

1178+
if (cpu == -1)
1179+
cpu = smp_processor_id();
1180+
node = cpu_to_node(cpu);
1181+
11771182
etr_perf = kzalloc_node(sizeof(*etr_perf), GFP_KERNEL, node);
11781183
if (!etr_perf)
11791184
return ERR_PTR(-ENOMEM);
@@ -1211,16 +1216,13 @@ tmc_etr_setup_perf_buf(struct tmc_drvdata *drvdata, int node, int nr_pages,
12111216

12121217

12131218
static void *tmc_alloc_etr_buffer(struct coresight_device *csdev,
1214-
int cpu, void **pages, int nr_pages,
1215-
bool snapshot)
1219+
struct perf_event *event, void **pages,
1220+
int nr_pages, bool snapshot)
12161221
{
12171222
struct etr_perf_buffer *etr_perf;
12181223
struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
12191224

1220-
if (cpu == -1)
1221-
cpu = smp_processor_id();
1222-
1223-
etr_perf = tmc_etr_setup_perf_buf(drvdata, cpu_to_node(cpu),
1225+
etr_perf = tmc_etr_setup_perf_buf(drvdata, event,
12241226
nr_pages, pages, snapshot);
12251227
if (IS_ERR(etr_perf)) {
12261228
dev_dbg(drvdata->dev, "Unable to allocate ETR buffer\n");

include/linux/coresight.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ struct coresight_device {
193193
struct coresight_ops_sink {
194194
int (*enable)(struct coresight_device *csdev, u32 mode, void *data);
195195
int (*disable)(struct coresight_device *csdev);
196-
void *(*alloc_buffer)(struct coresight_device *csdev, int cpu,
197-
void **pages, int nr_pages, bool overwrite);
196+
void *(*alloc_buffer)(struct coresight_device *csdev,
197+
struct perf_event *event, void **pages,
198+
int nr_pages, bool overwrite);
198199
void (*free_buffer)(void *config);
199200
unsigned long (*update_buffer)(struct coresight_device *csdev,
200201
struct perf_output_handle *handle,

0 commit comments

Comments
 (0)