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

coresight: tmc-etr: Introduce the notion of reference counting to ETR devices

This patch adds reference counting to struct etr_buf so that, in CPU-wide
trace scenarios, shared buffers can be disposed of when no longer used.
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 ef848e46
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/coresight.h> #include <linux/coresight.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/iommu.h> #include <linux/iommu.h>
#include <linux/refcount.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
...@@ -1222,7 +1223,11 @@ get_perf_etr_buf_per_thread(struct tmc_drvdata *drvdata, ...@@ -1222,7 +1223,11 @@ get_perf_etr_buf_per_thread(struct tmc_drvdata *drvdata,
* with memory allocation. * with memory allocation.
*/ */
etr_buf = alloc_etr_buf(drvdata, event, nr_pages, pages, snapshot); etr_buf = alloc_etr_buf(drvdata, event, nr_pages, pages, snapshot);
if (IS_ERR(etr_buf))
goto out;
refcount_set(&etr_buf->refcount, 1);
out:
return etr_buf; return etr_buf;
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
#include <linux/refcount.h>
#define TMC_RSZ 0x004 #define TMC_RSZ 0x004
#define TMC_STS 0x00c #define TMC_STS 0x00c
...@@ -133,6 +134,7 @@ struct etr_buf_operations; ...@@ -133,6 +134,7 @@ struct etr_buf_operations;
/** /**
* struct etr_buf - Details of the buffer used by ETR * struct etr_buf - Details of the buffer used by ETR
* refcount ; Number of sources currently using this etr_buf.
* @mode : Mode of the ETR buffer, contiguous, Scatter Gather etc. * @mode : Mode of the ETR buffer, contiguous, Scatter Gather etc.
* @full : Trace data overflow * @full : Trace data overflow
* @size : Size of the buffer. * @size : Size of the buffer.
...@@ -143,6 +145,7 @@ struct etr_buf_operations; ...@@ -143,6 +145,7 @@ struct etr_buf_operations;
* @private : Backend specific information for the buf * @private : Backend specific information for the buf
*/ */
struct etr_buf { struct etr_buf {
refcount_t refcount;
enum etr_mode mode; enum etr_mode mode;
bool full; bool full;
ssize_t size; ssize_t size;
......
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