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