~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/drm/drm_print.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/drm/drm_print.h (Version linux-6.12-rc7) and /include/drm/drm_print.h (Version linux-6.1.116)


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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php