From: "Dixit, Ashutosh" <ashutosh.dixit@intel.com>
To: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Cc: <igt-dev@lists.freedesktop.org>
Subject: Re: [PATCH i-g-t v2 4/4] tests/intel/xe_oa: Add an option to capture register accesses in ftrace
Date: Tue, 26 Aug 2025 16:52:14 -0700 [thread overview]
Message-ID: <87ecsxmyj5.wl-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <20250826224256.510692-10-umesh.nerlige.ramappa@intel.com>
On Tue, 26 Aug 2025 15:43:01 -0700, Umesh Nerlige Ramappa wrote:
>
> Capture ftrace with the --trace option when needed. This is not intended
> to run as default, but more of a debug functionality when manually
> running individual tests.
>
> v2: (Ashutosh)
> - Update commit title
> - Check ftrace buffer size sooner. Use defaults
> - s/Mb/MB
> - x 1024 instead of x 1000
Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
>
> Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
> ---
> tests/intel/xe_oa.c | 63 ++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 62 insertions(+), 1 deletion(-)
>
> diff --git a/tests/intel/xe_oa.c b/tests/intel/xe_oa.c
> index 24442e4b83c6..2fb7c332226e 100644
> --- a/tests/intel/xe_oa.c
> +++ b/tests/intel/xe_oa.c
> @@ -307,6 +307,8 @@ static struct oa_format lnl_oa_formats[XE_OA_FORMAT_MAX] = {
> .bc_report = 0 },
> };
>
> +static bool oa_trace = false;
> +static uint32_t oa_trace_buf_mb = 1;
> static int drm_fd = -1;
> static int sysfs = -1;
> static int pm_fd = -1;
> @@ -389,6 +391,31 @@ static u32 get_stream_status(int fd)
> return status.oa_status;
> }
>
> +static void enable_trace_log(void)
> +{
> + char cmd[64] = {0};
> +
> + if (!oa_trace)
> + return;
> +
> + snprintf(cmd, sizeof(cmd) - 1, "echo %d > /sys/kernel/debug/tracing/buffer_size_kb", oa_trace_buf_mb * 1024);
> + system(cmd);
> + system("echo 0 > /sys/kernel/debug/tracing/tracing_on");
> + system("echo > /sys/kernel/debug/tracing/trace");
> + system("echo 1 > /sys/kernel/debug/tracing/events/xe/enable");
> + system("echo 1 > /sys/kernel/debug/tracing/events/xe/xe_reg_rw/enable");
> + system("echo 1 > /sys/kernel/debug/tracing/tracing_on");
> +}
> +
> +static void disable_trace_log(void)
> +{
> + if (!oa_trace)
> + return;
> +
> + system("echo 0 > /sys/kernel/debug/tracing/tracing_on");
> + system("cat /sys/kernel/debug/tracing/trace");
> +}
> +
> static void
> dump_report(const uint32_t *report, uint32_t size, const char *message) {
> uint32_t i;
> @@ -4958,7 +4985,39 @@ static const char *xe_engine_class_name(uint32_t engine_class)
> igt_require_f(hwe, "no render engine\n"); \
> igt_dynamic_f("rcs-%d", hwe->engine_instance)
>
> -igt_main
> +static int opt_handler(int opt, int opt_index, void *data)
> +{
> + uint32_t tmp;
> +
> + switch (opt) {
> + case 'b':
> + tmp = strtoul(optarg, NULL, 0);
> + if (tmp <= 20 && tmp >= 1)
> + oa_trace_buf_mb = tmp;
> +
> + igt_debug("Trace buffer %d Mb\n", oa_trace_buf_mb);
> + break;
> + case 't':
> + oa_trace = true;
> + igt_debug("Trace enabled\n");
> + break;
> + default:
> + return IGT_OPT_HANDLER_ERROR;
> + }
> +
> + return IGT_OPT_HANDLER_SUCCESS;
> +}
> +
> +static const char *help_str = " --trace | -t\t\tEnable ftrace\n"
> + " --trace_buf_size_mb | -b\t\tSet ftrace buffer size in MB (default = 1, min = 1, max = 20)\n";
> +
> +static struct option long_options[] = {
> + {"trace", 0, 0, 't'},
> + {"trace_buf_size_mb", 0, 0, 'b'},
> + { NULL, 0, 0, 0 }
> +};
> +
> +igt_main_args("b:t", long_options, help_str, opt_handler, NULL)
> {
> const struct sync_section {
> const char *name;
> @@ -5002,6 +5061,7 @@ igt_main
> */
> igt_assert_eq(drm_fd, -1);
>
> + enable_trace_log();
> drm_fd = drm_open_driver(DRIVER_XE);
> xe_dev = xe_device_get(drm_fd);
>
> @@ -5235,5 +5295,6 @@ igt_main
> intel_xe_perf_free(intel_xe_perf);
>
> drm_close_driver(drm_fd);
> + disable_trace_log();
> }
> }
> --
> 2.43.0
>
next prev parent reply other threads:[~2025-08-26 23:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-26 22:42 [PATCH i-g-t v2 0/4] IGT xe_oa fixes, debug and new test Umesh Nerlige Ramappa
2025-08-26 22:42 ` [PATCH i-g-t v2 1/4] tests/intel/xe_oa: Fix report dumps in sanity check Umesh Nerlige Ramappa
2025-08-26 23:49 ` Dixit, Ashutosh
2025-08-26 22:42 ` [PATCH i-g-t v2 2/4] tests/intel/xe_oa: Fix waiting for mmaped reports Umesh Nerlige Ramappa
2025-08-26 22:43 ` [PATCH i-g-t v2 3/4] tests/intel/xe_oa: Add a test for tail address wrap Umesh Nerlige Ramappa
2025-08-27 18:38 ` Dixit, Ashutosh
2025-08-27 23:39 ` Umesh Nerlige Ramappa
2025-08-28 2:30 ` Dixit, Ashutosh
2025-08-28 8:21 ` Kamil Konieczny
2025-08-26 22:43 ` [PATCH i-g-t v2 4/4] tests/intel/xe_oa: Add an option to capture register accesses in ftrace Umesh Nerlige Ramappa
2025-08-26 23:52 ` Dixit, Ashutosh [this message]
2025-08-29 22:34 ` Umesh Nerlige Ramappa
2025-08-26 23:22 ` ✓ Xe.CI.BAT: success for IGT xe_oa fixes, debug and new test (rev2) Patchwork
2025-08-26 23:29 ` ✓ i915.CI.BAT: " Patchwork
2025-08-27 10:51 ` ✗ Xe.CI.Full: failure " Patchwork
2025-08-27 11:39 ` ✗ i915.CI.Full: " Patchwork
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=87ecsxmyj5.wl-ashutosh.dixit@intel.com \
--to=ashutosh.dixit@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=umesh.nerlige.ramappa@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.