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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
/* SPDX-License-Identifier: MIT */
/*
* Copyright © 2026 Intel Corporation
*/
#ifndef _XE_LOG_H_
#define _XE_LOG_H_
#include <linux/cper.h>
#include <linux/err.h>
#include "abi/xe_log_abi.h"
#include "abi/xe_sigid_abi.h"
#include "xe_any.h"
struct pci_dev;
__printf(8, 9)
void __xe_log_emit(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
u32 component, u32 location, const void *data, size_t len,
const char *fmt, ...);
#define __xe_log_const_sev_to_level(sev) \
(__builtin_constant_p(sev) ? (sev) == CPER_SEV_INFORMATIONAL ? KERN_INFO : KERN_ERR : NULL)
#define __xe_log_emit_printk_index(level, fmt) \
dev_printk_index_emit(level, "%s SIGID=%u %s" fmt);
#define xe_log_emit(pdev, sev, sig, comp, loc, data, len, fmt, args...) do { \
__xe_log_emit_printk_index(__xe_log_const_sev_to_level(sev), fmt); \
__xe_log_emit((pdev), (sev), (sig), (comp), (loc), (data), (len), fmt, ##args); \
} while (0)
#define xe_log_emit_fatal(pdev, sig, comp, loc, data, len, fmt, args...) \
xe_log_emit((pdev), CPER_SEV_FATAL, (sig), (comp), (loc), \
(data), (len), fmt, ##args)
#define xe_log_emit_recoverable(pdev, sig, comp, loc, data, len, fmt, args...) \
xe_log_emit((pdev), CPER_SEV_RECOVERABLE, (sig), (comp), (loc), \
(data), (len), fmt, ##args)
#define xe_log_emit_corrected(pdev, sig, comp, loc, data, len, fmt, args...) \
xe_log_emit((pdev), CPER_SEV_CORRECTED, (sig), (comp), (loc), \
(data), (len), fmt, ##args)
#define xe_log_emit_info(pdev, sig, comp, loc, data, len, fmt, args...) \
xe_log_emit((pdev), CPER_SEV_INFORMATIONAL, (sig), (comp), (loc), \
(data), (len), fmt, ##args)
#define xe_log_location_type(any) \
_Generic((any), \
struct xe_gt * : XE_LOG_LOCATION_TYPE_GT, \
const struct xe_gt * : XE_LOG_LOCATION_TYPE_GT, \
struct xe_tile * : XE_LOG_LOCATION_TYPE_TILE, \
const struct xe_tile * : XE_LOG_LOCATION_TYPE_TILE, \
struct xe_device * : XE_LOG_LOCATION_TYPE_DEVICE, \
const struct xe_device * : XE_LOG_LOCATION_TYPE_DEVICE, \
struct pci_dev * : XE_LOG_LOCATION_TYPE_DEVICE, \
struct device * : XE_LOG_LOCATION_TYPE_DEVICE)
#define xe_log_location(any) \
PREP_XE_LOG_LOCATION(xe_log_location_type(any), xe_any_id(any))
/**
* xe_log_from() - Emit a structured SIGID log entry using @any pointer as location.
* @any: the &xe_device or &xe_tile or &xe_gt pointer this report relates to
* @cper_sev: CPER severity (CPER_SEV_FATAL, CPER_SEV_RECOVERABLE, ...)
* @sigid: signature identifier, see &enum xe_sigid
* @component: component identifer
* @data: pointer to the additional details, or ERR_PTR, or NULL if not applicable
* @len: length of the @data in bytes, or 0 if not applicable
* @fmt: printf-style format string
* @args: arguments for the @fmt format string
*
* The location used to emit SIGID entry will be based on the @any pointer type.
* See xe_log_emit() for more details.
*/
#define xe_log_from(any, cper_sev, sigid, component, data, len, fmt, args...) do { \
typeof(any) ___any = (any); \
xe_log_emit(xe_any_to_pdev(___any), (cper_sev), (sigid), (component), \
xe_log_location(___any), (data), (len), fmt, ##args); \
} while (0)
#define xe_log_from_fatal(any, sig, comp, data, len, fmt, args...) \
xe_log_from((any), CPER_SEV_FATAL, (sig), (comp), \
(data), (len), fmt, ##args)
#define xe_log_from_recoverable(any, sig, comp, data, len, fmt, args...) \
xe_log_from((any), CPER_SEV_RECOVERABLE, (sig), (comp), \
(data), (len), fmt, ##args)
#define xe_log_from_corrected(any, sig, comp, data, len, fmt, args...) \
xe_log_from((any), CPER_SEV_CORRECTED, (sig), (comp), \
(data), (len), fmt, ##args)
#define xe_log_from_info(any, sig, comp, data, len, fmt, args...) \
xe_log_from((any), CPER_SEV_INFORMATIONAL, (sig), (comp), \
(data), (len), fmt, ##args)
/**
* xe_log_comp() - Emit a structured SIGID log entry on the component behalf.
* @any: the &xe_device or &xe_tile or &xe_gt pointer this report relates to
* @cper_sev: CPER severity (CPER_SEV_FATAL, CPER_SEV_RECOVERABLE, ...)
* @TAG: the component tag to use
* @data: pointer to the additional details, or ERR_PTR, or NULL if not applicable
* @len: length of the @data in bytes, or 0 if not applicable
* @fmt: printf-style free text format string (not a stable interface)
* @args: arguments for the @fmt format string
*
* The SIGID will be determined from the component's @TAG.
* The component identifier will be determined from the component's @TAG.
* The location used to emit SIGID entry will be based on the @any pointer type.
*/
#define xe_log_comp(any, cper_sev, TAG, data, len, fmt, args...) \
xe_log_from((any), (cper_sev), (int)XE_LOG_COMPONENT_##TAG##_SIGID, \
XE_LOG_COMPONENT_##TAG, (data), (len), fmt, ##args)
#define xe_log_comp_fatal(any, TAG, data, len, fmt, args...) \
xe_log_comp((any), CPER_SEV_FATAL, TAG, (data), (len), fmt, ##args)
#define xe_log_comp_recoverable(any, TAG, data, len, fmt, args...) \
xe_log_comp((any), CPER_SEV_RECOVERABLE, TAG, (data), (len), fmt, ##args)
#define xe_log_comp_corrected(any, TAG, data, len, fmt, args...) \
xe_log_comp((any), CPER_SEV_CORRECTED, TAG, (data), (len), fmt, ##args)
#define xe_log_comp_info(any, TAG, data, len, fmt, args...) \
xe_log_comp((any), CPER_SEV_INFORMATIONAL, TAG, (data), (len), fmt, ##args)
/**
* xe_log_err() - Emit a structured SIGID error log entry on the component behalf.
* @any: the &xe_device or &xe_tile or &xe_gt pointer this report relates to
* @TAG: the component tag to use
* @err: negative errno for the failing operation, or 0 if not applicable
* @fmt: printf-style free text format string (not a stable interface)
* @args: arguments for the @fmt format string
*
* The log entry will be emitted with @CPER_SEV_RECOVERABLE severity.
*/
#define xe_log_err(any, TAG, err, fmt, args...) \
xe_log_comp_recoverable((any), TAG, ERR_PTR(err), 0, fmt, ##args)
/**
* xe_log_err_fatal() - Emit a structured SIGID error log entry on the component behalf.
* @any: the &xe_device or &xe_tile or &xe_gt pointer this report relates to
* @TAG: the component tag to use
* @err: negative errno for the failing operation, or 0 if not applicable
* @fmt: printf-style free text format string (not a stable interface)
* @args: arguments for the @fmt format string
*
* The log entry will be emitted with @CPER_SEV_FATAL severity.
*/
#define xe_log_err_fatal(any, TAG, err, fmt, args...) \
xe_log_comp_fatal((any), TAG, ERR_PTR(err), 0, fmt, ##args)
/**
* xe_log_err_corrected() - Emit a structured SIGID error log entry on the component behalf.
* @any: the &xe_device or &xe_tile or &xe_gt pointer this report relates to
* @TAG: the component tag to use
* @err: negative errno for the failing operation, or 0 if not applicable
* @fmt: printf-style free text format string (not a stable interface)
* @args: arguments for the @fmt format string
*
* The log entry will be emitted with @CPER_SEV_CORRECTED severity.
*/
#define xe_log_err_corrected(any, TAG, err, fmt, args...) \
xe_log_comp_corrected((any), TAG, ERR_PTR(err), 0, fmt, ##args)
/**
* xe_log_err_info() - Emit a structured SIGID error log entry on the component behalf.
* @any: the &xe_device or &xe_tile or &xe_gt pointer this report relates to
* @TAG: the component tag to use
* @err: negative errno for the failing operation, or 0 if not applicable
* @fmt: printf-style free text format string (not a stable interface)
* @args: arguments for the @fmt format string
*
* The log entry will be emitted with @CPER_SEV_INFORMATIONAL severity.
*/
#define xe_log_err_info(any, TAG, err, fmt, args...) \
xe_log_comp_info((any), TAG, ERR_PTR(err), 0, fmt, ##args)
/**
* xe_log_info() - Emit a structured SIGID information log entry on the component behalf.
* @any: the &xe_device or &xe_tile or &xe_gt pointer this report relates to
* @TAG: the component tag to use
* @fmt: printf-style free text format string (not a stable interface)
* @args: arguments for the @fmt format string
*
* The log entry will be emitted with @CPER_SEV_INFORMATIONAL severity.
*/
#define xe_log_info(any, TAG, fmt, args...) \
xe_log_err_info((any), TAG, 0, fmt, ##args)
#endif
|