]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
coresight: tmc: Limit the trace to available data
authorSuzuki K Poulose <suzuki.poulose@arm.com>
Thu, 25 Aug 2016 21:18:57 +0000 (15:18 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 31 Aug 2016 11:05:42 +0000 (13:05 +0200)
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>
drivers/hwtracing/coresight/coresight-tmc-etf.c
drivers/hwtracing/coresight/coresight-tmc-etr.c
drivers/hwtracing/coresight/coresight-tmc.c
drivers/hwtracing/coresight/coresight-tmc.h

index 466af86fd76f5df9b81d0f9c8b59a18f686c664b..e68289b8c0721c721a44851d072b7eccde17de81 100644 (file)
@@ -48,6 +48,7 @@ static void tmc_etb_dump_hw(struct tmc_drvdata *drvdata)
        int i;
 
        bufp = drvdata->buf;
+       drvdata->len = 0;
        while (1) {
                for (i = 0; i < drvdata->memwidth; i++) {
                        read_data = readl_relaxed(drvdata->base + TMC_RRD);
@@ -55,6 +56,7 @@ static void tmc_etb_dump_hw(struct tmc_drvdata *drvdata)
                                return;
                        memcpy(bufp, &read_data, 4);
                        bufp += 4;
+                       drvdata->len += 4;
                }
        }
 }
index 688be9e060fc547f57a259bae61a49579edfa8e8..03f36cb8b0c8fb3abb002d1e4d7646a8370ff3b1 100644 (file)
@@ -64,11 +64,17 @@ static void tmc_etr_dump_hw(struct tmc_drvdata *drvdata)
        rwp = readl_relaxed(drvdata->base + TMC_RWP);
        val = readl_relaxed(drvdata->base + TMC_STS);
 
-       /* How much memory do we still have */
-       if (val & BIT(0))
+       /*
+        * Adjust the buffer to point to the beginning of the trace data
+        * and update the available trace data.
+        */
+       if (val & BIT(0)) {
                drvdata->buf = drvdata->vaddr + rwp - drvdata->paddr;
-       else
+               drvdata->len = drvdata->size;
+       } else {
                drvdata->buf = drvdata->vaddr;
+               drvdata->len = rwp - drvdata->paddr;
+       }
 }
 
 static void tmc_etr_disable_hw(struct tmc_drvdata *drvdata)
index 1b47258e01c9a6ef6ad11a586e2166819f6ca5fc..b3275bb4d035669e63bcd1e6a8df6bad51586bd6 100644 (file)
@@ -140,8 +140,8 @@ static ssize_t tmc_read(struct file *file, char __user *data, size_t len,
                                                   struct tmc_drvdata, miscdev);
        char *bufp = drvdata->buf + *ppos;
 
-       if (*ppos + len > drvdata->size)
-               len = drvdata->size - *ppos;
+       if (*ppos + len > drvdata->len)
+               len = drvdata->len - *ppos;
 
        if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) {
                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,
        *ppos += len;
 
        dev_dbg(drvdata->dev, "%s: %zu bytes copied, %d bytes left\n",
-               __func__, len, (int)(drvdata->size - *ppos));
+               __func__, len, (int)(drvdata->len - *ppos));
        return len;
 }
 
index 5c5fe2ad2ca70f351e80cef2970641d462da6647..44b3ae346118f45b7dc5d2dd79ed550cee8d8144 100644 (file)
@@ -98,7 +98,8 @@ enum tmc_mem_intf_width {
  * @buf:       area of memory where trace data get sent.
  * @paddr:     DMA start location in RAM.
  * @vaddr:     virtual representation of @paddr.
- * @size:      @buf size.
+ * @size:      trace buffer size.
+ * @len:       size of the available trace.
  * @mode:      how this TMC is being used.
  * @config_type: TMC variant, must be of type @tmc_config_type.
  * @memwidth:  width of the memory interface databus, in bytes.
@@ -115,6 +116,7 @@ struct tmc_drvdata {
        dma_addr_t              paddr;
        void __iomem            *vaddr;
        u32                     size;
+       u32                     len;
        local_t                 mode;
        enum tmc_config_type    config_type;
        enum tmc_mem_intf_width memwidth;