]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf: tools: cs-etm: Fix print issue for Coresight debug in ETE/TRBE trace
authorMike Leach <mike.leach@arm.com>
Wed, 18 Mar 2026 10:36:39 +0000 (10:36 +0000)
committerNamhyung Kim <namhyung@kernel.org>
Wed, 18 Mar 2026 18:47:24 +0000 (11:47 -0700)
Building perf with CORESIGHT=1 and the optional CSTRACE_RAW=1 enables
additional debug printing of raw trace data when using command:-
perf report --dump.

This raw trace prints the CoreSight formatted trace frames, which may be
used to investigate suspected issues with trace quality / corruption /
decode.

These frames are not present in ETE + TRBE trace.
This fix removes the unnecessary call to print these frames.

This fix also rationalises implementation - original code had helper
function that unnecessarily repeated initialisation calls that had
already been made.

Due to an addtional fault with the OpenCSD library, this call when ETE/TRBE
are being decoded will cause a segfault in perf. This fix also prevents
that problem for perf using older (<= 1.8.0 version) OpenCSD libraries.

Fixes: 68ffe3902898 ("perf tools: Add decoder mechanic to support dumping trace data")
Reported-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: Mike Leach <mike.leach@arm.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c

index 3050fe2126665b00c77ba3ac6b6f74324100f26b..8592a778b26a4f0fdd64bf7620e1c96b54cb4b72 100644 (file)
@@ -237,46 +237,24 @@ cs_etm_decoder__init_def_logger_printing(struct cs_etm_decoder_params *d_params,
                                              (void *)decoder,
                                              cs_etm_decoder__print_str_cb);
        if (ret != 0)
-               ret = -1;
-
-       return 0;
-}
+               return -1;
 
 #ifdef CS_LOG_RAW_FRAMES
-static void
-cs_etm_decoder__init_raw_frame_logging(struct cs_etm_decoder_params *d_params,
-                                      struct cs_etm_decoder *decoder)
-{
-       /* Only log these during a --dump operation */
-       if (d_params->operation == CS_ETM_OPERATION_PRINT) {
-               /* set up a library default logger to process the
-                *  raw frame printer we add later
-                */
-               ocsd_def_errlog_init(OCSD_ERR_SEV_ERROR, 1);
-
-               /* no stdout / err / file output */
-               ocsd_def_errlog_config_output(C_API_MSGLOGOUT_FLG_NONE, NULL);
-
-               /* set the string CB for the default logger,
-                * passes strings to perf print logger.
-                */
-               ocsd_def_errlog_set_strprint_cb(decoder->dcd_tree,
-                                               (void *)decoder,
-                                               cs_etm_decoder__print_str_cb);
-
+       /*
+        * Only log raw frames if --dump operation and hardware is actually
+        * generating formatted CoreSight trace frames
+        */
+       if ((d_params->operation == CS_ETM_OPERATION_PRINT) &&
+           (d_params->formatted == true)) {
                /* use the built in library printer for the raw frames */
-               ocsd_dt_set_raw_frame_printer(decoder->dcd_tree,
-                                             CS_RAW_DEBUG_FLAGS);
+               ret = ocsd_dt_set_raw_frame_printer(decoder->dcd_tree,
+                                                   CS_RAW_DEBUG_FLAGS);
+               if (ret != 0)
+                       return -1;
        }
-}
-#else
-static void
-cs_etm_decoder__init_raw_frame_logging(
-               struct cs_etm_decoder_params *d_params __maybe_unused,
-               struct cs_etm_decoder *decoder __maybe_unused)
-{
-}
 #endif
+       return 0;
+}
 
 static ocsd_datapath_resp_t
 cs_etm_decoder__do_soft_timestamp(struct cs_etm_queue *etmq,
@@ -738,9 +716,6 @@ cs_etm_decoder__new(int decoders, struct cs_etm_decoder_params *d_params,
        if (ret != 0)
                goto err_free_decoder;
 
-       /* init raw frame logging if required */
-       cs_etm_decoder__init_raw_frame_logging(d_params, decoder);
-
        for (i = 0; i < decoders; i++) {
                ret = cs_etm_decoder__create_etm_decoder(d_params,
                                                         &t_params[i],