Loading...
1/* SPDX-License-Identifier: MIT */
2/*
3 * Copyright © 2023 Intel Corporation
4 */
5
6#ifndef _XE_GT_PRINTK_H_
7#define _XE_GT_PRINTK_H_
8
9#include <drm/drm_print.h>
10
11#include "xe_gt_types.h"
12
13#define xe_gt_printk(_gt, _level, _fmt, ...) \
14 drm_##_level(>_to_xe(_gt)->drm, "GT%u: " _fmt, (_gt)->info.id, ##__VA_ARGS__)
15
16#define xe_gt_err_once(_gt, _fmt, ...) \
17 xe_gt_printk((_gt), err_once, _fmt, ##__VA_ARGS__)
18
19#define xe_gt_err(_gt, _fmt, ...) \
20 xe_gt_printk((_gt), err, _fmt, ##__VA_ARGS__)
21
22#define xe_gt_warn(_gt, _fmt, ...) \
23 xe_gt_printk((_gt), warn, _fmt, ##__VA_ARGS__)
24
25#define xe_gt_notice(_gt, _fmt, ...) \
26 xe_gt_printk((_gt), notice, _fmt, ##__VA_ARGS__)
27
28#define xe_gt_info(_gt, _fmt, ...) \
29 xe_gt_printk((_gt), info, _fmt, ##__VA_ARGS__)
30
31#define xe_gt_dbg(_gt, _fmt, ...) \
32 xe_gt_printk((_gt), dbg, _fmt, ##__VA_ARGS__)
33
34#define xe_gt_err_ratelimited(_gt, _fmt, ...) \
35 xe_gt_printk((_gt), err_ratelimited, _fmt, ##__VA_ARGS__)
36
37#define xe_gt_WARN(_gt, _condition, _fmt, ...) \
38 drm_WARN(>_to_xe(_gt)->drm, _condition, "GT%u: " _fmt, (_gt)->info.id, ##__VA_ARGS__)
39
40#define xe_gt_WARN_ONCE(_gt, _condition, _fmt, ...) \
41 drm_WARN_ONCE(>_to_xe(_gt)->drm, _condition, "GT%u: " _fmt, (_gt)->info.id, ##__VA_ARGS__)
42
43#define xe_gt_WARN_ON(_gt, _condition) \
44 xe_gt_WARN((_gt), _condition, "%s(%s)", "gt_WARN_ON", __stringify(_condition))
45
46#define xe_gt_WARN_ON_ONCE(_gt, _condition) \
47 xe_gt_WARN_ONCE((_gt), _condition, "%s(%s)", "gt_WARN_ON_ONCE", __stringify(_condition))
48
49static inline void __xe_gt_printfn_err(struct drm_printer *p, struct va_format *vaf)
50{
51 struct xe_gt *gt = p->arg;
52
53 xe_gt_err(gt, "%pV", vaf);
54}
55
56static inline void __xe_gt_printfn_info(struct drm_printer *p, struct va_format *vaf)
57{
58 struct xe_gt *gt = p->arg;
59
60 xe_gt_info(gt, "%pV", vaf);
61}
62
63/**
64 * xe_gt_err_printer - Construct a &drm_printer that outputs to xe_gt_err()
65 * @gt: the &xe_gt pointer to use in xe_gt_err()
66 *
67 * Return: The &drm_printer object.
68 */
69static inline struct drm_printer xe_gt_err_printer(struct xe_gt *gt)
70{
71 struct drm_printer p = {
72 .printfn = __xe_gt_printfn_err,
73 .arg = gt,
74 };
75 return p;
76}
77
78/**
79 * xe_gt_info_printer - Construct a &drm_printer that outputs to xe_gt_info()
80 * @gt: the &xe_gt pointer to use in xe_gt_info()
81 *
82 * Return: The &drm_printer object.
83 */
84static inline struct drm_printer xe_gt_info_printer(struct xe_gt *gt)
85{
86 struct drm_printer p = {
87 .printfn = __xe_gt_printfn_info,
88 .arg = gt,
89 };
90 return p;
91}
92
93#endif
1/* SPDX-License-Identifier: MIT */
2/*
3 * Copyright © 2023 Intel Corporation
4 */
5
6#ifndef _XE_GT_PRINTK_H_
7#define _XE_GT_PRINTK_H_
8
9#include <drm/drm_print.h>
10
11#include "xe_device_types.h"
12
13#define xe_gt_printk(_gt, _level, _fmt, ...) \
14 drm_##_level(>_to_xe(_gt)->drm, "GT%u: " _fmt, (_gt)->info.id, ##__VA_ARGS__)
15
16#define xe_gt_err(_gt, _fmt, ...) \
17 xe_gt_printk((_gt), err, _fmt, ##__VA_ARGS__)
18
19#define xe_gt_warn(_gt, _fmt, ...) \
20 xe_gt_printk((_gt), warn, _fmt, ##__VA_ARGS__)
21
22#define xe_gt_notice(_gt, _fmt, ...) \
23 xe_gt_printk((_gt), notice, _fmt, ##__VA_ARGS__)
24
25#define xe_gt_info(_gt, _fmt, ...) \
26 xe_gt_printk((_gt), info, _fmt, ##__VA_ARGS__)
27
28#define xe_gt_dbg(_gt, _fmt, ...) \
29 xe_gt_printk((_gt), dbg, _fmt, ##__VA_ARGS__)
30
31#define xe_gt_err_ratelimited(_gt, _fmt, ...) \
32 xe_gt_printk((_gt), err_ratelimited, _fmt, ##__VA_ARGS__)
33
34#define xe_gt_WARN(_gt, _condition, _fmt, ...) \
35 drm_WARN(>_to_xe(_gt)->drm, _condition, "GT%u: " _fmt, (_gt)->info.id, ##__VA_ARGS__)
36
37#define xe_gt_WARN_ONCE(_gt, _condition, _fmt, ...) \
38 drm_WARN_ONCE(>_to_xe(_gt)->drm, _condition, "GT%u: " _fmt, (_gt)->info.id, ##__VA_ARGS__)
39
40#define xe_gt_WARN_ON(_gt, _condition) \
41 xe_gt_WARN((_gt), _condition, "%s(%s)", "gt_WARN_ON", __stringify(_condition))
42
43#define xe_gt_WARN_ON_ONCE(_gt, _condition) \
44 xe_gt_WARN_ONCE((_gt), _condition, "%s(%s)", "gt_WARN_ON_ONCE", __stringify(_condition))
45
46static inline void __xe_gt_printfn_err(struct drm_printer *p, struct va_format *vaf)
47{
48 struct xe_gt *gt = p->arg;
49
50 xe_gt_err(gt, "%pV", vaf);
51}
52
53static inline void __xe_gt_printfn_info(struct drm_printer *p, struct va_format *vaf)
54{
55 struct xe_gt *gt = p->arg;
56
57 xe_gt_info(gt, "%pV", vaf);
58}
59
60/**
61 * xe_gt_err_printer - Construct a &drm_printer that outputs to xe_gt_err()
62 * @gt: the &xe_gt pointer to use in xe_gt_err()
63 *
64 * Return: The &drm_printer object.
65 */
66static inline struct drm_printer xe_gt_err_printer(struct xe_gt *gt)
67{
68 struct drm_printer p = {
69 .printfn = __xe_gt_printfn_err,
70 .arg = gt,
71 };
72 return p;
73}
74
75/**
76 * xe_gt_info_printer - Construct a &drm_printer that outputs to xe_gt_info()
77 * @gt: the &xe_gt pointer to use in xe_gt_info()
78 *
79 * Return: The &drm_printer object.
80 */
81static inline struct drm_printer xe_gt_info_printer(struct xe_gt *gt)
82{
83 struct drm_printer p = {
84 .printfn = __xe_gt_printfn_info,
85 .arg = gt,
86 };
87 return p;
88}
89
90#endif