Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/xe: Add dedicated printk macros for tile and device

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()

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://lore.kernel.org/r/20250909165941.31730-5-michal.wajdeczko@intel.com

+261 -6
+5 -6
drivers/gpu/drm/xe/xe_gt_printk.h
··· 6 6 #ifndef _XE_GT_PRINTK_H_ 7 7 #define _XE_GT_PRINTK_H_ 8 8 9 - #include <drm/drm_print.h> 10 - 11 9 #include "xe_gt_types.h" 10 + #include "xe_tile_printk.h" 12 11 13 12 #define __XE_GT_PRINTK_FMT(_gt, _fmt, _args...) "GT%u: " _fmt, (_gt)->info.id, ##_args 14 13 15 14 #define xe_gt_printk(_gt, _level, _fmt, ...) \ 16 - drm_##_level(&gt_to_xe(_gt)->drm, __XE_GT_PRINTK_FMT((_gt), _fmt, ##__VA_ARGS__)) 15 + xe_tile_printk((_gt)->tile, _level, __XE_GT_PRINTK_FMT((_gt), _fmt, ##__VA_ARGS__)) 17 16 18 17 #define xe_gt_err(_gt, _fmt, ...) \ 19 18 xe_gt_printk((_gt), err, _fmt, ##__VA_ARGS__) ··· 36 37 xe_gt_printk((_gt), dbg, _fmt, ##__VA_ARGS__) 37 38 38 39 #define xe_gt_WARN_type(_gt, _type, _condition, _fmt, ...) \ 39 - drm_WARN##_type(&gt_to_xe(_gt)->drm, _condition, _fmt, ## __VA_ARGS__) 40 + xe_tile_WARN##_type((_gt)->tile, _condition, _fmt, ## __VA_ARGS__) 40 41 41 42 #define xe_gt_WARN(_gt, _condition, _fmt, ...) \ 42 43 xe_gt_WARN_type((_gt),, _condition, __XE_GT_PRINTK_FMT((_gt), _fmt, ##__VA_ARGS__)) ··· 71 72 72 73 /* 73 74 * The original xe_gt_dbg() callsite annotations are useless here, 74 - * redirect to the tweaked drm_dbg_printer() instead. 75 + * redirect to the tweaked xe_tile_dbg_printer() instead. 75 76 */ 76 - dbg = drm_dbg_printer(&gt_to_xe(gt)->drm, DRM_UT_DRIVER, NULL); 77 + dbg = xe_tile_dbg_printer((gt)->tile); 77 78 dbg.origin = p->origin; 78 79 79 80 drm_printf(&dbg, __XE_GT_PRINTK_FMT(gt, "%pV", vaf));
+129
drivers/gpu/drm/xe/xe_printk.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* 3 + * Copyright © 2025 Intel Corporation 4 + */ 5 + 6 + #ifndef _XE_PRINTK_H_ 7 + #define _XE_PRINTK_H_ 8 + 9 + #include <drm/drm_print.h> 10 + 11 + #include "xe_device_types.h" 12 + 13 + #define __XE_PRINTK_FMT(_xe, _fmt, _args...) _fmt, ##_args 14 + 15 + #define xe_printk(_xe, _level, _fmt, ...) \ 16 + drm_##_level(&(_xe)->drm, __XE_PRINTK_FMT((_xe), _fmt, ## __VA_ARGS__)) 17 + 18 + #define xe_err(_xe, _fmt, ...) \ 19 + xe_printk((_xe), err, _fmt, ##__VA_ARGS__) 20 + 21 + #define xe_err_once(_xe, _fmt, ...) \ 22 + xe_printk((_xe), err_once, _fmt, ##__VA_ARGS__) 23 + 24 + #define xe_err_ratelimited(_xe, _fmt, ...) \ 25 + xe_printk((_xe), err_ratelimited, _fmt, ##__VA_ARGS__) 26 + 27 + #define xe_warn(_xe, _fmt, ...) \ 28 + xe_printk((_xe), warn, _fmt, ##__VA_ARGS__) 29 + 30 + #define xe_notice(_xe, _fmt, ...) \ 31 + xe_printk((_xe), notice, _fmt, ##__VA_ARGS__) 32 + 33 + #define xe_info(_xe, _fmt, ...) \ 34 + xe_printk((_xe), info, _fmt, ##__VA_ARGS__) 35 + 36 + #define xe_dbg(_xe, _fmt, ...) \ 37 + xe_printk((_xe), dbg, _fmt, ##__VA_ARGS__) 38 + 39 + #define xe_WARN_type(_xe, _type, _condition, _fmt, ...) \ 40 + drm_WARN##_type(&(_xe)->drm, _condition, _fmt, ## __VA_ARGS__) 41 + 42 + #define xe_WARN(_xe, _condition, _fmt, ...) \ 43 + xe_WARN_type((_xe),, _condition, __XE_PRINTK_FMT((_xe), _fmt, ## __VA_ARGS__)) 44 + 45 + #define xe_WARN_ONCE(_xe, _condition, _fmt, ...) \ 46 + xe_WARN_type((_xe), _ONCE, _condition, __XE_PRINTK_FMT((_xe), _fmt, ## __VA_ARGS__)) 47 + 48 + #define xe_WARN_ON(_xe, _condition) \ 49 + xe_WARN((_xe), _condition, "%s(%s)", "WARN_ON", __stringify(_condition)) 50 + 51 + #define xe_WARN_ON_ONCE(_xe, _condition) \ 52 + xe_WARN_ONCE((_xe), _condition, "%s(%s)", "WARN_ON_ONCE", __stringify(_condition)) 53 + 54 + static inline void __xe_printfn_err(struct drm_printer *p, struct va_format *vaf) 55 + { 56 + struct xe_device *xe = p->arg; 57 + 58 + xe_err(xe, "%pV", vaf); 59 + } 60 + 61 + static inline void __xe_printfn_info(struct drm_printer *p, struct va_format *vaf) 62 + { 63 + struct xe_device *xe = p->arg; 64 + 65 + xe_info(xe, "%pV", vaf); 66 + } 67 + 68 + static inline void __xe_printfn_dbg(struct drm_printer *p, struct va_format *vaf) 69 + { 70 + struct xe_device *xe = p->arg; 71 + struct drm_printer ddp; 72 + 73 + /* 74 + * The original xe_dbg() callsite annotations are useless here, 75 + * redirect to the tweaked drm_dbg_printer() instead. 76 + */ 77 + ddp = drm_dbg_printer(&xe->drm, DRM_UT_DRIVER, NULL); 78 + ddp.origin = p->origin; 79 + 80 + drm_printf(&ddp, __XE_PRINTK_FMT(xe, "%pV", vaf)); 81 + } 82 + 83 + /** 84 + * xe_err_printer - Construct a &drm_printer that outputs to xe_err() 85 + * @xe: the &xe_device pointer to use in xe_err() 86 + * 87 + * Return: The &drm_printer object. 88 + */ 89 + static inline struct drm_printer xe_err_printer(struct xe_device *xe) 90 + { 91 + struct drm_printer p = { 92 + .printfn = __xe_printfn_err, 93 + .arg = xe, 94 + }; 95 + return p; 96 + } 97 + 98 + /** 99 + * xe_info_printer - Construct a &drm_printer that outputs to xe_info() 100 + * @xe: the &xe_device pointer to use in xe_info() 101 + * 102 + * Return: The &drm_printer object. 103 + */ 104 + static inline struct drm_printer xe_info_printer(struct xe_device *xe) 105 + { 106 + struct drm_printer p = { 107 + .printfn = __xe_printfn_info, 108 + .arg = xe, 109 + }; 110 + return p; 111 + } 112 + 113 + /** 114 + * xe_dbg_printer - Construct a &drm_printer that outputs like xe_dbg() 115 + * @xe: the &xe_device pointer to use in xe_dbg() 116 + * 117 + * Return: The &drm_printer object. 118 + */ 119 + static inline struct drm_printer xe_dbg_printer(struct xe_device *xe) 120 + { 121 + struct drm_printer p = { 122 + .printfn = __xe_printfn_dbg, 123 + .arg = xe, 124 + .origin = (const void *)_THIS_IP_, 125 + }; 126 + return p; 127 + } 128 + 129 + #endif
+127
drivers/gpu/drm/xe/xe_tile_printk.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* 3 + * Copyright © 2025 Intel Corporation 4 + */ 5 + 6 + #ifndef _xe_tile_printk_H_ 7 + #define _xe_tile_printk_H_ 8 + 9 + #include "xe_printk.h" 10 + 11 + #define __XE_TILE_PRINTK_FMT(_tile, _fmt, _args...) "Tile%u: " _fmt, (_tile)->id, ##_args 12 + 13 + #define xe_tile_printk(_tile, _level, _fmt, ...) \ 14 + xe_printk((_tile)->xe, _level, __XE_TILE_PRINTK_FMT((_tile), _fmt, ##__VA_ARGS__)) 15 + 16 + #define xe_tile_err(_tile, _fmt, ...) \ 17 + xe_tile_printk((_tile), err, _fmt, ##__VA_ARGS__) 18 + 19 + #define xe_tile_err_once(_tile, _fmt, ...) \ 20 + xe_tile_printk((_tile), err_once, _fmt, ##__VA_ARGS__) 21 + 22 + #define xe_tile_err_ratelimited(_tile, _fmt, ...) \ 23 + xe_tile_printk((_tile), err_ratelimited, _fmt, ##__VA_ARGS__) 24 + 25 + #define xe_tile_warn(_tile, _fmt, ...) \ 26 + xe_tile_printk((_tile), warn, _fmt, ##__VA_ARGS__) 27 + 28 + #define xe_tile_notice(_tile, _fmt, ...) \ 29 + xe_tile_printk((_tile), notice, _fmt, ##__VA_ARGS__) 30 + 31 + #define xe_tile_info(_tile, _fmt, ...) \ 32 + xe_tile_printk((_tile), info, _fmt, ##__VA_ARGS__) 33 + 34 + #define xe_tile_dbg(_tile, _fmt, ...) \ 35 + xe_tile_printk((_tile), dbg, _fmt, ##__VA_ARGS__) 36 + 37 + #define xe_tile_WARN_type(_tile, _type, _condition, _fmt, ...) \ 38 + xe_WARN##_type((_tile)->xe, _condition, _fmt, ## __VA_ARGS__) 39 + 40 + #define xe_tile_WARN(_tile, _condition, _fmt, ...) \ 41 + xe_tile_WARN_type((_tile),, _condition, __XE_TILE_PRINTK_FMT((_tile), _fmt, ##__VA_ARGS__)) 42 + 43 + #define xe_tile_WARN_ONCE(_tile, _condition, _fmt, ...) \ 44 + xe_tile_WARN_type((_tile), _ONCE, _condition, __XE_TILE_PRINTK_FMT((_tile), _fmt, ##__VA_ARGS__)) 45 + 46 + #define xe_tile_WARN_ON(_tile, _condition) \ 47 + xe_tile_WARN((_tile), _condition, "%s(%s)", "WARN_ON", __stringify(_condition)) 48 + 49 + #define xe_tile_WARN_ON_ONCE(_tile, _condition) \ 50 + xe_tile_WARN_ONCE((_tile), _condition, "%s(%s)", "WARN_ON_ONCE", __stringify(_condition)) 51 + 52 + static inline void __xe_tile_printfn_err(struct drm_printer *p, struct va_format *vaf) 53 + { 54 + struct xe_tile *tile = p->arg; 55 + 56 + xe_tile_err(tile, "%pV", vaf); 57 + } 58 + 59 + static inline void __xe_tile_printfn_info(struct drm_printer *p, struct va_format *vaf) 60 + { 61 + struct xe_tile *tile = p->arg; 62 + 63 + xe_tile_info(tile, "%pV", vaf); 64 + } 65 + 66 + static inline void __xe_tile_printfn_dbg(struct drm_printer *p, struct va_format *vaf) 67 + { 68 + struct xe_tile *tile = p->arg; 69 + struct drm_printer dbg; 70 + 71 + /* 72 + * The original xe_tile_dbg() callsite annotations are useless here, 73 + * redirect to the tweaked xe_dbg_printer() instead. 74 + */ 75 + dbg = xe_dbg_printer(tile->xe); 76 + dbg.origin = p->origin; 77 + 78 + drm_printf(&dbg, __XE_TILE_PRINTK_FMT(tile, "%pV", vaf)); 79 + } 80 + 81 + /** 82 + * xe_tile_err_printer - Construct a &drm_printer that outputs to xe_tile_err() 83 + * @tile: the &xe_tile pointer to use in xe_tile_err() 84 + * 85 + * Return: The &drm_printer object. 86 + */ 87 + static inline struct drm_printer xe_tile_err_printer(struct xe_tile *tile) 88 + { 89 + struct drm_printer p = { 90 + .printfn = __xe_tile_printfn_err, 91 + .arg = tile, 92 + }; 93 + return p; 94 + } 95 + 96 + /** 97 + * xe_tile_info_printer - Construct a &drm_printer that outputs to xe_tile_info() 98 + * @tile: the &xe_tile pointer to use in xe_tile_info() 99 + * 100 + * Return: The &drm_printer object. 101 + */ 102 + static inline struct drm_printer xe_tile_info_printer(struct xe_tile *tile) 103 + { 104 + struct drm_printer p = { 105 + .printfn = __xe_tile_printfn_info, 106 + .arg = tile, 107 + }; 108 + return p; 109 + } 110 + 111 + /** 112 + * xe_tile_dbg_printer - Construct a &drm_printer that outputs like xe_tile_dbg() 113 + * @tile: the &xe_tile pointer to use in xe_tile_dbg() 114 + * 115 + * Return: The &drm_printer object. 116 + */ 117 + static inline struct drm_printer xe_tile_dbg_printer(struct xe_tile *tile) 118 + { 119 + struct drm_printer p = { 120 + .printfn = __xe_tile_printfn_dbg, 121 + .arg = tile, 122 + .origin = (const void *)_THIS_IP_, 123 + }; 124 + return p; 125 + } 126 + 127 + #endif