From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: John.C.Harrison@Intel.com, Intel-Xe@Lists.FreeDesktop.Org
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>,
Jani Nikula <jani.nikula@intel.com>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v9 07/11] drm/print: Introduce drm_line_printer
Date: Fri, 4 Oct 2024 15:57:06 +0200 [thread overview]
Message-ID: <35fb9448-4742-4d2b-8eca-1654dd8e235c@linux.intel.com> (raw)
In-Reply-To: <20241003004611.2323493-8-John.C.Harrison@Intel.com>
I don't think there's an immediate use for this in drm-misc, so its
easier to merge through xe. :-)
Acked-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Den 2024-10-03 kl. 02:46, skrev John.C.Harrison@Intel.com:
> From: Michal Wajdeczko <michal.wajdeczko@intel.com>
>
> This drm printer wrapper can be used to increase the robustness of
> the captured output generated by any other drm_printer to make sure
> we didn't lost any intermediate lines of the output by adding line
> numbers to each output line. Helpful for capturing some crash data.
>
> v2: Extended short int counters to full int (JohnH)
>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Cc: John Harrison <John.C.Harrison@Intel.com>
> Cc: dri-devel@lists.freedesktop.org
> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> ---
> drivers/gpu/drm/drm_print.c | 14 ++++++++
> include/drm/drm_print.h | 64 +++++++++++++++++++++++++++++++++++++
> 2 files changed, 78 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c
> index 0081190201a7..08cfea04e22b 100644
> --- a/drivers/gpu/drm/drm_print.c
> +++ b/drivers/gpu/drm/drm_print.c
> @@ -235,6 +235,20 @@ void __drm_printfn_err(struct drm_printer *p, struct va_format *vaf)
> }
> EXPORT_SYMBOL(__drm_printfn_err);
>
> +void __drm_printfn_line(struct drm_printer *p, struct va_format *vaf)
> +{
> + unsigned int counter = ++p->line.counter;
> + const char *prefix = p->prefix ?: "";
> + const char *pad = p->prefix ? " " : "";
> +
> + if (p->line.series)
> + drm_printf(p->arg, "%s%s%u.%u: %pV",
> + prefix, pad, p->line.series, counter, vaf);
> + else
> + drm_printf(p->arg, "%s%s%u: %pV", prefix, pad, counter, vaf);
> +}
> +EXPORT_SYMBOL(__drm_printfn_line);
> +
> /**
> * drm_puts - print a const string to a &drm_printer stream
> * @p: the &drm printer
> diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
> index d2676831d765..b3906dc04388 100644
> --- a/include/drm/drm_print.h
> +++ b/include/drm/drm_print.h
> @@ -177,6 +177,10 @@ struct drm_printer {
> void *arg;
> const void *origin;
> const char *prefix;
> + struct {
> + unsigned int series;
> + unsigned int counter;
> + } line;
> enum drm_debug_category category;
> };
>
> @@ -187,6 +191,7 @@ void __drm_puts_seq_file(struct drm_printer *p, const char *str);
> void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf);
> void __drm_printfn_dbg(struct drm_printer *p, struct va_format *vaf);
> void __drm_printfn_err(struct drm_printer *p, struct va_format *vaf);
> +void __drm_printfn_line(struct drm_printer *p, struct va_format *vaf);
>
> __printf(2, 3)
> void drm_printf(struct drm_printer *p, const char *f, ...);
> @@ -411,6 +416,65 @@ static inline struct drm_printer drm_err_printer(struct drm_device *drm,
> return p;
> }
>
> +/**
> + * drm_line_printer - construct a &drm_printer that prefixes outputs with line numbers
> + * @p: the &struct drm_printer which actually generates the output
> + * @prefix: optional output prefix, or NULL for no prefix
> + * @series: optional unique series identifier, or 0 to omit identifier in the output
> + *
> + * This printer can be used to increase the robustness of the captured output
> + * to make sure we didn't lost any intermediate lines of the output. Helpful
> + * while capturing some crash data.
> + *
> + * Example 1::
> + *
> + * void crash_dump(struct drm_device *drm)
> + * {
> + * static unsigned int id;
> + * struct drm_printer p = drm_err_printer(drm, "crash");
> + * struct drm_printer lp = drm_line_printer(&p, "dump", ++id);
> + *
> + * drm_printf(&lp, "foo");
> + * drm_printf(&lp, "bar");
> + * }
> + *
> + * Above code will print into the dmesg something like::
> + *
> + * [ ] 0000:00:00.0: [drm] *ERROR* crash dump 1.1: foo
> + * [ ] 0000:00:00.0: [drm] *ERROR* crash dump 1.2: bar
> + *
> + * Example 2::
> + *
> + * void line_dump(struct device *dev)
> + * {
> + * struct drm_printer p = drm_info_printer(dev);
> + * struct drm_printer lp = drm_line_printer(&p, NULL, 0);
> + *
> + * drm_printf(&lp, "foo");
> + * drm_printf(&lp, "bar");
> + * }
> + *
> + * Above code will print::
> + *
> + * [ ] 0000:00:00.0: [drm] 1: foo
> + * [ ] 0000:00:00.0: [drm] 2: bar
> + *
> + * RETURNS:
> + * The &drm_printer object
> + */
> +static inline struct drm_printer drm_line_printer(struct drm_printer *p,
> + const char *prefix,
> + unsigned int series)
> +{
> + struct drm_printer lp = {
> + .printfn = __drm_printfn_line,
> + .arg = p,
> + .prefix = prefix,
> + .line = { .series = series, },
> + };
> + return lp;
> +}
> +
> /*
> * struct device based logging
> *
next prev parent reply other threads:[~2024-10-04 13:57 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-03 0:46 [PATCH v9 00/11] drm/xe/guc: Improve GuC log dumping and add to devcoredump John.C.Harrison
2024-10-03 0:46 ` [PATCH v9 01/11] drm/xe/guc: Remove spurious line feed in debug print John.C.Harrison
2024-10-03 0:46 ` [PATCH v9 02/11] drm/xe/devcoredump: Use drm_puts and already cached local variables John.C.Harrison
2024-10-03 0:46 ` [PATCH v9 03/11] drm/xe/devcoredump: Improve section headings and add tile info John.C.Harrison
2024-12-12 18:17 ` Souza, Jose
2024-12-12 18:59 ` John Harrison
2024-12-12 19:31 ` Souza, Jose
2024-12-12 20:06 ` John Harrison
2024-12-12 20:30 ` Souza, Jose
2024-12-12 20:38 ` John Harrison
2024-10-03 0:46 ` [PATCH v9 04/11] drm/xe/devcoredump: Add ASCII85 dump helper function John.C.Harrison
2024-12-12 17:41 ` Souza, Jose
2024-12-12 18:45 ` Lucas De Marchi
2024-12-12 19:14 ` John Harrison
2024-12-12 20:52 ` Lucas De Marchi
2024-12-12 21:04 ` John Harrison
2024-12-13 0:32 ` Lucas De Marchi
2024-12-13 16:36 ` John Harrison
2024-12-13 17:20 ` Lucas De Marchi
2024-12-13 17:34 ` John Harrison
2024-12-13 14:18 ` Rodrigo Vivi
2024-12-13 16:42 ` John Harrison
2024-10-03 0:46 ` [PATCH v9 05/11] drm/xe/guc: Copy GuC log prior to dumping John.C.Harrison
2024-10-03 0:46 ` [PATCH v9 06/11] drm/xe/guc: Use a two stage dump for GuC logs and add more info John.C.Harrison
2024-10-08 21:18 ` [v9, " Kees Bakker
2024-10-03 0:46 ` [PATCH v9 07/11] drm/print: Introduce drm_line_printer John.C.Harrison
2024-10-04 13:57 ` Maarten Lankhorst [this message]
2024-10-03 0:46 ` [PATCH v9 08/11] drm/xe/guc: Dead CT helper John.C.Harrison
2024-10-03 0:46 ` [PATCH v9 09/11] drm/xe/guc: Dump entire CTB on errors John.C.Harrison
2024-10-03 0:46 ` [PATCH v9 10/11] drm/xe/guc: Add GuC log to devcoredump captures John.C.Harrison
2024-10-03 0:46 ` [PATCH v9 11/11] drm/xe/guc: Add a helper function for dumping GuC log to dmesg John.C.Harrison
2024-10-03 1:15 ` ✓ CI.Patch_applied: success for drm/xe/guc: Improve GuC log dumping and add to devcoredump (rev6) Patchwork
2024-10-03 1:15 ` ✗ CI.checkpatch: warning " Patchwork
2024-10-03 1:17 ` ✓ CI.KUnit: success " Patchwork
2024-10-03 1:28 ` ✓ CI.Build: " Patchwork
2024-10-03 1:30 ` ✓ CI.Hooks: " Patchwork
2024-10-03 1:32 ` ✗ CI.checksparse: warning " Patchwork
2024-10-03 1:49 ` ✓ CI.BAT: success " Patchwork
2024-10-03 2:40 ` ✗ CI.FULL: failure " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2024-10-02 21:14 [PATCH v9 00/11] drm/xe/guc: Improve GuC log dumping and add to devcoredump John.C.Harrison
2024-10-02 21:14 ` [PATCH v9 07/11] drm/print: Introduce drm_line_printer John.C.Harrison
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=35fb9448-4742-4d2b-8eca-1654dd8e235c@linux.intel.com \
--to=maarten.lankhorst@linux.intel.com \
--cc=Intel-Xe@Lists.FreeDesktop.Org \
--cc=John.C.Harrison@Intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
--cc=michal.wajdeczko@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox