This set addresses problems observed with the CLAIM tag feature. The first patch adds support for CLAIM tags to the ETB10 drivers. The remaining 3 patches deal with properly handling the tags on ETF and ETM3x devices.
Regards, Mathieu
Changes since V1: * Added Suzuki's review tags to patch 1 and 2. * Addressed ordering issued in ETM3x enable/disable functions (Leo Yan)
Mathieu Poirier (4): coresight: etb10: Add support for CLAIM tag coresight: etf: Release CLAIM tag after disabling the HW coresight: etm3x: Deal with CLAIM tag before and after accessing HW coresight: etm3x: Release CLAIM tag when operated from perf
drivers/hwtracing/coresight/coresight-etb10.c | 23 +++++++++++++++++------ drivers/hwtracing/coresight/coresight-etm3x.c | 17 +++++++++-------- drivers/hwtracing/coresight/coresight-tmc-etf.c | 2 +- 3 files changed, 27 insertions(+), 15 deletions(-)
Following in the footstep of what was done for other CoreSight devices, add CLAIM tag support to ETB10 in order to synchronise access to the HW between the kernel and an external agent.
Signed-off-by: Mathieu Poirier mathieu.poirier@linaro.org Reviewed-by: Suzuki K Poulose suzuki.poulose@arm.com --- drivers/hwtracing/coresight/coresight-etb10.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 824be0c5f592..105782ea64c7 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -136,6 +136,11 @@ static void __etb_enable_hw(struct etb_drvdata *drvdata)
static int etb_enable_hw(struct etb_drvdata *drvdata) { + int rc = coresight_claim_device(drvdata->base); + + if (rc) + return rc; + __etb_enable_hw(drvdata); return 0; } @@ -223,7 +228,7 @@ static int etb_enable(struct coresight_device *csdev, u32 mode, void *data) return 0; }
-static void etb_disable_hw(struct etb_drvdata *drvdata) +static void __etb_disable_hw(struct etb_drvdata *drvdata) { u32 ffcr;
@@ -313,6 +318,13 @@ static void etb_dump_hw(struct etb_drvdata *drvdata) CS_LOCK(drvdata->base); }
+static void etb_disable_hw(struct etb_drvdata *drvdata) +{ + __etb_disable_hw(drvdata); + etb_dump_hw(drvdata); + coresight_disclaim_device(drvdata->base); +} + static void etb_disable(struct coresight_device *csdev) { struct etb_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); @@ -323,7 +335,6 @@ static void etb_disable(struct coresight_device *csdev) /* Disable the ETB only if it needs to */ if (drvdata->mode != CS_MODE_DISABLED) { etb_disable_hw(drvdata); - etb_dump_hw(drvdata); drvdata->mode = CS_MODE_DISABLED; } spin_unlock_irqrestore(&drvdata->spinlock, flags); @@ -402,7 +413,7 @@ static unsigned long etb_update_buffer(struct coresight_device *csdev,
capacity = drvdata->buffer_depth * ETB_FRAME_SIZE_WORDS;
- etb_disable_hw(drvdata); + __etb_disable_hw(drvdata); CS_UNLOCK(drvdata->base);
/* unit is in words, not bytes */ @@ -510,7 +521,7 @@ static unsigned long etb_update_buffer(struct coresight_device *csdev, handle->head = (cur * PAGE_SIZE) + offset; to_read = buf->nr_pages << PAGE_SHIFT; } - etb_enable_hw(drvdata); + __etb_enable_hw(drvdata); CS_LOCK(drvdata->base);
return to_read; @@ -534,9 +545,9 @@ static void etb_dump(struct etb_drvdata *drvdata)
spin_lock_irqsave(&drvdata->spinlock, flags); if (drvdata->mode == CS_MODE_SYSFS) { - etb_disable_hw(drvdata); + __etb_disable_hw(drvdata); etb_dump_hw(drvdata); - etb_enable_hw(drvdata); + __etb_enable_hw(drvdata); } spin_unlock_irqrestore(&drvdata->spinlock, flags);
This patch rectifies the sequence of events in function tmc_etb_disable_hw() by disabling the HW first and then releasing the CLAIM tag. Otherwise we could be corrupting the configuration done by an external agent that would have claimed the device after we have released it.
Signed-off-by: Mathieu Poirier mathieu.poirier@linaro.org Reviewed-by: Suzuki K Poulose suzuki.poulose@arm.com --- drivers/hwtracing/coresight/coresight-tmc-etf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index 5864ac55e275..a5f053f2db2c 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -86,8 +86,8 @@ static void __tmc_etb_disable_hw(struct tmc_drvdata *drvdata)
static void tmc_etb_disable_hw(struct tmc_drvdata *drvdata) { - coresight_disclaim_device(drvdata->base); __tmc_etb_disable_hw(drvdata); + coresight_disclaim_device(drvdata->base); }
static void __tmc_etf_enable_hw(struct tmc_drvdata *drvdata)
This patch moves access to the CLAIM tag so that no modification to the HW happens before and after the CLAIM operation has been carried.
Signed-off-by: Mathieu Poirier mathieu.poirier@linaro.org --- drivers/hwtracing/coresight/coresight-etm3x.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c index fd5c4cca7db5..4f638d81a66a 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x.c +++ b/drivers/hwtracing/coresight/coresight-etm3x.c @@ -363,15 +363,16 @@ static int etm_enable_hw(struct etm_drvdata *drvdata)
CS_UNLOCK(drvdata->base);
+ rc = coresight_claim_device_unlocked(drvdata->base); + if (rc) + goto done; + /* Turn engine on */ etm_clr_pwrdwn(drvdata); /* Apply power to trace registers */ etm_set_pwrup(drvdata); /* Make sure all registers are accessible */ etm_os_unlock(drvdata); - rc = coresight_claim_device_unlocked(drvdata->base); - if (rc) - goto done;
etm_set_prog(drvdata);
@@ -422,12 +423,11 @@ static int etm_enable_hw(struct etm_drvdata *drvdata) etm_clr_prog(drvdata);
done: - if (rc) - etm_set_pwrdwn(drvdata); CS_LOCK(drvdata->base);
- dev_dbg(drvdata->dev, "cpu: %d enable smp call done: %d\n", - drvdata->cpu, rc); + if (!rc) + dev_dbg(drvdata->dev, "cpu: %d enable smp call done: %d\n", + drvdata->cpu, rc); return rc; }
@@ -577,9 +577,9 @@ static void etm_disable_hw(void *info) for (i = 0; i < drvdata->nr_cntr; i++) config->cntr_val[i] = etm_readl(drvdata, ETMCNTVRn(i));
+ etm_set_pwrdwn(drvdata); coresight_disclaim_device_unlocked(drvdata->base);
- etm_set_pwrdwn(drvdata); CS_LOCK(drvdata->base);
dev_dbg(drvdata->dev, "cpu: %d disable smp call done\n", drvdata->cpu);
Hi,
On 07/11/2018 23:08, Mathieu Poirier wrote:
This patch moves access to the CLAIM tag so that no modification to the HW happens before and after the CLAIM operation has been carried.
Signed-off-by: Mathieu Poirier mathieu.poirier@linaro.org
drivers/hwtracing/coresight/coresight-etm3x.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c index fd5c4cca7db5..4f638d81a66a 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x.c +++ b/drivers/hwtracing/coresight/coresight-etm3x.c @@ -363,15 +363,16 @@ static int etm_enable_hw(struct etm_drvdata *drvdata) CS_UNLOCK(drvdata->base);
- rc = coresight_claim_device_unlocked(drvdata->base);
- if (rc)
goto done;
- /* Turn engine on */ etm_clr_pwrdwn(drvdata); /* Apply power to trace registers */ etm_set_pwrup(drvdata); /* Make sure all registers are accessible */ etm_os_unlock(drvdata);
- rc = coresight_claim_device_unlocked(drvdata->base);
- if (rc)
goto done;
etm_set_prog(drvdata); @@ -422,12 +423,11 @@ static int etm_enable_hw(struct etm_drvdata *drvdata) etm_clr_prog(drvdata); done:
- if (rc)
CS_LOCK(drvdata->base);etm_set_pwrdwn(drvdata);
- dev_dbg(drvdata->dev, "cpu: %d enable smp call done: %d\n",
drvdata->cpu, rc);
- if (!rc)
dev_dbg(drvdata->dev, "cpu: %d enable smp call done: %d\n",
drvdata->cpu, rc);
Isn't it good to report the failure case too ? Anyway it is dev_dbg and will be a useful info when we debug issues. Otherwise,
Reviewed-by: Suzuki K Poulose suzuki.poulose@arm.com
return rc; } @@ -577,9 +577,9 @@ static void etm_disable_hw(void *info) for (i = 0; i < drvdata->nr_cntr; i++) config->cntr_val[i] = etm_readl(drvdata, ETMCNTVRn(i));
- etm_set_pwrdwn(drvdata); coresight_disclaim_device_unlocked(drvdata->base);
- etm_set_pwrdwn(drvdata); CS_LOCK(drvdata->base);
dev_dbg(drvdata->dev, "cpu: %d disable smp call done\n", drvdata->cpu);
On Thu, 8 Nov 2018 at 10:13, Suzuki K Poulose suzuki.poulose@arm.com wrote:
Hi,
On 07/11/2018 23:08, Mathieu Poirier wrote:
This patch moves access to the CLAIM tag so that no modification to the HW happens before and after the CLAIM operation has been carried.
Signed-off-by: Mathieu Poirier mathieu.poirier@linaro.org
drivers/hwtracing/coresight/coresight-etm3x.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c index fd5c4cca7db5..4f638d81a66a 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x.c +++ b/drivers/hwtracing/coresight/coresight-etm3x.c @@ -363,15 +363,16 @@ static int etm_enable_hw(struct etm_drvdata *drvdata)
CS_UNLOCK(drvdata->base);
rc = coresight_claim_device_unlocked(drvdata->base);
if (rc)
goto done;
/* Turn engine on */ etm_clr_pwrdwn(drvdata); /* Apply power to trace registers */ etm_set_pwrup(drvdata); /* Make sure all registers are accessible */ etm_os_unlock(drvdata);
rc = coresight_claim_device_unlocked(drvdata->base);
if (rc)
goto done; etm_set_prog(drvdata);
@@ -422,12 +423,11 @@ static int etm_enable_hw(struct etm_drvdata *drvdata) etm_clr_prog(drvdata);
done:
if (rc)
etm_set_pwrdwn(drvdata); CS_LOCK(drvdata->base);
dev_dbg(drvdata->dev, "cpu: %d enable smp call done: %d\n",
drvdata->cpu, rc);
if (!rc)
dev_dbg(drvdata->dev, "cpu: %d enable smp call done: %d\n",
drvdata->cpu, rc);
Isn't it good to report the failure case too ? Anyway it is dev_dbg and will be a useful info when we debug issues. Otherwise,
Simply removing the "if (!rc)" will do the trick. Can I do the modification and add your tag or you prefer to see another revision?
Reviewed-by: Suzuki K Poulose suzuki.poulose@arm.com
return rc;
}
@@ -577,9 +577,9 @@ static void etm_disable_hw(void *info) for (i = 0; i < drvdata->nr_cntr; i++) config->cntr_val[i] = etm_readl(drvdata, ETMCNTVRn(i));
etm_set_pwrdwn(drvdata); coresight_disclaim_device_unlocked(drvdata->base);
etm_set_pwrdwn(drvdata); CS_LOCK(drvdata->base); dev_dbg(drvdata->dev, "cpu: %d disable smp call done\n", drvdata->cpu);
On 11/09/2018 05:59 PM, Mathieu Poirier wrote:
On Thu, 8 Nov 2018 at 10:13, Suzuki K Poulose suzuki.poulose@arm.com wrote:
Hi,
On 07/11/2018 23:08, Mathieu Poirier wrote:
This patch moves access to the CLAIM tag so that no modification to the HW happens before and after the CLAIM operation has been carried.
Signed-off-by: Mathieu Poirier mathieu.poirier@linaro.org
drivers/hwtracing/coresight/coresight-etm3x.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c index fd5c4cca7db5..4f638d81a66a 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x.c +++ b/drivers/hwtracing/coresight/coresight-etm3x.c @@ -363,15 +363,16 @@ static int etm_enable_hw(struct etm_drvdata *drvdata)
CS_UNLOCK(drvdata->base);
rc = coresight_claim_device_unlocked(drvdata->base);
if (rc)
goto done;
/* Turn engine on */ etm_clr_pwrdwn(drvdata); /* Apply power to trace registers */ etm_set_pwrup(drvdata); /* Make sure all registers are accessible */ etm_os_unlock(drvdata);
rc = coresight_claim_device_unlocked(drvdata->base);
if (rc)
goto done; etm_set_prog(drvdata);
@@ -422,12 +423,11 @@ static int etm_enable_hw(struct etm_drvdata *drvdata) etm_clr_prog(drvdata);
done:
if (rc)
etm_set_pwrdwn(drvdata); CS_LOCK(drvdata->base);
dev_dbg(drvdata->dev, "cpu: %d enable smp call done: %d\n",
drvdata->cpu, rc);
if (!rc)
dev_dbg(drvdata->dev, "cpu: %d enable smp call done: %d\n",
drvdata->cpu, rc);
Isn't it good to report the failure case too ? Anyway it is dev_dbg and will be a useful info when we debug issues. Otherwise,
Simply removing the "if (!rc)" will do the trick. Can I do the modification and add your tag or you prefer to see another revision?
I am fine with that change folded in, no need to respin it.
Reviewed-by: Suzuki K Poulose suzuki.poulose@arm.com
Cheers Suzuki
return rc;
}
@@ -577,9 +577,9 @@ static void etm_disable_hw(void *info) for (i = 0; i < drvdata->nr_cntr; i++) config->cntr_val[i] = etm_readl(drvdata, ETMCNTVRn(i));
etm_set_pwrdwn(drvdata); coresight_disclaim_device_unlocked(drvdata->base);
etm_set_pwrdwn(drvdata); CS_LOCK(drvdata->base); dev_dbg(drvdata->dev, "cpu: %d disable smp call done\n", drvdata->cpu);
This patch deals with the release of the CLAIM tag when the ETM is operated from perf. Otherwise the tag is left asserted and subsequent requests to use the device fail.
Signed-off-by: Mathieu Poirier mathieu.poirier@linaro.org --- drivers/hwtracing/coresight/coresight-etm3x.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c index 4f638d81a66a..d7f452e62193 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x.c +++ b/drivers/hwtracing/coresight/coresight-etm3x.c @@ -602,6 +602,7 @@ static void etm_disable_perf(struct coresight_device *csdev) * power down the tracer. */ etm_set_pwrdwn(drvdata); + coresight_disclaim_device_unlocked(drvdata->base);
CS_LOCK(drvdata->base); }
On 07/11/2018 23:08, Mathieu Poirier wrote:
This patch deals with the release of the CLAIM tag when the ETM is operated from perf. Otherwise the tag is left asserted and subsequent requests to use the device fail.
Signed-off-by: Mathieu Poirier mathieu.poirier@linaro.org
drivers/hwtracing/coresight/coresight-etm3x.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c index 4f638d81a66a..d7f452e62193 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x.c +++ b/drivers/hwtracing/coresight/coresight-etm3x.c @@ -602,6 +602,7 @@ static void etm_disable_perf(struct coresight_device *csdev) * power down the tracer. */ etm_set_pwrdwn(drvdata);
- coresight_disclaim_device_unlocked(drvdata->base);
Thanks for fixing this. IIUC, I think we have a problem in general with mixing perf vs sysfs. Once a perf session uses the etm3x, we overwrite the drvdata->config with the perf event specific controls and the sysfs user may not be aware of that. We may have to do something similar we do for ETR buf for sysfs/perf sessions. And then we may be able to merge the enable/disable routines.
For this patch:
Reviewed-by: Suzuki K Poulose suzuki.poulose@arm.com