Extend logging on TMC start / stop errors
Recent issues with trying to debug TMC timeouts and flush issues shows
a general lack of logging and context around the possible errors
Add logging to general wait for stop coresight routines and return values of
watched registers.
Update TMC to use this logging.
Changes since v1:
Rebase to coresight/next (kernel 6.13-rc2)
Mike Leach (3):
coresight: Update timeout functions to allow return of test register
value
coresight: tmc: Update error logging in tmc common functions
coresight: etf: etr: Update logging around flush_and_stop() errors
drivers/hwtracing/coresight/coresight-core.c | 50 +++++++++++++++----
.../hwtracing/coresight/coresight-tmc-core.c | 37 +++++++++++---
.../hwtracing/coresight/coresight-tmc-etf.c | 12 +++--
.../hwtracing/coresight/coresight-tmc-etr.c | 8 ++-
drivers/hwtracing/coresight/coresight-tmc.h | 2 +-
include/linux/coresight.h | 2 +
6 files changed, 86 insertions(+), 25 deletions(-)
--
2.25.1
The QCOM extended CTI is a heavily parameterized version of ARM’s CSCTI.
It allows a debugger to send to trigger events to a processor or to send
a trigger event to one or more processors when a trigger event occurs on
another processor on the same SoC, or even between SoCs.
QCOM extended CTI supports up to 128 triggers. And some of the register
offsets are changed.
The commands to configure CTI triggers are the same as ARM's CTI.
Mao Jinlong (2):
dt-bindings: arm: Add Qualcomm extended CTI
coresight: cti: Add Qualcomm extended CTI support
.../bindings/arm/arm,coresight-cti.yaml | 14 ++
.../hwtracing/coresight/coresight-cti-core.c | 75 +++++++----
.../coresight/coresight-cti-platform.c | 16 ++-
.../hwtracing/coresight/coresight-cti-sysfs.c | 124 ++++++++++++++----
drivers/hwtracing/coresight/coresight-cti.h | 123 +++++++++++------
5 files changed, 253 insertions(+), 99 deletions(-)
--
2.41.0
On 12/4/2024 11:16 PM, Leo Yan wrote:
> Hi Yuanfang,
>
> Recently I just acrossed this part, so some comments.
>
> On Wed, Dec 04, 2024 at 07:23:32PM +0800, yuanfang zhang wrote:
>>
>> From: Yuanfang Zhang <quic_yuanfang(a)quicinc.com>
>>
>> As recommended by section 4.3.7 ("Synchronization when using system
>> instructions to progrom the trace unit") of ARM IHI 0064H.b, the
>> self-hosted trace analyzer must perform a Context synchronization
>> event between writing to the TRCPRGCTLR and reading the TRCSTATR.
>>
>> Fixes: ebddaad09e10 ("coresight: etm4x: Add missing single-shot control API to sysfs")
>> Signed-off-by: Yuanfang Zhang <quic_yuanfang(a)quicinc.com>
>> ---
>> Change in V2:
>> Added comments in the code.
>> drivers/hwtracing/coresight/coresight-etm4x-core.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
>> index 66d44a404ad0..decb3a87e27e 100644
>> --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
>> +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
>> @@ -906,6 +906,13 @@ static void etm4_disable_hw(void *info)
>> tsb_csync();
>> etm4x_relaxed_write32(csa, control, TRCPRGCTLR);
>>
>> + /*
>> + * As recommended by section 4.3.7 ("Synchronization when using system
>> + * instructions to progrom the trace unit") of ARM IHI 0064H.b, the
>> + * self-hosted trace analyzer must perform a Context synchronization
>> + * event between writing to the TRCPRGCTLR and reading the TRCSTATR.
>> + */
>> + isb();
>
> As described in the doc, the "isb" is only required for system
> instructions case. It is good to only apply the ISB on system
> register case:
>
> if (!csa->io_mem)
> isb();
>
updated in PATCH V3.
>> /* wait for TRCSTATR.PMSTABLE to go to '1' */
>> if (coresight_timeout(csa, TRCSTATR, TRCSTATR_PMSTABLE_BIT, 1))
>> dev_err(etm_dev,
>
> As mentioned in system register case: "Arm recommends that the
> self-hosted trace analyzer always executes an ISB instruction after
> programming the trace unit registers, to ensure that all updates are
> committed to the trace unit before normal code execution resumes."
>
> And for MMIO case:
>
> "When the memory is marked as Device-nGnRE or stronger.
> ...
> - Poll TRCSTATR to ensure the previous write has completed.
> — Execute an ISB operation."
>
> Thus we need to add an ISB after polling.
>
> isb();
>
updated in PATCH V3.
> For consistent behaviour, a relevant thing is the dsb(sy) in
> etm4_enable_hw(). I do not think the dsb(sy) is necessary, as the
> driver uses the sequence "write TRCPRGCTLR + polling TRCSTATR" to
> ensure the data has been populated to trace unit, the polling
> operations somehow act as a read back. And the ETM manual does not
> mention the requirement for DSB when enabling trace unit. Thus, we
> should remove dsb(sy) (maybe use a separte patch).
>
updated in PATCH V3.
> Mike / Suzuki / James, please confirm if my conclusions are valid.
>
> Thanks,
> Leo
This patch series is rebased on coresight-next-v6.12.rc4
* Patches 1 & 2 adds support for allocation of trace buffer pages from reserved RAM
* Patches 3 & 4 adds support for saving metadata at the time of kernel panic
* Patch 5 adds support for reading trace data captured at the time of panic
* Patches 6 & 7 adds support for disabling coresight blocks at the time of panic
* Patch 8: Gives the full description about this feature as part of documentation
V11 is posted here,
https://lore.kernel.org/linux-arm-kernel/20241111124746.2210378-1-lcherian@…
Changelog from v11:
Convert all commands to literal code blocks, that was missed out in v11.
No other code changes.
Changelog from v10:
* Converted all csdev_access_* to readl functions in tmc_panic_sync_*
* Added "tmc" prefix for register snapshots in struct tmc_crash_metadata
* Converted dev_info to dev_dbg in panic handlers
* Converted dsb to dmb in panic handlers
* Fixed marking metadata as invalid when a user is trying to use the
reserved buffer. Earlier this was wrongly set at the time of reading
reserved trace buffer.
* Moved common validation checks to is_tmc_crashdata_valid and minor
code rearrangements for efficiency
* Got rid of sink specific prepare/unprepare invocations
* Got rid of full from struct tmc_resrv_buf
* While reading crashdata, size is now calculated from metdata instead
of relying on reserved buffer size populated by dtb
* Minor documenation fixes
Changelog from v9:
* Add common helper function of_tmc_get_reserved_resource_by_name
for better code reuse
* Reserved buffer validity and crashdata validity has been separated to
avoid interdependence
* New fields added to crash metadata: version, ffcr, ffsr, mode
* Version checks added for metadata validation
* Special file /dev/crash_tmc_xxx would be available only when
crash metadata is valid
* Removed READ_CRASHDATA mode meant for special casing crashdata reads.
Instead, dedicated read function added for crashdata reads from reserved
buffer which is common for both ETR and ETF sinks as well.
* Documentation added to Documentation/tracing/coresight/panic.rst
Changelog from v8:
* Added missing exit path on error in __tmc_probe.
* Few whitespace fixes, checkpatch fixes.
* With perf sessions honouring stop_on_flush sysfs attribute,
removed redundant variable stop_on_flush_en.
Changelog from v7:
* Fixed breakage on perf test -vvvv "arm coresight".
No issues seen with and without "resrv" buffer mode
* Moved the crashdev registration into a separate function.
* Removed redundant variable in tmc_etr_setup_crashdata_buf
* Avoided a redundant memcpy in tmc_panic_sync_etf.
* Tested kernel panic with trace session started uisng perf.
Please see the title "Perf based testing" below for details.
For this, stop_on_flush sysfs attribute is taken into
consideration while starting perf sessions as well.
Changelog from v6:
* Added special device files for reading crashdata, so that
read_prevboot mode flag is removed.
* Added new sysfs TMC device attribute, stop_on_flush.
Stop on flush trigger event is disabled by default.
User need to explicitly enable this from sysfs for panic stop
to work.
* Address parameter for panicstop ETM configuration is
chosen as kernel "panic" address by default.
* Added missing tmc_wait_for_tmcready during panic handling
* Few other misc code rearrangements.
Changelog from v5:
* Fixed issues reported by CONFIG_DEBUG_ATOMIC_SLEEP
* Fixed a memory leak while reading data from /dev/tmc_etrx in
READ_PREVBOOT mode
* Tested reading trace data from crashdump kernel
Changelog from v4:
* Device tree binding
- Description is made more explicit on the usage of reserved memory
region
- Mismatch in memory region names in dts binding and driver fixed
- Removed "mem" suffix from the memory region names
* Rename "struct tmc_register_snapshot" -> "struct tmc_crash_metadata",
since it contains more than register snapshot.
Related variables are named accordingly.
* Rename struct tmc_drvdata members
resrv_buf -> crash_tbuf
metadata -> crash_mdata
* Size field in metadata refers to RSZ register and hence indicates the
size in 32 bit words. ETR metadata follows this convention, the same
has been extended to ETF metadata as well.
* Added crc32 for more robust metadata and tracedata validation.
* Added/modified dev_dbg messages during metadata validation
* Fixed a typo in patch 5 commit description
Changelog from v3:
* Converted the Coresight ETM driver change to a named configuration.
RFC tag has been removed with this change.
* Fixed yaml issues reported by "make dt_binding_check"
* Added names for reserved memory regions 0 and 1
* Added prevalidation checks for metadata processing
* Fixed a regression introduced in RFC v3
- TMC Status register was getting saved wrongly
* Reverted memremap attribute changes from _WB to _WC to match
with the dma map attributes
* Introduced reserved buffer mode specific .sync op.
This fixes a possible crash when reserved buffer mode was used in
normal trace capture, due to unwanted dma maintenance operations.
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
.../bindings/arm/arm,coresight-tmc.yaml | 26 ++
Documentation/trace/coresight/panic.rst | 362 ++++++++++++++++++
drivers/hwtracing/coresight/Makefile | 2 +-
.../coresight/coresight-cfg-preload.c | 2 +
.../coresight/coresight-cfg-preload.h | 2 +
.../hwtracing/coresight/coresight-cfg-pstop.c | 83 ++++
drivers/hwtracing/coresight/coresight-core.c | 42 ++
.../hwtracing/coresight/coresight-tmc-core.c | 326 +++++++++++++++-
.../hwtracing/coresight/coresight-tmc-etf.c | 92 ++++-
.../hwtracing/coresight/coresight-tmc-etr.c | 181 ++++++++-
drivers/hwtracing/coresight/coresight-tmc.h | 104 +++++
include/linux/coresight.h | 12 +
12 files changed, 1222 insertions(+), 12 deletions(-)
create mode 100644 Documentation/trace/coresight/panic.rst
create mode 100644 drivers/hwtracing/coresight/coresight-cfg-pstop.c
--
2.34.1
On 2024/12/11 16:46, Krzysztof Kozlowski wrote:
> On Tue, Dec 10, 2024 at 08:22:51PM +0800, Mao Jinlong wrote:
>> With current design, the name of the non-cpu bounded coresight
>> component is the device type with the number. And with 'ls' command
>> we can get the register address of the component. But from these
>> information, we can't know what the HW or system the component belongs
>> to. Add label in DT and show the hw information by reading label sysfs
>> node.
>>
>> cti_sys0 -> ../../../devices/platform/soc(a)0/138f0000.cti/cti_sys0
>> cti_sys1 -> ../../../devices/platform/soc(a)0/13900000.cti/cti_sys1
>> tpdm0 -> ../../../devices/platform/soc(a)0/10b0d000.tpdm/tpdm0
>> tpdm1 -> ../../../devices/platform/soc(a)0/10c28000.tpdm/tpdm1
>> tpdm2 -> ../../../devices/platform/soc(a)0/10c29000.tpdm/tpdm2
>>
>> /sys/bus/coresight/devices # cat cti*/label
>> cti_dlct_0
>> cti_dlct_1
>> cti_apss_0
>> cti_apss_1
>> cti_apss_2
>>
>> Change since V4:
>> 1. Add label in DT and add label sysfs node for each coresight device.
>
> This is v5, no links to previous versions (I really suggest to start
> using b4 if you want to make your process easier for you), no other
> changes so subject is obviously the same and looking for this patchset
> previous versions gives me 0 results:
>
> https://lore.kernel.org/all/?q=%22coresight%3A+Add+label+sysfs+node+support…
>
> OK, let's try b4 diff:
>
> b4 diff '20241210122253.31926-1-quic_jinlmao(a)quicinc.com'
> Grabbing thread from lore.kernel.org/all/20241210122253.31926-1-quic_jinlmao@quicinc.com/t.mbox.…
> Checking for older revisions
> Grabbing search results from lore.kernel.org
> Nothing matching that query.
> ---
> Analyzing 3 messages in the thread
> Could not find lower series to compare against.
>
>
> So how do you expect us to do any meaningful review?
>
> Best regards,
> Krzysztof
I will resend the patches with the links of lower series.
>
On Thu, 21 Nov 2024 10:40:03 +0800, Pei Xiao wrote:
> dsb_mode_store() warn: unsigned 'val' is never less than zero.
>
>
Applied, thanks!
[1/1] coresight: Fix dsb_mode_store() unsigned val is never less than zero
https://git.kernel.org/coresight/c/d4276259f3a57131291d879b53fc05863c6b59fa
Best regards,
--
Suzuki K Poulose <suzuki.poulose(a)arm.com>
Some HW has static trace id which cannot be changed via
software programming. For this case, configure the trace id
in device tree with "arm,static-trace-id = <xxx>", and
call coresight_trace_id_get_static_system_id with the trace id value
in device probe function. The id will be reserved for the HW
all the time if the device is probed.
Changes since V6:
1. Add code to handle a case where the preferred_id is not valid when
use static id.
2. Returen busy when static id is not freed.
Changes since V5:
1. Remove the warn for staic id not available.
2. Drop the system_id if registering the coresight device fails.
3. Return busy when static id is not available in dummy driver.
Changes since V4:
1. Use fwnode_property_read_u32 in fwnode_property_read_u32.
2. Update date and version in sysfs-bus-coresight-devices-dummy-source
Changes since V3:
1. Adda new API function
int coresight_trace_id_get_system_static_id(int trace_id).
2. Use the term "static trace id" for these devices where
the hardware sets a non-programmable trace ID.
Changes since V2:
1. Change "trace-id" to "arm,trace-id".
2. Add trace id flag for getting preferred id or ODD id.
Changes since V1:
1. Add argument to coresight_trace_id_get_system_id for preferred id
instead of adding new function coresight_trace_id_reserve_system_id.
2. Add constraint to trace-id in dt-binding file.
Mao Jinlong (3):
dt-bindings: arm: Add arm,static-trace-id for coresight dummy source
coresight: Add support to get static id for system trace sources
coresight: dummy: Add static trace id support for dummy source
.../sysfs-bus-coresight-devices-dummy-source | 15 ++++
.../arm/arm,coresight-dummy-source.yaml | 6 ++
drivers/hwtracing/coresight/coresight-dummy.c | 81 ++++++++++++++++---
.../hwtracing/coresight/coresight-platform.c | 6 ++
.../hwtracing/coresight/coresight-trace-id.c | 43 +++++++---
.../hwtracing/coresight/coresight-trace-id.h | 9 +++
include/linux/coresight.h | 1 +
7 files changed, 140 insertions(+), 21 deletions(-)
create mode 100644 Documentation/ABI/testing/sysfs-bus-coresight-devices-dummy-source
--
2.17.1