On Wed, Nov 18, 2026 at 08:58:26PM +0200, Igor Velkov wrote:
> On Wed, Nov 18, 2026 at 10:49:17AM +0000, Leo Yan wrote:
> > 1) If idle_cpu(cpu) == 0, sample the CPU directly.
> > 2) If idle_cpu(cpu) == 1, follow the existing flow to request
> > power-up before sampling.
>
> I tried step 2 on RK3399 (Cortex-A53 + A72, cpuidle with core
> powerdown), following debug_read_regs() on a running system:
>
> - Idle A53 (EDPRSR.PU = 0): the EDOSLAR write raises an SError on the
> reading CPU. COREPURQ brings the core up only for a moment; with
> COREPURQ | CORENPDRQ it is off again within 10 ms, and the write
> still faults.
> - Idle A72 (PU = 1, R = 1): the same SError on the EDOSLAR write.
> - Busy CPUs (idle_cpu() == 0) on both clusters: no errors, full PC.
>
> So on this SoC only step 1 is safe.
This is why I suggested 3) in my previous reply. Seems you should skip
sample idle CPUs if COREPURQ/CORENPDRQ are not properly integrated in
the SoC.
Thanks,
Leo
Hi,
On Thu, Nov 19, 2026 at 11:10:50AM +0000, Kepplinger-Novakovic Martin wrote:
> hi Suzuki, Mike and others,
>
> I don't really know the coresight hardware but with CORESIGHT enabled, when I do
> "reboot tests" on imx8mp, I see the kernel hang after (randomly) 200 to 2000 (sometimes
> a hang was seen even later) reboots at *about* the line below. But indeed not exactly
> that line. sometimes it stops 4-7 lines earlier!
Could you enable earlycon together with ignore_loglevel and initcall_debug?
So far, the info is too limited to give any useful hints.
> [ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
> [ 0.000000] Linux version 6.18.63-ge-26.10+-ge_bep4-eta-1-00195-gb8bebc692f96 (root@ginzinger) (aarch64-buildroot-linux-gnu-gcc.br_real (Buildroot
> -gf002287f) 13.4.0, GNU ld (GNU Binutils) 2.43.1) #41 SMP PREEMPT Thu Nov 12 09:08:03 CET 2026
> [ 0.000000] KASLR disabled due to lack of seed
> [ 0.000000] Machine model: BE-P4 i.MX8MPlus in NDM
> [ 0.000000] NUMA: Faking a node at [mem 0x0000000040000000-0x000000007fffffff]
> [ 0.000000] NODE_DATA(0) allocated [mem 0x7fdb6e80-0x7fdb9b7f]
> [ 0.000000] Zone ranges:
> [ 0.000000] DMA [mem 0x0000000040000000-0x000000007fffffff]
> [ 0.000000] DMA32 empty
> [ 0.000000] Normal empty
> [ 0.000000] Movable zone start for each node
> [ 0.000000] Early memory node ranges
> [ 0.000000] node 0: [mem 0x0000000040000000-0x000000007fffffff]
> [ 0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x000000007fffffff]
> [ 0.000000] cma: Reserved 32 MiB at 0x000000007cc00000
> [ 0.000000] psci: probing for conduit method from DT.
> [ 0.000000] psci: PSCIv1.1 detected in firmware.
> [ 0.000000] psci: Using standard PSCI v0.2 function IDs
> [ 0.000000] psci: MIGRATE_INFO_TYPE not supported.
>
> The kernel does not panic. It hangs. The problem goes away and it reboots indefinitely
> when I disable coresight in the config.
Could you confirm what exactly CoreSight modules have been enabled?
> I sometimes need to run an old v5.10-imx based kernel, where I've *not* reproduced
> this hang with coresight enabled.
>
> Was there a regression in mainline or does NXP have a fix in their tree? Have you see
> something like this before?
I am not aware of a CoreSight regression. I cannot comment on NXP
board as I don't have it.
As separate diagnostic tests, could you try clk_ignore_unused and
nohlt, one at a time, to see whether unused-clock disabling or
CPU idle affects reproduction?
Thanks,
Leo
Concurrent per-thread events results in a WARN on N1SDP which leads to
the realization that per-thread events shouldn't have been sharing sinks
in the first place.
This slips through because different per-thread events will have the
same PID if owned by the same process, and we only check the PID and
nothing else. That results in unexpected WARNs because it looks like we
assumed it couldn't happen (although exclusive PMU rules allow it). But
even if it was supported it would result in trace from the wrong thread
in another event's per-thread buffer, so we should disallow it.
Fix it by determining if sharing can happen at setup time. Then remove
everywhere the same PID checking logic was copy pasted in each sink.
The first three patches fix configuration initialization, AUX cleanup
and topology locking. The remaining patches enforce the sharing rules
and simplify the sink drivers.
Signed-off-by: James Clark <james.clark(a)linaro.org>
---
Changes in v4:
- Count CPU sources in the registered topology and retain each sink's
sharing classification until its last AUX session ends.
- Serialize AUX topology access and provide locked and locking path
release functions.
- Reject unexpected path setup errors while retaining silent skips for
missing ETMs and unreachable sinks.
- Prevent all problematic sharing cases at aux setup rather than at
runtime. (Leo)
- Drop "coresight: tmc-etr: Don't stop Perf cleanup for active sysfs
reads". It was a pre-existing bug and is even more unrelated now with
the new model.
- Remove workqueue rather than fix the lifecycle, its no longer
needed. (Leo)
- Add a getter for the config manager, cscfg_get_state(). (Leo)
- Link to v3: https://lore.kernel.org/r/20260728-james-cs-multiple-per-threads-v3-0-6aee7…
Changes in v3:
- Storing and accessing event owners at runtime causes problems due to
various scenarios of: events (and sibling events) exiting, children
inheriting event FDs, PID reuse, CPU affine events that also have a
target process set but different inherit settings. Fix it by creating
a session ID in etm_setup_aux() and holding the references in it for
the duration of the whole session. (Leo)
- Make the ETR buffer allocator consistent with sink sharing rules by
not doing numeric PID comparisons there either.
- Fix up some Sashiko reports that it sees after interacting with cscfg
and taking extra references to tasks and PIDs.
- Link to v2: https://lore.kernel.org/r/20260709-james-cs-multiple-per-threads-v2-0-10ac7…
Changes in v2:
- Fix inherited events by following event->parent
- Link to v1: https://lore.kernel.org/r/20260709-james-cs-multiple-per-threads-v1-0-d384e…
---
James Clark (10):
coresight: configfs: Don't assume active until cscfg_mgr is set
coresight: etm-perf: Remove workqueue for freeing AUX data
coresight: etm-perf: Serialize AUX topology access
coresight: etm-perf: Reject event if building path fails
coresight: etm-perf: Prevent sink sharing at setup time
coresight: tmc-etr: Reflect new sharing rules in allocator
coresight: tmc-etr: Remove sharing guards from ETR
coresight: tmc-etf: Remove sharing guards from ETF
coresight: etb10: Remove sharing guards from ETB10
coresight: ultrasoc-smb: Remove sharing guards from SMB
drivers/hwtracing/coresight/coresight-core.c | 104 +++++++++++++++--
drivers/hwtracing/coresight/coresight-etb10.c | 28 +----
drivers/hwtracing/coresight/coresight-etm-perf.c | 119 ++++++++++---------
drivers/hwtracing/coresight/coresight-etm-perf.h | 2 -
drivers/hwtracing/coresight/coresight-priv.h | 4 +-
drivers/hwtracing/coresight/coresight-syscfg.c | 11 +-
drivers/hwtracing/coresight/coresight-sysfs.c | 4 +-
drivers/hwtracing/coresight/coresight-tmc-core.c | 6 +-
drivers/hwtracing/coresight/coresight-tmc-etf.c | 22 +---
drivers/hwtracing/coresight/coresight-tmc-etr.c | 142 +++++++----------------
drivers/hwtracing/coresight/coresight-tmc.h | 16 +--
drivers/hwtracing/coresight/coresight-trace-id.c | 97 ++++++++++++++--
drivers/hwtracing/coresight/coresight-trace-id.h | 26 +++--
drivers/hwtracing/coresight/ultrasoc-smb.c | 20 +---
drivers/hwtracing/coresight/ultrasoc-smb.h | 3 -
include/linux/coresight.h | 26 ++++-
16 files changed, 346 insertions(+), 284 deletions(-)
---
base-commit: 343cfcbb3ecfdb80aa576a428cfa3b65ad783842
change-id: 20260708-james-cs-multiple-per-threads-ed1d25ed1734
Best regards,
--
James Clark <james.clark(a)linaro.org>
On Sun, Nov 15, 2026 at 08:32:16PM +0530, Dev Jain wrote:
[...]
> > 1. Make opportunistic high-order AUX allocations no-reclaim:
> > When !(event->pmu->capabilities & PERF_PMU_CAP_AUX_NO_SG) and
> > order > 0, clear __GFP_RECLAIM (and add __GFP_NOMEMALLOC, matching
> > SLUB's allocate_slab() and GFP_TRANSHUGE_LIGHT):
> >
> > gfp_t gfp = PERF_AUX_GFP;
> >
> > if (order && !has_no_sg)
> > gfp = (PERF_AUX_GFP | __GFP_NOMEMALLOC) & ~__GFP_RECLAIM;
>
> Thanks for your reply.
>
> This looks like the correct solution. Note commit 0e05a469c294
> ("mm/page_alloc: avoid direct reclaim and compaction for costly __GFP_NORETRY allocations")
> post which the regression you report should reduce drastically. It only
> removes GFP_DIRECT_RECLAIM flag, I assume you are seeing latency even
> due to reclaim/compaction daemon wakeups.
>
> So instead of enhancing this commit even more by making a page-allocator
> change, I would rather make your proposed change on the perf side to
> keep it simple. This should completely solve the problem.
Thanks a lot, Dev!
The revert (526d945ad9c0) and 0e05a469c294 are now in mainline. My tests
show significantly lower PSI on v7.4-rc3, consistent with the expected
benefit of 0e05a469c294.
The following PSI some values are totals in milliseconds across runs
2-10 (nine runs), excluding the first run of each case to avoid
glitches caused by its proximity to lauching the pressure workload:
Memory usage v7.4-rc1 v7.4-rc3 rc3 + perf patch [1]
90% 0.000 0.000 0.000
95% 21.781 0.000 2.061
100% 27.946 0.000 0.000
My perf patch [1] reduces pageoutrun and compact_daemon_wake, but
increases pgscan_kswapd at 95%. The following totals compare v7.4-rc3
and v7.4-rc + my patch, also across runs 2-10:
Usage pageoutrun compact_daemon_wake pgscan_kswapd
90% 58 -> 0 57 -> 0 1,932 -> 0
95% 3 -> 2 2 -> 1 9,664 -> 148,079
100% 40 -> 1 40 -> 0 11,616 -> 1,918
I would wait for Yabin's testing before deciding whether to proceed
with the additional perf changes. In my patch, changing order 0 to
__GFP_RETRY_MAYFAIL needs care: it may reduce allocation failures when
free memory is scarce, at the cost of longer reclaim stalls and
higher PSI.
Yabin, could you test the current mainline (or backport
526d945ad9c0/0e05a469c294) and confirm whether it resolves the PSI issue
on Android? If still see the reclaim pressure or observe AUX allocation
failures, it may also be worth testing patch [1].
Thanks,
Leo
[1] https://lore.kernel.org/lkml/20261109-perf_aux_alloc_optimize_psi-v1-1-d56a…
Restructure the Coresight decoder to decode trace in order with the Perf
events. This improves decoding accuracy all workloads, but particularly
with JIT code when instructions at the same addresses are re-written.
The resulting decode loop structure is simplified to
cs_etm__insert_heap() and cs_etm__pop_heap(), which work in the same way
for all of the timeless/per-thread/per-cpu etc modes.
For every Perf event, we pop from the heap while the packet's timestamps
are before the current Perf event. When a packet is popped, the next
packet is decoded and re-inserted.
The same path works for timeless mode because we can just assign the
timestamp of the AUX record to all trace from that buffer. This also
improves timeless decoding accuracy because now we don't use the
timestamp from the very last AUX record for all samples.
In Coresight trace, timestamps come after their associated atoms and
Perf uses a single decoder for both searching forwards for a timestamp
and decoding. It does this by caching decoded packets into
packet_buffer[] and replaying them once a timestamp is received.
Unfortunately this does't work for strict ordering with Perf events
because while searching for the timestamp the decoder will decode trace
using previously seen mmap which is incorrect.
To fix this, add a "packet only" decoder for each queue. This is used
for searching for the next timestamp after a discontinuity and not for
decoding trace. Once it's found, the backend re-orders that timestamp
and the previous packet before delivering them to the frontend so that
we can be at the correct Perf event before processing context packets or
ranges. Excluding the tests, this patchset results in similar total
lines of code but if we updated OpenCSD to return timestamps and
discontinuities in the correct order, then it would be a significant
reduction in code and complexity.
This series depends on https://lore.kernel.org/linux-perf-users/20261105-james-cs-unformatted-per-…
Signed-off-by: James Clark <james.clark(a)linaro.org>
---
James Clark (34):
perf jit: Support JITDUMP_USE_ARCH_TIMESTAMP on arm64
perf jit: Add name of clock in error message
perf jit: Add address ranges to DWARF compilation units
perf libdw: Don't look up the module by ELF address
perf cs-etm: Use the exception level to tell kernel from user
perf cs-etm: Don't read past the end of the map
perf build-id: Cache the vDSO in build ID mmap mode
perf cs-etm: arm-spe: Use arch timestamp in HW tracers
perf cs-etm: arm-spe: Report error if default clock isn't used
perf cs-etm: Remove old pipe mode support
perf cs-etm: Track threads in timeless mode
perf cs-etm: Track sched out events
perf cs-etm: Handle PERF_RECORD_SWITCH events
perf cs-etm: Always enable Perf event timestamps
perf cs-etm: Use time from Perf samples
perf cs-etm: Don't buffer non-timestamped packets
perf cs-etm: Decode in order of Perf samples
perf cs-etm: Don't special case per-thread mode
perf cs-etm: Decode one packet at a time and don't estimate timestamps
perf cs-etm: Remove the decoded packet ring buffer
perf cs-etm: Fold packet state into the trace ID queue
perf cs-etm: Rename trace ID queues to trace ID contexts
perf cs-etm: Rename tidq variables to tidc
perf cs-etm: Share the thread ctxt between frontend and backend
perf cs-etm: Consume each OpenCSD packet immediately
perf cs-etm: Split base and packet decoder state
perf cs-etm: Add packet-only timestamp decoder ops
perf cs-etm: Create timestamp decoders
perf cs-etm: Find timestamps by searching ahead
perf cs-etm: Invalidate OpenCSD's cache on MMAPs
perf test cs-etm: Add a Java JIT source-line test
perf test cs-etm: Test trace is ordered with context switch records
perf test cs-etm: Test decoding of kernel modules
perf test cs-etm: Add an HHVM JIT call stack test
tools/perf/Makefile.perf | 4 +-
tools/perf/arch/arm/util/cs-etm.c | 21 +-
tools/perf/arch/arm64/util/arm-spe.c | 11 +
tools/perf/jvmti/jvmti_agent.c | 5 +
tools/perf/tests/genelf.c | 70 +-
.../tests/shell/coresight/context_switch_thread.sh | 20 +-
tools/perf/tests/shell/coresight/hhvm-jit.sh | 89 ++
tools/perf/tests/shell/coresight/java-jit.sh | 65 +
tools/perf/tests/shell/coresight/kernel_module.sh | 54 +
tools/perf/tests/shell/coresight/lib/PerfJit.java | 82 ++
tools/perf/tests/shell/coresight/per-thread.sh | 45 +-
tools/perf/tests/workloads/jitdump.c | 7 +-
tools/perf/util/auxtrace.h | 2 +
tools/perf/util/build-id.c | 12 +
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 790 ++++++----
tools/perf/util/cs-etm-decoder/cs-etm-decoder.h | 28 +-
tools/perf/util/cs-etm.c | 1515 ++++++++------------
tools/perf/util/cs-etm.h | 56 +-
tools/perf/util/genelf.c | 2 +-
tools/perf/util/genelf.h | 3 +-
tools/perf/util/genelf_debug.c | 22 +-
tools/perf/util/jitdump.c | 2 +-
tools/perf/util/libdw.c | 16 +-
23 files changed, 1643 insertions(+), 1278 deletions(-)
---
base-commit: b7ff10b9ddec8da75304c40fe4abf1ee4f9f0a43
change-id: 20260824-james-coresight-jit-250f19309e35
prerequisite-message-id: <20261105-james-cs-unformatted-per-thread-fix-v4-0-7759e0ce2449(a)linaro.org>
prerequisite-patch-id: 9c49b9ffb75309e9187eb2e3ef84026118fcfdb5
prerequisite-patch-id: 4ce0ba0ab1302c9043f0d0734d9cf6a35298bc47
prerequisite-patch-id: 5e69770fbaf94296da5c474ce09539a1993bc61e
prerequisite-patch-id: 41d797af2aba7e97ff4435ae2659629e026d36ec
prerequisite-patch-id: d5f67b3b704f4f4b3d9e39c4299d13a086b29363
prerequisite-patch-id: a99348cc2065af31840f652286f840f23395892f
prerequisite-patch-id: aa90408e69dedf9e68d7158f2499bd9fbc7b0b40
prerequisite-patch-id: cd31a650f8dd3e7a9795fa641eee2415b126ad29
prerequisite-patch-id: 922a7fe2937a575beb8d0e7777fd869a11023eb2
prerequisite-patch-id: b0436630e22fd92803e277cd08d782c50f135be6
prerequisite-patch-id: e136ff402ddf5121c63c1393b7fc00a826f60a69
prerequisite-patch-id: 8a2674fa45e40848742e8b8472003e2b9706211d
prerequisite-patch-id: df905386a100ac4b8b047328de08da86b3adf241
prerequisite-patch-id: 44ee88eeafd54c0148ed2332dc5e33f1ba6dfce4
prerequisite-patch-id: b9622164f99682ca6b813b9d38ced3e95170653e
prerequisite-patch-id: 2f22df1738caf5af3a631851d8a57fc3bfea7742
prerequisite-patch-id: afe679ea285ddc6cd281f697ce504b7a18888999
prerequisite-patch-id: f507254858995051e8e1b96fb9fd95506228c5e6
prerequisite-patch-id: 6fe822580ea330633f8a23260aa7b2c7de834ab3
Best regards,
--
James Clark <james.clark(a)linaro.org>
On 18/11/2026 08:02, Jie Gan wrote:
> Add tmc_etr_switch_buf_node() to switch the ETR to a free etr_buf of the
> etr_buf_list without disabling the sink. It returns the node of the
> switched out etr_buf, so its synced data can be read while the ETR keeps
> tracing into the new one.
>
> Stopping the ETR, swapping the etr_buf and restarting the ETR have to be
> done in one critical section. Otherwise tmc_disable_etr_sink() can run
> in between and leave drvdata->etr_buf out of sync with the hardware.
> Provide the sequence as a TMC helper, so callers don't need to know
> about the locking of the ETR state.
>
> Signed-off-by: Jie Gan <jie.gan(a)oss.qualcomm.com>
> ---
> drivers/hwtracing/coresight/coresight-tmc-etr.c | 65 +++++++++++++++++++++++++
> drivers/hwtracing/coresight/coresight-tmc.h | 4 ++
> 2 files changed, 69 insertions(+)
>
> diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c
> index e9213f456834..5032f5598e15 100644
> --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c
> +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c
> @@ -1224,6 +1224,71 @@ static void __tmc_etr_disable_hw(struct tmc_drvdata *drvdata)
>
> }
>
> +static void tmc_etr_reset_sysfs_buf(struct tmc_drvdata *drvdata)
> +{
> + u32 sts;
> +
> + CS_UNLOCK(drvdata->base);
> + tmc_write_rrp(drvdata, drvdata->sysfs_buf->hwaddr);
> + tmc_write_rwp(drvdata, drvdata->sysfs_buf->hwaddr);
> + sts = readl_relaxed(drvdata->base + TMC_STS) & ~TMC_STS_FULL;
> + writel_relaxed(sts, drvdata->base + TMC_STS);
see below
> + CS_LOCK(drvdata->base);
> +}
> +
> +/**
> + * tmc_etr_switch_buf_node - switch the ETR to a free buffer of the etr_buf_list.
> + * @drvdata: drvdata of the TMC device.
> + *
> + * Stop the ETR, hand over the current buffer for reading, switch to a free
> + * buffer and restart the ETR. All of this is done with @drvdata->spinlock held,
> + * so it can't race with the sink disable path.
> + *
> + * Return: the node of the switched out buffer, or NULL if the sink isn't in
> + * sysfs mode or there is no free buffer. The ETR is left untouched in both
> + * cases.
> + */
> +struct etr_buf_node *tmc_etr_switch_buf_node(struct tmc_drvdata *drvdata)
> +{
> + struct etr_buf_node *nd, *curr_node = NULL, *picked_node = NULL;
> + unsigned long flags;
> +
> + raw_spin_lock_irqsave(&drvdata->spinlock, flags);
> + if (coresight_get_mode(drvdata->csdev) != CS_MODE_SYSFS)
> + goto out;
> +
> + list_for_each_entry(nd, &drvdata->etr_buf_list, link) {
> + if (nd->sysfs_buf == drvdata->sysfs_buf)
> + curr_node = nd;
> + else if (!picked_node && nd->is_free && !nd->reading)
> + picked_node = nd;
> + }
> +
> + if (!curr_node || !picked_node) {
> + curr_node = NULL;
> + goto out;
> + }
> +
> + __tmc_etr_disable_hw(drvdata);
> +
> + /* The switched out buffer is free again once it has been read */
> + curr_node->is_free = true;
> + curr_node->pos = 0;
> + curr_node->reading = true;
> + picked_node->is_free = false;
> + drvdata->sysfs_buf = picked_node->sysfs_buf;
> + drvdata->etr_buf = picked_node->sysfs_buf;
> +
> + tmc_etr_reset_sysfs_buf(drvdata);
Why are we doing this, when the following __tmc_etr_enable_hw() already
does the right thing ?
Suzuki
> + if (__tmc_etr_enable_hw(drvdata))
> + dev_err(&drvdata->csdev->dev, "Failed to restart the ETR\n");
> +out:
> + raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
> +
> + return curr_node;
> +}
> +EXPORT_SYMBOL_GPL(tmc_etr_switch_buf_node);
> +
> void tmc_etr_disable_hw(struct tmc_drvdata *drvdata)
> {
> __tmc_etr_disable_hw(drvdata);
> diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracing/coresight/coresight-tmc.h
> index 7c604b9f92e5..30b15c38b080 100644
> --- a/drivers/hwtracing/coresight/coresight-tmc.h
> +++ b/drivers/hwtracing/coresight/coresight-tmc.h
> @@ -212,12 +212,15 @@ struct tmc_resrv_buf {
> * struct etr_buf_node - node of the etr_buf_list
> * @sysfs_buf: Allocated sysfs_buf.
> * @is_free: Indicates whether the buffer is free to choose.
> + * @reading: Indicates the buffer attached to the node is being read by
> + * the user.
> * @pos: Offset to the start of the buffer.
> * @link: list_head of the node.
> */
> struct etr_buf_node {
> struct etr_buf *sysfs_buf;
> bool is_free;
> + bool reading;
> loff_t pos;
> struct list_head link;
> };
> @@ -465,5 +468,6 @@ struct etr_buf *tmc_etr_get_buffer(struct coresight_device *csdev,
> extern const struct attribute_group coresight_etr_group;
> void tmc_clean_etr_buf_list(struct tmc_drvdata *drvdata);
> int tmc_create_etr_buf_list(struct tmc_drvdata *drvdata, int num_nodes);
> +struct etr_buf_node *tmc_etr_switch_buf_node(struct tmc_drvdata *drvdata);
>
> #endif
>
On 18/11/2026 08:02, Jie Gan wrote:
> Introduce functions for creating and inserting or removing the
> etr_buf_node to/from the etr_buf_list.
>
> The byte-cntr functionality requires two etr_buf to receive trace data.
> The active etr_buf collects the trace data from source device, while the
> byte-cntr reading function accesses the deactivated etr_buf after is
> has been filled and synced, transferring data to the userspace.
>
> Reviewed-by: Mike Leach <mike.leach(a)arm.com>
> Signed-off-by: Jie Gan <jie.gan(a)oss.qualcomm.com>
> ---
> drivers/hwtracing/coresight/coresight-tmc-core.c | 1 +
> drivers/hwtracing/coresight/coresight-tmc-etr.c | 205 ++++++++++++++++++++++-
> drivers/hwtracing/coresight/coresight-tmc.h | 18 ++
> 3 files changed, 222 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/drivers/hwtracing/coresight/coresight-tmc-core.c
> index bc5a133ada3e..bc7dd676da47 100644
> --- a/drivers/hwtracing/coresight/coresight-tmc-core.c
> +++ b/drivers/hwtracing/coresight/coresight-tmc-core.c
> @@ -835,6 +835,7 @@ static int __tmc_probe(struct device *dev, struct resource *res)
> idr_init(&drvdata->idr);
> mutex_init(&drvdata->idr_mutex);
> dev_list = "tmc_etr";
> + INIT_LIST_HEAD(&drvdata->etr_buf_list);
> break;
> case TMC_CONFIG_TYPE_ETF:
> desc.groups = coresight_etf_groups;
> diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c
> index 361a433e6f0c..e9213f456834 100644
> --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c
> +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c
> @@ -1268,7 +1268,9 @@ static struct etr_buf *tmc_etr_get_sysfs_buffer(struct coresight_device *csdev)
> raw_spin_lock_irqsave(&drvdata->spinlock, flags);
> }
>
> - if (drvdata->reading || coresight_get_mode(csdev) == CS_MODE_PERF) {
> + /* The sysfs_buf is owned by the etr_buf_list, don't replace it */
> + if (drvdata->reading || coresight_get_mode(csdev) == CS_MODE_PERF ||
> + !list_empty(&drvdata->etr_buf_list)) {
> ret = -EBUSY;
> goto out;
> }
> @@ -1918,6 +1920,204 @@ const struct coresight_ops tmc_etr_cs_ops = {
> .panic_ops = &tmc_etr_sync_ops,
> };
>
> +/* Remove the nodes of the list, the buffer @keep is never freed. */
> +static void __tmc_clean_etr_buf_list(struct tmc_drvdata *drvdata,
> + struct etr_buf *keep)
> +{
> + struct etr_buf_node *nd, *next;
> + unsigned long flags;
> +
> + list_for_each_entry_safe(nd, next, &drvdata->etr_buf_list, link) {
> + raw_spin_lock_irqsave(&drvdata->spinlock, flags);
> + if (keep && nd->sysfs_buf == keep) {
> + /*
> + * The buffer is owned by drvdata->sysfs_buf and may hold
> + * the captured trace data, whatever the mode of the sink
> + * is now. Only drop the list's reference to it.
> + */
> + nd->sysfs_buf = NULL;
> + } else if (nd->sysfs_buf == drvdata->sysfs_buf) {
> + if (coresight_get_mode(drvdata->csdev) == CS_MODE_SYSFS)
> + /*
> + * The sink is still enabled in sysfs mode. Keep
> + * the live buffer owned by drvdata->sysfs_buf
> + * and only drop the list's reference to it.
> + */
> + nd->sysfs_buf = NULL;
> + else
> + /* Free the buffer below through nd->sysfs_buf */
> + drvdata->sysfs_buf = NULL;
> + }
> + list_del(&nd->link);
> + raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
> +
> + /* Free the buffer (NULL is ignored) and the node out of the lock */
> + tmc_etr_free_sysfs_buf(nd->sysfs_buf);
> + kfree(nd);
> + }
> +}
> +
> +/**
> + * tmc_clean_etr_buf_list - clean the etr_buf_list.
> + * @drvdata: driver data of the TMC device.
> + *
> + * Remove all nodes from @drvdata->etr_buf_list and free their buffers.
> + * If a node holds the live sysfs_buf and the sink is enabled in sysfs mode, the
> + * node is removed but the buffer is not freed; ownership stays with
> + * drvdata->sysfs_buf.
> + *
> + * Locking: must not be called with @drvdata->spinlock held. The spinlock is
> + * taken internally to serialise the @drvdata->sysfs_buf accesses and the
> + * removal of the nodes against the ETR sink enable/disable paths and the
> + * generic sysfs read. There must be only one owner of the list at a time.
> + * Must be called from process context: buffers are freed with the lock
> + * released.
> + */
> +void tmc_clean_etr_buf_list(struct tmc_drvdata *drvdata)
> +{
> + __tmc_clean_etr_buf_list(drvdata, NULL);
> +}
> +EXPORT_SYMBOL_GPL(tmc_clean_etr_buf_list);
> +
> +/**
> + * tmc_create_etr_buf_list - create a list to manage the etr_buf_node.
> + * @drvdata: driver data of the TMC device.
> + * @num_nodes: number of nodes want to create with the list.
> + *
> + * Locking: must not be called with @drvdata->spinlock held. The spinlock is
> + * taken internally to serialise the @drvdata->sysfs_buf accesses and every
> + * update of @drvdata->etr_buf_list against the ETR sink enable/disable paths
> + * and the generic sysfs read. There must be only one owner of the list at a
> + * time. Must be called from process context: buffers and nodes are allocated
> + * with the lock released.
> + *
> + * Return: 0 upon success, else the error number: -EBUSY if a generic sysfs
> + * read is in progress, -EINVAL if the sink is not enabled in sysfs mode or
> + * a buffer is of the reserved buffer mode, or the error of the allocation.
> + * The live sysfs_buf is never freed on failure.
> + */
> +int tmc_create_etr_buf_list(struct tmc_drvdata *drvdata, int num_nodes)
> +{
> + struct etr_buf_node *new_node;
> + struct etr_buf *sysfs_buf, *live_buf = NULL;
> + unsigned long flags;
> + size_t size = drvdata->size;
> + int i = 0, ret = 0;
> +
> + /* We don't need a list if there is only one node */
> + if (num_nodes < 2)
> + return -EINVAL;
> +
> + /*
> + * All the etr_buf of the reserved mode are mapped to the same reserved
> + * region, so they can't be used as separate buffers of the list.
> + */
> + if (drvdata->etr_mode == ETR_MODE_RESRV)
> + return -EINVAL;
> +
> + /*
> + * We expect that sysfs_buf in drvdata has already been allocated.
> + * Wrap the live sysfs_buf into the first node so the captured trace
> + * data is preserved. Take the sysfs_buf and add the node under the
> + * lock, so that the ETR sink enable path sees a non-empty list and
> + * doesn't replace the buffer.
> + */
> + new_node = kzalloc_obj(*new_node, GFP_KERNEL);
> + if (!new_node)
> + return -ENOMEM;
Since we know we need num_node entries at max, could we not allocate
them in oneshot (kcalloc()) and free the unused ones at the end ?
> +
> + raw_spin_lock_irqsave(&drvdata->spinlock, flags);
> + /* The sysfs_buf is in use by a sysfs read session */
> + if (drvdata->reading) {
> + raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
> + kfree(new_node);
> + return -EBUSY;
This pattern is repeating quite a lot, do you think this can be a single
exit from the function for such cases, something like goto err_unlock;
> + }
> +
> + /*
> + * The sink enable path reuses or frees the sysfs_buf of a sink which
> + * isn't enabled, so only wrap it while the sink is enabled in sysfs mode.
> + */
> + if (coresight_get_mode(drvdata->csdev) != CS_MODE_SYSFS) {
> + raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
> + kfree(new_node);
> + return -EINVAL;
2
> + }
> +
> + if (drvdata->sysfs_buf) {
> + /* The mode may have been changed since the sink was enabled */
> + if (drvdata->sysfs_buf->mode == ETR_MODE_RESRV) {
> + raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
> + kfree(new_node);
> + return -EINVAL;
3
> + }
> +
> + live_buf = drvdata->sysfs_buf;
> + /* Keep the buffers of the list in the size of the live one */
> + size = live_buf->size;
> + new_node->sysfs_buf = live_buf;
> + new_node->is_free = false;
> + list_add(&new_node->link, &drvdata->etr_buf_list);
> + new_node = NULL;
> + i++;
> + }
> + raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
> + /* Free the node if there is no live sysfs_buf to wrap */
> + kfree(new_node);
> +
> + while (i < num_nodes) {
> + new_node = kzalloc_obj(*new_node, GFP_KERNEL);
> + if (!new_node) {
> + ret = -ENOMEM;
> + break;
> + }
> +
> + /* Allocate the buffer with the lock released */
> + sysfs_buf = tmc_alloc_etr_buf(drvdata, size, 0, cpu_to_node(0), NULL);
> + if (IS_ERR(sysfs_buf)) {
> + kfree(new_node);
> + ret = PTR_ERR(sysfs_buf);
> + break;
> + }
> +
> + /* The buffer mode may have been changed to the reserved mode */
> + if (sysfs_buf->mode == ETR_MODE_RESRV) {
> + tmc_etr_free_sysfs_buf(sysfs_buf);
> + kfree(new_node);
> + ret = -EINVAL;
> + break;
> + }
> +
> + new_node->sysfs_buf = sysfs_buf;
> + /*
> + * The drvdata->sysfs_buf write and the list update need the
> + * spinlock, to serialise against the ETR sink enable/disable
> + * paths.
> + */
> + raw_spin_lock_irqsave(&drvdata->spinlock, flags);
> + /* We don't have an available sysfs_buf in drvdata, set one up */
> + if (!drvdata->sysfs_buf) {
> + drvdata->sysfs_buf = sysfs_buf;
> + new_node->is_free = false;
Is this supposed to be done in enable ?
> + } else {
> + new_node->is_free = true;
> + }
> + list_add_tail(&new_node->link, &drvdata->etr_buf_list);
> + raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
Instead of adding every node as we go, could we maintain a local list
and add that to the the etr_buf_list at the end of all the allocations
and when we are sure that things are still sane to do ?
Set all new_node->free = true and when we get to add the local list
set the sys_buf with the first entry and mark it false.
> + i++;
> + }
> +
> + /*
> + * Clean the list if there is an error, but keep the live sysfs_buf even
> + * if the sink was disabled meanwhile, as it holds the captured trace data.
> + */
> + if (ret)
> + __tmc_clean_etr_buf_list(drvdata, live_buf);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(tmc_create_etr_buf_list);
> +
> int tmc_read_prepare_etr(struct tmc_drvdata *drvdata)
> {
> int ret = 0;
> @@ -1928,7 +2128,8 @@ int tmc_read_prepare_etr(struct tmc_drvdata *drvdata)
> return -EINVAL;
>
> raw_spin_lock_irqsave(&drvdata->spinlock, flags);
> - if (drvdata->reading) {
> + /* The sysfs_buf is owned by the etr_buf_list */
> + if (drvdata->reading || !list_empty(&drvdata->etr_buf_list)) {
> ret = -EBUSY;
> goto out;
> }
> diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracing/coresight/coresight-tmc.h
> index 319a354ede9f..7c604b9f92e5 100644
> --- a/drivers/hwtracing/coresight/coresight-tmc.h
> +++ b/drivers/hwtracing/coresight/coresight-tmc.h
> @@ -208,6 +208,20 @@ struct tmc_resrv_buf {
> s64 len;
> };
>
> +/**
> + * struct etr_buf_node - node of the etr_buf_list
> + * @sysfs_buf: Allocated sysfs_buf.
> + * @is_free: Indicates whether the buffer is free to choose.
super minor nit: Does this mean the buffer is available for tracing ?
Simply "free" is good enough. Or choose inverted logic "live" or "busy"
Suzuki
> + * @pos: Offset to the start of the buffer.
> + * @link: list_head of the node.
> + */
> +struct etr_buf_node {
> + struct etr_buf *sysfs_buf;
> + bool is_free;
> + loff_t pos;
> + struct list_head link;
> +};
> +
> /**
> * struct tmc_drvdata - specifics associated to an TMC component
> * @atclk: optional clock for the core parts of the TMC.
> @@ -245,6 +259,7 @@ struct tmc_resrv_buf {
> * (after crash) by default.
> * @crash_mdata: Reserved memory for storing tmc crash metadata.
> * Used by ETR/ETF.
> + * @etr_buf_list: List that is used to manage allocated etr_buf.
> */
> struct tmc_drvdata {
> struct clk *atclk;
> @@ -275,6 +290,7 @@ struct tmc_drvdata {
> struct etr_buf *perf_buf;
> struct tmc_resrv_buf resrv_buf;
> struct tmc_resrv_buf crash_mdata;
> + struct list_head etr_buf_list;
> };
>
> struct etr_buf_operations {
> @@ -447,5 +463,7 @@ struct etr_buf *tmc_etr_get_buffer(struct coresight_device *csdev,
> enum cs_mode mode,
> struct coresight_path *path);
> extern const struct attribute_group coresight_etr_group;
> +void tmc_clean_etr_buf_list(struct tmc_drvdata *drvdata);
> +int tmc_create_etr_buf_list(struct tmc_drvdata *drvdata, int num_nodes);
>
> #endif
>
On Tue, Nov 17, 2026 at 08:50:00PM +0200, Igor Velkov wrote:
> On Tue, Nov 17, 2026 at 06:32:41PM +0000, Leo Yan wrote:
> > Could we explore a hook in the CPU hard lockup detector? Seems this
> > module is more relevant to hard lockup rather than panic.
>
> Yes, that fits better. The hard lockup detector reports a CPU that
> missed its watchdog hrtimer interrupts, so it runs with IRQs masked and
> is not in an idle powerdown. The backtrace request then names the CPUs
> that did not answer ("these CPUS still haven't responded"). I would
> sample PCSR only for those, from a hook at that point, and leave the
> panic notifier alone. Does that sound right?
Yes, sampling CPUs that do not respond to the backtrace request sounds
reasonable.
The hard lockup detector can also call panic(), so we should avoid a
second dump from the panic notifier. After hook with hard-lockup
diagnosis, then makes sense to remove that panic notifier.
For CPU power state, could we take a cautious approach in the driver?
1) If idle_cpu(cpu) == 0, sample the CPU directly.
2) If idle_cpu(cpu) == 1, follow the existing flow to request
power-up before sampling.
3) Consider adding a module parameter, such as skip_idle, for
hardware that doesn't support or honour EDPRCR_COREPURQ. This
would allow the driver to sample only active CPUs.
Thanks,
Leo
On 18/11/2026 07:01, Jie Gan wrote:
> The traceNoC (Trace Network-On-Chip) node on kaanapali, sm8750 and glymur
> is described with the "qcom,coresight-tnoc", "arm,primecell" compatible,
> so the device is created on the AMBA bus. To bind an AMBA device, the bus
> reads the peripheral and component ID registers (PID/CID) at the top of
> the device's register block and matches them against the primecell ID.
> On these platforms the Component ID returned by the hardware is
> 0x00000000 instead of a valid AMBA Component ID, so the AMBA probe fails
> and the traceNoC is left stuck in deferred probe indefinitely, leaving
> its trace path unavailable.
>
> This series fixes the issue in the simplest way: keep the existing
> "arm,primecell" compatible and add the "arm,primecell-periphid" property
> to the traceNoC nodes. The AMBA bus then uses the peripheral ID given in
> the device tree instead of reading it from the device, which lets the
> traceNoC probe on this hardware. No binding or driver change is needed.
>
> History of this issue:
>
> This is an alternative to the series that fixes the same problem by
> moving the traceNoC onto the platform bus instead of AMBA.
>
> Latest revision of that series:
> https://lore.kernel.org/all/20261110-fix-trace-noc-probe-issue-v7-0-2f06905…
>
> That approach requires a binding change and a driver change in addition
> to the DT changes. This series instead keeps the hardware described as an
> AMBA device and works around the invalid Component ID with the existing
> "arm,primecell-periphid" property, so only the device tree is touched.
>
> Signed-off-by: Jie Gan <jie.gan(a)oss.qualcomm.com>
> ---
> Jie Gan (4):
> dt-bindings: arm: coresight-tnoc: Allow arm,primecell-periphid
> arm64: dts: qcom: kaanapali: add periphid for traceNoC
> arm64: dts: qcom: sm8750: add periphid for traceNoC
> arm64: dts: qcom: glymur: use Aggregator TNOC compatible
>
> Documentation/devicetree/bindings/arm/qcom,coresight-tnoc.yaml | 5 ++++-
> arch/arm64/boot/dts/qcom/glymur.dtsi | 8 +++++---
> arch/arm64/boot/dts/qcom/kaanapali.dtsi | 2 ++
> arch/arm64/boot/dts/qcom/sm8750.dtsi | 2 ++
> 4 files changed, 13 insertions(+), 4 deletions(-)
> ---
> base-commit: 7cfbf79c66c63e807ea452abf0546e6f6d6833a6
> change-id: 20261118-fix-tracenoc-probe-bf8025cad2ca
>
> Best regards,
I assume this would go through the qcom platform tree, as this is mostly
DTS changes.
For the series,
Acked-by: Suzuki K Poulose <suzuki.poulose(a)arm.com>
On Sat, Nov 14, 2026 at 02:08:16AM +0200, Igor Velkov wrote:
> The cpu-debug panic notifier reads every possible CPU after COREPURQ;
> on RK3399 on the crash path without pseudo-NMI it hit an SError on the
> first CPU that was off.
Seems the SoC does not honor COREPURQ. The current driver relies on an
accessible debug interface; these platform limitations are already
documented in [1].
> So I would send:
> 1. cpu-debug notifier: online CPUs other than the panic CPU, read only
> with PU=1, R=0 and DLK=0, no COREPURQ;
Sampling only CPUs still online after the stop request may help, but the
online mask does not guarantee register accessibility. A late stop
acknowledgement can race with that check, and an offline CPU may still be
running (or stuck) in firmware - the driver is also helpful for CPU stuck
not in kernel.
We also need to consider FEAT_DoPD: EDPRCR and EDPRSR move from debug
power domain into the Core power domain, and COREPURQ is absent. We then
need another mechanism before accessing PCSR register.
I would check a bit if any suggestions for safely access registers.
Otherwise, we may need to explore kernel states as you suggested (not
only cpu online but also idle states).
> 2. PMPCSR when EDDEVID.PCSample is 0 and PMDEVID.PCSample is not.
This is fine for me.
> Panic notifiers run after the stop only with crash_kexec_post_notifiers;
> with a crash kernel loaded and without it, they do not run at all. Is
> that acceptable, or would you rather see a hook in the crash stop path?
I agree that the notifier need improvement.
Could we explore a hook in the CPU hard lockup detector? Seems this
module is more relevant to hard lockup rather than panic.
Thanks,
Leo
[1] Documentation/trace/coresight/coresight-cpu-debug.rst