Skip to contentSkip to conversation

coresight: next v4.12-rc4

PATCH New Mathieu Poirier 5 participants 33 messages Jun 5, 2017 – Aug 23, 2017 1 message not in the archive

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

cover coresight: next v4.12-rc4

Hi Greg,

Please consider for inclusion in the 4.13 cycle. Of particular interest is patch 15/17, which adds a new driver under the CoreSight umbrella. Everything applies cleanly on today's char-misc-next branch (73726380a26f).

Regards,
Mathieu

Leo Yan (10):
coresight: tmc: minor fix for output log
coresight: use const for device_node structures
coresight: bindings for CPU debug module
doc: Add documentation for Coresight CPU debug
doc: Add coresight_cpu_debug.enable to kernel-parameters.txt
MAINTAINERS: update file entries for Coresight subsystem
coresight: refactor with function of_coresight_get_cpu
coresight: add support for CPU debug module
arm64: dts: hi6220: register debug module
arm64: dts: qcom: msm8916: Add debug unit

Markus Elfring (2):
coresight: etb10: Delete an error message for a failed memory
allocation in etb_probe()
coresight: etb10: Fix a typo in a comment line

Robin Murphy (1):
coresight: tmc: Configure DMA mask appropriately

Suzuki K Poulose (4):
coresight: Disable the path only when the source is disabled
coresight: Fix reference count for software sources
coresight: etm_perf: Fix using uninitialised work
coresight: of_get_coresight_platform_data: Add missing of_node_put

 Documentation/admin-guide/kernel-parameters.txt    |   7 +
 .../bindings/arm/coresight-cpu-debug.txt           |  49 ++
 Documentation/trace/coresight-cpu-debug.txt        | 175 ++++++
 MAINTAINERS                                        |   2 +
 arch/arm64/boot/dts/hisilicon/hi6220.dtsi          |  64 ++
 arch/arm64/boot/dts/qcom/msm8916.dtsi              |  32 +
 drivers/hwtracing/coresight/Kconfig                |  14 +
 drivers/hwtracing/coresight/Makefile               |   1 +
 drivers/hwtracing/coresight/coresight-cpu-debug.c  | 700 +++++++++++++++++++++
 drivers/hwtracing/coresight/coresight-etb10.c      |   7 +-
 drivers/hwtracing/coresight/coresight-etm-perf.c   |   3 +-
 drivers/hwtracing/coresight/coresight-tmc-etf.c    |  25 +-
 drivers/hwtracing/coresight/coresight-tmc.c        |   7 +
 drivers/hwtracing/coresight/coresight.c            |  34 +-
 drivers/hwtracing/coresight/of_coresight.c         |  47 +-
 include/linux/coresight.h                          |  10 +-
 16 files changed, 1136 insertions(+), 41 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/coresight-cpu-debug.txt
 create mode 100644 Documentation/trace/coresight-cpu-debug.txt
 create mode 100644 drivers/hwtracing/coresight/coresight-cpu-debug.c
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/17 coresight: Disable the path only when the source is disabled

From: Suzuki K Poulose <[email protected]>

With a coresight tracing session, the components along the path from the source to sink are disabled after the source is disabled. However, if the source was not actually disabled due to active users, we should not disable the components in the path.

---
 drivers/hwtracing/coresight/coresight.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/hwtracing/coresight/coresight.c +13 -6
index 0c37356e417c..532a2acfa8cc 100644
@@ -253,14 +253,22 @@ static int coresight_enable_source(struct coresight_device *csdev, u32 mode)
 	return 0;
 }
 
-static void coresight_disable_source(struct coresight_device *csdev)
+/**
+ *  coresight_disable_source - Drop the reference count by 1 and disable
+ *  the device if there are no users left.
+ *
+ *  @csdev - The coresight device to disable
+ *
+ *  Returns true if the device has been disabled.
+ */
+static bool coresight_disable_source(struct coresight_device *csdev)
 {
 	if (atomic_dec_return(csdev->refcnt) == 0) {
-		if (source_ops(csdev)->disable) {
+		if (source_ops(csdev)->disable)
 			source_ops(csdev)->disable(csdev, NULL);
-			csdev->enable = false;
-		}
+		csdev->enable = false;
 	}
+	return !csdev->enable;
 }
 
 void coresight_disable_path(struct list_head *path)
@@ -629,7 +637,7 @@ void coresight_disable(struct coresight_device *csdev)
 	if (ret)
 		goto out;
 
-	if (!csdev->enable)
+	if (!csdev->enable || !coresight_disable_source(csdev))
 		goto out;
 
 	switch (csdev->subtype.source_subtype) {
@@ -647,7 +655,6 @@ void coresight_disable(struct coresight_device *csdev)
 		break;
 	}
 
-	coresight_disable_source(csdev);
 	coresight_disable_path(path);
 	coresight_release_path(path);
 
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/17 coresight: Fix reference count for software sources

In reply to Mathieu Poirier

From: Suzuki K Poulose <[email protected]>

For software sources (i.e STM), there could be multiple agents generating the trace data, unlike the ETMs. So we need to properly do the accounting for the active number of users to disable the device when the last user goes away. Right now, the reference counting is broken for sources as we skip the actions when we detect that the source is enabled.

This patch fixes the problem by adding the refcounting for software sources, even when they are enabled.

---
 drivers/hwtracing/coresight/coresight.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/hwtracing/coresight/coresight.c +13 -2
index 532a2acfa8cc..6a0202b7384f 100644
@@ -558,6 +558,9 @@ int coresight_enable(struct coresight_device *csdev)
 	int cpu, ret = 0;
 	struct coresight_device *sink;
 	struct list_head *path;
+	enum coresight_dev_subtype_source subtype;
+
+	subtype = csdev->subtype.source_subtype;
 
 	mutex_lock(&coresight_mutex);
 
@@ -565,8 +568,16 @@ int coresight_enable(struct coresight_device *csdev)
 	if (ret)
 		goto out;
 
-	if (csdev->enable)
+	if (csdev->enable) {
+		/*
+		 * There could be multiple applications driving the software
+		 * source. So keep the refcount for each such user when the
+		 * source is already enabled.
+		 */
+		if (subtype == CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE)
+			atomic_inc(csdev->refcnt);
 		goto out;
+	}
 
 	/*
 	 * Search for a valid sink for this session but don't reset the
@@ -593,7 +604,7 @@ int coresight_enable(struct coresight_device *csdev)
 	if (ret)
 		goto err_source;
 
-	switch (csdev->subtype.source_subtype) {
+	switch (subtype) {
 	case CORESIGHT_DEV_SUBTYPE_SOURCE_PROC:
 		/*
 		 * When working from sysFS it is important to keep track
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/17 coresight: etm_perf: Fix using uninitialised work

In reply to Mathieu Poirier

From: Suzuki K Poulose <[email protected]>

With 4.11-rc4, the following command triggers a WARN_ON, when a sink is not enabled.

perf record -e cs_etm/@20010000.etf/

 [88286.547741] ------------[ cut here ]------------
 [88286.552332] WARNING: CPU: 3 PID: 2156 at kernel/workqueue.c:1442 __queue_work+0x29c/0x3b8
 [88286.560427] Modules linked in:
 [88286.563451]
 [88286.564928] CPU: 3 PID: 2156 Comm: perf_v4.11 Not tainted 4.11.0-rc4 #217
 [88286.573453] Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Aug 15
  2016
 [88286.584128] task: ffff80097597c200 task.stack: ffff8009768b0000
 [88286.589990] PC is at __queue_work+0x29c/0x3b8
 [88286.594303] LR is at __queue_work+0x104/0x3b8
 [88286.598614] pc : [<ffff0000080d8c7c>] lr : [<ffff0000080d8ae4>] pstate: a00001c5
 [88286.605934] sp : ffff8009768b3aa0
 [88286.609212] x29: ffff8009768b3aa0 x28: ffff80097ff3da00
 [88286.614477] x27: ffff80097ff89c00 x26: ffff8009751b0e00
 [88286.619741] x25: ffff000008c9f000 x24: 0000000000000003
 [88286.625004] x23: 0000000000000040 x22: ffff000008d3dab8
 [88286.630268] x21: ffff800977804400 x20: 0000000000000007
 [88286.635532] x19: ffff000008c54000 x18: 0000fffff9185160
 [88286.640795] x17: 0000ffffb33d9a38 x16: ffff000008088270
 [88286.646059] x15: 0000ffffb345b590 x14: 0000000000000000
 [88286.651322] x13: 0000000000000004 x12: 0000000000000040
 [88286.656586] x11: 0000000000000068 x10: 0000000000000000
 [88286.661849] x9 : ffff800977400028 x8 : 0000000000000000
 [88286.667113] x7 : 0000000000000000 x6 : ffff0000080d8ae4
 [88286.672376] x5 : 0000000000000000 x4 : 0000000000000080
 [88286.677639] x3 : 0000000000000000 x2 : 0000000000000000
 [88286.682903] x1 : 0000000000000000 x0 : ffff8009751b0e08
 [88286.688166]
 [88286.689638] ---[ end trace 31633f18fd33d4cb ]---
 [88286.694206] Call trace:
 [88286.696627] Exception stack(0xffff8009768b38d0 to 0xffff8009768b3a00)
 [88286.703004] 38c0:                                   ffff000008c54000 0001000000000000
 [88286.710757] 38e0: ffff8009768b3aa0 ffff0000080d8c7c ffff8009768b3b50 ffff80097ff8a5b0
 [88286.718511] 3900: 0000800977325000 0000000000000000 0000000000000040 ffff80097ffc6180
 [88286.726264] 3920: ffff8009768b3940 ffff0000088a8694 ffff80097ffc5800 0000000000000000
 [88286.734017] 3940: ffff8009768b3960 ffff0000081919c0 ffff80097ffc5280 0000000000000001
 [88286.741771] 3960: ffff8009768b3a50 ffff00000819206c ffff8009751b0e08 0000000000000000
 [88286.749523] 3980: 0000000000000000 0000000000000000 0000000000000080 0000000000000000
 [88286.757277] 39a0: ffff0000080d8ae4 0000000000000000 0000000000000000 ffff800977400028
 [88286.765029] 39c0: 0000000000000000 0000000000000068 0000000000000040 0000000000000004
 [88286.772783] 39e0: 0000000000000000 0000ffffb345b590 ffff000008088270 0000ffffb33d9a38
 [88286.780537] [<ffff0000080d8c7c>] __queue_work+0x29c/0x3b8
 [88286.785883] [<ffff0000080d8df8>] queue_work_on+0x60/0x78
 [88286.791146] [<ffff000008764c68>] etm_setup_aux+0x178/0x238
 [88286.796578] [<ffff000008183600>] rb_alloc_aux+0x228/0x310
 [88286.801925] [<ffff00000817e564>] perf_mmap+0x404/0x5a8
 [88286.807015] [<ffff0000081c60cc>] mmap_region+0x394/0x5c0
 [88286.812276] [<ffff0000081c654c>] do_mmap+0x254/0x388
 [88286.817191] [<ffff0000081a989c>] vm_mmap_pgoff+0xbc/0xe0
 [88286.822452] [<ffff0000081c3ffc>] SyS_mmap_pgoff+0xac/0x228
 [88286.827884] [<ffff000008088288>] sys_mmap+0x18/0x28
 [88286.832714] [<ffff000008082f30>] el0_svc_naked+0x24/0x28

The patch makes sure that the event_data->work is initialised properly before we could possibly use it.

---
 drivers/hwtracing/coresight/coresight-etm-perf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/hwtracing/coresight/coresight-etm-perf.c +1 -2
index 288a423c1b27..8f546f59a3fd 100644
@@ -201,6 +201,7 @@ static void *etm_setup_aux(int event_cpu, void **pages,
 	event_data = alloc_event_data(event_cpu);
 	if (!event_data)
 		return NULL;
+	INIT_WORK(&event_data->work, free_event_data);
 
 	/*
 	 * In theory nothing prevent tracers in a trace session from being
@@ -217,8 +218,6 @@ static void *etm_setup_aux(int event_cpu, void **pages,
 	if (!sink)
 		goto err;
 
-	INIT_WORK(&event_data->work, free_event_data);
-
 	mask = &event_data->mask;
 
 	/* Setup the path for each CPU in a trace session */
Signature · 1 line
2.7.4
#4 lore raw

PATCH 3/17 coresight: etm_perf: Fix using uninitialised work

Quoted 60 lines · On Mon, 5 Jun 2017 14:15:04 -0600 Mathieu Poirier…

From: Suzuki K Poulose <[email protected]>

With 4.11-rc4, the following command triggers a WARN_ON, when a sink is not enabled.

perf record -e cs_etm/@20010000.etf/

 [88286.547741] ------------[ cut here ]------------
 [88286.552332] WARNING: CPU: 3 PID: 2156 at kernel/workqueue.c:1442 __queue_work+0x29c/0x3b8
 [88286.560427] Modules linked in:
 [88286.563451]
 [88286.564928] CPU: 3 PID: 2156 Comm: perf_v4.11 Not tainted 4.11.0-rc4 #217
 [88286.573453] Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Aug 15
  2016
 [88286.584128] task: ffff80097597c200 task.stack: ffff8009768b0000
 [88286.589990] PC is at __queue_work+0x29c/0x3b8
 [88286.594303] LR is at __queue_work+0x104/0x3b8
 [88286.598614] pc : [<ffff0000080d8c7c>] lr : [<ffff0000080d8ae4>] pstate: a00001c5
 [88286.605934] sp : ffff8009768b3aa0
 [88286.609212] x29: ffff8009768b3aa0 x28: ffff80097ff3da00
 [88286.614477] x27: ffff80097ff89c00 x26: ffff8009751b0e00
 [88286.619741] x25: ffff000008c9f000 x24: 0000000000000003
 [88286.625004] x23: 0000000000000040 x22: ffff000008d3dab8
 [88286.630268] x21: ffff800977804400 x20: 0000000000000007
 [88286.635532] x19: ffff000008c54000 x18: 0000fffff9185160
 [88286.640795] x17: 0000ffffb33d9a38 x16: ffff000008088270
 [88286.646059] x15: 0000ffffb345b590 x14: 0000000000000000
 [88286.651322] x13: 0000000000000004 x12: 0000000000000040
 [88286.656586] x11: 0000000000000068 x10: 0000000000000000
 [88286.661849] x9 : ffff800977400028 x8 : 0000000000000000
 [88286.667113] x7 : 0000000000000000 x6 : ffff0000080d8ae4
 [88286.672376] x5 : 0000000000000000 x4 : 0000000000000080
 [88286.677639] x3 : 0000000000000000 x2 : 0000000000000000
 [88286.682903] x1 : 0000000000000000 x0 : ffff8009751b0e08
 [88286.688166]
 [88286.689638] ---[ end trace 31633f18fd33d4cb ]---
 [88286.694206] Call trace:
 [88286.696627] Exception stack(0xffff8009768b38d0 to 0xffff8009768b3a00)
 [88286.703004] 38c0:                                   ffff000008c54000 0001000000000000
 [88286.710757] 38e0: ffff8009768b3aa0 ffff0000080d8c7c ffff8009768b3b50 ffff80097ff8a5b0
 [88286.718511] 3900: 0000800977325000 0000000000000000 0000000000000040 ffff80097ffc6180
 [88286.726264] 3920: ffff8009768b3940 ffff0000088a8694 ffff80097ffc5800 0000000000000000
 [88286.734017] 3940: ffff8009768b3960 ffff0000081919c0 ffff80097ffc5280 0000000000000001
 [88286.741771] 3960: ffff8009768b3a50 ffff00000819206c ffff8009751b0e08 0000000000000000
 [88286.749523] 3980: 0000000000000000 0000000000000000 0000000000000080 0000000000000000
 [88286.757277] 39a0: ffff0000080d8ae4 0000000000000000 0000000000000000 ffff800977400028
 [88286.765029] 39c0: 0000000000000000 0000000000000068 0000000000000040 0000000000000004
 [88286.772783] 39e0: 0000000000000000 0000ffffb345b590 ffff000008088270 0000ffffb33d9a38
 [88286.780537] [<ffff0000080d8c7c>] __queue_work+0x29c/0x3b8
 [88286.785883] [<ffff0000080d8df8>] queue_work_on+0x60/0x78
 [88286.791146] [<ffff000008764c68>] etm_setup_aux+0x178/0x238
 [88286.796578] [<ffff000008183600>] rb_alloc_aux+0x228/0x310
 [88286.801925] [<ffff00000817e564>] perf_mmap+0x404/0x5a8
 [88286.807015] [<ffff0000081c60cc>] mmap_region+0x394/0x5c0
 [88286.812276] [<ffff0000081c654c>] do_mmap+0x254/0x388
 [88286.817191] [<ffff0000081a989c>] vm_mmap_pgoff+0xbc/0xe0
 [88286.822452] [<ffff0000081c3ffc>] SyS_mmap_pgoff+0xac/0x228
 [88286.827884] [<ffff000008088288>] sys_mmap+0x18/0x28
 [88286.832714] [<ffff000008082f30>] el0_svc_naked+0x24/0x28
Quoted 7 lines

The patch makes sure that the event_data->work is initialised properly before we could possibly use it.

[Reported-and-]Tested-by: Kim Phillips <[email protected]>

Kim

#5 lore raw

PATCH 4/17 coresight: tmc: minor fix for output log

In reply to Mathieu Poirier

From: Leo Yan <[email protected]>

In current code the output logs are not well symmetric for sink and link enabling and disabling. This patch is to fix that so can output paired logs.

---
 drivers/hwtracing/coresight/coresight-tmc-etf.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/hwtracing/coresight/coresight-tmc-etf.c +17 -8
index aec61a6d5c63..e3b9fb82eb8d 100644
@@ -166,9 +166,6 @@ static int tmc_enable_etf_sink_sysfs(struct coresight_device *csdev)
 	if (!used)
 		kfree(buf);
 
-	if (!ret)
-		dev_info(drvdata->dev, "TMC-ETB/ETF enabled\n");
-
 	return ret;
 }
 
@@ -204,15 +201,27 @@ static int tmc_enable_etf_sink_perf(struct coresight_device *csdev)
 
 static int tmc_enable_etf_sink(struct coresight_device *csdev, u32 mode)
 {
+	int ret;
+	struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+
 	switch (mode) {
 	case CS_MODE_SYSFS:
-		return tmc_enable_etf_sink_sysfs(csdev);
+		ret = tmc_enable_etf_sink_sysfs(csdev);
+		break;
 	case CS_MODE_PERF:
-		return tmc_enable_etf_sink_perf(csdev);
+		ret = tmc_enable_etf_sink_perf(csdev);
+		break;
+	/* We shouldn't be here */
+	default:
+		ret = -EINVAL;
+		break;
 	}
 
-	/* We shouldn't be here */
-	return -EINVAL;
+	if (ret)
+		return ret;
+
+	dev_info(drvdata->dev, "TMC-ETB/ETF enabled\n");
+	return 0;
 }
 
 static void tmc_disable_etf_sink(struct coresight_device *csdev)
@@ -273,7 +282,7 @@ static void tmc_disable_etf_link(struct coresight_device *csdev,
 	drvdata->mode = CS_MODE_DISABLED;
 	spin_unlock_irqrestore(&drvdata->spinlock, flags);
 
-	dev_info(drvdata->dev, "TMC disabled\n");
+	dev_info(drvdata->dev, "TMC-ETF disabled\n");
 }
 
 static void *tmc_alloc_etf_buffer(struct coresight_device *csdev, int cpu,
Signature · 1 line
2.7.4
#6 lore raw

PATCH 5/17 coresight: use const for device_node structures

In reply to Mathieu Poirier

From: Leo Yan <[email protected]>

Almost low level functions from open firmware have used const to qualify device_node structures, so add const for device_node parameters in of_coresight related functions.

---
 drivers/hwtracing/coresight/of_coresight.c | 7 ++++---
 include/linux/coresight.h                  | 7 ++++---
 2 files changed, 8 insertions(+), 6 deletions(-)
drivers/hwtracing/coresight/of_coresight.c +4 -3
index 09142e99e915..2749853b9010 100644
@@ -52,7 +52,7 @@ of_coresight_get_endpoint_device(struct device_node *endpoint)
 			       endpoint, of_dev_node_match);
 }
 
-static void of_coresight_get_ports(struct device_node *node,
+static void of_coresight_get_ports(const struct device_node *node,
 				   int *nr_inport, int *nr_outport)
 {
 	struct device_node *ep = NULL;
@@ -101,8 +101,9 @@ static int of_coresight_alloc_memory(struct device *dev,
 	return 0;
 }
 
-struct coresight_platform_data *of_get_coresight_platform_data(
-				struct device *dev, struct device_node *node)
+struct coresight_platform_data *
+of_get_coresight_platform_data(struct device *dev,
+			       const struct device_node *node)
 {
 	int i = 0, ret = 0, cpu;
 	struct coresight_platform_data *pdata;
include/linux/coresight.h +4 -3
index 035c16c9a505..bf0aa50880be 100644
@@ -263,11 +263,12 @@ static inline int coresight_timeout(void __iomem *addr, u32 offset,
 #endif
 
 #ifdef CONFIG_OF
-extern struct coresight_platform_data *of_get_coresight_platform_data(
-				struct device *dev, struct device_node *node);
+extern struct coresight_platform_data *
+of_get_coresight_platform_data(struct device *dev,
+			       const struct device_node *node);
 #else
 static inline struct coresight_platform_data *of_get_coresight_platform_data(
-	struct device *dev, struct device_node *node) { return NULL; }
+	struct device *dev, const struct device_node *node) { return NULL; }
 #endif
 
 #ifdef CONFIG_PID_NS
Signature · 1 line
2.7.4
#7 lore raw

PATCH 6/17 coresight: etb10: Delete an error message for a failed memory allocation in etb_probe()

In reply to Mathieu Poirier

From: Markus Elfring <[email protected]>

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/hwtracing/coresight/coresight-etb10.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/hwtracing/coresight/coresight-etb10.c +1 -4
index 979ea6ec7902..837aebf22c45 100644
@@ -675,11 +675,8 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id)
 
 	drvdata->buf = devm_kzalloc(dev,
 				    drvdata->buffer_depth * 4, GFP_KERNEL);
-	if (!drvdata->buf) {
-		dev_err(dev, "Failed to allocate %u bytes for buffer data\n",
-			drvdata->buffer_depth * 4);
+	if (!drvdata->buf)
 		return -ENOMEM;
-	}
 
 	desc.type = CORESIGHT_DEV_TYPE_SINK;
 	desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER;
Signature · 1 line
2.7.4
#8 lore raw

PATCH 7/17 coresight: etb10: Fix a typo in a comment line

In reply to Mathieu Poirier

From: Markus Elfring <[email protected]>

Delete a character in this description for a condition check.

---
 drivers/hwtracing/coresight/coresight-etb10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-etb10.c +1 -1
index 837aebf22c45..d5b96423e1a5 100644
@@ -375,7 +375,7 @@ static void etb_update_buffer(struct coresight_device *csdev,
 
 	/*
 	 * Entries should be aligned to the frame size.  If they are not
-	 * go back to the last alignement point to give decoding tools a
+	 * go back to the last alignment point to give decoding tools a
 	 * chance to fix things.
 	 */
 	if (write_ptr % ETB_FRAME_SIZE_WORDS) {
Signature · 1 line
2.7.4
#9 lore raw

PATCH 8/17 coresight: tmc: Configure DMA mask appropriately

In reply to Mathieu Poirier

From: Robin Murphy <[email protected]>

Before making any DMA API calls, the ETR driver should really be setting its masks to ensure that DMA is possible. Especially since it can address more than the 32-bit default mask set by the AMBA bus code.

---
 drivers/hwtracing/coresight/coresight-tmc.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/hwtracing/coresight/coresight-tmc.c +7 -0
index d8517d2a968c..864488793f09 100644
@@ -362,6 +362,13 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
 		desc.type = CORESIGHT_DEV_TYPE_SINK;
 		desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER;
 		desc.ops = &tmc_etr_cs_ops;
+		/*
+		 * ETR configuration uses a 40-bit AXI master in place of
+		 * the embedded SRAM of ETB/ETF.
+		 */
+		ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40));
+		if (ret)
+			goto out;
 	} else {
 		desc.type = CORESIGHT_DEV_TYPE_LINKSINK;
 		desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_FIFO;
Signature · 1 line
2.7.4
#10 lore raw

PATCH 9/17 coresight: bindings for CPU debug module

In reply to Mathieu Poirier

From: Leo Yan <[email protected]>

According to ARMv8 architecture reference manual (ARM DDI 0487A.k) Chapter 'Part H: External debug', the CPU can integrate debug module and it can support self-hosted debug and external debug. Especially for supporting self-hosted debug, this means the program can access the debug module from mmio region; and usually the mmio region is integrated with coresight.

So add document for binding debug component, includes binding to APB clock; and also need specify the CPU node which the debug module is dedicated to specific CPU.

---
 .../bindings/arm/coresight-cpu-debug.txt           | 49 ++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/coresight-cpu-debug.txt
Documentation/devicetree/bindings/arm/coresight-cpu-debug.txt new file +49 -0
new file mode 100644
index 000000000000..298291211ea4
@@ -0,0 +1,49 @@
+* CoreSight CPU Debug Component:
+
+CoreSight CPU debug component are compliant with the ARMv8 architecture
+reference manual (ARM DDI 0487A.k) Chapter 'Part H: External debug'. The
+external debug module is mainly used for two modes: self-hosted debug and
+external debug, and it can be accessed from mmio region from Coresight
+and eventually the debug module connects with CPU for debugging. And the
+debug module provides sample-based profiling extension, which can be used
+to sample CPU program counter, secure state and exception level, etc;
+usually every CPU has one dedicated debug module to be connected.
+
+Required properties:
+
+- compatible : should be "arm,coresight-cpu-debug"; supplemented with
+               "arm,primecell" since this driver is using the AMBA bus
+	       interface.
+
+- reg : physical base address and length of the register set.
+
+- clocks : the clock associated to this component.
+
+- clock-names : the name of the clock referenced by the code. Since we are
+                using the AMBA framework, the name of the clock providing
+		the interconnect should be "apb_pclk" and the clock is
+		mandatory. The interface between the debug logic and the
+		processor core is clocked by the internal CPU clock, so it
+		is enabled with CPU clock by default.
+
+- cpu : the CPU phandle the debug module is affined to. When omitted
+	the module is considered to belong to CPU0.
+
+Optional properties:
+
+- power-domains: a phandle to the debug power domain. We use "power-domains"
+                 binding to turn on the debug logic if it has own dedicated
+		 power domain and if necessary to use "cpuidle.off=1" or
+		 "nohlt" in the kernel command line or sysfs node to
+		 constrain idle states to ensure registers in the CPU power
+		 domain are accessible.
+
+Example:
+
+	debug at f6590000 {
+		compatible = "arm,coresight-cpu-debug","arm,primecell";
+		reg = <0 0xf6590000 0 0x1000>;
+		clocks = <&sys_ctrl HI6220_DAPB_CLK>;
+		clock-names = "apb_pclk";
+		cpu = <&cpu0>;
+	};
Signature · 1 line
2.7.4
#11 lore raw

PATCH 10/17 doc: Add documentation for Coresight CPU debug

In reply to Mathieu Poirier

From: Leo Yan <[email protected]>

Add detailed documentation for Coresight CPU debug driver, which contains the info for driver implementation, Mike Leach excellent summary for "clock and power domain". At the end some examples on how to enable the debugging functionality are provided.

---
 Documentation/trace/coresight-cpu-debug.txt | 175 ++++++++++++++++++++++++++++
 1 file changed, 175 insertions(+)
 create mode 100644 Documentation/trace/coresight-cpu-debug.txt
Documentation/trace/coresight-cpu-debug.txt new file +175 -0
new file mode 100644
index 000000000000..b3da1f90b861
@@ -0,0 +1,175 @@
+		Coresight CPU Debug Module
+		==========================
+
+   Author:   Leo Yan <[email protected]>
+   Date:     April 5th, 2017
+
+Introduction
+------------
+
+Coresight CPU debug module is defined in ARMv8-a architecture reference manual
+(ARM DDI 0487A.k) Chapter 'Part H: External debug', the CPU can integrate
+debug module and it is mainly used for two modes: self-hosted debug and
+external debug. Usually the external debug mode is well known as the external
+debugger connects with SoC from JTAG port; on the other hand the program can
+explore debugging method which rely on self-hosted debug mode, this document
+is to focus on this part.
+
+The debug module provides sample-based profiling extension, which can be used
+to sample CPU program counter, secure state and exception level, etc; usually
+every CPU has one dedicated debug module to be connected. Based on self-hosted
+debug mechanism, Linux kernel can access these related registers from mmio
+region when the kernel panic happens. The callback notifier for kernel panic
+will dump related registers for every CPU; finally this is good for assistant
+analysis for panic.
+
+
+Implementation
+--------------
+
+- During driver registration, it uses EDDEVID and EDDEVID1 - two device ID
+  registers to decide if sample-based profiling is implemented or not. On some
+  platforms this hardware feature is fully or partially implemented; and if
+  this feature is not supported then registration will fail.
+
+- At the time this documentation was written, the debug driver mainly relies on
+  information gathered by the kernel panic callback notifier from three
+  sampling registers: EDPCSR, EDVIDSR and EDCIDSR: from EDPCSR we can get
+  program counter; EDVIDSR has information for secure state, exception level,
+  bit width, etc; EDCIDSR is context ID value which contains the sampled value
+  of CONTEXTIDR_EL1.
+
+- The driver supports a CPU running in either AArch64 or AArch32 mode. The
+  registers naming convention is a bit different between them, AArch64 uses
+  'ED' for register prefix (ARM DDI 0487A.k, chapter H9.1) and AArch32 uses
+  'DBG' as prefix (ARM DDI 0487A.k, chapter G5.1). The driver is unified to
+  use AArch64 naming convention.
+
+- ARMv8-a (ARM DDI 0487A.k) and ARMv7-a (ARM DDI 0406C.b) have different
+  register bits definition. So the driver consolidates two difference:
+
+  If PCSROffset=0b0000, on ARMv8-a the feature of EDPCSR is not implemented;
+  but ARMv7-a defines "PCSR samples are offset by a value that depends on the
+  instruction set state". For ARMv7-a, the driver checks furthermore if CPU
+  runs with ARM or thumb instruction set and calibrate PCSR value, the
+  detailed description for offset is in ARMv7-a ARM (ARM DDI 0406C.b) chapter
+  C11.11.34 "DBGPCSR, Program Counter Sampling Register".
+
+  If PCSROffset=0b0010, ARMv8-a defines "EDPCSR implemented, and samples have
+  no offset applied and do not sample the instruction set state in AArch32
+  state". So on ARMv8 if EDDEVID1.PCSROffset is 0b0010 and the CPU operates
+  in AArch32 state, EDPCSR is not sampled; when the CPU operates in AArch64
+  state EDPCSR is sampled and no offset are applied.
+
+
+Clock and power domain
+----------------------
+
+Before accessing debug registers, we should ensure the clock and power domain
+have been enabled properly. In ARMv8-a ARM (ARM DDI 0487A.k) chapter 'H9.1
+Debug registers', the debug registers are spread into two domains: the debug
+domain and the CPU domain.
+
+                                +---------------+
+                                |               |
+                                |               |
+                     +----------+--+            |
+        dbg_clock -->|          |**|            |<-- cpu_clock
+                     |    Debug |**|   CPU      |
+ dbg_power_domain -->|          |**|            |<-- cpu_power_domain
+                     +----------+--+            |
+                                |               |
+                                |               |
+                                +---------------+
+
+For debug domain, the user uses DT binding "clocks" and "power-domains" to
+specify the corresponding clock source and power supply for the debug logic.
+The driver calls the pm_runtime_{put|get} operations as needed to handle the
+debug power domain.
+
+For CPU domain, the different SoC designs have different power management
+schemes and finally this heavily impacts external debug module. So we can
+divide into below cases:
+
+- On systems with a sane power controller which can behave correctly with
+  respect to CPU power domain, the CPU power domain can be controlled by
+  register EDPRCR in driver. The driver firstly writes bit EDPRCR.COREPURQ
+  to power up the CPU, and then writes bit EDPRCR.CORENPDRQ for emulation
+  of CPU power down. As result, this can ensure the CPU power domain is
+  powered on properly during the period when access debug related registers;
+
+- Some designs will power down an entire cluster if all CPUs on the cluster
+  are powered down - including the parts of the debug registers that should
+  remain powered in the debug power domain. The bits in EDPRCR are not
+  respected in these cases, so these designs do not support debug over
+  power down in the way that the CoreSight / Debug designers anticipated.
+  This means that even checking EDPRSR has the potential to cause a bus hang
+  if the target register is unpowered.
+
+  In this case, accessing to the debug registers while they are not powered
+  is a recipe for disaster; so we need preventing CPU low power states at boot
+  time or when user enable module at the run time. Please see chapter
+  "How to use the module" for detailed usage info for this.
+
+
+Device Tree Bindings
+--------------------
+
+See Documentation/devicetree/bindings/arm/coresight-cpu-debug.txt for details.
+
+
+How to use the module
+---------------------
+
+If you want to enable debugging functionality@boot time, you can add
+"coresight_cpu_debug.enable=1" to the kernel command line parameter.
+
+The driver also can work as module, so can enable the debugging when insmod
+module:
+# insmod coresight_cpu_debug.ko debug=1
+
+When boot time or insmod module you have not enabled the debugging, the driver
+uses the debugfs file system to provide a knob to dynamically enable or disable
+debugging:
+
+To enable it, write a '1' into /sys/kernel/debug/coresight_cpu_debug/enable:
+# echo 1 > /sys/kernel/debug/coresight_cpu_debug/enable
+
+To disable it, write a '0' into /sys/kernel/debug/coresight_cpu_debug/enable:
+# echo 0 > /sys/kernel/debug/coresight_cpu_debug/enable
+
+As explained in chapter "Clock and power domain", if you are working on one
+platform which has idle states to power off debug logic and the power
+controller cannot work well for the request from EDPRCR, then you should
+firstly constraint CPU idle states before enable CPU debugging feature; so can
+ensure the accessing to debug logic.
+
+If you want to limit idle states at boot time, you can use "nohlt" or
+"cpuidle.off=1" in the kernel command line.
+
+At the runtime you can disable idle states with below methods:
+
+Set latency request to /dev/cpu_dma_latency to disable all CPUs specific idle
+states (if latency = 0uS then disable all idle states):
+# echo "what_ever_latency_you_need_in_uS" > /dev/cpu_dma_latency
+
+Disable specific CPU's specific idle state:
+# echo 1 > /sys/devices/system/cpu/cpu$cpu/cpuidle/state$state/disable
+
+
+Output format
+-------------
+
+Here is an example of the debugging output format:
+
+ARM external debug module:
+coresight-cpu-debug 850000.debug: CPU[0]:
+coresight-cpu-debug 850000.debug:  EDPRSR:  00000001 (Power:On DLK:Unlock)
+coresight-cpu-debug 850000.debug:  EDPCSR:  [<ffff00000808e9bc>] handle_IPI+0x174/0x1d8
+coresight-cpu-debug 850000.debug:  EDCIDSR: 00000000
+coresight-cpu-debug 850000.debug:  EDVIDSR: 90000000 (State:Non-secure Mode:EL1/0 Width:64bits VMID:0)
+coresight-cpu-debug 852000.debug: CPU[1]:
+coresight-cpu-debug 852000.debug:  EDPRSR:  00000001 (Power:On DLK:Unlock)
+coresight-cpu-debug 852000.debug:  EDPCSR:  [<ffff0000087fab34>] debug_notifier_call+0x23c/0x358
+coresight-cpu-debug 852000.debug:  EDCIDSR: 00000000
+coresight-cpu-debug 852000.debug:  EDVIDSR: 90000000 (State:Non-secure Mode:EL1/0 Width:64bits VMID:0)
Signature · 1 line
2.7.4
#12 lore raw

PATCH 11/17 doc: Add coresight_cpu_debug.enable to kernel-parameters.txt

In reply to Mathieu Poirier

From: Leo Yan <[email protected]>

Add coresight_cpu_debug.enable to kernel-parameters.txt, this flag is used to enable/disable the CPU sampling based debugging.

---
 Documentation/admin-guide/kernel-parameters.txt | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +7 -0
index 15f79c27748d..ff67ad7d2c55 100644
@@ -649,6 +649,13 @@
 			/proc/<pid>/coredump_filter.
 			See also Documentation/filesystems/proc.txt.
 
+	coresight_cpu_debug.enable
+			[ARM,ARM64]
+			Format: <bool>
+			Enable/disable the CPU sampling based debugging.
+			0: default value, disable debugging
+			1: enable debugging at boot time
+
 	cpuidle.off=1	[CPU_IDLE]
 			disable the cpuidle sub-system
 
Signature · 1 line
2.7.4
#13 lore raw

PATCH 12/17 MAINTAINERS: update file entries for Coresight subsystem

In reply to Mathieu Poirier

From: Leo Yan <[email protected]>

Update document file entries for Coresight debug module.

---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
index f7d568b8f133..d443258e3283 100644
@@ -1208,7 +1208,9 @@ L:	linux-arm-kernel at lists.infradead.org (moderated for non-subscribers)
 S:	Maintained
 F:	drivers/hwtracing/coresight/*
 F:	Documentation/trace/coresight.txt
+F:	Documentation/trace/coresight-cpu-debug.txt
 F:	Documentation/devicetree/bindings/arm/coresight.txt
+F:	Documentation/devicetree/bindings/arm/coresight-cpu-debug.txt
 F:	Documentation/ABI/testing/sysfs-bus-coresight-devices-*
 F:	tools/perf/arch/arm/util/pmu.c
 F:	tools/perf/arch/arm/util/auxtrace.c
Signature · 1 line
2.7.4
#14 lore raw

PATCH 13/17 coresight: of_get_coresight_platform_data: Add missing of_node_put

In reply to Mathieu Poirier

From: Suzuki K Poulose <[email protected]>

The of_get_coresight_platform_data iterates over the possible CPU nodes to find a given cpu phandle. However it does not drop the reference to the node pointer returned by the of_get_coresight_platform_data.

This patch also introduces another minor fix is to use of_cpu_device_node_get() to replace of_get_cpu_node().

Cc Mathieu Poirier <[email protected]>
[Leo: minor tweaks for of_get_coresight_platform_data]
---
 drivers/hwtracing/coresight/of_coresight.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/hwtracing/coresight/of_coresight.c +10 -7
index 2749853b9010..225b2dd5970c 100644
@@ -109,7 +109,8 @@ of_get_coresight_platform_data(struct device *dev,
 	struct coresight_platform_data *pdata;
 	struct of_endpoint endpoint, rendpoint;
 	struct device *rdev;
-	struct device_node *dn;
+	bool found;
+	struct device_node *dn, *np;
 	struct device_node *ep = NULL;
 	struct device_node *rparent = NULL;
 	struct device_node *rport = NULL;
@@ -176,17 +177,19 @@ of_get_coresight_platform_data(struct device *dev,
 		} while (ep);
 	}
 
-	/* Affinity defaults to CPU0 */
-	pdata->cpu = 0;
 	dn = of_parse_phandle(node, "cpu", 0);
-	for (cpu = 0; dn && cpu < nr_cpu_ids; cpu++) {
-		if (dn == of_get_cpu_node(cpu, NULL)) {
-			pdata->cpu = cpu;
+	for_each_possible_cpu(cpu) {
+		np = of_cpu_device_node_get(cpu);
+		found = (dn == np);
+		of_node_put(np);
+		if (found)
 			break;
-		}
 	}
 	of_node_put(dn);
 
+	/* Affinity to CPU0 if no cpu nodes are found */
+	pdata->cpu = found ? cpu : 0;
+
 	return pdata;
 }
 EXPORT_SYMBOL_GPL(of_get_coresight_platform_data);
Signature · 1 line
2.7.4
#15 lore raw

PATCH 14/17 coresight: refactor with function of_coresight_get_cpu

In reply to Mathieu Poirier

From: Leo Yan <[email protected]>

This is refactor to add function of_coresight_get_cpu(), so it's used to retrieve CPU id for coresight component. Finally can use it as a common function for multiple places.

---
 drivers/hwtracing/coresight/of_coresight.c | 43 +++++++++++++++++++-----------
 include/linux/coresight.h                  |  3 +++
 2 files changed, 31 insertions(+), 15 deletions(-)
drivers/hwtracing/coresight/of_coresight.c +28 -15
index 225b2dd5970c..a18794128bf8 100644
@@ -101,16 +101,40 @@ static int of_coresight_alloc_memory(struct device *dev,
 	return 0;
 }
 
+int of_coresight_get_cpu(const struct device_node *node)
+{
+	int cpu;
+	bool found;
+	struct device_node *dn, *np;
+
+	dn = of_parse_phandle(node, "cpu", 0);
+
+	/* Affinity defaults to CPU0 */
+	if (!dn)
+		return 0;
+
+	for_each_possible_cpu(cpu) {
+		np = of_cpu_device_node_get(cpu);
+		found = (dn == np);
+		of_node_put(np);
+		if (found)
+			break;
+	}
+	of_node_put(dn);
+
+	/* Affinity to CPU0 if no cpu nodes are found */
+	return found ? cpu : 0;
+}
+EXPORT_SYMBOL_GPL(of_coresight_get_cpu);
+
 struct coresight_platform_data *
 of_get_coresight_platform_data(struct device *dev,
 			       const struct device_node *node)
 {
-	int i = 0, ret = 0, cpu;
+	int i = 0, ret = 0;
 	struct coresight_platform_data *pdata;
 	struct of_endpoint endpoint, rendpoint;
 	struct device *rdev;
-	bool found;
-	struct device_node *dn, *np;
 	struct device_node *ep = NULL;
 	struct device_node *rparent = NULL;
 	struct device_node *rport = NULL;
@@ -177,18 +201,7 @@ of_get_coresight_platform_data(struct device *dev,
 		} while (ep);
 	}
 
-	dn = of_parse_phandle(node, "cpu", 0);
-	for_each_possible_cpu(cpu) {
-		np = of_cpu_device_node_get(cpu);
-		found = (dn == np);
-		of_node_put(np);
-		if (found)
-			break;
-	}
-	of_node_put(dn);
-
-	/* Affinity to CPU0 if no cpu nodes are found */
-	pdata->cpu = found ? cpu : 0;
+	pdata->cpu = of_coresight_get_cpu(node);
 
 	return pdata;
 }
include/linux/coresight.h +3 -0
index bf0aa50880be..d950dad5056a 100644
@@ -263,10 +263,13 @@ static inline int coresight_timeout(void __iomem *addr, u32 offset,
 #endif
 
 #ifdef CONFIG_OF
+extern int of_coresight_get_cpu(const struct device_node *node);
 extern struct coresight_platform_data *
 of_get_coresight_platform_data(struct device *dev,
 			       const struct device_node *node);
 #else
+static inline int of_coresight_get_cpu(const struct device_node *node)
+{ return 0; }
 static inline struct coresight_platform_data *of_get_coresight_platform_data(
 	struct device *dev, const struct device_node *node) { return NULL; }
 #endif
Signature · 1 line
2.7.4
#16 lore raw

PATCH 15/17 coresight: add support for CPU debug module

In reply to Mathieu Poirier

From: Leo Yan <[email protected]>

Coresight includes debug module and usually the module connects with CPU debug logic. ARMv8 architecture reference manual (ARM DDI 0487A.k) has description for related info in "Part H: External Debug".

Chapter H7 "The Sample-based Profiling Extension" introduces several sampling registers, e.g. we can check program counter value with combined CPU exception level, secure state, etc. So this is helpful for analysis CPU lockup scenarios, e.g. if one CPU has run into infinite loop with IRQ disabled. In this case the CPU cannot switch context and handle any interrupt (including IPIs), as the result it cannot handle SMP call for stack dump.

This patch is to enable coresight debug module, so firstly this driver is to bind apb clock for debug module and this is to ensure the debug module can be accessed from program or external debugger. And the driver uses sample-based registers for debug purpose, e.g. when system triggers panic, the driver will dump program counter and combined context registers (EDCIDSR, EDVIDSR); by parsing context registers so can quickly get to know CPU secure state, exception level, etc.

Some of the debug module registers are located in CPU power domain, so this requires the CPU power domain stays on when access related debug registers, but the power management for CPU power domain is quite dependent on SoC integration for power management. For the platforms which with sane power controller implementations, this driver follows the method to set EDPRCR to try to pull the CPU out of low power state and then set 'no power down request' bit so the CPU has no chance to lose power.

If the SoC has not followed up this design well for power management controller, the user should use the command line parameter or sysfs to constrain all or partial idle states to ensure the CPU power domain is enabled and access coresight CPU debug component safely.

---
 drivers/hwtracing/coresight/Kconfig               |  14 +
 drivers/hwtracing/coresight/Makefile              |   1 +
 drivers/hwtracing/coresight/coresight-cpu-debug.c | 700 ++++++++++++++++++++++
 3 files changed, 715 insertions(+)
 create mode 100644 drivers/hwtracing/coresight/coresight-cpu-debug.c
drivers/hwtracing/coresight/Kconfig +14 -0
index 130cb2114059..8d55d6d79015 100644
@@ -89,4 +89,18 @@ config CORESIGHT_STM
 	  logging useful software events or data coming from various entities
 	  in the system, possibly running different OSs
 
+config CORESIGHT_CPU_DEBUG
+	tristate "CoreSight CPU Debug driver"
+	depends on ARM || ARM64
+	depends on DEBUG_FS
+	help
+	  This driver provides support for coresight debugging module. This
+	  is primarily used to dump sample-based profiling registers when
+	  system triggers panic, the driver will parse context registers so
+	  can quickly get to know program counter (PC), secure state,
+	  exception level, etc. Before use debugging functionality, platform
+	  needs to ensure the clock domain and power domain are enabled
+	  properly, please refer Documentation/trace/coresight-cpu-debug.txt
+	  for detailed description and the example for usage.
+
 endif
drivers/hwtracing/coresight/Makefile +1 -0
index af480d9c1441..433d59025eb6 100644
@@ -16,3 +16,4 @@ obj-$(CONFIG_CORESIGHT_SOURCE_ETM4X) += coresight-etm4x.o \
 					coresight-etm4x-sysfs.o
 obj-$(CONFIG_CORESIGHT_QCOM_REPLICATOR) += coresight-replicator-qcom.o
 obj-$(CONFIG_CORESIGHT_STM) += coresight-stm.o
+obj-$(CONFIG_CORESIGHT_CPU_DEBUG) += coresight-cpu-debug.o
drivers/hwtracing/coresight/coresight-cpu-debug.c new file +700 -0

700 lines not on this page · raw message

Signature · 1 line
2.7.4
#17 lore raw

PATCH 16/17 arm64: dts: hi6220: register debug module

In reply to Mathieu Poirier

From: Leo Yan <[email protected]>

Bind debug module driver for Hi6220.

---
 arch/arm64/boot/dts/hisilicon/hi6220.dtsi | 64 +++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)
arch/arm64/boot/dts/hisilicon/hi6220.dtsi +64 -0
index 1e5129b19280..21805b9786c7 100644
@@ -916,5 +916,69 @@
 				};
 			};
 		};
+
+		debug at f6590000 {
+			compatible = "arm,coresight-cpu-debug","arm,primecell";
+			reg = <0 0xf6590000 0 0x1000>;
+			clocks = <&sys_ctrl HI6220_DAPB_CLK>;
+			clock-names = "apb_pclk";
+			cpu = <&cpu0>;
+		};
+
+		debug at f6592000 {
+			compatible = "arm,coresight-cpu-debug","arm,primecell";
+			reg = <0 0xf6592000 0 0x1000>;
+			clocks = <&sys_ctrl HI6220_DAPB_CLK>;
+			clock-names = "apb_pclk";
+			cpu = <&cpu1>;
+		};
+
+		debug at f6594000 {
+			compatible = "arm,coresight-cpu-debug","arm,primecell";
+			reg = <0 0xf6594000 0 0x1000>;
+			clocks = <&sys_ctrl HI6220_DAPB_CLK>;
+			clock-names = "apb_pclk";
+			cpu = <&cpu2>;
+		};
+
+		debug at f6596000 {
+			compatible = "arm,coresight-cpu-debug","arm,primecell";
+			reg = <0 0xf6596000 0 0x1000>;
+			clocks = <&sys_ctrl HI6220_DAPB_CLK>;
+			clock-names = "apb_pclk";
+			cpu = <&cpu3>;
+		};
+
+		debug at f65d0000 {
+			compatible = "arm,coresight-cpu-debug","arm,primecell";
+			reg = <0 0xf65d0000 0 0x1000>;
+			clocks = <&sys_ctrl HI6220_DAPB_CLK>;
+			clock-names = "apb_pclk";
+			cpu = <&cpu4>;
+		};
+
+		debug at f65d2000 {
+			compatible = "arm,coresight-cpu-debug","arm,primecell";
+			reg = <0 0xf65d2000 0 0x1000>;
+			clocks = <&sys_ctrl HI6220_DAPB_CLK>;
+			clock-names = "apb_pclk";
+			cpu = <&cpu5>;
+		};
+
+		debug at f65d4000 {
+			compatible = "arm,coresight-cpu-debug","arm,primecell";
+			reg = <0 0xf65d4000 0 0x1000>;
+			clocks = <&sys_ctrl HI6220_DAPB_CLK>;
+			clock-names = "apb_pclk";
+			cpu = <&cpu6>;
+		};
+
+		debug at f65d6000 {
+			compatible = "arm,coresight-cpu-debug","arm,primecell";
+			reg = <0 0xf65d6000 0 0x1000>;
+			clocks = <&sys_ctrl HI6220_DAPB_CLK>;
+			clock-names = "apb_pclk";
+			cpu = <&cpu7>;
+		};
 	};
 };
Signature · 1 line
2.7.4
#18 lore raw

PATCH 17/17 arm64: dts: qcom: msm8916: Add debug unit

In reply to Mathieu Poirier

From: Leo Yan <[email protected]>

Add debug unit on Qualcomm msm8916 based platforms, including the DragonBoard 410c board.

---
 arch/arm64/boot/dts/qcom/msm8916.dtsi | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
arch/arm64/boot/dts/qcom/msm8916.dtsi +32 -0
index ab3093995ded..17691abea608 100644
@@ -1116,6 +1116,38 @@
 			};
 		};
 
+		debug at 850000 {
+			compatible = "arm,coresight-cpu-debug","arm,primecell";
+			reg = <0x850000 0x1000>;
+			clocks = <&rpmcc RPM_QDSS_CLK>;
+			clock-names = "apb_pclk";
+			cpu = <&CPU0>;
+		};
+
+		debug at 852000 {
+			compatible = "arm,coresight-cpu-debug","arm,primecell";
+			reg = <0x852000 0x1000>;
+			clocks = <&rpmcc RPM_QDSS_CLK>;
+			clock-names = "apb_pclk";
+			cpu = <&CPU1>;
+		};
+
+		debug at 854000 {
+			compatible = "arm,coresight-cpu-debug","arm,primecell";
+			reg = <0x854000 0x1000>;
+			clocks = <&rpmcc RPM_QDSS_CLK>;
+			clock-names = "apb_pclk";
+			cpu = <&CPU2>;
+		};
+
+		debug at 856000 {
+			compatible = "arm,coresight-cpu-debug","arm,primecell";
+			reg = <0x856000 0x1000>;
+			clocks = <&rpmcc RPM_QDSS_CLK>;
+			clock-names = "apb_pclk";
+			cpu = <&CPU3>;
+		};
+
 		etm at 85c000 {
 			compatible = "arm,coresight-etm4x", "arm,primecell";
 			reg = <0x85c000 0x1000>;
Signature · 1 line
2.7.4
#19 lore raw

cover coresight: next v4.12-rc4

In reply to Mathieu Poirier

On Mon, 5 Jun 2017 14:15:01 -0600
Mathieu Poirier <[email protected]> wrote:

Hi Mathieu,

Quoted 2 lines

Please consider for inclusion in the 4.13 cycle. Of particular interest is patch 15/17, which adds a new driver under the CoreSight umbrella.

After applying the patchseries, the devices now have self-named subdirectories under them:

$ find /sys/devices/ -name \*sink\*
/sys/devices/platform/20140000.etf/20140000.etf/enable_sink
/sys/devices/platform/20070000.etr/20070000.etr/enable_sink
/sys/devices/platform/20030000.tpiu/20030000.tpiu/enable_sink
/sys/devices/platform/20010000.etf/20010000.etf/enable_sink
$ 

Which doesn't match the coresight.txt usage documentation...

Also, do the current juno platforms not have CPU debug modules? I'd like to test the new driver.

Thanks,

Kim

#20 lore raw

cover coresight: next v4.12-rc4

Hi Kim,

Quoted 11 lines · Kim Phillips

On Mon, 5 Jun 2017 14:15:01 -0600
Mathieu Poirier <[email protected]> wrote:

Hi Mathieu,

Quoted 2 lines

Please consider for inclusion in the 4.13 cycle. Of particular interest is patch 15/17, which adds a new driver under the CoreSight umbrella.

After applying the patchseries, the devices now have self-named subdirectories under them:

Quoted 8 lines
$ find /sys/devices/ -name \*sink\*
/sys/devices/platform/20140000.etf/20140000.etf/enable_sink
/sys/devices/platform/20070000.etr/20070000.etr/enable_sink
/sys/devices/platform/20030000.tpiu/20030000.tpiu/enable_sink
/sys/devices/platform/20010000.etf/20010000.etf/enable_sink
$ 

Which doesn't match the coresight.txt usage documentation...

I am worry if my patches do some bad thing, so I did a quick test with mainline kernel on Hikey, if without this patch series I still can see self-named subdirectories in '/sys/devices/platform/':

root at linaro-developer:~# find /sys/devices/ -name \*sink\* /sys/devices/platform/amba/f6404000.etr/f6404000.etr/enable_sink /sys/devices/platform/amba/f6402000.etf/f6402000.etf/enable_sink

But if search '/sys/bus/coresight/devices/', we can get below info:
root at linaro-developer:~# ls /sys/bus/coresight/devices/*/*sink* -l -rw-r--r-- 1 root root 4096 Nov 18 08:04 /sys/bus/coresight/devices/f6402000.etf/enable_sink -rw-r--r-- 1 root root 4096 Nov 18 08:07 /sys/bus/coresight/devices/f6404000.etr/enable_sink

I checked coresight.txt and it uses folder '/sys/bus/coresight/devices/' as example but not '/sys/devices/'.

Quoted 2 lines

Also, do the current juno platforms not have CPU debug modules? I'd like to test the new driver.

Suzuki's Juno patch has been picked from ARM tree:
http://archive.armlinux.org.uk/lurker/message/20170519.042557.c8b56c20.en.html

Thanks,
Leo Yan

A message that is not in the archive (sent off-list or not yet received): CANLsYky8XLbOwinxVc2xKaNzhkpUOX0NsNxrFF4=MsjzC3iY1g@mail.gmail.com

#22 lore raw

cover coresight: next v4.12-rc4

On Mon, 12 Jun 2017 10:50:43 -0600
Mathieu Poirier <[email protected]> wrote:

Hi Mathieu,

Quoted 22 lines · Kim Phillips
Quoted 13 lines

On Mon, 5 Jun 2017 14:15:01 -0600
Mathieu Poirier <[email protected]> wrote:

Hi Mathieu,

Quoted 1 line

Please consider for inclusion in the 4.13 cycle. Of particular interest

is

Quoted 1 line

patch 15/17, which adds a new driver under the CoreSight umbrella.

After applying the patchseries, the devices now have self-named subdirectories under them:

Quoted 7 lines
$ find /sys/devices/ -name \*sink\*
/sys/devices/platform/20140000.etf/20140000.etf/enable_sink
/sys/devices/platform/20070000.etr/20070000.etr/enable_sink
/sys/devices/platform/20030000.tpiu/20030000.tpiu/enable_sink
/sys/devices/platform/20010000.etf/20010000.etf/enable_sink
$
Quoted 3 lines

This is the expected behaviour. CoreSight devices are found on the AMBA bus and like other AMBA devices they will show up under /sys/devices/platform/.

right, but there are subdevices of themselves, e.g., 20010000.etf/20010000.etf:

kim at juno platform$ find /sys/devices/ -name \*etf\* /sys/devices/platform/20140000.etf
/sys/devices/platform/20140000.etf/20140000.etf <- THIS
/sys/devices/platform/20010000.etf
/sys/devices/platform/20010000.etf/20010000.etf <- and this
/sys/devices/virtual/misc/20140000.etf /sys/devices/virtual/misc/20010000.etf

'tree' output:

??? 20010000.etf
??? ??? 20010000.etf
??? ??? ??? enable_sink
??? ??? ??? mgmt
??? ??? ??? ??? ctl
??? ??? ??? ??? devid
??? ??? ??? ??? ffcr
??? ??? ??? ??? ffsr
??? ??? ??? ??? mode
??? ??? ??? ??? pscr
??? ??? ??? ??? rrp
??? ??? ??? ??? rsz
??? ??? ??? ??? rwp
??? ??? ??? ??? sts
??? ??? ??? ??? trg
??? ??? ??? power
??? ??? ??? ??? autosuspend_delay_ms
??? ??? ??? ??? control
??? ??? ??? ??? runtime_active_time
??? ??? ??? ??? runtime_status
??? ??? ??? ??? runtime_suspended_time
??? ??? ??? subsystem -> ../../../../bus/coresight
??? ??? ??? trigger_cntr
??? ??? ??? uevent
??? ??? driver -> ../../../bus/amba/drivers/coresight-tmc ??? ??? driver_override
??? ??? id
??? ??? of_node -> ../../../firmware/devicetree/base/etf at 20010000 ??? ??? power
??? ??? ??? autosuspend_delay_ms
??? ??? ??? control
??? ??? ??? runtime_active_time
??? ??? ??? runtime_status
??? ??? ??? runtime_suspended_time
??? ??? resource
??? ??? subsystem -> ../../../bus/amba
??? ??? uevent

so things like power/ are duplicated, driver pointers missing from the sub-node, etc. I tried reading the documentation to find the reasoning behind it, and didn't see any, but I may have missed it. Normally each platform device gets its own single node, and doesn't create a node under itself with the same name.

If the subsystem pointer is of use, then I would have thought 'bus/coresight' would have registered itself as a 'bus/amba' node?

Quoted 7 lines
Quoted 1 line

Which doesn't match the coresight.txt usage documentation...

When operating CoreSight from the sysFS interface there is nothing preventing people from using the entries under /sys/devices/platform should they wish to. It is simply easier to use /sys/bus/coresight/devices/, and that is well documented in coresight.txt.

Quoted 5 lines
Quoted 2 lines

Also, do the current juno platforms not have CPU debug modules? I'd like to test the new driver.

By all means - Leo pointed out the patch adding the CPU debug entries in the DT file for Juno.

Thanks, I applied it, was able to
toggle /sys/kernel/debug/coresight_cpu_debug/enable, but wasn't sure how to trigger the cpu debug output...

Thanks,

Kim

#23 lore raw

cover coresight: next v4.12-rc4

Hi Kim,

On Tue, Jun 13, 2017 at 04:17:12PM -0500, Kim Phillips wrote:

[...]

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

Also, do the current juno platforms not have CPU debug modules? I'd like to test the new driver.

By all means - Leo pointed out the patch adding the CPU debug entries in the DT file for Juno.

Thanks, I applied it, was able to
toggle /sys/kernel/debug/coresight_cpu_debug/enable, but wasn't sure how to trigger the cpu debug output...

You could trigger panic flow with command, then can see CPU debug output:
echo c > /proc/sysrq-trigger

Thanks,
Leo Yan

#24 lore raw

cover coresight: next v4.12-rc4

Quoted 12 lines · On Wed, 14 Jun 2017 14:22:29 +0800 Leo Yan <[email protected]> wrote:

Hi Kim,

On Tue, Jun 13, 2017 at 04:17:12PM -0500, Kim Phillips wrote:

[...]

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

Also, do the current juno platforms not have CPU debug modules? I'd like to test the new driver.

By all means - Leo pointed out the patch adding the CPU debug entries in the DT file for Juno.

Quoted 6 lines
Quoted 3 lines

Thanks, I applied it, was able to
toggle /sys/kernel/debug/coresight_cpu_debug/enable, but wasn't sure how to trigger the cpu debug output...

You could trigger panic flow with command, then can see CPU debug output:
echo c > /proc/sysrq-trigger

That worked, thanks.

The coresight CPU debug documentation states:

Quoted 8 lines

At the runtime you can disable idle states with below methods:

Set latency request to /dev/cpu_dma_latency to disable all CPUs specific idle states (if latency = 0uS then disable all idle states):

# echo "what_ever_latency_you_need_in_uS" > /dev/cpu_dma_latency

Disable specific CPU's specific idle state:

# echo 1 > /sys/devices/system/cpu/cpu$cpu/cpuidle/state$state/disable

So I tried two values in /dev/cpu_dma_latency and expected a difference in the per-cpu latency files, but didn't observe it:

root at juno:~# echo 0 > /dev/cpu_dma_latency
root at juno:~# more /sys/devices/system/cpu/cpu2/cpuidle*/state*/*laten* ::::::::::::::
/sys/devices/system/cpu/cpu2/cpuidle/state0/latency ::::::::::::::
1
::::::::::::::
/sys/devices/system/cpu/cpu2/cpuidle/state1/latency ::::::::::::::
1500
::::::::::::::
/sys/devices/system/cpu/cpu2/cpuidle/state2/latency ::::::::::::::
1600
root at juno:~# echo 1500 > /dev/cpu_dma_latency
root at juno:~# more /sys/devices/system/cpu/cpu2/cpuidle*/state*/*laten* ::::::::::::::
/sys/devices/system/cpu/cpu2/cpuidle/state0/latency ::::::::::::::
1
::::::::::::::
/sys/devices/system/cpu/cpu2/cpuidle/state1/latency ::::::::::::::
1500
::::::::::::::
/sys/devices/system/cpu/cpu2/cpuidle/state2/latency ::::::::::::::
1600
root at juno:~# cat /sys/kernel/debug/coresight_cpu_debug/enable 1

How does one tell whether writes to /dev/cpu_dma_latency are effective?

Thanks,

Kim

#25 lore raw

cover coresight: next v4.12-rc4

On 15/06/17 04:34, Kim Phillips wrote:
[...]

Quoted 3 lines

How does one tell whether writes to /dev/cpu_dma_latency are effective?

Watch /sys/devices/system/cpu/cpu*/cpuidle/state*/{usage,time}, they shouldn't tick based on the value set to cpu_dma_latency.

E.g. a value of 0 should stop entering all the idle states.

Signature · 2 lines
Regards,
Sudeep
#26 lore raw

cover coresight: next v4.12-rc4

Quoted 8 lines · On Thu, 15 Jun 2017 09:41:22 +0100 Sudeep Holla <[email protected]> wrote:

On 15/06/17 04:34, Kim Phillips wrote:
[...]

Quoted 2 lines

How does one tell whether writes to /dev/cpu_dma_latency are effective?

Watch /sys/devices/system/cpu/cpu*/cpuidle/state*/{usage,time}, they shouldn't tick based on the value set to cpu_dma_latency.

E.g. a value of 0 should stop entering all the idle states.

I see all states following the same pattern whether 0 or not:

root at juno:~# cat show2.sh
show()

{
	echo $1 > /dev/cpu_dma_latency
	echo === $1:
	cat /sys/devices/system/cpu/cpu2/cpuidle/state*/{usage,time}
	echo ---
	sleep 10
	cat /sys/devices/system/cpu/cpu2/cpuidle/state*/{usage,time}
}

show 0
show 1500
show 0
root at juno:~# taskset -c 2 bash ./show2.sh
=== 0:
1893
894
5417
1398675
65997648
3818880750
---
1895
905
5434
1401721
68076867
3826795502
=== 1500:
1895
905
5434
1401721
68076867
3826795502
---
1895
918
5447
1401721
69403510
3835466081
=== 0:
1895
918
5447
1401721
69403510
3835466081
---
1896
929
5463
1403577
71454839
3843409979

googling suggests the /dev/cpu_dma_latency file should be *kept* open, and written a 32-bit binary number:

https://access.redhat.com/articles/65410

If so (I don't have time to test), this cpu debug documentation is very deceptive.

Kim

#27 lore raw

cover coresight: next v4.12-rc4

Hi Kim,

Quoted 72 lines · Kim Phillips
Quoted 8 lines · On Thu, 15 Jun 2017 09:41:22 +0100 Sudeep Holla <[email protected]> wrote:

On 15/06/17 04:34, Kim Phillips wrote:
[...]

Quoted 2 lines

How does one tell whether writes to /dev/cpu_dma_latency are effective?

Watch /sys/devices/system/cpu/cpu*/cpuidle/state*/{usage,time}, they shouldn't tick based on the value set to cpu_dma_latency.

E.g. a value of 0 should stop entering all the idle states.

I see all states following the same pattern whether 0 or not:

root at juno:~# cat show2.sh
show()

{
	echo $1 > /dev/cpu_dma_latency
	echo === $1:
	cat /sys/devices/system/cpu/cpu2/cpuidle/state*/{usage,time}
	echo ---
	sleep 10
	cat /sys/devices/system/cpu/cpu2/cpuidle/state*/{usage,time}
}

show 0
show 1500
show 0
root at juno:~# taskset -c 2 bash ./show2.sh
=== 0:
1893
894
5417
1398675
65997648
3818880750
---
1895
905
5434
1401721
68076867
3826795502
=== 1500:
1895
905
5434
1401721
68076867
3826795502
---
1895
918
5447
1401721
69403510
3835466081
=== 0:
1895
918
5447
1401721
69403510
3835466081
---
1896
929
5463
1403577
71454839
3843409979

Quoted 7 lines

googling suggests the /dev/cpu_dma_latency file should be *kept* open, and written a 32-bit binary number:

https://access.redhat.com/articles/65410

If so (I don't have time to test), this cpu debug documentation is very deceptive.

Looked into the code, and I must apologize I have not verified the command when wrote the doc. As you pointed out, the closing file operation releases the constraint for PM QoS.

Below command can work (I tested):
exec 3<> /dev/cpu_dma_latency; echo 0 >&3

Will commit one patch for this.

Thanks,
Leo Yan

#28 lore raw

cover coresight: next v4.12-rc4

Quoted 8 lines · On Thu, 15 Jun 2017 23:50:54 +0800 Leo Yan <[email protected]> wrote:

Looked into the code, and I must apologize I have not verified the command when wrote the doc. As you pointed out, the closing file operation releases the constraint for PM QoS.

Below command can work (I tested):
exec 3<> /dev/cpu_dma_latency; echo 0 >&3

Will commit one patch for this.

Did I miss this? Where was it posted?

Thanks,

Kim

#29 lore raw

cover coresight: next v4.12-rc4

Hi Kim,

Quoted 7 lines · Kim Phillips
Quoted 4 lines · On Thu, 15 Jun 2017 23:50:54 +0800 Leo Yan <[email protected]> wrote:

Looked into the code, and I must apologize I have not verified the command when wrote the doc. As you pointed out, the closing file operation releases the constraint for PM QoS.

Quoted 6 lines
Quoted 4 lines

Below command can work (I tested):
exec 3<> /dev/cpu_dma_latency; echo 0 >&3

Will commit one patch for this.

Did I miss this? Where was it posted?

Thanks for reminding, please review the patch:
http://archive.armlinux.org.uk/lurker/message/20170823.072318.6c34761c.en.html

Thanks,
Leo Yan

maintainer
#30 lore raw

cover coresight: next v4.12-rc4

In reply to Leo Yan
Quoted 12 lines · Leo Yan

Hi Kim,

On Tue, Jun 13, 2017 at 04:17:12PM -0500, Kim Phillips wrote:

[...]

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

Also, do the current juno platforms not have CPU debug modules? I'd like to test the new driver.

By all means - Leo pointed out the patch adding the CPU debug entries in the DT file for Juno.

Quoted 6 lines
Quoted 3 lines

Thanks, I applied it, was able to
toggle /sys/kernel/debug/coresight_cpu_debug/enable, but wasn't sure how to trigger the cpu debug output...

You could trigger panic flow with command, then can see CPU debug output:
echo c > /proc/sysrq-trigger

I think, may be we should provide a handle to trigger the CPU debug dump manually, rather than using it only for panic. Something like :

echo 1 > /sys/kernel/debug/coresight_cpu_debug/trigger

Thoughts ?

Suzuki

#31 lore raw

cover coresight: next v4.12-rc4

Quoted 20 lines · On Thu, 15 Jun 2017 14:08:09 +0100 Suzuki K Poulose <[email protected]>…
Quoted 12 lines · Leo Yan

Hi Kim,

On Tue, Jun 13, 2017 at 04:17:12PM -0500, Kim Phillips wrote:

[...]

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

Also, do the current juno platforms not have CPU debug modules? I'd like to test the new driver.

By all means - Leo pointed out the patch adding the CPU debug entries in the DT file for Juno.

Quoted 6 lines
Quoted 3 lines

Thanks, I applied it, was able to
toggle /sys/kernel/debug/coresight_cpu_debug/enable, but wasn't sure how to trigger the cpu debug output...

You could trigger panic flow with command, then can see CPU debug output:
echo c > /proc/sysrq-trigger

Quoted 6 lines

I think, may be we should provide a handle to trigger the CPU debug dump manually, rather than using it only for panic. Something like :

echo 1 > /sys/kernel/debug/coresight_cpu_debug/trigger

Thoughts ?

what's the use-case? I just wanted to do a simple test, and although it halted my machine, the sysrq-trigger switch did the job.

I'm personally not a huge fan of adding more switches, rather for doing the right thing on behalf of the user in the first place. E.g., in the case of cpu debug, if configured =y, I don't think it would necessarily harm the simple user to have it always be enabled, at boot time and beyond, thereby doing away with the .../coresight_cpu_debug/enable switch and kernel command line option. If there are users that want to turn it on and off dynamically, that can be done by loading and unloading the module.

Kim

maintainer
#32 lore raw

cover coresight: next v4.12-rc4

Quoted 26 lines · Kim Phillips
Quoted 23 lines · On Thu, 15 Jun 2017 14:08:09 +0100 Suzuki K Poulose <[email protected]>…
Quoted 12 lines · Leo Yan

Hi Kim,

On Tue, Jun 13, 2017 at 04:17:12PM -0500, Kim Phillips wrote:

[...]

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

Also, do the current juno platforms not have CPU debug modules? I'd like to test the new driver.

By all means - Leo pointed out the patch adding the CPU debug entries in the DT file for Juno.

Quoted 6 lines
Quoted 3 lines

Thanks, I applied it, was able to
toggle /sys/kernel/debug/coresight_cpu_debug/enable, but wasn't sure how to trigger the cpu debug output...

You could trigger panic flow with command, then can see CPU debug output:
echo c > /proc/sysrq-trigger

I think, may be we should provide a handle to trigger the CPU debug dump manually, rather than using it only for panic. Something like :

Quoted 6 lines
Quoted 3 lines

echo 1 > /sys/kernel/debug/coresight_cpu_debug/trigger

Thoughts ?

what's the use-case? I just wanted to do a simple test, and although it halted my machine, the sysrq-trigger switch did the job.

Get the CPU dump without crashing the system, when the CPU is looping indefinitely (with interrupts disabled) ? sysrq-t doesn't tell you where the task/CPU is at if it is in running state. This can augment the details by providing the PC. Sure, you can also do this by crashing the system as above. But it doesn't hurt to provide the same without the crash.

Quoted 6 lines

I'm personally not a huge fan of adding more switches, rather for doing the right thing on behalf of the user in the first place. E.g., in the case of cpu debug, if configured =y, I don't think it would necessarily harm the simple user to have it always be enabled, at boot time and beyond, thereby doing away with the .../coresight_cpu_debug/enable

The reasoning behind this is to avoid keeping the debug power domain on until someone really wants it enabled, so that one can use a single kernel image in production/development and be able to switch things on at runtime.

Quoted 3 lines

switch and kernel command line option. If there are users that want to turn it on and off dynamically, that can be done by loading and unloading the module.

Sure, if someone is building it as a module, they have the luxury. But this may not be always useful, e.g, crashes at early boot.

Suzuki

#33 lore raw

cover coresight: next v4.12-rc4

Quoted 31 lines · On Thu, 15 Jun 2017 15:02:21 +0100 Suzuki K Poulose <[email protected]>…
Quoted 30 lines · Kim Phillips
Quoted 26 lines · On Thu, 15 Jun 2017 14:08:09 +0100 Suzuki K Poulose <[email protected]>…
Quoted 12 lines · Leo Yan

Hi Kim,

On Tue, Jun 13, 2017 at 04:17:12PM -0500, Kim Phillips wrote:

[...]

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

Also, do the current juno platforms not have CPU debug modules? I'd like to test the new driver.

By all means - Leo pointed out the patch adding the CPU debug entries in the DT file for Juno.

Quoted 6 lines
Quoted 3 lines

Thanks, I applied it, was able to
toggle /sys/kernel/debug/coresight_cpu_debug/enable, but wasn't sure how to trigger the cpu debug output...

You could trigger panic flow with command, then can see CPU debug output:
echo c > /proc/sysrq-trigger

I think, may be we should provide a handle to trigger the CPU debug dump manually, rather than using it only for panic. Something like :

echo 1 > /sys/kernel/debug/coresight_cpu_debug/trigger

Thoughts ?

Quoted 8 lines
Quoted 2 lines

what's the use-case? I just wanted to do a simple test, and although it halted my machine, the sysrq-trigger switch did the job.

Get the CPU dump without crashing the system, when the CPU is looping indefinitely (with interrupts disabled) ? sysrq-t doesn't tell you where the task/CPU is at if it is in running state. This can augment the details by providing the PC. Sure, you can also do this by crashing the system as above. But it doesn't hurt to provide the same without the crash.

Can sysrq-t be amended, or another sysrq- dump mechanism - like 'v' which apparently causes an ETM buffer dump [ARM-specific] - be used instead?

Quoted 9 lines
Quoted 5 lines

I'm personally not a huge fan of adding more switches, rather for doing the right thing on behalf of the user in the first place. E.g., in the case of cpu debug, if configured =y, I don't think it would necessarily harm the simple user to have it always be enabled, at boot time and beyond, thereby doing away with the .../coresight_cpu_debug/enable

The reasoning behind this is to avoid keeping the debug power domain on until someone really wants it enabled, so that one can use a single kernel image in production/development and be able to switch things on at runtime.

OK, thanks for explaining the trade-off.

Quoted 6 lines
Quoted 3 lines

switch and kernel command line option. If there are users that want to turn it on and off dynamically, that can be done by loading and unloading the module.

Sure, if someone is building it as a module, they have the luxury. But this may not be always useful, e.g, crashes at early boot.

the thinking was that one could set it to =y at that point, but, yes, point taken.

Kim