Commit a0f08a6a authored by Mathieu Poirier's avatar Mathieu Poirier Committed by Greg Kroah-Hartman

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: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Tested-by: default avatarLeo Yan <leo.yan@linaro.org>
Tested-by: default avatarRobert Walker <robert.walker@arm.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f5200aa9
...@@ -343,10 +343,11 @@ static int etb_disable(struct coresight_device *csdev) ...@@ -343,10 +343,11 @@ static int etb_disable(struct coresight_device *csdev)
return 0; return 0;
} }
static void *etb_alloc_buffer(struct coresight_device *csdev, int cpu, static void *etb_alloc_buffer(struct coresight_device *csdev,
void **pages, int nr_pages, bool overwrite) struct perf_event *event, void **pages,
int nr_pages, bool overwrite)
{ {
int node; int node, cpu = event->cpu;
struct cs_buffers *buf; struct cs_buffers *buf;
if (cpu == -1) if (cpu == -1)
......
...@@ -277,7 +277,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, ...@@ -277,7 +277,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
/* Allocate the sink buffer for this session */ /* Allocate the sink buffer for this session */
event_data->snk_config = event_data->snk_config =
sink_ops(sink)->alloc_buffer(sink, cpu, pages, sink_ops(sink)->alloc_buffer(sink, event, pages,
nr_pages, overwrite); nr_pages, overwrite);
if (!event_data->snk_config) if (!event_data->snk_config)
goto err; goto err;
......
...@@ -350,10 +350,11 @@ static void tmc_disable_etf_link(struct coresight_device *csdev, ...@@ -350,10 +350,11 @@ static void tmc_disable_etf_link(struct coresight_device *csdev,
dev_dbg(drvdata->dev, "TMC-ETF disabled\n"); dev_dbg(drvdata->dev, "TMC-ETF disabled\n");
} }
static void *tmc_alloc_etf_buffer(struct coresight_device *csdev, int cpu, static void *tmc_alloc_etf_buffer(struct coresight_device *csdev,
void **pages, int nr_pages, bool overwrite) struct perf_event *event, void **pages,
int nr_pages, bool overwrite)
{ {
int node; int node, cpu = event->cpu;
struct cs_buffers *buf; struct cs_buffers *buf;
if (cpu == -1) if (cpu == -1)
......
...@@ -1167,13 +1167,18 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev) ...@@ -1167,13 +1167,18 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev)
* reaches a minimum limit (1M), beyond which we give up. * reaches a minimum limit (1M), beyond which we give up.
*/ */
static struct etr_perf_buffer * static struct etr_perf_buffer *
tmc_etr_setup_perf_buf(struct tmc_drvdata *drvdata, int node, int nr_pages, tmc_etr_setup_perf_buf(struct tmc_drvdata *drvdata, struct perf_event *event,
void **pages, bool snapshot) int nr_pages, void **pages, bool snapshot)
{ {
int node, cpu = event->cpu;
struct etr_buf *etr_buf; struct etr_buf *etr_buf;
struct etr_perf_buffer *etr_perf; struct etr_perf_buffer *etr_perf;
unsigned long size; unsigned long size;
if (cpu == -1)
cpu = smp_processor_id();
node = cpu_to_node(cpu);
etr_perf = kzalloc_node(sizeof(*etr_perf), GFP_KERNEL, node); etr_perf = kzalloc_node(sizeof(*etr_perf), GFP_KERNEL, node);
if (!etr_perf) if (!etr_perf)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -1211,16 +1216,13 @@ tmc_etr_setup_perf_buf(struct tmc_drvdata *drvdata, int node, int nr_pages, ...@@ -1211,16 +1216,13 @@ tmc_etr_setup_perf_buf(struct tmc_drvdata *drvdata, int node, int nr_pages,
static void *tmc_alloc_etr_buffer(struct coresight_device *csdev, static void *tmc_alloc_etr_buffer(struct coresight_device *csdev,
int cpu, void **pages, int nr_pages, struct perf_event *event, void **pages,
bool snapshot) int nr_pages, bool snapshot)
{ {
struct etr_perf_buffer *etr_perf; struct etr_perf_buffer *etr_perf;
struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
if (cpu == -1) etr_perf = tmc_etr_setup_perf_buf(drvdata, event,
cpu = smp_processor_id();
etr_perf = tmc_etr_setup_perf_buf(drvdata, cpu_to_node(cpu),
nr_pages, pages, snapshot); nr_pages, pages, snapshot);
if (IS_ERR(etr_perf)) { if (IS_ERR(etr_perf)) {
dev_dbg(drvdata->dev, "Unable to allocate ETR buffer\n"); dev_dbg(drvdata->dev, "Unable to allocate ETR buffer\n");
......
...@@ -193,8 +193,9 @@ struct coresight_device { ...@@ -193,8 +193,9 @@ struct coresight_device {
struct coresight_ops_sink { struct coresight_ops_sink {
int (*enable)(struct coresight_device *csdev, u32 mode, void *data); int (*enable)(struct coresight_device *csdev, u32 mode, void *data);
int (*disable)(struct coresight_device *csdev); int (*disable)(struct coresight_device *csdev);
void *(*alloc_buffer)(struct coresight_device *csdev, int cpu, void *(*alloc_buffer)(struct coresight_device *csdev,
void **pages, int nr_pages, bool overwrite); struct perf_event *event, void **pages,
int nr_pages, bool overwrite);
void (*free_buffer)(void *config); void (*free_buffer)(void *config);
unsigned long (*update_buffer)(struct coresight_device *csdev, unsigned long (*update_buffer)(struct coresight_device *csdev,
struct perf_output_handle *handle, struct perf_output_handle *handle,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment