From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH 4/7] drm/xe: Add dedicated printk macros for tile and device
Date: Tue, 9 Sep 2025 09:57:08 -0400 [thread overview]
Message-ID: <aMAyNIn2yVK1bLN1@intel.com> (raw)
In-Reply-To: <20250903213712.6364-5-michal.wajdeczko@intel.com>
On Wed, Sep 03, 2025 at 11:36:09PM +0200, Michal Wajdeczko wrote:
> We already have dedicated helper macros for printing GT-oriented
> messages but we don't have any to print messages that are tile
> oriented and we wrongly try to use plain drm or GT-oriented ones.
>
> Add tile-oriented printk messages and to provide similar coverage
> as we have with xe_assert() macros. Also add set of simple macros
> for the top level xe_device, which we could easily tweak to include
> extra device specific info if needed.
>
> Typical output of our printk macros will look like:
>
> [drm] this is xe_WARN()
> [drm] *ERROR* this is xe_err()
> [drm] *ERROR* this is xe_err_printer()
> [drm] this is xe_info()
> [drm] this is xe_info_printer()
> [drm:printk_demo.cold] this is xe_dbg()
> [drm:printk_demo.cold] this is xe_dbg_printer()
>
> [drm] Tile0: this is xe_tile_WARN()
> [drm] *ERROR* Tile0: this is xe_tile_err()
> [drm] *ERROR* Tile0: this is xe_tile_err_printer()
> [drm] Tile0: this is xe_tile_info()
> [drm] Tile0: this is xe_tile_info_printer()
> [drm:printk_demo.cold] Tile0: this is xe_tile_dbg()
> [drm:printk_demo.cold] Tile0: this is xe_tile_dbg_printer()
>
> [drm] Tile0: GT0: this is xe_gt_WARN()
> [drm] *ERROR* Tile0: GT0: this is xe_gt_err()
> [drm] *ERROR* Tile0: GT0: this is xe_gt_err_printer()
> [drm] Tile0: GT0: this is xe_gt_info()
> [drm] Tile0: GT0: this is xe_gt_info_printer()
> [drm:printk_demo.cold] Tile0: GT0: this is xe_gt_dbg()
> [drm:printk_demo.cold] Tile0: GT0: this is xe_gt_dbg_printer()
Although I hate macros I like these results ;)
>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> ---
> drivers/gpu/drm/xe/xe_gt_printk.h | 11 ++-
> drivers/gpu/drm/xe/xe_printk.h | 129 ++++++++++++++++++++++++++++
> drivers/gpu/drm/xe/xe_tile_printk.h | 127 +++++++++++++++++++++++++++
> 3 files changed, 261 insertions(+), 6 deletions(-)
> create mode 100644 drivers/gpu/drm/xe/xe_printk.h
> create mode 100644 drivers/gpu/drm/xe/xe_tile_printk.h
>
> diff --git a/drivers/gpu/drm/xe/xe_gt_printk.h b/drivers/gpu/drm/xe/xe_gt_printk.h
> index 5aaacaa6780c..8dc4217ddb4e 100644
> --- a/drivers/gpu/drm/xe/xe_gt_printk.h
> +++ b/drivers/gpu/drm/xe/xe_gt_printk.h
> @@ -6,14 +6,13 @@
> #ifndef _XE_GT_PRINTK_H_
> #define _XE_GT_PRINTK_H_
>
> -#include <drm/drm_print.h>
> -
> #include "xe_gt_types.h"
> +#include "xe_tile_printk.h"
>
> #define __xe_gt_printk_fmt(_gt, _fmt, _args...) "GT%u: " _fmt, (_gt)->info.id, ##_args
>
> #define xe_gt_printk(_gt, _level, _fmt, ...) \
> - drm_##_level(>_to_xe(_gt)->drm, __xe_gt_printk_fmt((_gt), _fmt, ##__VA_ARGS__))
> + xe_tile_printk((_gt)->tile, _level, __xe_gt_printk_fmt((_gt), _fmt, ##__VA_ARGS__))
>
> #define xe_gt_err(_gt, _fmt, ...) \
> xe_gt_printk((_gt), err, _fmt, ##__VA_ARGS__)
> @@ -37,7 +36,7 @@
> xe_gt_printk((_gt), dbg, _fmt, ##__VA_ARGS__)
>
> #define xe_gt_WARN_type(_gt, _type, _condition, _fmt, ...) \
> - drm_WARN##_type(>_to_xe(_gt)->drm, _condition, _fmt, ## __VA_ARGS__)
> + xe_tile_WARN##_type((_gt)->tile, _condition, _fmt, ## __VA_ARGS__)
>
> #define xe_gt_WARN(_gt, _condition, _fmt, ...) \
> xe_gt_WARN_type((_gt),, _condition, __xe_gt_printk_fmt((_gt), _fmt, ##__VA_ARGS__))
> @@ -72,9 +71,9 @@ static inline void __xe_gt_printfn_dbg(struct drm_printer *p, struct va_format *
>
> /*
> * The original xe_gt_dbg() callsite annotations are useless here,
> - * redirect to the tweaked drm_dbg_printer() instead.
> + * redirect to the tweaked xe_tile_dbg_printer() instead.
> */
> - dbg = drm_dbg_printer(>_to_xe(gt)->drm, DRM_UT_DRIVER, NULL);
> + dbg = xe_tile_dbg_printer((gt)->tile);
> dbg.origin = p->origin;
>
> drm_printf(&dbg, __xe_gt_printk_fmt(gt, "%pV", vaf));
> diff --git a/drivers/gpu/drm/xe/xe_printk.h b/drivers/gpu/drm/xe/xe_printk.h
> new file mode 100644
> index 000000000000..691d3611b889
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/xe_printk.h
> @@ -0,0 +1,129 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2025 Intel Corporation
> + */
> +
> +#ifndef _XE_PRINTK_H_
> +#define _XE_PRINTK_H_
> +
> +#include <drm/drm_print.h>
> +
> +#include "xe_device_types.h"
> +
> +#define __xe_printk_fmt(_xe, _fmt, _args...) _fmt, ##_args
> +
> +#define xe_printk(_xe, _level, _fmt, ...) \
> + drm_##_level(&(_xe)->drm, __xe_printk_fmt((_xe), _fmt, ## __VA_ARGS__))
> +
> +#define xe_err(_xe, _fmt, ...) \
> + xe_printk((_xe), err, _fmt, ##__VA_ARGS__)
> +
> +#define xe_err_once(_xe, _fmt, ...) \
> + xe_printk((_xe), err_once, _fmt, ##__VA_ARGS__)
> +
> +#define xe_err_ratelimited(_xe, _fmt, ...) \
> + xe_printk((_xe), err_ratelimited, _fmt, ##__VA_ARGS__)
> +
> +#define xe_warn(_xe, _fmt, ...) \
> + xe_printk((_xe), warn, _fmt, ##__VA_ARGS__)
> +
> +#define xe_notice(_xe, _fmt, ...) \
> + xe_printk((_xe), notice, _fmt, ##__VA_ARGS__)
> +
> +#define xe_info(_xe, _fmt, ...) \
> + xe_printk((_xe), info, _fmt, ##__VA_ARGS__)
> +
> +#define xe_dbg(_xe, _fmt, ...) \
> + xe_printk((_xe), dbg, _fmt, ##__VA_ARGS__)
> +
> +#define xe_WARN_type(_xe, _type, _condition, _fmt, ...) \
> + drm_WARN##_type(&(_xe)->drm, _condition, _fmt, ## __VA_ARGS__)
> +
> +#define xe_WARN(_xe, _condition, _fmt, ...) \
> + xe_WARN_type((_xe),, _condition, __xe_printk_fmt((_xe), _fmt, ## __VA_ARGS__))
> +
> +#define xe_WARN_ONCE(_xe, _condition, _fmt, ...) \
> + xe_WARN_type((_xe), _ONCE, _condition, __xe_printk_fmt((_xe), _fmt, ## __VA_ARGS__))
> +
> +#define xe_WARN_ON(_xe, _condition) \
> + xe_WARN((_xe), _condition, "%s(%s)", "WARN_ON", __stringify(_condition))
> +
> +#define xe_WARN_ON_ONCE(_xe, _condition) \
> + xe_WARN_ONCE((_xe), _condition, "%s(%s)", "WARN_ON_ONCE", __stringify(_condition))
> +
> +static inline void __xe_printfn_err(struct drm_printer *p, struct va_format *vaf)
> +{
> + struct xe_device *xe = p->arg;
> +
> + xe_err(xe, "%pV", vaf);
> +}
> +
> +static inline void __xe_printfn_info(struct drm_printer *p, struct va_format *vaf)
> +{
> + struct xe_device *xe = p->arg;
> +
> + xe_info(xe, "%pV", vaf);
> +}
> +
> +static inline void __xe_printfn_dbg(struct drm_printer *p, struct va_format *vaf)
> +{
> + struct xe_device *xe = p->arg;
> + struct drm_printer ddp;
> +
> + /*
> + * The original xe_dbg() callsite annotations are useless here,
> + * redirect to the tweaked drm_dbg_printer() instead.
> + */
> + ddp = drm_dbg_printer(&xe->drm, DRM_UT_DRIVER, NULL);
> + ddp.origin = p->origin;
> +
> + drm_printf(&ddp, __xe_printk_fmt(xe, "%pV", vaf));
> +}
> +
> +/**
> + * xe_err_printer - Construct a &drm_printer that outputs to xe_err()
> + * @xe: the &xe_device pointer to use in xe_err()
> + *
> + * Return: The &drm_printer object.
> + */
> +static inline struct drm_printer xe_err_printer(struct xe_device *xe)
> +{
> + struct drm_printer p = {
> + .printfn = __xe_printfn_err,
> + .arg = xe,
> + };
> + return p;
> +}
> +
> +/**
> + * xe_info_printer - Construct a &drm_printer that outputs to xe_info()
> + * @xe: the &xe_device pointer to use in xe_info()
> + *
> + * Return: The &drm_printer object.
> + */
> +static inline struct drm_printer xe_info_printer(struct xe_device *xe)
> +{
> + struct drm_printer p = {
> + .printfn = __xe_printfn_info,
> + .arg = xe,
> + };
> + return p;
> +}
> +
> +/**
> + * xe_dbg_printer - Construct a &drm_printer that outputs like xe_dbg()
> + * @xe: the &xe_device pointer to use in xe_dbg()
> + *
> + * Return: The &drm_printer object.
> + */
> +static inline struct drm_printer xe_dbg_printer(struct xe_device *xe)
> +{
> + struct drm_printer p = {
> + .printfn = __xe_printfn_dbg,
> + .arg = xe,
> + .origin = (const void *)_THIS_IP_,
> + };
> + return p;
> +}
> +
> +#endif
> diff --git a/drivers/gpu/drm/xe/xe_tile_printk.h b/drivers/gpu/drm/xe/xe_tile_printk.h
> new file mode 100644
> index 000000000000..ed951cdb08cb
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/xe_tile_printk.h
> @@ -0,0 +1,127 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2025 Intel Corporation
> + */
> +
> +#ifndef _xe_tile_printk_H_
> +#define _xe_tile_printk_H_
> +
> +#include "xe_printk.h"
> +
> +#define __xe_tile_printk_fmt(_tile, _fmt, _args...) "Tile%u: " _fmt, (_tile)->id, ##_args
> +
> +#define xe_tile_printk(_tile, _level, _fmt, ...) \
> + xe_printk((_tile)->xe, _level, __xe_tile_printk_fmt((_tile), _fmt, ##__VA_ARGS__))
> +
> +#define xe_tile_err(_tile, _fmt, ...) \
> + xe_tile_printk((_tile), err, _fmt, ##__VA_ARGS__)
> +
> +#define xe_tile_err_once(_tile, _fmt, ...) \
> + xe_tile_printk((_tile), err_once, _fmt, ##__VA_ARGS__)
> +
> +#define xe_tile_err_ratelimited(_tile, _fmt, ...) \
> + xe_tile_printk((_tile), err_ratelimited, _fmt, ##__VA_ARGS__)
> +
> +#define xe_tile_warn(_tile, _fmt, ...) \
> + xe_tile_printk((_tile), warn, _fmt, ##__VA_ARGS__)
> +
> +#define xe_tile_notice(_tile, _fmt, ...) \
> + xe_tile_printk((_tile), notice, _fmt, ##__VA_ARGS__)
> +
> +#define xe_tile_info(_tile, _fmt, ...) \
> + xe_tile_printk((_tile), info, _fmt, ##__VA_ARGS__)
> +
> +#define xe_tile_dbg(_tile, _fmt, ...) \
> + xe_tile_printk((_tile), dbg, _fmt, ##__VA_ARGS__)
> +
> +#define xe_tile_WARN_type(_tile, _type, _condition, _fmt, ...) \
> + xe_WARN##_type((_tile)->xe, _condition, _fmt, ## __VA_ARGS__)
> +
> +#define xe_tile_WARN(_tile, _condition, _fmt, ...) \
> + xe_tile_WARN_type((_tile),, _condition, __xe_tile_printk_fmt((_tile), _fmt, ##__VA_ARGS__))
> +
> +#define xe_tile_WARN_ONCE(_tile, _condition, _fmt, ...) \
> + xe_tile_WARN_type((_tile), _ONCE, _condition, __xe_tile_printk_fmt((_tile), _fmt, ##__VA_ARGS__))
> +
> +#define xe_tile_WARN_ON(_tile, _condition) \
> + xe_tile_WARN((_tile), _condition, "%s(%s)", "WARN_ON", __stringify(_condition))
> +
> +#define xe_tile_WARN_ON_ONCE(_tile, _condition) \
> + xe_tile_WARN_ONCE((_tile), _condition, "%s(%s)", "WARN_ON_ONCE", __stringify(_condition))
> +
> +static inline void __xe_tile_printfn_err(struct drm_printer *p, struct va_format *vaf)
> +{
> + struct xe_tile *tile = p->arg;
> +
> + xe_tile_err(tile, "%pV", vaf);
> +}
> +
> +static inline void __xe_tile_printfn_info(struct drm_printer *p, struct va_format *vaf)
> +{
> + struct xe_tile *tile = p->arg;
> +
> + xe_tile_info(tile, "%pV", vaf);
> +}
> +
> +static inline void __xe_tile_printfn_dbg(struct drm_printer *p, struct va_format *vaf)
> +{
> + struct xe_tile *tile = p->arg;
> + struct drm_printer dbg;
> +
> + /*
> + * The original xe_tile_dbg() callsite annotations are useless here,
> + * redirect to the tweaked xe_dbg_printer() instead.
> + */
> + dbg = xe_dbg_printer(tile->xe);
> + dbg.origin = p->origin;
> +
> + drm_printf(&dbg, __xe_tile_printk_fmt(tile, "%pV", vaf));
> +}
> +
> +/**
> + * xe_tile_err_printer - Construct a &drm_printer that outputs to xe_tile_err()
> + * @tile: the &xe_tile pointer to use in xe_tile_err()
> + *
> + * Return: The &drm_printer object.
> + */
> +static inline struct drm_printer xe_tile_err_printer(struct xe_tile *tile)
> +{
> + struct drm_printer p = {
> + .printfn = __xe_tile_printfn_err,
> + .arg = tile,
> + };
> + return p;
> +}
> +
> +/**
> + * xe_tile_info_printer - Construct a &drm_printer that outputs to xe_tile_info()
> + * @tile: the &xe_tile pointer to use in xe_tile_info()
> + *
> + * Return: The &drm_printer object.
> + */
> +static inline struct drm_printer xe_tile_info_printer(struct xe_tile *tile)
> +{
> + struct drm_printer p = {
> + .printfn = __xe_tile_printfn_info,
> + .arg = tile,
> + };
> + return p;
> +}
> +
> +/**
> + * xe_tile_dbg_printer - Construct a &drm_printer that outputs like xe_tile_dbg()
> + * @tile: the &xe_tile pointer to use in xe_tile_dbg()
> + *
> + * Return: The &drm_printer object.
> + */
> +static inline struct drm_printer xe_tile_dbg_printer(struct xe_tile *tile)
> +{
> + struct drm_printer p = {
> + .printfn = __xe_tile_printfn_dbg,
> + .arg = tile,
> + .origin = (const void *)_THIS_IP_,
> + };
> + return p;
> +}
> +
> +#endif
> --
> 2.47.1
>
next prev parent reply other threads:[~2025-09-09 13:57 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-03 21:36 [PATCH 0/7] RFC: Add dedicated printk macros for tile and device Michal Wajdeczko
2025-09-03 21:36 ` [PATCH 1/7] drm/xe: Keep xe_gt_err() macro definitions together Michal Wajdeczko
2025-09-03 21:59 ` Lucas De Marchi
2025-09-03 21:36 ` [PATCH 2/7] drm/xe: Drop "gt_" prefix from xe_gt_WARN() macros Michal Wajdeczko
2025-09-03 22:00 ` Lucas De Marchi
2025-09-03 21:36 ` [PATCH 3/7] drm/xe: Prepare format for GT-oriented messages in one place Michal Wajdeczko
2025-09-09 13:55 ` Rodrigo Vivi
2025-09-03 21:36 ` [PATCH 4/7] drm/xe: Add dedicated printk macros for tile and device Michal Wajdeczko
2025-09-09 13:57 ` Rodrigo Vivi [this message]
2025-09-03 21:36 ` [PATCH 5/7] drm/xe: Define verbose debug macros Michal Wajdeczko
2025-09-03 22:06 ` Lucas De Marchi
2025-09-03 22:19 ` Michal Wajdeczko
2025-09-09 14:01 ` Rodrigo Vivi
2025-09-03 21:36 ` [PATCH 6/7] drm/xe: Use tile-oriented messages in GGTT code Michal Wajdeczko
2025-09-09 13:58 ` Rodrigo Vivi
2025-09-03 21:36 ` [PATCH 7/7] drm/xe: Use tile-oriented messages in LMTT code Michal Wajdeczko
2025-09-09 13:58 ` Rodrigo Vivi
2025-09-03 21:43 ` ✗ CI.checkpatch: warning for RFC: Add dedicated printk macros for tile and device Patchwork
2025-09-03 21:44 ` ✓ CI.KUnit: success " Patchwork
2025-09-03 22:21 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-09-04 4:49 ` ✗ Xe.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=aMAyNIn2yVK1bLN1@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--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