The following changes since commit 6eaae198076080886b9e7d57f4ae06fa782f90ef:
Linux 6.5-rc3 (2023-07-23 15:24:10 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/coresight/linux.git tags/coresight-next-v6.6
for you to fetch changes up to c0a232f1e19e378c5c4e5973a996392942c80090:
coresight: trbe: Fix TRBE potential sleep in atomic context (2023-08-18 16:42:26 +0100)
----------------------------------------------------------------
coresigh: Updates for v6.6
Coresight and hwtracing subsystem updates for Linux v6.6 includes:
- ACPI support for CoreSight ETMv4x via system instructions and Arm ETE (v9.x).
- Fix potential sleeping in atomic context for TRBE driver
- Fix memory leak in ACPI platform parsing code
- Fix all warnings with W=1
- Fix warning with double free attempt for TRBE platform data
- Miscellaneous cleanups and fixes
Signed-off-by: Suzuki K Poulose <suzuki.poulose(a)arm.com>
----------------------------------------------------------------
Anshuman Khandual (6):
coresight: etm4x: Allocate and device assign 'struct etmv4_drvdata' earlier
coresight: etm4x: Drop iomem 'base' argument from etm4_probe()
coresight: etm4x: Drop pid argument from etm4_probe()
coresight: etm4x: Change etm4_platform_driver driver for MMIO devices
coresight: trbe: Directly use ID_AA64DFR0_EL1_TraceBuffer_IMP
coresight: etm4x: Ensure valid drvdata and clock before clk_put()
James Clark (1):
coresight: Fix all W=1 build warnings
Junhao He (2):
coresight: Fix memory leak in acpi_buffer->pointer
coresight: trbe: Fix TRBE potential sleep in atomic context
Rob Herring (1):
hwtracing: coresight: Explicitly include correct DT includes
Ruidong Tian (1):
coresight: tmc: Explicit type conversions to prevent integer overflow
Suzuki K Poulose (3):
coresight: platform: acpi: Ignore the absence of graph
coresight: etm4x: Add ACPI support in platform driver
coresight: trbe: Allocate platform data per device
Xiongfeng Wang (1):
hwtracing: hisi_ptt: Use pci_dev_id() to simplify the code
Yang Yingliang (1):
coresight: dummy: simplify the code with module_platform_driver
drivers/acpi/acpi_amba.c | 1 -
drivers/hwtracing/coresight/coresight-core.c | 2 +-
drivers/hwtracing/coresight/coresight-cti-core.c | 2 +-
drivers/hwtracing/coresight/coresight-dummy.c | 12 +--
drivers/hwtracing/coresight/coresight-etm4x-cfg.c | 4 +-
drivers/hwtracing/coresight/coresight-etm4x-core.c | 118 +++++++++++++++++----
drivers/hwtracing/coresight/coresight-etm4x.h | 4 +
drivers/hwtracing/coresight/coresight-platform.c | 46 +++++---
drivers/hwtracing/coresight/coresight-tmc-etf.c | 2 +-
drivers/hwtracing/coresight/coresight-tmc-etr.c | 5 +-
drivers/hwtracing/coresight/coresight-tmc.h | 2 +-
drivers/hwtracing/coresight/coresight-trbe.c | 43 ++++----
drivers/hwtracing/coresight/coresight-trbe.h | 2 +-
drivers/hwtracing/ptt/hisi_ptt.c | 8 +-
include/linux/coresight.h | 59 +++++++++++
15 files changed, 225 insertions(+), 85 deletions(-)
This series makes ETM TRCCCCTRL based 'cc_threshold' user configurable via
the perf event attribute. But first, this implements an errata work around
affecting ETM TRCIDR3.CCITMIN value on certain cpus, overriding the field.
This series applies on v6.5-rc5.
Cc: Catalin Marinas <catalin.marinas(a)arm.com>
Cc: Will Deacon <will(a)kernel.org>
Cc: Suzuki K Poulose <suzuki.poulose(a)arm.com>
Cc: Mike Leach <mike.leach(a)linaro.org>
Cc: James Clark <james.clark(a)arm.com>
Cc: Leo Yan <leo.yan(a)linaro.org>
Cc: Jonathan Corbet <corbet(a)lwn.net>
Cc: linux-doc(a)vger.kernel.org
Cc: coresight(a)lists.linaro.org
Cc: linux-arm-kernel(a)lists.infradead.org
Cc: linux-kernel(a)vger.kernel.org
Changes in V3:
- Added errata work around affecting TRCIDR3.CCITMIN
- Split the document update into a separate patch
Changes in V2:
https://lore.kernel.org/all/20230808074533.380537-1-anshuman.khandual@arm.c…
- s/treshhold/threshold
Changes in V1:
https://lore.kernel.org/all/20230804044720.1478900-1-anshuman.khandual@arm.…
Anshuman Khandual (3):
coresight: etm: Override TRCIDR3.CCITMIN on errata affected cpus
coresight: etm: Make cycle count threshold user configurable
Documentation: coresight: Add cc_threshold tunable
Documentation/arch/arm64/silicon-errata.rst | 10 ++++
Documentation/trace/coresight/coresight.rst | 4 ++
.../hwtracing/coresight/coresight-etm-perf.c | 2 +
.../coresight/coresight-etm4x-core.c | 49 ++++++++++++++++++-
4 files changed, 63 insertions(+), 2 deletions(-)
--
2.25.1
Hi Yabin
On 17/08/2023 22:06, Yabin Cui wrote:
> Hi coresight driver maintainers,
>
> I am from the Android toolchain team. I am trying to use ETE (Embedded
> Trace Extension). But on my device, the system crashes when the ETM
> driver is trying to read TRCDEVARCH via sysreg interface.
When you say crashes, what exactly is reported ? Does the kernel
get an exception ? Or system hangs completely ?
I suspect :
1) You are running some hyp at EL2, which doesn't allow
accessing the TRC* registers and injects a Illegal instruction ?
2) If not the above, the ETE is not powered (very unlikely)
Suzuki
> In
> https://github.com/torvalds/linux/blob/master/drivers/hwtracing/coresight/c… <https://github.com/torvalds/linux/blob/master/drivers/hwtracing/coresight/c…> :
>
> static bool etm4_init_sysreg_access(struct etmv4_drvdata *drvdata,
> struct csdev_access *csa)
> {
> u32 devarch;
>
> if (!cpu_supports_sysreg_trace()) <- this returns true
> return false;
>
> /*
> * ETMs implementing sysreg access must implement TRCDEVARCH.
> */
> devarch = read_etm4x_sysreg_const_offset(TRCDEVARCH); <- never see the
> message logged immediately after this line, so should abort here.
> ...
> }
>
> Do you have any suggestions on how I can debug the problem? Is there any
> other place making sysreg interface to ETE not accessible? Or can the
> ETE sysreg interface not be implemented?
> I tried the memory mapped register interface of ETE, it works fine. The
> only change I need is to bypass the devarch version check
> in etm4_init_iomem_access, in in
> https://github.com/torvalds/linux/blob/master/drivers/hwtracing/coresight/c… <https://github.com/torvalds/linux/blob/master/drivers/hwtracing/coresight/c…>
> I wonder if we can allow iomem access for ETE if the sysreg access
> doesn't work on some devices.
>
> Thanks,
> Yabin
This validates 'drvdata' and 'drvdata->pclk' clock before calling clk_put()
in etm4_remove_platform_dev(). The problem was detected using Smatch static
checker as reported.
Cc: Suzuki K Poulose <suzuki.poulose(a)arm.com>
Cc: Mike Leach <mike.leach(a)linaro.org>
Cc: James Clark <james.clark(a)arm.com>
Cc: coresight(a)lists.linaro.org
Cc: linux-arm-kernel(a)lists.infradead.org
Cc: linux-kernel(a)vger.kernel.org
Reported-by: Dan Carpenter <dan.carpenter(a)linaro.org>
Closes: https://lists.linaro.org/archives/list/coresight@lists.linaro.org/thread/G4…
Reviewed-by: James Clark <james.clark(a)arm.com>
Reviewed-by: Mike Leach <mike.leach(a)lnaro.org>
Signed-off-by: Anshuman Khandual <anshuman.khandual(a)arm.com>
---
This applies on coresight-next
Changes in V2:
- Dropped drvdata->pclk check for non-NULL
- Replaced IS_ERR() with IS_ERR_OR_NULL() for drvdata->pclk
Changes in V1:
https://lore.kernel.org/all/20230811062738.1066787-1-anshuman.khandual@arm.…
drivers/hwtracing/coresight/coresight-etm4x-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
index 703b6fcbb6a5..77b0271ce6eb 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
@@ -2269,7 +2269,7 @@ static int __exit etm4_remove_platform_dev(struct platform_device *pdev)
etm4_remove_dev(drvdata);
pm_runtime_disable(&pdev->dev);
- if (drvdata->pclk)
+ if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
clk_put(drvdata->pclk);
return 0;
--
2.25.1
The TRBE driver support is build as a module, we found some driver issues
based on the patchset [1] and set CONFIG_CORESIGHT_TRBE=m.
1. TRBE driver potential sleep in atomic context when unregister device
2. Multiple free the platform data resource when rmmod coresight TRBE
driver
[1] "coresight: trbe: Enable ACPI based devices"
https://lore.kernel.org/all/20230808082247.383405-1-anshuman.khandual@arm.c…
Junhao He (2):
coresight: trbe: Fix TRBE potential sleep in atomic context
coresight: core: Fix multiple free TRBE platform data resource
drivers/hwtracing/coresight/coresight-core.c | 7 ++--
drivers/hwtracing/coresight/coresight-trbe.c | 35 +++++++++++---------
2 files changed, 24 insertions(+), 18 deletions(-)
--
2.33.0
This series enables detection of ACPI based TRBE devices via a stand alone
purpose built representative platform device. But as a pre-requisite this
changes coresight_platform_data structure assignment for the TRBE device.
This series is based on v6.5-rc5 kernel, is also dependent on the following
EDK2 changes posted earlier by Sami.
https://edk2.groups.io/g/devel/message/107239https://edk2.groups.io/g/devel/message/107241
Changes in V5:
- Detected zeroed parsed GSI as a mismatch but handled all zero scenario
- Changed condition check from 'if (ret < 0)' into a 'if (ret)'
- Dropped pr_warn() message after platform_device_register()
Changes in V4:
https://lore.kernel.org/all/20230808082247.383405-1-anshuman.khandual@arm.c…
- Added in-code comment for arm_trbe_device_probe()
- Reverted back using IS_ENABLED() for SPE PMU platform device
- Replaced #ifdef with IS_ENABLED() for TRBE platform device
- Protected arm_trbe_acpi_match with ACPI_PTR() - preventing a build failure
when CONFIG_ACPI is not enabled
- Added __maybe_unused for arm_acpi_register_pmu_device() and dropped config
checks with IS_ENABLED()
Changes in V3:
https://lore.kernel.org/all/20230803055652.1322801-1-anshuman.khandual@arm.…
- Changed ARMV8_TRBE_PDEV_NAME from "arm-trbe-acpi" into "arm,trbe"
- Dropped local variable 'matched'
- Replaced 'matched' with 'valid gsi' as being already matched once
- Moved find_acpi_cpu_topology_hetero_id() outside conditional check
Changes in V2:
https://lore.kernel.org/all/20230801094052.750416-1-anshuman.khandual@arm.c…
- Refactored arm_spe_acpi_register_device() in a separate patch
- Renamed trbe_acpi_resources as trbe_resources
- Renamed trbe_acpi_dev as trbe_dev
Changes in V1:
https://lore.kernel.org/all/20230728112733.359620-1-anshuman.khandual@arm.c…
Cc: Sami Mujawar <sami.mujawar(a)arm.com>
Cc: Catalin Marinas <catalin.marinas(a)arm.com>
Cc: Will Deacon <will(a)kernel.org>
Cc: Mark Rutland <mark.rutland(a)arm.com>
Cc: Suzuki K Poulose <suzuki.poulose(a)arm.com>
Cc: Mike Leach <mike.leach(a)linaro.org>
Cc: Leo Yan <leo.yan(a)linaro.org>
Cc: Alexander Shishkin <alexander.shishkin(a)linux.intel.com>
Cc: James Clark <james.clark(a)arm.com>
Cc: coresight(a)lists.linaro.org
Cc: linux-arm-kernel(a)lists.infradead.org
Cc: linux-kernel(a)vger.kernel.org
Anshuman Khandual (4):
arm_pmu: acpi: Refactor arm_spe_acpi_register_device()
arm_pmu: acpi: Add a representative platform device for TRBE
coresight: trbe: Add a representative coresight_platform_data for TRBE
coresight: trbe: Enable ACPI based TRBE devices
arch/arm64/include/asm/acpi.h | 3 +
drivers/hwtracing/coresight/coresight-trbe.c | 26 +++-
drivers/hwtracing/coresight/coresight-trbe.h | 2 +
drivers/perf/arm_pmu_acpi.c | 142 ++++++++++++++-----
include/linux/perf/arm_pmu.h | 1 +
5 files changed, 132 insertions(+), 42 deletions(-)
--
2.25.1
On 15/08/2023 10:40, John Garry wrote:
> On 11/08/2023 15:39, James Clark wrote:
>> N2 r0p3 doesn't require the workaround [1], so gating on (#slots - 5) no
>> longer works because all N2s have 5 slots. Add a new expression builtin
>> that allows calling strcmp_cpuid_str() and comparing CPUIDs in metric
>> formulas.
>>
>> In this case, the commented formula looks like this:
>>
>> strcmp_cpuid_str(0x410fd493) # greater than or equal to N2 r0p3
>> | strcmp_cpuid_str(0x410fd490) ^ 1 # OR NOT any version of N2
>>
>> [1]:https://urldefense.com/v3/__https://gitlab.arm.com/telemetry-solution/te… Signed-off-by: James Clark<james.clark(a)arm.com>
>> ---
>> tools/perf/arch/arm64/util/pmu.c | 18 +-----------------
>> .../arch/arm64/arm/neoverse-n2-v2/metrics.json | 8 ++++----
>> tools/perf/pmu-events/metric.py | 17 +++++++++++++++--
>> tools/perf/util/expr.c | 18 ++++++++++++++++++
>> tools/perf/util/expr.h | 1 +
>> tools/perf/util/expr.l | 1 +
>> tools/perf/util/expr.y | 8 +++++++-
>> tools/perf/util/pmu.c | 17 +++++++++++++++++
>> tools/perf/util/pmu.h | 1 +
>> 9 files changed, 65 insertions(+), 24 deletions(-)
>
> This patch looks ok, but I think that it would be better to separate out
> the metrics.json change into a separate patch.
>
Yep I thought about doing that, I can change it in the next version.
> Thanks,
> John