I've gotten stuck a few times with unusable Coresight after a warm boot
due to lingering claim tags, especially when testing the Coresight
panic patchsets.
This change does some tidy ups, adds some debug messages and clears the
self hosted claim tag on probe. The last two commits are unrelated
tidyups but they touch some of the same functions so to avoid extra
conflicts I'm including them here.
This gets as far as fixing the claim tag issue, but there is some other
state not being cleared on probe that results in the following error.
This can be fixed up as a later change:
coresight tmc_etf0: timeout while waiting for TMC to be Ready
coresight tmc_etf0: Failed to enable : TMC is not ready
Changes in v2:
* Revert most of the interface changes, just call
coresight_clear_self_claim_tag() directly. This is possible because
we're not doing the read first, so it has fewer knock on effects.
* Split out the change to add struct cs_access to etm3x
* Add another warning for racing with external debugger
--
2.34.1
---
James Clark (8):
coresight: Rename coresight_{set,clear}_claim_tags()
coresight: Convert tag clear function to take a struct cs_access
coresight: Only check bottom two claim bits
coresight: Add claim tag warnings and debug messages
coresight: etm3x: Convert raw base pointer to struct coresight access
coresight: Clear self hosted claim tag on probe
coresight: Remove inlines from static function definitions
coresight: Remove extern from function declarations
drivers/hwtracing/coresight/coresight-catu.c | 12 +--
drivers/hwtracing/coresight/coresight-core.c | 85 ++++++++++++++--------
drivers/hwtracing/coresight/coresight-cti-core.c | 2 +
drivers/hwtracing/coresight/coresight-etb10.c | 4 +-
drivers/hwtracing/coresight/coresight-etm.h | 6 +-
drivers/hwtracing/coresight/coresight-etm3x-core.c | 28 +++----
.../hwtracing/coresight/coresight-etm3x-sysfs.c | 8 +-
drivers/hwtracing/coresight/coresight-etm4x-core.c | 10 ++-
.../hwtracing/coresight/coresight-etm4x-sysfs.c | 4 +-
drivers/hwtracing/coresight/coresight-funnel.c | 1 +
drivers/hwtracing/coresight/coresight-platform.c | 26 +++----
drivers/hwtracing/coresight/coresight-priv.h | 20 ++---
drivers/hwtracing/coresight/coresight-replicator.c | 3 +-
drivers/hwtracing/coresight/coresight-stm.c | 6 +-
.../coresight/coresight-syscfg-configfs.c | 2 +-
drivers/hwtracing/coresight/coresight-tmc-core.c | 9 ++-
drivers/hwtracing/coresight/coresight-tmc-etr.c | 16 ++--
drivers/hwtracing/coresight/coresight-trbe.c | 18 ++---
include/linux/coresight.h | 40 +++++-----
19 files changed, 166 insertions(+), 134 deletions(-)
---
base-commit: 5442d22da7dbff3ba8c6720fc6f23ea4934d402d
change-id: 20250317-james-coresight-claim-tags-ae1461f1f5e0
Best regards,
--
James Clark <james.clark(a)linaro.org>
I've gotten stuck a few times with unusable Coresight after a warm boot
due to lingering claim tags, especially when testing the Coresight
panic patchsets.
This change does some tidy ups, adds some debug messages and clears the
self hosted claim tag on probe. The last two commits are unrelated
tidyups but they touch some of the same functions so to avoid extra
conflicts I'm including them here.
This gets as far as fixing the claim tag issue, but there is some other
state not being cleared on probe that results in the following error.
This can be fixed up as a later change:
coresight tmc_etf0: timeout while waiting for TMC to be Ready
coresight tmc_etf0: Failed to enable : TMC is not ready
James Clark (7):
coresight: Rename coresight_{set,clear}_claim_tags()
coresight: Convert disclaim functions to take a struct cs_access
coresight: Only check bottom two claim bits
coresight: Add claim tag warnings and debug messages
coresight: Clear self hosted claim tag on probe
coresight: Remove inlines from static function definitions
coresight: Remove extern from function declarations
drivers/hwtracing/coresight/coresight-catu.c | 14 +-
drivers/hwtracing/coresight/coresight-core.c | 132 +++++++++++-------
.../hwtracing/coresight/coresight-cti-core.c | 8 +-
drivers/hwtracing/coresight/coresight-etb10.c | 6 +-
drivers/hwtracing/coresight/coresight-etm.h | 6 +-
.../coresight/coresight-etm3x-core.c | 32 ++---
.../coresight/coresight-etm3x-sysfs.c | 8 +-
.../coresight/coresight-etm4x-core.c | 12 +-
.../coresight/coresight-etm4x-sysfs.c | 4 +-
.../hwtracing/coresight/coresight-funnel.c | 4 +-
.../hwtracing/coresight/coresight-platform.c | 26 ++--
drivers/hwtracing/coresight/coresight-priv.h | 20 +--
.../coresight/coresight-replicator.c | 7 +-
drivers/hwtracing/coresight/coresight-stm.c | 6 +-
.../coresight/coresight-syscfg-configfs.c | 2 +-
.../hwtracing/coresight/coresight-tmc-core.c | 9 +-
.../hwtracing/coresight/coresight-tmc-etf.c | 8 +-
.../hwtracing/coresight/coresight-tmc-etr.c | 20 ++-
drivers/hwtracing/coresight/coresight-trbe.c | 18 +--
include/linux/coresight.h | 32 ++---
20 files changed, 209 insertions(+), 165 deletions(-)
--
2.34.1
Hi Greg,
Please find the updates for coresight/hwtracing subsystem targeting v6.15.
Kindly pull,
Suzuki
The following changes since commit 0ad2507d5d93f39619fc42372c347d6006b64319:
Linux 6.14-rc3 (2025-02-16 14:02:44 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/coresight/linux.git tags/coresight-next-v6.15
for you to fetch changes up to 5442d22da7dbff3ba8c6720fc6f23ea4934d402d:
Coresight: Fix a NULL vs IS_ERR() bug in probe (2025-03-14 12:43:53 +0000)
----------------------------------------------------------------
coresight: updates for Linux v6.15
CoreSight self-hosted tracing driver subsystem update for Linux v6.15.
The update includes:
- CoreSight trace capture for Panic/Watchdog timeouts
- Fixes to ETM4x driver to synchronize register reads as required by the TRM
- Support for Qualcomm CoreSight TMC Control Unit driver
- Conversion of device locks to raw_spinlock for components that are used
by the Perf mode.
- Miscellaneous fixes for the subsystem
Signed-off-by: Suzuki K Poulose <suzuki.poulose(a)arm.com>
----------------------------------------------------------------
Christophe JAILLET (1):
coresight: configfs: Constify struct config_item_type
Dan Carpenter (1):
Coresight: Fix a NULL vs IS_ERR() bug in probe
Ilkka Koskinen (1):
coresight: catu: Fix number of pages while using 64k pages
James Clark (2):
Coresight: Use coresight_etm_get_trace_id() in traceid_show()
coresight: docs: Remove target sink from examples
Jie Gan (9):
Coresight: Add support for new APB clock name
Coresight: Add trace_id function to retrieving the trace ID
Coresight: Introduce a new struct coresight_path
Coresight: Allocate trace ID after building the path
Coresight: Change to read the trace ID from coresight_path
Coresight: Change functions to accept the coresight_path
dt-bindings: arm: Add Coresight TMC Control Unit hardware
Coresight: Add Coresight TMC Control Unit driver
coresight: add verification process for coresight_etm_get_trace_id
Krzysztof Kozlowski (5):
coresight: catu: Constify amba_id table
coresight: tpda: Constify amba_id table
coresight: tpdm: Constify amba_id table
dt-bindings: coresight: qcom,coresight-tpda: Fix too many 'reg'
dt-bindings: coresight: qcom,coresight-tpdm: Fix too many 'reg'
Linu Cherian (8):
dt-bindings: arm: coresight-tmc: Add "memory-region" property
coresight: tmc-etr: Add support to use reserved trace memory
coresight: core: Add provision for panic callbacks
coresight: tmc: Enable panic sync handling
coresight: tmc: Add support for reading crash data
coresight: tmc: Stop trace capture on FlIn
coresight: config: Add preloaded configuration
Documentation: coresight: Panic support
Mao Jinlong (1):
coresight-tpdm: Add MCMB dataset support
Tao Zhang (2):
coresight-tpdm: Add support to select lane
coresight-tpdm: Add support to enable the lane for MCMB TPDM
Wolfram Sang (1):
coresight: etm4x: don't include '<linux/pm_wakeup.h>' directly
Yeoreum Yun (9):
coresight: change coresight_device lock type to raw_spinlock_t
coresight-etm4x: change etmv4_drvdata spinlock type to raw_spinlock_t
coresight: change coresight_trace_id_map's lock type to raw_spinlock_t
coresight-cti: change cti_drvdata spinlock's type to raw_spinlock_t
coresight-etb10: change etb_drvdata spinlock's type to raw_spinlock_t
coresight-funnel: change funnel_drvdata spinlock's type to raw_spinlock_t
coresight-replicator: change replicator_drvdata spinlock's type to raw_spinlock_t
coresight-tmc: change tmc_drvdata spinlock's type to raw_spinlock_t
coresight/ultrasoc: change smb_drv_data spinlock's type to raw_spinlock_t
Yuanfang Zhang (1):
coresight-etm4x: add isb() before reading the TRCSTATR
.../ABI/testing/sysfs-bus-coresight-devices-tpdm | 15 +
.../devicetree/bindings/arm/arm,coresight-tmc.yaml | 26 ++
.../bindings/arm/qcom,coresight-ctcu.yaml | 84 +++++
.../bindings/arm/qcom,coresight-tpda.yaml | 3 +-
.../bindings/arm/qcom,coresight-tpdm.yaml | 3 +-
Documentation/trace/coresight/coresight.rst | 41 +--
Documentation/trace/coresight/panic.rst | 362 +++++++++++++++++++++
Documentation/userspace-api/perf_ring_buffer.rst | 4 +-
drivers/hwtracing/coresight/Kconfig | 12 +
drivers/hwtracing/coresight/Makefile | 4 +-
drivers/hwtracing/coresight/coresight-catu.c | 4 +-
.../hwtracing/coresight/coresight-cfg-preload.c | 2 +
.../hwtracing/coresight/coresight-cfg-preload.h | 2 +
drivers/hwtracing/coresight/coresight-cfg-pstop.c | 83 +++++
drivers/hwtracing/coresight/coresight-config.c | 8 +-
drivers/hwtracing/coresight/coresight-config.h | 2 +-
drivers/hwtracing/coresight/coresight-core.c | 192 +++++++++--
drivers/hwtracing/coresight/coresight-ctcu-core.c | 326 +++++++++++++++++++
drivers/hwtracing/coresight/coresight-ctcu.h | 39 +++
drivers/hwtracing/coresight/coresight-cti-core.c | 44 +--
drivers/hwtracing/coresight/coresight-cti-sysfs.c | 76 ++---
drivers/hwtracing/coresight/coresight-cti.h | 2 +-
drivers/hwtracing/coresight/coresight-dummy.c | 15 +-
drivers/hwtracing/coresight/coresight-etb10.c | 26 +-
drivers/hwtracing/coresight/coresight-etm-perf.c | 27 +-
drivers/hwtracing/coresight/coresight-etm-perf.h | 2 +-
drivers/hwtracing/coresight/coresight-etm.h | 1 -
drivers/hwtracing/coresight/coresight-etm3x-core.c | 55 +---
.../hwtracing/coresight/coresight-etm3x-sysfs.c | 3 +-
drivers/hwtracing/coresight/coresight-etm4x-core.c | 122 +++----
.../hwtracing/coresight/coresight-etm4x-sysfs.c | 254 +++++++--------
drivers/hwtracing/coresight/coresight-etm4x.h | 3 +-
drivers/hwtracing/coresight/coresight-funnel.c | 12 +-
drivers/hwtracing/coresight/coresight-priv.h | 14 +-
drivers/hwtracing/coresight/coresight-replicator.c | 12 +-
drivers/hwtracing/coresight/coresight-stm.c | 13 +-
.../coresight/coresight-syscfg-configfs.c | 12 +-
drivers/hwtracing/coresight/coresight-syscfg.c | 26 +-
drivers/hwtracing/coresight/coresight-sysfs.c | 17 +-
drivers/hwtracing/coresight/coresight-tmc-core.c | 327 ++++++++++++++++++-
drivers/hwtracing/coresight/coresight-tmc-etf.c | 140 ++++++--
drivers/hwtracing/coresight/coresight-tmc-etr.c | 224 +++++++++++--
drivers/hwtracing/coresight/coresight-tmc.h | 106 +++++-
drivers/hwtracing/coresight/coresight-tpda.c | 20 +-
drivers/hwtracing/coresight/coresight-tpdm.c | 124 ++++++-
drivers/hwtracing/coresight/coresight-tpdm.h | 33 +-
drivers/hwtracing/coresight/coresight-trace-id.c | 22 +-
drivers/hwtracing/coresight/ultrasoc-smb.c | 12 +-
drivers/hwtracing/coresight/ultrasoc-smb.h | 2 +-
include/linux/coresight.h | 47 ++-
50 files changed, 2452 insertions(+), 553 deletions(-)
create mode 100644 Documentation/devicetree/bindings/arm/qcom,coresight-ctcu.yaml
create mode 100644 Documentation/trace/coresight/panic.rst
create mode 100644 drivers/hwtracing/coresight/coresight-cfg-pstop.c
create mode 100644 drivers/hwtracing/coresight/coresight-ctcu-core.c
create mode 100644 drivers/hwtracing/coresight/coresight-ctcu.h
Add a test to confirm that default sink selection skips over an ETF
and returns an ETR even if it's further away.
This also makes it easier to add new unit tests in the future.
Reviewed-by: Leo Yan <leo.yan(a)arm.com>
Signed-off-by: James Clark <james.clark(a)linaro.org>
---
Changes in v4:
- Rename etm to src now that it's not CORESIGHT_DEV_SUBTYPE_SOURCE_PROC
- Remove the now empty src_ops too
- Fix a rebase mistake in the Makefile that removed CTCU
- Link to v3: https://lore.kernel.org/r/20250312-james-cs-kunit-test-v3-1-dcfb69730161@li…
Changes in v3:
- Use CORESIGHT_DEV_SUBTYPE_SOURCE_BUS type instead of the default
(CORESIGHT_DEV_SUBTYPE_SOURCE_PROC) so that the test still works even
when TRBE sinks are registered. This also removes the need for the
fake CPU ID callback.
- Link to v2: https://lore.kernel.org/r/20250305-james-cs-kunit-test-v2-1-83ba682b976c@li…
Changes in v2:
- Let devm free everything rather than doing individual kfrees:
"Like with managed drivers, KUnit-managed fake devices are
automatically cleaned up when the test finishes, but can be manually
cleaned up early with kunit_device_unregister()."
- Link to v1: https://lore.kernel.org/r/20250225164639.522741-1-james.clark@linaro.org
---
drivers/hwtracing/coresight/Kconfig | 9 +++
drivers/hwtracing/coresight/Makefile | 1 +
drivers/hwtracing/coresight/coresight-core.c | 1 +
.../hwtracing/coresight/coresight-kunit-tests.c | 74 ++++++++++++++++++++++
4 files changed, 85 insertions(+)
diff --git a/drivers/hwtracing/coresight/Kconfig b/drivers/hwtracing/coresight/Kconfig
index ecd7086a5b83..f064e3d172b3 100644
--- a/drivers/hwtracing/coresight/Kconfig
+++ b/drivers/hwtracing/coresight/Kconfig
@@ -259,4 +259,13 @@ config CORESIGHT_DUMMY
To compile this driver as a module, choose M here: the module will be
called coresight-dummy.
+
+config CORESIGHT_KUNIT_TESTS
+ tristate "Enable Coresight unit tests"
+ depends on KUNIT
+ default KUNIT_ALL_TESTS
+ help
+ Enable Coresight unit tests. Only useful for development and not
+ intended for production.
+
endif
diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/hwtracing/coresight/Makefile
index 8e62c3150aeb..4e6ea5b05b01 100644
--- a/drivers/hwtracing/coresight/Makefile
+++ b/drivers/hwtracing/coresight/Makefile
@@ -53,3 +53,4 @@ obj-$(CONFIG_ULTRASOC_SMB) += ultrasoc-smb.o
obj-$(CONFIG_CORESIGHT_DUMMY) += coresight-dummy.o
obj-$(CONFIG_CORESIGHT_CTCU) += coresight-ctcu.o
coresight-ctcu-y := coresight-ctcu-core.o
+obj-$(CONFIG_CORESIGHT_KUNIT_TESTS) += coresight-kunit-tests.o
diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
index fb43ef6a3b1f..47af75ba7a00 100644
--- a/drivers/hwtracing/coresight/coresight-core.c
+++ b/drivers/hwtracing/coresight/coresight-core.c
@@ -959,6 +959,7 @@ coresight_find_default_sink(struct coresight_device *csdev)
}
return csdev->def_sink;
}
+EXPORT_SYMBOL_GPL(coresight_find_default_sink);
static int coresight_remove_sink_ref(struct device *dev, void *data)
{
diff --git a/drivers/hwtracing/coresight/coresight-kunit-tests.c b/drivers/hwtracing/coresight/coresight-kunit-tests.c
new file mode 100644
index 000000000000..c8f361767c45
--- /dev/null
+++ b/drivers/hwtracing/coresight/coresight-kunit-tests.c
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <kunit/test.h>
+#include <kunit/device.h>
+#include <linux/coresight.h>
+
+#include "coresight-priv.h"
+
+static struct coresight_device *coresight_test_device(struct device *dev)
+{
+ struct coresight_device *csdev = devm_kcalloc(dev, 1,
+ sizeof(struct coresight_device),
+ GFP_KERNEL);
+ csdev->pdata = devm_kcalloc(dev, 1,
+ sizeof(struct coresight_platform_data),
+ GFP_KERNEL);
+ return csdev;
+}
+
+static void test_default_sink(struct kunit *test)
+{
+ /*
+ * Source -> ETF -> ETR -> CATU
+ * ^
+ * | default
+ */
+ struct device *dev = kunit_device_register(test, "coresight_kunit");
+ struct coresight_device *src = coresight_test_device(dev),
+ *etf = coresight_test_device(dev),
+ *etr = coresight_test_device(dev),
+ *catu = coresight_test_device(dev);
+ struct coresight_connection conn = {};
+
+ src->type = CORESIGHT_DEV_TYPE_SOURCE;
+ /*
+ * Don't use CORESIGHT_DEV_SUBTYPE_SOURCE_PROC, that would always return
+ * a TRBE sink if one is registered.
+ */
+ src->subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_BUS;
+ etf->type = CORESIGHT_DEV_TYPE_LINKSINK;
+ etf->subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER;
+ etr->type = CORESIGHT_DEV_TYPE_SINK;
+ etr->subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_SYSMEM;
+ catu->type = CORESIGHT_DEV_TYPE_HELPER;
+
+ conn.src_dev = src;
+ conn.dest_dev = etf;
+ coresight_add_out_conn(dev, src->pdata, &conn);
+
+ conn.src_dev = etf;
+ conn.dest_dev = etr;
+ coresight_add_out_conn(dev, etf->pdata, &conn);
+
+ conn.src_dev = etr;
+ conn.dest_dev = catu;
+ coresight_add_out_conn(dev, etr->pdata, &conn);
+
+ KUNIT_ASSERT_PTR_EQ(test, coresight_find_default_sink(src), etr);
+}
+
+static struct kunit_case coresight_testcases[] = {
+ KUNIT_CASE(test_default_sink),
+ {}
+};
+
+static struct kunit_suite coresight_test_suite = {
+ .name = "coresight_test_suite",
+ .test_cases = coresight_testcases,
+};
+
+kunit_test_suites(&coresight_test_suite);
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("James Clark <james.clark(a)linaro.org>");
+MODULE_DESCRIPTION("Arm CoreSight KUnit tests");
---
base-commit: 3eadce8308bc8d808fd9e3a9d211c84215087451
change-id: 20250305-james-cs-kunit-test-3af1df2401e6
Best regards,
--
James Clark <james.clark(a)linaro.org>
On Fri, 14 Mar 2025 13:55:10 +0300, Dan Carpenter wrote:
> The devm_platform_get_and_ioremap_resource() function doesn't
> return NULL, it returns error pointers. Update the checking to
> match.
>
>
Applied, thanks!
[1/1] Coresight: Fix a NULL vs IS_ERR() bug in probe
(no commit info)
Best regards,
--
Suzuki K Poulose <suzuki.poulose(a)arm.com>