aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwtracing
diff options
context:
space:
mode:
authorSuzuki K Poulose <suzuki.poulose@arm.com>2016-08-25 17:18:57 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-08-31 07:05:42 -0400
commit8505feaed9246791e94c30e8bf52fa4c3ef2e7af (patch)
treef63d393a3a2fd4f20650342b11d182513904d4e5 /drivers/hwtracing
parent068c0a542f6edce90f7d8a9b35a849d990001018 (diff)
coresight: tmc: Limit the trace to available data
At present the ETF or ETR gives out the entire device buffer, even if there is less or even no trace data available. This patch limits the trace data given out to the actual trace data collected. Cc: mathieu.poirier@linaro.org Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hwtracing')
-rw-r--r--drivers/hwtracing/coresight/coresight-tmc-etf.c2
-rw-r--r--drivers/hwtracing/coresight/coresight-tmc-etr.c12
-rw-r--r--drivers/hwtracing/coresight/coresight-tmc.c6
-rw-r--r--drivers/hwtracing/coresight/coresight-tmc.h4
4 files changed, 17 insertions, 7 deletions
diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c
index 466af86fd76f..e68289b8c072 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-etf.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c
@@ -48,6 +48,7 @@ static void tmc_etb_dump_hw(struct tmc_drvdata *drvdata)
48 int i; 48 int i;
49 49
50 bufp = drvdata->buf; 50 bufp = drvdata->buf;
51 drvdata->len = 0;
51 while (1) { 52 while (1) {
52 for (i = 0; i < drvdata->memwidth; i++) { 53 for (i = 0; i < drvdata->memwidth; i++) {
53 read_data = readl_relaxed(drvdata->base + TMC_RRD); 54 read_data = readl_relaxed(drvdata->base + TMC_RRD);
@@ -55,6 +56,7 @@ static void tmc_etb_dump_hw(struct tmc_drvdata *drvdata)
55 return; 56 return;
56 memcpy(bufp, &read_data, 4); 57 memcpy(bufp, &read_data, 4);
57 bufp += 4; 58 bufp += 4;
59 drvdata->len += 4;
58 } 60 }
59 } 61 }
60} 62}
diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c
index 688be9e060fc..03f36cb8b0c8 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-etr.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c
@@ -64,11 +64,17 @@ static void tmc_etr_dump_hw(struct tmc_drvdata *drvdata)
64 rwp = readl_relaxed(drvdata->base + TMC_RWP); 64 rwp = readl_relaxed(drvdata->base + TMC_RWP);
65 val = readl_relaxed(drvdata->base + TMC_STS); 65 val = readl_relaxed(drvdata->base + TMC_STS);
66 66
67 /* How much memory do we still have */ 67 /*
68 if (val & BIT(0)) 68 * Adjust the buffer to point to the beginning of the trace data
69 * and update the available trace data.
70 */
71 if (val & BIT(0)) {
69 drvdata->buf = drvdata->vaddr + rwp - drvdata->paddr; 72 drvdata->buf = drvdata->vaddr + rwp - drvdata->paddr;
70 else 73 drvdata->len = drvdata->size;
74 } else {
71 drvdata->buf = drvdata->vaddr; 75 drvdata->buf = drvdata->vaddr;
76 drvdata->len = rwp - drvdata->paddr;
77 }
72} 78}
73 79
74static void tmc_etr_disable_hw(struct tmc_drvdata *drvdata) 80static void tmc_etr_disable_hw(struct tmc_drvdata *drvdata)
diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c
index 1b47258e01c9..b3275bb4d035 100644
--- a/drivers/hwtracing/coresight/coresight-tmc.c
+++ b/drivers/hwtracing/coresight/coresight-tmc.c
@@ -140,8 +140,8 @@ static ssize_t tmc_read(struct file *file, char __user *data, size_t len,
140 struct tmc_drvdata, miscdev); 140 struct tmc_drvdata, miscdev);
141 char *bufp = drvdata->buf + *ppos; 141 char *bufp = drvdata->buf + *ppos;
142 142
143 if (*ppos + len > drvdata->size) 143 if (*ppos + len > drvdata->len)
144 len = drvdata->size - *ppos; 144 len = drvdata->len - *ppos;
145 145
146 if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) { 146 if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) {
147 if (bufp == (char *)(drvdata->vaddr + drvdata->size)) 147 if (bufp == (char *)(drvdata->vaddr + drvdata->size))
@@ -160,7 +160,7 @@ static ssize_t tmc_read(struct file *file, char __user *data, size_t len,
160 *ppos += len; 160 *ppos += len;
161 161
162 dev_dbg(drvdata->dev, "%s: %zu bytes copied, %d bytes left\n", 162 dev_dbg(drvdata->dev, "%s: %zu bytes copied, %d bytes left\n",
163 __func__, len, (int)(drvdata->size - *ppos)); 163 __func__, len, (int)(drvdata->len - *ppos));
164 return len; 164 return len;
165} 165}
166 166
diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracing/coresight/coresight-tmc.h
index 5c5fe2ad2ca7..44b3ae346118 100644
--- a/drivers/hwtracing/coresight/coresight-tmc.h
+++ b/drivers/hwtracing/coresight/coresight-tmc.h
@@ -98,7 +98,8 @@ enum tmc_mem_intf_width {
98 * @buf: area of memory where trace data get sent. 98 * @buf: area of memory where trace data get sent.
99 * @paddr: DMA start location in RAM. 99 * @paddr: DMA start location in RAM.
100 * @vaddr: virtual representation of @paddr. 100 * @vaddr: virtual representation of @paddr.
101 * @size: @buf size. 101 * @size: trace buffer size.
102 * @len: size of the available trace.
102 * @mode: how this TMC is being used. 103 * @mode: how this TMC is being used.
103 * @config_type: TMC variant, must be of type @tmc_config_type. 104 * @config_type: TMC variant, must be of type @tmc_config_type.
104 * @memwidth: width of the memory interface databus, in bytes. 105 * @memwidth: width of the memory interface databus, in bytes.
@@ -115,6 +116,7 @@ struct tmc_drvdata {
115 dma_addr_t paddr; 116 dma_addr_t paddr;
116 void __iomem *vaddr; 117 void __iomem *vaddr;
117 u32 size; 118 u32 size;
119 u32 len;
118 local_t mode; 120 local_t mode;
119 enum tmc_config_type config_type; 121 enum tmc_config_type config_type;
120 enum tmc_mem_intf_width memwidth; 122 enum tmc_mem_intf_width memwidth;