| 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(xe: tile->xe); |
| 76 | dbg.origin = p->origin; |
| 77 | |
| 78 | drm_printf(p: &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 |
| 128 | |