1 /* 1 /* 2 * Copyright (C) 2016 Red Hat 2 * Copyright (C) 2016 Red Hat 3 * 3 * 4 * Permission is hereby granted, free of charg 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated docume 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, pub 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to 9 * Software is furnished to do so, subject to the following conditions: 10 * 10 * 11 * The above copyright notice and this permiss 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the S 12 * all copies or substantial portions of the Software. 13 * 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT W 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE W 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINF 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIA 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CO 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 20 * OTHER DEALINGS IN THE SOFTWARE. 21 * 21 * 22 * Authors: 22 * Authors: 23 * Rob Clark <robdclark@gmail.com> 23 * Rob Clark <robdclark@gmail.com> 24 */ 24 */ 25 25 26 #ifndef DRM_PRINT_H_ 26 #ifndef DRM_PRINT_H_ 27 #define DRM_PRINT_H_ 27 #define DRM_PRINT_H_ 28 28 29 #include <linux/compiler.h> 29 #include <linux/compiler.h> 30 #include <linux/printk.h> 30 #include <linux/printk.h> >> 31 #include <linux/seq_file.h> 31 #include <linux/device.h> 32 #include <linux/device.h> 32 #include <linux/dynamic_debug.h> << 33 << 34 #include <drm/drm.h> << 35 << 36 struct debugfs_regset32; << 37 struct drm_device; << 38 struct seq_file; << 39 << 40 /* Do *not* use outside of drm_print.[ch]! */ << 41 extern unsigned long __drm_debug; << 42 33 43 /** 34 /** 44 * DOC: print 35 * DOC: print 45 * 36 * 46 * A simple wrapper for dev_printk(), seq_prin 37 * A simple wrapper for dev_printk(), seq_printf(), etc. Allows same 47 * debug code to be used for both debugfs and 38 * debug code to be used for both debugfs and printk logging. 48 * 39 * 49 * For example:: 40 * For example:: 50 * 41 * 51 * void log_some_info(struct drm_printer * 42 * void log_some_info(struct drm_printer *p) 52 * { 43 * { 53 * drm_printf(p, "foo=%d\n", foo); 44 * drm_printf(p, "foo=%d\n", foo); 54 * drm_printf(p, "bar=%d\n", bar); 45 * drm_printf(p, "bar=%d\n", bar); 55 * } 46 * } 56 * 47 * 57 * #ifdef CONFIG_DEBUG_FS 48 * #ifdef CONFIG_DEBUG_FS 58 * void debugfs_show(struct seq_file *f) 49 * void debugfs_show(struct seq_file *f) 59 * { 50 * { 60 * struct drm_printer p = drm_seq_ 51 * struct drm_printer p = drm_seq_file_printer(f); 61 * log_some_info(&p); 52 * log_some_info(&p); 62 * } 53 * } 63 * #endif 54 * #endif 64 * 55 * 65 * void some_other_function(...) 56 * void some_other_function(...) 66 * { 57 * { 67 * struct drm_printer p = drm_info 58 * struct drm_printer p = drm_info_printer(drm->dev); 68 * log_some_info(&p); 59 * log_some_info(&p); 69 * } 60 * } 70 */ 61 */ 71 62 72 /** 63 /** 73 * enum drm_debug_category - The DRM debug cat << 74 * << 75 * Each of the DRM debug logging macros use a << 76 * is filtered by the drm.debug module paramet << 77 * for the interface. << 78 * << 79 * Each DRM_DEBUG_<CATEGORY> macro logs to DRM << 80 * DRM_DEBUG() logs to DRM_UT_CORE. << 81 * << 82 * Enabling verbose debug messages is done thr << 83 * category being enabled by a bit: << 84 * << 85 * - drm.debug=0x1 will enable CORE messages << 86 * - drm.debug=0x2 will enable DRIVER message << 87 * - drm.debug=0x3 will enable CORE and DRIVE << 88 * - ... << 89 * - drm.debug=0x1ff will enable all messages << 90 * << 91 * An interesting feature is that it's possibl << 92 * run-time by echoing the debug value in its << 93 * << 94 * # echo 0xf > /sys/module/drm/parameters/d << 95 * << 96 */ << 97 enum drm_debug_category { << 98 /* These names must match those in DYN << 99 /** << 100 * @DRM_UT_CORE: Used in the generic d << 101 * drm_memory.c, ... << 102 */ << 103 DRM_UT_CORE, << 104 /** << 105 * @DRM_UT_DRIVER: Used in the vendor << 106 * radeon, ... macro. << 107 */ << 108 DRM_UT_DRIVER, << 109 /** << 110 * @DRM_UT_KMS: Used in the modesettin << 111 */ << 112 DRM_UT_KMS, << 113 /** << 114 * @DRM_UT_PRIME: Used in the prime co << 115 */ << 116 DRM_UT_PRIME, << 117 /** << 118 * @DRM_UT_ATOMIC: Used in the atomic << 119 */ << 120 DRM_UT_ATOMIC, << 121 /** << 122 * @DRM_UT_VBL: Used for verbose debug << 123 */ << 124 DRM_UT_VBL, << 125 /** << 126 * @DRM_UT_STATE: Used for verbose ato << 127 */ << 128 DRM_UT_STATE, << 129 /** << 130 * @DRM_UT_LEASE: Used in the lease co << 131 */ << 132 DRM_UT_LEASE, << 133 /** << 134 * @DRM_UT_DP: Used in the DP code. << 135 */ << 136 DRM_UT_DP, << 137 /** << 138 * @DRM_UT_DRMRES: Used in the drm man << 139 */ << 140 DRM_UT_DRMRES << 141 }; << 142 << 143 static inline bool drm_debug_enabled_raw(enum << 144 { << 145 return unlikely(__drm_debug & BIT(cate << 146 } << 147 << 148 #define drm_debug_enabled_instrumented(categor << 149 ({ << 150 pr_debug("todo: is this freque << 151 drm_debug_enabled_raw(category << 152 }) << 153 << 154 #if defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) << 155 /* << 156 * the drm.debug API uses dyndbg, so each drm_ << 157 * a descriptor, and only enabled callsites ar << 158 * the private macro to avoid re-testing the e << 159 */ << 160 #define __drm_debug_enabled(category) true << 161 #define drm_debug_enabled(category) drm_de << 162 #else << 163 #define __drm_debug_enabled(category) drm_de << 164 #define drm_debug_enabled(category) drm_de << 165 #endif << 166 << 167 /** << 168 * struct drm_printer - drm output "stream" 64 * struct drm_printer - drm output "stream" 169 * 65 * 170 * Do not use struct members directly. Use dr 66 * Do not use struct members directly. Use drm_printer_seq_file(), 171 * drm_printer_info(), etc to initialize. And 67 * drm_printer_info(), etc to initialize. And drm_printf() for output. 172 */ 68 */ 173 struct drm_printer { 69 struct drm_printer { 174 /* private: */ 70 /* private: */ 175 void (*printfn)(struct drm_printer *p, 71 void (*printfn)(struct drm_printer *p, struct va_format *vaf); 176 void (*puts)(struct drm_printer *p, co 72 void (*puts)(struct drm_printer *p, const char *str); 177 void *arg; 73 void *arg; 178 const void *origin; << 179 const char *prefix; 74 const char *prefix; 180 enum drm_debug_category category; << 181 }; 75 }; 182 76 183 void __drm_printfn_coredump(struct drm_printer 77 void __drm_printfn_coredump(struct drm_printer *p, struct va_format *vaf); 184 void __drm_puts_coredump(struct drm_printer *p 78 void __drm_puts_coredump(struct drm_printer *p, const char *str); 185 void __drm_printfn_seq_file(struct drm_printer 79 void __drm_printfn_seq_file(struct drm_printer *p, struct va_format *vaf); 186 void __drm_puts_seq_file(struct drm_printer *p 80 void __drm_puts_seq_file(struct drm_printer *p, const char *str); 187 void __drm_printfn_info(struct drm_printer *p, 81 void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf); 188 void __drm_printfn_dbg(struct drm_printer *p, !! 82 void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf); 189 void __drm_printfn_err(struct drm_printer *p, << 190 83 191 __printf(2, 3) 84 __printf(2, 3) 192 void drm_printf(struct drm_printer *p, const c 85 void drm_printf(struct drm_printer *p, const char *f, ...); 193 void drm_puts(struct drm_printer *p, const cha 86 void drm_puts(struct drm_printer *p, const char *str); 194 void drm_print_regset32(struct drm_printer *p, << 195 void drm_print_bits(struct drm_printer *p, uns << 196 const char * const bits[], << 197 87 198 __printf(2, 0) 88 __printf(2, 0) 199 /** 89 /** 200 * drm_vprintf - print to a &drm_printer strea 90 * drm_vprintf - print to a &drm_printer stream 201 * @p: the &drm_printer 91 * @p: the &drm_printer 202 * @fmt: format string 92 * @fmt: format string 203 * @va: the va_list 93 * @va: the va_list 204 */ 94 */ 205 static inline void 95 static inline void 206 drm_vprintf(struct drm_printer *p, const char 96 drm_vprintf(struct drm_printer *p, const char *fmt, va_list *va) 207 { 97 { 208 struct va_format vaf = { .fmt = fmt, . 98 struct va_format vaf = { .fmt = fmt, .va = va }; 209 99 210 p->printfn(p, &vaf); 100 p->printfn(p, &vaf); 211 } 101 } 212 102 213 /** 103 /** 214 * drm_printf_indent - Print to a &drm_printer 104 * drm_printf_indent - Print to a &drm_printer stream with indentation 215 * @printer: DRM printer 105 * @printer: DRM printer 216 * @indent: Tab indentation level (max 5) 106 * @indent: Tab indentation level (max 5) 217 * @fmt: Format string 107 * @fmt: Format string 218 */ 108 */ 219 #define drm_printf_indent(printer, indent, fmt 109 #define drm_printf_indent(printer, indent, fmt, ...) \ 220 drm_printf((printer), "%.*s" fmt, (ind 110 drm_printf((printer), "%.*s" fmt, (indent), "\t\t\t\t\tX", ##__VA_ARGS__) 221 111 222 /** 112 /** 223 * struct drm_print_iterator - local struct us 113 * struct drm_print_iterator - local struct used with drm_printer_coredump 224 * @data: Pointer to the devcoredump output bu !! 114 * @data: Pointer to the devcoredump output buffer 225 * drm_printer_coredump to determine size of d << 226 * @start: The offset within the buffer to sta 115 * @start: The offset within the buffer to start writing 227 * @remain: The number of bytes to write for t 116 * @remain: The number of bytes to write for this iteration 228 */ 117 */ 229 struct drm_print_iterator { 118 struct drm_print_iterator { 230 void *data; 119 void *data; 231 ssize_t start; 120 ssize_t start; 232 ssize_t remain; 121 ssize_t remain; 233 /* private: */ 122 /* private: */ 234 ssize_t offset; 123 ssize_t offset; 235 }; 124 }; 236 125 237 /** 126 /** 238 * drm_coredump_printer - construct a &drm_pri 127 * drm_coredump_printer - construct a &drm_printer that can output to a buffer 239 * from the read function for devcoredump 128 * from the read function for devcoredump 240 * @iter: A pointer to a struct drm_print_iter 129 * @iter: A pointer to a struct drm_print_iterator for the read instance 241 * 130 * 242 * This wrapper extends drm_printf() to work w 131 * This wrapper extends drm_printf() to work with a dev_coredumpm() callback 243 * function. The passed in drm_print_iterator 132 * function. The passed in drm_print_iterator struct contains the buffer 244 * pointer, size and offset as passed in from 133 * pointer, size and offset as passed in from devcoredump. 245 * 134 * 246 * For example:: 135 * For example:: 247 * 136 * 248 * void coredump_read(char *buffer, loff_ 137 * void coredump_read(char *buffer, loff_t offset, size_t count, 249 * void *data, size_t datalen) 138 * void *data, size_t datalen) 250 * { 139 * { 251 * struct drm_print_iterator iter 140 * struct drm_print_iterator iter; 252 * struct drm_printer p; 141 * struct drm_printer p; 253 * 142 * 254 * iter.data = buffer; 143 * iter.data = buffer; 255 * iter.start = offset; 144 * iter.start = offset; 256 * iter.remain = count; 145 * iter.remain = count; 257 * 146 * 258 * p = drm_coredump_printer(&iter 147 * p = drm_coredump_printer(&iter); 259 * 148 * 260 * drm_printf(p, "foo=%d\n", foo) 149 * drm_printf(p, "foo=%d\n", foo); 261 * } 150 * } 262 * 151 * 263 * void makecoredump(...) 152 * void makecoredump(...) 264 * { 153 * { 265 * ... 154 * ... 266 * dev_coredumpm(dev, THIS_MODULE 155 * dev_coredumpm(dev, THIS_MODULE, data, 0, GFP_KERNEL, 267 * coredump_read, ...) 156 * coredump_read, ...) 268 * } 157 * } 269 * 158 * 270 * The above example has a time complexity of << 271 * devcoredump. This is acceptable for small d << 272 * larger ones. << 273 * << 274 * Another use case for drm_coredump_printer i << 275 * a saved buffer before the dev_coredump() ca << 276 * one to determine the size of the devcoredum << 277 * buffer. Then, in dev_coredump(), copy from << 278 * devcoredump read buffer. << 279 * << 280 * For example:: << 281 * << 282 * char *devcoredump_saved_buffer; << 283 * << 284 * ssize_t __coredump_print(char *buffer, << 285 * { << 286 * struct drm_print_iterator iter << 287 * struct drm_printer p; << 288 * << 289 * iter.data = buffer; << 290 * iter.start = 0; << 291 * iter.remain = count; << 292 * << 293 * p = drm_coredump_printer(&iter << 294 * << 295 * drm_printf(p, "foo=%d\n", foo) << 296 * ... << 297 * return count - iter.remain; << 298 * } << 299 * << 300 * void coredump_print(...) << 301 * { << 302 * ssize_t count; << 303 * << 304 * count = __coredump_print(NULL, << 305 * devcoredump_saved_buffer = kvm << 306 * __coredump_print(devcoredump_s << 307 * } << 308 * << 309 * void coredump_read(char *buffer, loff_ << 310 * void *data, size_t << 311 * { << 312 * ... << 313 * memcpy(buffer, devcoredump_sav << 314 * ... << 315 * } << 316 * << 317 * The above example has a time complexity of << 318 * devcoredump. This scales better than the pr << 319 * devcoredumps. << 320 * << 321 * RETURNS: 159 * RETURNS: 322 * The &drm_printer object 160 * The &drm_printer object 323 */ 161 */ 324 static inline struct drm_printer 162 static inline struct drm_printer 325 drm_coredump_printer(struct drm_print_iterator 163 drm_coredump_printer(struct drm_print_iterator *iter) 326 { 164 { 327 struct drm_printer p = { 165 struct drm_printer p = { 328 .printfn = __drm_printfn_cored 166 .printfn = __drm_printfn_coredump, 329 .puts = __drm_puts_coredump, 167 .puts = __drm_puts_coredump, 330 .arg = iter, 168 .arg = iter, 331 }; 169 }; 332 170 333 /* Set the internal offset of the iter 171 /* Set the internal offset of the iterator to zero */ 334 iter->offset = 0; 172 iter->offset = 0; 335 173 336 return p; 174 return p; 337 } 175 } 338 176 339 /** 177 /** 340 * drm_seq_file_printer - construct a &drm_pri 178 * drm_seq_file_printer - construct a &drm_printer that outputs to &seq_file 341 * @f: the &struct seq_file to output to 179 * @f: the &struct seq_file to output to 342 * 180 * 343 * RETURNS: 181 * RETURNS: 344 * The &drm_printer object 182 * The &drm_printer object 345 */ 183 */ 346 static inline struct drm_printer drm_seq_file_ 184 static inline struct drm_printer drm_seq_file_printer(struct seq_file *f) 347 { 185 { 348 struct drm_printer p = { 186 struct drm_printer p = { 349 .printfn = __drm_printfn_seq_f 187 .printfn = __drm_printfn_seq_file, 350 .puts = __drm_puts_seq_file, 188 .puts = __drm_puts_seq_file, 351 .arg = f, 189 .arg = f, 352 }; 190 }; 353 return p; 191 return p; 354 } 192 } 355 193 356 /** 194 /** 357 * drm_info_printer - construct a &drm_printer 195 * drm_info_printer - construct a &drm_printer that outputs to dev_printk() 358 * @dev: the &struct device pointer 196 * @dev: the &struct device pointer 359 * 197 * 360 * RETURNS: 198 * RETURNS: 361 * The &drm_printer object 199 * The &drm_printer object 362 */ 200 */ 363 static inline struct drm_printer drm_info_prin 201 static inline struct drm_printer drm_info_printer(struct device *dev) 364 { 202 { 365 struct drm_printer p = { 203 struct drm_printer p = { 366 .printfn = __drm_printfn_info, 204 .printfn = __drm_printfn_info, 367 .arg = dev, 205 .arg = dev, 368 }; 206 }; 369 return p; 207 return p; 370 } 208 } 371 209 372 /** 210 /** 373 * drm_dbg_printer - construct a &drm_printer !! 211 * drm_debug_printer - construct a &drm_printer that outputs to pr_debug() 374 * @drm: the &struct drm_device pointer, or NU !! 212 * @prefix: debug output prefix 375 * @category: the debug category to use << 376 * @prefix: debug output prefix, or NULL for n << 377 * 213 * 378 * RETURNS: 214 * RETURNS: 379 * The &drm_printer object 215 * The &drm_printer object 380 */ 216 */ 381 static inline struct drm_printer drm_dbg_print !! 217 static inline struct drm_printer drm_debug_printer(const char *prefix) 382 << 383 << 384 { 218 { 385 struct drm_printer p = { 219 struct drm_printer p = { 386 .printfn = __drm_printfn_dbg, !! 220 .printfn = __drm_printfn_debug, 387 .arg = drm, << 388 .origin = (const void *)_THIS_ << 389 .prefix = prefix, << 390 .category = category, << 391 }; << 392 return p; << 393 } << 394 << 395 /** << 396 * drm_err_printer - construct a &drm_printer << 397 * @drm: the &struct drm_device pointer << 398 * @prefix: debug output prefix, or NULL for n << 399 * << 400 * RETURNS: << 401 * The &drm_printer object << 402 */ << 403 static inline struct drm_printer drm_err_print << 404 << 405 { << 406 struct drm_printer p = { << 407 .printfn = __drm_printfn_err, << 408 .arg = drm, << 409 .prefix = prefix 221 .prefix = prefix 410 }; 222 }; 411 return p; 223 return p; 412 } 224 } 413 225 414 /* 226 /* 415 * struct device based logging !! 227 * The following categories are defined: >> 228 * >> 229 * CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ... >> 230 * This is the category used by the DRM_DEBUG() macro. 416 * 231 * 417 * Prefer drm_device based logging over device !! 232 * DRIVER: Used in the vendor specific part of the driver: i915, radeon, ... >> 233 * This is the category used by the DRM_DEBUG_DRIVER() macro. >> 234 * >> 235 * KMS: used in the modesetting code. >> 236 * This is the category used by the DRM_DEBUG_KMS() macro. >> 237 * >> 238 * PRIME: used in the prime code. >> 239 * This is the category used by the DRM_DEBUG_PRIME() macro. >> 240 * >> 241 * ATOMIC: used in the atomic code. >> 242 * This is the category used by the DRM_DEBUG_ATOMIC() macro. >> 243 * >> 244 * VBL: used for verbose debug message in the vblank code >> 245 * This is the category used by the DRM_DEBUG_VBL() macro. >> 246 * >> 247 * Enabling verbose debug messages is done through the drm.debug parameter, >> 248 * each category being enabled by a bit. >> 249 * >> 250 * drm.debug=0x1 will enable CORE messages >> 251 * drm.debug=0x2 will enable DRIVER messages >> 252 * drm.debug=0x3 will enable CORE and DRIVER messages >> 253 * ... >> 254 * drm.debug=0x3f will enable all messages >> 255 * >> 256 * An interesting feature is that it's possible to enable verbose logging at >> 257 * run-time by echoing the debug value in its sysfs node: >> 258 * # echo 0xf > /sys/module/drm/parameters/debug 418 */ 259 */ >> 260 #define DRM_UT_NONE 0x00 >> 261 #define DRM_UT_CORE 0x01 >> 262 #define DRM_UT_DRIVER 0x02 >> 263 #define DRM_UT_KMS 0x04 >> 264 #define DRM_UT_PRIME 0x08 >> 265 #define DRM_UT_ATOMIC 0x10 >> 266 #define DRM_UT_VBL 0x20 >> 267 #define DRM_UT_STATE 0x40 >> 268 #define DRM_UT_LEASE 0x80 >> 269 #define DRM_UT_DP 0x100 419 270 420 __printf(3, 4) 271 __printf(3, 4) 421 void drm_dev_printk(const struct device *dev, 272 void drm_dev_printk(const struct device *dev, const char *level, 422 const char *format, ...); 273 const char *format, ...); 423 struct _ddebug; !! 274 __printf(3, 4) 424 __printf(4, 5) !! 275 void drm_dev_dbg(const struct device *dev, unsigned int category, 425 void __drm_dev_dbg(struct _ddebug *desc, const !! 276 const char *format, ...); 426 enum drm_debug_category cat !! 277 >> 278 __printf(2, 3) >> 279 void drm_dbg(unsigned int category, const char *format, ...); >> 280 __printf(1, 2) >> 281 void drm_err(const char *format, ...); >> 282 >> 283 /* Macros to make printk easier */ >> 284 >> 285 #define _DRM_PRINTK(once, level, fmt, ...) \ >> 286 printk##once(KERN_##level "[" DRM_NAME "] " fmt, ##__VA_ARGS__) >> 287 >> 288 #define DRM_INFO(fmt, ...) \ >> 289 _DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__) >> 290 #define DRM_NOTE(fmt, ...) \ >> 291 _DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS__) >> 292 #define DRM_WARN(fmt, ...) \ >> 293 _DRM_PRINTK(, WARNING, fmt, ##__VA_ARGS__) >> 294 >> 295 #define DRM_INFO_ONCE(fmt, ...) \ >> 296 _DRM_PRINTK(_once, INFO, fmt, ##__VA_ARGS__) >> 297 #define DRM_NOTE_ONCE(fmt, ...) \ >> 298 _DRM_PRINTK(_once, NOTICE, fmt, ##__VA_ARGS__) >> 299 #define DRM_WARN_ONCE(fmt, ...) \ >> 300 _DRM_PRINTK(_once, WARNING, fmt, ##__VA_ARGS__) 427 301 428 /** 302 /** 429 * DRM_DEV_ERROR() - Error output. !! 303 * Error output. 430 * << 431 * NOTE: this is deprecated in favor of drm_er << 432 * 304 * 433 * @dev: device pointer 305 * @dev: device pointer 434 * @fmt: printf() like format string. 306 * @fmt: printf() like format string. 435 */ 307 */ 436 #define DRM_DEV_ERROR(dev, fmt, ...) 308 #define DRM_DEV_ERROR(dev, fmt, ...) \ 437 drm_dev_printk(dev, KERN_ERR, "*ERROR* 309 drm_dev_printk(dev, KERN_ERR, "*ERROR* " fmt, ##__VA_ARGS__) >> 310 #define DRM_ERROR(fmt, ...) \ >> 311 drm_err(fmt, ##__VA_ARGS__) 438 312 439 /** 313 /** 440 * DRM_DEV_ERROR_RATELIMITED() - Rate limited !! 314 * Rate limited error output. Like DRM_ERROR() but won't flood the log. 441 * << 442 * NOTE: this is deprecated in favor of drm_er << 443 * dev_err_ratelimited(). << 444 * 315 * 445 * @dev: device pointer 316 * @dev: device pointer 446 * @fmt: printf() like format string. 317 * @fmt: printf() like format string. 447 * << 448 * Like DRM_ERROR() but won't flood the log. << 449 */ 318 */ 450 #define DRM_DEV_ERROR_RATELIMITED(dev, fmt, .. 319 #define DRM_DEV_ERROR_RATELIMITED(dev, fmt, ...) \ 451 ({ 320 ({ \ 452 static DEFINE_RATELIMIT_STATE(_rs, 321 static DEFINE_RATELIMIT_STATE(_rs, \ 453 DEFAULT_ 322 DEFAULT_RATELIMIT_INTERVAL, \ 454 DEFAULT_ 323 DEFAULT_RATELIMIT_BURST); \ 455 324 \ 456 if (__ratelimit(&_rs)) 325 if (__ratelimit(&_rs)) \ 457 DRM_DEV_ERROR(dev, fmt, ##__VA 326 DRM_DEV_ERROR(dev, fmt, ##__VA_ARGS__); \ 458 }) 327 }) >> 328 #define DRM_ERROR_RATELIMITED(fmt, ...) \ >> 329 DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__) 459 330 460 /* NOTE: this is deprecated in favor of drm_in !! 331 #define DRM_DEV_INFO(dev, fmt, ...) \ 461 #define DRM_DEV_INFO(dev, fmt, ...) << 462 drm_dev_printk(dev, KERN_INFO, fmt, ## 332 drm_dev_printk(dev, KERN_INFO, fmt, ##__VA_ARGS__) 463 333 464 /* NOTE: this is deprecated in favor of drm_in << 465 #define DRM_DEV_INFO_ONCE(dev, fmt, ...) 334 #define DRM_DEV_INFO_ONCE(dev, fmt, ...) \ 466 ({ 335 ({ \ 467 static bool __print_once __read_mostly 336 static bool __print_once __read_mostly; \ 468 if (!__print_once) { 337 if (!__print_once) { \ 469 __print_once = true; 338 __print_once = true; \ 470 DRM_DEV_INFO(dev, fmt, ##__VA_ 339 DRM_DEV_INFO(dev, fmt, ##__VA_ARGS__); \ 471 } 340 } \ 472 }) 341 }) 473 342 474 #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) << 475 #define drm_dev_dbg(dev, cat, fmt, ...) << 476 __drm_dev_dbg(NULL, dev, cat, fmt, ##_ << 477 #else << 478 #define drm_dev_dbg(dev, cat, fmt, ...) << 479 _dynamic_func_call_cls(cat, fmt, __drm << 480 dev, cat, fmt, << 481 #endif << 482 << 483 /** 343 /** 484 * DRM_DEV_DEBUG() - Debug output for generic !! 344 * Debug output. 485 * << 486 * NOTE: this is deprecated in favor of drm_db << 487 * 345 * 488 * @dev: device pointer 346 * @dev: device pointer 489 * @fmt: printf() like format string. 347 * @fmt: printf() like format string. 490 */ 348 */ 491 #define DRM_DEV_DEBUG(dev, fmt, ...) 349 #define DRM_DEV_DEBUG(dev, fmt, ...) \ 492 drm_dev_dbg(dev, DRM_UT_CORE, fmt, ##_ 350 drm_dev_dbg(dev, DRM_UT_CORE, fmt, ##__VA_ARGS__) 493 /** << 494 * DRM_DEV_DEBUG_DRIVER() - Debug output for v << 495 * << 496 * NOTE: this is deprecated in favor of drm_db << 497 * << 498 * @dev: device pointer << 499 * @fmt: printf() like format string. << 500 */ << 501 #define DRM_DEV_DEBUG_DRIVER(dev, fmt, ...) << 502 drm_dev_dbg(dev, DRM_UT_DRIVER, fmt, # << 503 /** << 504 * DRM_DEV_DEBUG_KMS() - Debug output for mode << 505 * << 506 * NOTE: this is deprecated in favor of drm_db << 507 * << 508 * @dev: device pointer << 509 * @fmt: printf() like format string. << 510 */ << 511 #define DRM_DEV_DEBUG_KMS(dev, fmt, ...) << 512 drm_dev_dbg(dev, DRM_UT_KMS, fmt, ##__ << 513 << 514 /* << 515 * struct drm_device based logging << 516 * << 517 * Prefer drm_device based logging over device << 518 */ << 519 << 520 /* Helper for struct drm_device based logging. << 521 #define __drm_printk(drm, level, type, fmt, .. << 522 dev_##level##type((drm) ? (drm)->dev : << 523 << 524 << 525 #define drm_info(drm, fmt, ...) << 526 __drm_printk((drm), info,, fmt, ##__VA << 527 << 528 #define drm_notice(drm, fmt, ...) << 529 __drm_printk((drm), notice,, fmt, ##__ << 530 << 531 #define drm_warn(drm, fmt, ...) << 532 __drm_printk((drm), warn,, fmt, ##__VA << 533 << 534 #define drm_err(drm, fmt, ...) << 535 __drm_printk((drm), err,, "*ERROR* " f << 536 << 537 << 538 #define drm_info_once(drm, fmt, ...) << 539 __drm_printk((drm), info, _once, fmt, << 540 << 541 #define drm_notice_once(drm, fmt, ...) << 542 __drm_printk((drm), notice, _once, fmt << 543 << 544 #define drm_warn_once(drm, fmt, ...) << 545 __drm_printk((drm), warn, _once, fmt, << 546 << 547 #define drm_err_once(drm, fmt, ...) << 548 __drm_printk((drm), err, _once, "*ERRO << 549 << 550 << 551 #define drm_err_ratelimited(drm, fmt, ...) << 552 __drm_printk((drm), err, _ratelimited, << 553 << 554 << 555 #define drm_dbg_core(drm, fmt, ...) << 556 drm_dev_dbg((drm) ? (drm)->dev : NULL, << 557 #define drm_dbg_driver(drm, fmt, ...) << 558 drm_dev_dbg((drm) ? (drm)->dev : NULL, << 559 #define drm_dbg_kms(drm, fmt, ...) << 560 drm_dev_dbg((drm) ? (drm)->dev : NULL, << 561 #define drm_dbg_prime(drm, fmt, ...) << 562 drm_dev_dbg((drm) ? (drm)->dev : NULL, << 563 #define drm_dbg_atomic(drm, fmt, ...) << 564 drm_dev_dbg((drm) ? (drm)->dev : NULL, << 565 #define drm_dbg_vbl(drm, fmt, ...) << 566 drm_dev_dbg((drm) ? (drm)->dev : NULL, << 567 #define drm_dbg_state(drm, fmt, ...) << 568 drm_dev_dbg((drm) ? (drm)->dev : NULL, << 569 #define drm_dbg_lease(drm, fmt, ...) << 570 drm_dev_dbg((drm) ? (drm)->dev : NULL, << 571 #define drm_dbg_dp(drm, fmt, ...) << 572 drm_dev_dbg((drm) ? (drm)->dev : NULL, << 573 #define drm_dbg_drmres(drm, fmt, ...) << 574 drm_dev_dbg((drm) ? (drm)->dev : NULL, << 575 << 576 #define drm_dbg(drm, fmt, ...) drm_dbg_driver << 577 << 578 /* << 579 * printk based logging << 580 * << 581 * Prefer drm_device based logging over device << 582 */ << 583 << 584 __printf(1, 2) << 585 void __drm_err(const char *format, ...); << 586 << 587 #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) << 588 #define __drm_dbg(cat, fmt, ...) __drm_ << 589 #else << 590 #define __drm_dbg(cat, fmt, ...) << 591 _dynamic_func_call_cls(cat, fmt, __drm << 592 NULL, cat, fmt, << 593 #endif << 594 << 595 /* Macros to make printk easier */ << 596 << 597 #define _DRM_PRINTK(once, level, fmt, ...) << 598 printk##once(KERN_##level "[" DRM_NAME << 599 << 600 /* NOTE: this is deprecated in favor of pr_inf << 601 #define DRM_INFO(fmt, ...) << 602 _DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__ << 603 /* NOTE: this is deprecated in favor of pr_not << 604 #define DRM_NOTE(fmt, ...) << 605 _DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS << 606 /* NOTE: this is deprecated in favor of pr_war << 607 #define DRM_WARN(fmt, ...) << 608 _DRM_PRINTK(, WARNING, fmt, ##__VA_ARG << 609 << 610 /* NOTE: this is deprecated in favor of pr_inf << 611 #define DRM_INFO_ONCE(fmt, ...) << 612 _DRM_PRINTK(_once, INFO, fmt, ##__VA_A << 613 /* NOTE: this is deprecated in favor of pr_not << 614 #define DRM_NOTE_ONCE(fmt, ...) << 615 _DRM_PRINTK(_once, NOTICE, fmt, ##__VA << 616 /* NOTE: this is deprecated in favor of pr_war << 617 #define DRM_WARN_ONCE(fmt, ...) << 618 _DRM_PRINTK(_once, WARNING, fmt, ##__V << 619 << 620 /* NOTE: this is deprecated in favor of pr_err << 621 #define DRM_ERROR(fmt, ...) << 622 __drm_err(fmt, ##__VA_ARGS__) << 623 << 624 /* NOTE: this is deprecated in favor of pr_err << 625 #define DRM_ERROR_RATELIMITED(fmt, ...) << 626 DRM_DEV_ERROR_RATELIMITED(NULL, fmt, # << 627 << 628 /* NOTE: this is deprecated in favor of drm_db << 629 #define DRM_DEBUG(fmt, ...) 351 #define DRM_DEBUG(fmt, ...) \ 630 __drm_dbg(DRM_UT_CORE, fmt, ##__VA_ARG !! 352 drm_dbg(DRM_UT_CORE, fmt, ##__VA_ARGS__) 631 353 632 /* NOTE: this is deprecated in favor of drm_db !! 354 #define DRM_DEV_DEBUG_DRIVER(dev, fmt, ...) \ >> 355 drm_dev_dbg(dev, DRM_UT_DRIVER, fmt, ##__VA_ARGS__) 633 #define DRM_DEBUG_DRIVER(fmt, ...) 356 #define DRM_DEBUG_DRIVER(fmt, ...) \ 634 __drm_dbg(DRM_UT_DRIVER, fmt, ##__VA_A !! 357 drm_dbg(DRM_UT_DRIVER, fmt, ##__VA_ARGS__) 635 358 636 /* NOTE: this is deprecated in favor of drm_db !! 359 #define DRM_DEV_DEBUG_KMS(dev, fmt, ...) \ >> 360 drm_dev_dbg(dev, DRM_UT_KMS, fmt, ##__VA_ARGS__) 637 #define DRM_DEBUG_KMS(fmt, ...) 361 #define DRM_DEBUG_KMS(fmt, ...) \ 638 __drm_dbg(DRM_UT_KMS, fmt, ##__VA_ARGS !! 362 drm_dbg(DRM_UT_KMS, fmt, ##__VA_ARGS__) 639 363 640 /* NOTE: this is deprecated in favor of drm_db !! 364 #define DRM_DEV_DEBUG_PRIME(dev, fmt, ...) \ >> 365 drm_dev_dbg(dev, DRM_UT_PRIME, fmt, ##__VA_ARGS__) 641 #define DRM_DEBUG_PRIME(fmt, ...) 366 #define DRM_DEBUG_PRIME(fmt, ...) \ 642 __drm_dbg(DRM_UT_PRIME, fmt, ##__VA_AR !! 367 drm_dbg(DRM_UT_PRIME, fmt, ##__VA_ARGS__) 643 368 644 /* NOTE: this is deprecated in favor of drm_db !! 369 #define DRM_DEV_DEBUG_ATOMIC(dev, fmt, ...) \ >> 370 drm_dev_dbg(dev, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__) 645 #define DRM_DEBUG_ATOMIC(fmt, ...) 371 #define DRM_DEBUG_ATOMIC(fmt, ...) \ 646 __drm_dbg(DRM_UT_ATOMIC, fmt, ##__VA_A !! 372 drm_dbg(DRM_UT_ATOMIC, fmt, ##__VA_ARGS__) 647 373 648 /* NOTE: this is deprecated in favor of drm_db !! 374 #define DRM_DEV_DEBUG_VBL(dev, fmt, ...) \ >> 375 drm_dev_dbg(dev, DRM_UT_VBL, fmt, ##__VA_ARGS__) 649 #define DRM_DEBUG_VBL(fmt, ...) 376 #define DRM_DEBUG_VBL(fmt, ...) \ 650 __drm_dbg(DRM_UT_VBL, fmt, ##__VA_ARGS !! 377 drm_dbg(DRM_UT_VBL, fmt, ##__VA_ARGS__) 651 378 652 /* NOTE: this is deprecated in favor of drm_db << 653 #define DRM_DEBUG_LEASE(fmt, ...) 379 #define DRM_DEBUG_LEASE(fmt, ...) \ 654 __drm_dbg(DRM_UT_LEASE, fmt, ##__VA_AR !! 380 drm_dbg(DRM_UT_LEASE, fmt, ##__VA_ARGS__) 655 381 656 /* NOTE: this is deprecated in favor of drm_db !! 382 #define DRM_DEV_DEBUG_DP(dev, fmt, ...) \ >> 383 drm_dev_dbg(dev, DRM_UT_DP, fmt, ## __VA_ARGS__) 657 #define DRM_DEBUG_DP(fmt, ...) 384 #define DRM_DEBUG_DP(fmt, ...) \ 658 __drm_dbg(DRM_UT_DP, fmt, ## __VA_ARGS !! 385 drm_dbg(DRM_UT_DP, fmt, ## __VA_ARGS__) 659 386 660 #define __DRM_DEFINE_DBG_RATELIMITED(category, !! 387 #define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, category, fmt, ...) \ 661 ({ !! 388 ({ \ 662 static DEFINE_RATELIMIT_STATE(rs_, DEF !! 389 static DEFINE_RATELIMIT_STATE(_rs, \ 663 const struct drm_device *drm_ = (drm); !! 390 DEFAULT_RATELIMIT_INTERVAL, \ 664 !! 391 DEFAULT_RATELIMIT_BURST); \ 665 if (drm_debug_enabled(DRM_UT_ ## categ !! 392 if (__ratelimit(&_rs)) \ 666 drm_dev_printk(drm_ ? drm_->de !! 393 drm_dev_dbg(dev, category, fmt, ##__VA_ARGS__); \ 667 }) 394 }) 668 395 669 #define drm_dbg_ratelimited(drm, fmt, ...) \ !! 396 /** 670 __DRM_DEFINE_DBG_RATELIMITED(DRIVER, d !! 397 * Rate limited debug output. Like DRM_DEBUG() but won't flood the log. 671 << 672 #define drm_dbg_kms_ratelimited(drm, fmt, ...) << 673 __DRM_DEFINE_DBG_RATELIMITED(KMS, drm, << 674 << 675 /* << 676 * struct drm_device based WARNs << 677 * << 678 * drm_WARN*() acts like WARN*(), but with the << 679 * using device specific information so that w << 680 * warning is originating from. << 681 * 398 * 682 * Prefer drm_device based drm_WARN* over regu !! 399 * @dev: device pointer >> 400 * @fmt: printf() like format string. 683 */ 401 */ 684 !! 402 #define DRM_DEV_DEBUG_RATELIMITED(dev, fmt, ...) \ 685 /* Helper for struct drm_device based WARNs */ !! 403 _DEV_DRM_DEFINE_DEBUG_RATELIMITED(dev, DRM_UT_CORE, \ 686 #define drm_WARN(drm, condition, format, arg.. !! 404 fmt, ##__VA_ARGS__) 687 WARN(condition, "%s %s: [drm] " format !! 405 #define DRM_DEBUG_RATELIMITED(fmt, ...) \ 688 dev_driver_string((drm !! 406 DRM_DEV_DEBUG_RATELIMITED(NULL, fmt, ##__VA_ARGS__) 689 dev_name((drm)->dev), !! 407 690 !! 408 #define DRM_DEV_DEBUG_DRIVER_RATELIMITED(dev, fmt, ...) \ 691 #define drm_WARN_ONCE(drm, condition, format, !! 409 _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRM_UT_DRIVER, \ 692 WARN_ONCE(condition, "%s %s: [drm] " f !! 410 fmt, ##__VA_ARGS__) 693 dev_driver_string((drm !! 411 #define DRM_DEBUG_DRIVER_RATELIMITED(fmt, ...) \ 694 dev_name((drm)->dev), !! 412 DRM_DEV_DEBUG_DRIVER_RATELIMITED(NULL, fmt, ##__VA_ARGS__) 695 !! 413 696 #define drm_WARN_ON(drm, x) !! 414 #define DRM_DEV_DEBUG_KMS_RATELIMITED(dev, fmt, ...) \ 697 drm_WARN((drm), (x), "%s", !! 415 _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRM_UT_KMS, \ 698 "drm_WARN_ON(" __stringify(x) !! 416 fmt, ##__VA_ARGS__) 699 !! 417 #define DRM_DEBUG_KMS_RATELIMITED(fmt, ...) \ 700 #define drm_WARN_ON_ONCE(drm, x) !! 418 DRM_DEV_DEBUG_KMS_RATELIMITED(NULL, fmt, ##__VA_ARGS__) 701 drm_WARN_ONCE((drm), (x), "%s", !! 419 702 "drm_WARN_ON_ONCE(" __st !! 420 #define DRM_DEV_DEBUG_PRIME_RATELIMITED(dev, fmt, ...) \ >> 421 _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRM_UT_PRIME, \ >> 422 fmt, ##__VA_ARGS__) >> 423 #define DRM_DEBUG_PRIME_RATELIMITED(fmt, ...) \ >> 424 DRM_DEV_DEBUG_PRIME_RATELIMITED(NULL, fmt, ##__VA_ARGS__) 703 425 704 #endif /* DRM_PRINT_H_ */ 426 #endif /* DRM_PRINT_H_ */ 705 427
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.