1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 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
|