From: James Clark <james.clark@linaro.org>
To: Leo Yan <leo.yan@arm.com>
Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Mike Leach <mike.leach@linaro.org>,
Anshuman Khandual <anshuman.khandual@arm.com>,
Yeoreum Yun <yeoreum.yun@arm.com>, Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Tamas Petz <tamas.petz@arm.com>,
Tamas Zsoldos <tamas.zsoldos@arm.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>
Subject: Re: [PATCH 06/19] coresight: trbe: Refactor syndrome decoding
Date: Tue, 9 Dec 2025 13:17:50 +0000 [thread overview]
Message-ID: <1c1092e6-aa5d-4bb1-84e5-81151a02cc6f@linaro.org> (raw)
In-Reply-To: <65c84357-0bda-454f-88c3-623b3ff9d29d@arm.com>
On 02/12/2025 11:06 am, Suzuki K Poulose wrote:
> Hi Leo
>
> A couple of minor nits below. Otherwise looks like a nice cleanup
>
>
> On 01/12/2025 11:21, Leo Yan wrote:
>> It gives priority to TRBSR_EL1.EA (external abort); an external abort
>> will immediately bail out and return an error.
>>
>> Next, the syndrome decoding is refactored based on two levels of
>> information: the EC (Event Class) bits and the BSC (Trace Buffer Status
>> Code) bits.
>>
>> If TRBSR_EL1.EC==0b000000, the driver continues parsing TRBSR_EL1.BSC to
>> identify the specific trace buffer event. Otherwise, any non-zero
>> TRBSR_EL1.EC is treated as an error.
>>
>> For error cases, the driver prints an error string and dumps registers
>> for debugging.
>
> minor nit: Please avoid describing the code, which cod does well.
> Briefly mention what you are doing, giving any additional contexts
> that may not be evident from the code.
>
> e.g:
>
> "Add support for decoding the syndrome for TRBE, providing a verbose
> description of the code for Fatal/unhandled events.
> While at it add the new definitions from the latest Arm ARM for
> EC and BSC"
>
>
>
>
>>
>> No additional checks are required for wrap mode beyond verifying the
>> TRBSR_EL1.WRAP bit, even on units with overwrite errata, as this bit
>
>
>> reliably indicates a buffer wrap.
>>
>> Signed-off-by: Leo Yan <leo.yan@arm.com>
>> ---
>> drivers/hwtracing/coresight/coresight-trbe.c | 60 ++++++++++++++++++
>> +++-------
>> drivers/hwtracing/coresight/coresight-trbe.h | 8 ++--
>> 2 files changed, 51 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/
>> hwtracing/coresight/coresight-trbe.c
>> index
>> 9e565122816949b37b8ff5e4ba04cfbc317c6f25..28e2bfa68074f19ccaa4a737d00af577aea818fe 100644
>> --- a/drivers/hwtracing/coresight/coresight-trbe.c
>> +++ b/drivers/hwtracing/coresight/coresight-trbe.c
>> @@ -643,29 +643,61 @@ static void trbe_enable_hw(struct trbe_buf *buf)
>> static enum trbe_fault_action trbe_get_fault_act(struct
>> perf_output_handle *handle,
>> u64 trbsr)
>> {
>> + const char *err_str;
>> int ec = get_trbe_ec(trbsr);
>> int bsc = get_trbe_bsc(trbsr);
>> - struct trbe_buf *buf = etm_perf_sink_config(handle);
>> - struct trbe_cpudata *cpudata = buf->cpudata;
>> WARN_ON(is_trbe_running(trbsr));
>> - if (is_trbe_trg(trbsr) || is_trbe_abort(trbsr))
>> - return TRBE_FAULT_ACT_FATAL;
>> - if ((ec == TRBE_EC_STAGE1_ABORT) || (ec == TRBE_EC_STAGE2_ABORT))
>> - return TRBE_FAULT_ACT_FATAL;
>> + if (is_trbe_abort(trbsr)) {
>> + err_str = "External abort";
>> + goto out_fatal;
>> + }
>> - /*
>> - * If the trbe is affected by TRBE_WORKAROUND_OVERWRITE_FILL_MODE,
>> - * it might write data after a WRAP event in the fill mode.
>> - * Thus the check TRBPTR == TRBBASER will not be honored.
>> - */
>> - if ((is_trbe_wrap(trbsr) && (ec == TRBE_EC_OTHERS) && (bsc ==
>> TRBE_BSC_FILLED)) &&
>> - (trbe_may_overwrite_in_fill_mode(cpudata) ||
>> - get_trbe_write_pointer() == get_trbe_base_pointer()))
>> + switch (ec) {
>> + case TRBE_EC_OTHERS:
>> + break;
>> + case TRBE_EC_BUF_MGMT_IMPL:
>> + err_str = "Unexpected implemented management";
>
> minor nit: "Unexpected IMPDEF buffer management event"
>
>
> Suzuki
>
>> + goto out_fatal;
>> + case TRBE_EC_GP_CHECK_FAULT:
>> + err_str = "Granule Protection Check fault";
>> + goto out_fatal;
>> + case TRBE_EC_STAGE1_ABORT:
>> + err_str = "Stage 1 data abort";
>> + goto out_fatal;
>> + case TRBE_EC_STAGE2_ABORT:
>> + err_str = "Stage 2 data abort";
>> + goto out_fatal;
>> + default:
>> + err_str = "Unknown error code";
>> + goto out_fatal;
>> + }
>> +
>> + switch (bsc) {
>> + case TRBE_BSC_NOT_STOPPED:
>> + break;
>> + case TRBE_BSC_FILLED:
>> + break;
>> + case TRBE_BSC_TRIGGERED:
>> + err_str = "Unexpected trigger status";
>> + goto out_fatal;
>> + default:
>> + err_str = "Unexpected buffer status code";
>> + goto out_fatal;
>> + }
>> +
>> + if (is_trbe_wrap(trbsr))
>> return TRBE_FAULT_ACT_WRAP;
>> return TRBE_FAULT_ACT_SPURIOUS;
>> +
>> +out_fatal:
>> + pr_err_ratelimited("%s on CPU %d [TRBSR=0x%016llx,
>> TRBPTR=0x%016llx, TRBLIMITR=0x%016llx]\n",
>> + err_str, smp_processor_id(), trbsr,
>> + read_sysreg_s(SYS_TRBPTR_EL1),
>> + read_sysreg_s(SYS_TRBLIMITR_EL1));
Don't you need to use %p to not leak pointers?
>> + return TRBE_FAULT_ACT_FATAL;
>> }
>> static unsigned long trbe_get_trace_size(struct perf_output_handle
>> *handle,
>> diff --git a/drivers/hwtracing/coresight/coresight-trbe.h b/drivers/
>> hwtracing/coresight/coresight-trbe.h
>> index
>> 45202c48accec7c86ba56130e2737bc2d1830fae..d7f7cd763c0c7139cf322b7336ee563073e3bea0 100644
>> --- a/drivers/hwtracing/coresight/coresight-trbe.h
>> +++ b/drivers/hwtracing/coresight/coresight-trbe.h
>> @@ -35,9 +35,11 @@ static inline bool is_trbe_enabled(void)
>> return trblimitr & TRBLIMITR_EL1_E;
>> }
>> -#define TRBE_EC_OTHERS 0
>> -#define TRBE_EC_STAGE1_ABORT 36
>> -#define TRBE_EC_STAGE2_ABORT 37
>> +#define TRBE_EC_OTHERS 0x0
>> +#define TRBE_EC_GP_CHECK_FAULT 0X1e
>> +#define TRBE_EC_BUF_MGMT_IMPL 0x1f
>> +#define TRBE_EC_STAGE1_ABORT 0x24
>> +#define TRBE_EC_STAGE2_ABORT 0x25
I know some were already defined here, but this should probably be an
enum in sysreg.
>> static inline int get_trbe_ec(u64 trbsr)
>> {
>>
>
next prev parent reply other threads:[~2025-12-09 13:17 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-01 11:21 [PATCH 00/19] coresight: trbe: Support trigger and circle buffer modes Leo Yan
2025-12-01 11:21 ` [PATCH 01/19] coresight: trbe: Use helpers for checking errata Leo Yan
2025-12-04 12:08 ` Anshuman Khandual
2025-12-01 11:21 ` [PATCH 02/19] coresight: trbe: Remove redundant disable operation Leo Yan
2025-12-04 12:25 ` Anshuman Khandual
2025-12-01 11:21 ` [PATCH 03/19] coresight: trbe: Remove buffer disabling in trbe_handle_overflow() Leo Yan
2025-12-04 12:31 ` Anshuman Khandual
2025-12-01 11:21 ` [PATCH 04/19] coresight: trbe: Remove set_trbe_disabled() from the enable flow Leo Yan
2025-12-04 12:43 ` Anshuman Khandual
2025-12-04 13:25 ` Leo Yan
2025-12-01 11:21 ` [PATCH 05/19] coresight: trbe: Refactor status clearing Leo Yan
2025-12-04 12:57 ` Anshuman Khandual
2025-12-09 15:29 ` Leo Yan
2025-12-01 11:21 ` [PATCH 06/19] coresight: trbe: Refactor syndrome decoding Leo Yan
2025-12-02 11:06 ` Suzuki K Poulose
2025-12-02 14:24 ` Leo Yan
2025-12-09 13:17 ` James Clark [this message]
2025-12-09 16:06 ` Leo Yan
2025-12-05 4:10 ` Anshuman Khandual
2025-12-09 15:57 ` Leo Yan
2025-12-01 11:21 ` [PATCH 07/19] coresight: trbe: Refactor AUX flag setting Leo Yan
2025-12-02 11:15 ` Suzuki K Poulose
2025-12-02 14:21 ` Leo Yan
2025-12-09 13:37 ` James Clark
2025-12-10 15:43 ` Leo Yan
2025-12-12 14:50 ` James Clark
2025-12-12 15:27 ` Leo Yan
2025-12-12 15:52 ` James Clark
2025-12-01 11:21 ` [PATCH 08/19] coresight: trbe: Use PERF_AUX_FLAG_PARTIAL instead of PERF_AUX_FLAG_COLLISION Leo Yan
2025-12-05 4:28 ` Anshuman Khandual
2025-12-09 13:40 ` James Clark
2025-12-10 16:19 ` Leo Yan
2025-12-01 11:21 ` [PATCH 09/19] coresight: trbe: Add fault action argument to trbe_handle_overflow() Leo Yan
2025-12-01 11:22 ` [PATCH 10/19] coresight: trbe: Always check fault action when updating buffer Leo Yan
2025-12-02 12:00 ` Suzuki K Poulose
2025-12-01 11:22 ` [PATCH 11/19] coresight: trbe: Apply overwrite erratum for only wrap event Leo Yan
2025-12-02 12:05 ` Suzuki K Poulose
2025-12-02 16:56 ` Leo Yan
2025-12-02 17:12 ` Leo Yan
2025-12-01 11:22 ` [PATCH 12/19] coresight: trbe: Calculate size for buffer wrapping Leo Yan
2025-12-01 11:22 ` [PATCH 13/19] coresight: trbe: Remove misleading comment Leo Yan
2025-12-01 11:22 ` [PATCH 14/19] coresight: trbe: Refactor compute_trbe_buffer_limit() Leo Yan
2025-12-01 11:22 ` [PATCH 15/19] coresight: trbe: Add static key for bypassing trigger mode Leo Yan
2025-12-02 12:10 ` Suzuki K Poulose
2025-12-01 11:22 ` [PATCH 16/19] coresight: trbe: Support " Leo Yan
2025-12-01 11:22 ` [PATCH 17/19] coresight: trbe: Enable circle mode for snapshot Leo Yan
2025-12-01 11:22 ` [PATCH 18/19] coresight: trbe: Add kunit tests Leo Yan
2025-12-01 11:22 ` [PATCH 19/19] perf: cs-etm: Set watermark for AUX trace Leo Yan
2025-12-05 4:48 ` Anshuman Khandual
2025-12-09 14:54 ` James Clark
2025-12-10 2:22 ` Anshuman Khandual
2025-12-05 4:53 ` [PATCH 00/19] coresight: trbe: Support trigger and circle buffer modes Anshuman Khandual
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1c1092e6-aa5d-4bb1-84e5-81151a02cc6f@linaro.org \
--to=james.clark@linaro.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=anshuman.khandual@arm.com \
--cc=coresight@lists.linaro.org \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=leo.yan@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mike.leach@linaro.org \
--cc=namhyung@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=tamas.petz@arm.com \
--cc=tamas.zsoldos@arm.com \
--cc=will@kernel.org \
--cc=yeoreum.yun@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).