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

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

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/drm/drm_print.h (Architecture sparc64) and /include/drm/drm_print.h (Architecture i386)


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

~ [ 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