Home | History | Annotate | Line # | Download | only in drm
drm_print.c revision 1.9
      1  1.9  riastrad /*	$NetBSD: drm_print.c,v 1.9 2021/12/19 11:46:00 riastradh Exp $	*/
      2  1.1  riastrad 
      3  1.1  riastrad /*
      4  1.1  riastrad  * Copyright (C) 2016 Red Hat
      5  1.1  riastrad  *
      6  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining a
      7  1.1  riastrad  * copy of this software and associated documentation files (the "Software"),
      8  1.1  riastrad  * to deal in the Software without restriction, including without limitation
      9  1.1  riastrad  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     10  1.1  riastrad  * and/or sell copies of the Software, and to permit persons to whom the
     11  1.1  riastrad  * Software is furnished to do so, subject to the following conditions:
     12  1.1  riastrad  *
     13  1.1  riastrad  * The above copyright notice and this permission notice shall be included in
     14  1.1  riastrad  * all copies or substantial portions of the Software.
     15  1.1  riastrad  *
     16  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17  1.1  riastrad  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18  1.1  riastrad  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     19  1.1  riastrad  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     20  1.1  riastrad  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     21  1.1  riastrad  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     22  1.1  riastrad  * OTHER DEALINGS IN THE SOFTWARE.
     23  1.1  riastrad  *
     24  1.1  riastrad  * Authors:
     25  1.1  riastrad  * Rob Clark <robdclark (at) gmail.com>
     26  1.1  riastrad  */
     27  1.1  riastrad 
     28  1.1  riastrad #include <sys/cdefs.h>
     29  1.9  riastrad __KERNEL_RCSID(0, "$NetBSD: drm_print.c,v 1.9 2021/12/19 11:46:00 riastradh Exp $");
     30  1.1  riastrad 
     31  1.4  riastrad #ifndef __NetBSD__		/* XXX ??? */
     32  1.1  riastrad #define DEBUG /* for pr_debug() */
     33  1.4  riastrad #endif
     34  1.1  riastrad 
     35  1.3  riastrad #ifdef __NetBSD__
     36  1.6  riastrad #include <sys/param.h>
     37  1.3  riastrad #include <sys/stdarg.h>
     38  1.6  riastrad #include <sys/device.h>
     39  1.9  riastrad #include <sys/ksyms.h>
     40  1.3  riastrad #else
     41  1.1  riastrad #include <stdarg.h>
     42  1.1  riastrad 
     43  1.1  riastrad #include <linux/io.h>
     44  1.1  riastrad #include <linux/moduleparam.h>
     45  1.3  riastrad #endif
     46  1.1  riastrad #include <linux/seq_file.h>
     47  1.1  riastrad #include <linux/slab.h>
     48  1.1  riastrad 
     49  1.1  riastrad #include <drm/drm.h>
     50  1.1  riastrad #include <drm/drm_drv.h>
     51  1.1  riastrad #include <drm/drm_print.h>
     52  1.1  riastrad 
     53  1.1  riastrad /*
     54  1.1  riastrad  * __drm_debug: Enable debug output.
     55  1.1  riastrad  * Bitmask of DRM_UT_x. See include/drm/drm_print.h for details.
     56  1.1  riastrad  */
     57  1.1  riastrad unsigned int __drm_debug;
     58  1.1  riastrad EXPORT_SYMBOL(__drm_debug);
     59  1.1  riastrad 
     60  1.7  riastrad #ifdef __linux__
     61  1.1  riastrad MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug category.\n"
     62  1.1  riastrad "\t\tBit 0 (0x01)  will enable CORE messages (drm core code)\n"
     63  1.1  riastrad "\t\tBit 1 (0x02)  will enable DRIVER messages (drm controller code)\n"
     64  1.1  riastrad "\t\tBit 2 (0x04)  will enable KMS messages (modesetting code)\n"
     65  1.1  riastrad "\t\tBit 3 (0x08)  will enable PRIME messages (prime code)\n"
     66  1.1  riastrad "\t\tBit 4 (0x10)  will enable ATOMIC messages (atomic code)\n"
     67  1.1  riastrad "\t\tBit 5 (0x20)  will enable VBL messages (vblank code)\n"
     68  1.1  riastrad "\t\tBit 7 (0x80)  will enable LEASE messages (leasing code)\n"
     69  1.1  riastrad "\t\tBit 8 (0x100) will enable DP messages (displayport code)");
     70  1.1  riastrad module_param_named(debug, __drm_debug, int, 0600);
     71  1.7  riastrad #endif
     72  1.1  riastrad 
     73  1.9  riastrad #ifdef __NetBSD__
     74  1.9  riastrad static void
     75  1.9  riastrad drm_symstr(vaddr_t val, char *out, size_t outsize)
     76  1.9  riastrad {
     77  1.9  riastrad 	unsigned long naddr;
     78  1.9  riastrad 	const char *mod;
     79  1.9  riastrad 	const char *sym;
     80  1.9  riastrad 
     81  1.9  riastrad 	if (ksyms_getname(&mod, &sym, val, KSYMS_PROC|KSYMS_CLOSEST) == 0) {
     82  1.9  riastrad 		char offset[32];
     83  1.9  riastrad 
     84  1.9  riastrad 		if (ksyms_getval(mod, sym, &naddr, KSYMS_ANY) == 0 &&
     85  1.9  riastrad 		    (val - naddr) != 0)
     86  1.9  riastrad 			snprintf(offset, sizeof offset, "+%p",
     87  1.9  riastrad 			    (void *)(val - naddr));
     88  1.9  riastrad 		else
     89  1.9  riastrad 			offset[0] = '\0';
     90  1.9  riastrad 		snprintf(out, outsize, "%s:%s%s", mod, sym, offset);
     91  1.9  riastrad 		return;
     92  1.9  riastrad 	}
     93  1.9  riastrad 	snprintf(out, outsize, "%p", (void *)val);
     94  1.9  riastrad }
     95  1.9  riastrad #endif
     96  1.9  riastrad 
     97  1.1  riastrad void __drm_puts_coredump(struct drm_printer *p, const char *str)
     98  1.1  riastrad {
     99  1.1  riastrad 	struct drm_print_iterator *iterator = p->arg;
    100  1.1  riastrad 	ssize_t len;
    101  1.1  riastrad 
    102  1.1  riastrad 	if (!iterator->remain)
    103  1.1  riastrad 		return;
    104  1.1  riastrad 
    105  1.1  riastrad 	if (iterator->offset < iterator->start) {
    106  1.1  riastrad 		ssize_t copy;
    107  1.1  riastrad 
    108  1.1  riastrad 		len = strlen(str);
    109  1.1  riastrad 
    110  1.1  riastrad 		if (iterator->offset + len <= iterator->start) {
    111  1.1  riastrad 			iterator->offset += len;
    112  1.1  riastrad 			return;
    113  1.1  riastrad 		}
    114  1.1  riastrad 
    115  1.1  riastrad 		copy = len - (iterator->start - iterator->offset);
    116  1.1  riastrad 
    117  1.1  riastrad 		if (copy > iterator->remain)
    118  1.1  riastrad 			copy = iterator->remain;
    119  1.1  riastrad 
    120  1.1  riastrad 		/* Copy out the bit of the string that we need */
    121  1.1  riastrad 		memcpy(iterator->data,
    122  1.1  riastrad 			str + (iterator->start - iterator->offset), copy);
    123  1.1  riastrad 
    124  1.1  riastrad 		iterator->offset = iterator->start + copy;
    125  1.1  riastrad 		iterator->remain -= copy;
    126  1.1  riastrad 	} else {
    127  1.1  riastrad 		ssize_t pos = iterator->offset - iterator->start;
    128  1.1  riastrad 
    129  1.1  riastrad 		len = min_t(ssize_t, strlen(str), iterator->remain);
    130  1.1  riastrad 
    131  1.4  riastrad 		memcpy((char *)iterator->data + pos, str, len);
    132  1.1  riastrad 
    133  1.1  riastrad 		iterator->offset += len;
    134  1.1  riastrad 		iterator->remain -= len;
    135  1.1  riastrad 	}
    136  1.1  riastrad }
    137  1.1  riastrad EXPORT_SYMBOL(__drm_puts_coredump);
    138  1.1  riastrad 
    139  1.1  riastrad void __drm_printfn_coredump(struct drm_printer *p, struct va_format *vaf)
    140  1.1  riastrad {
    141  1.1  riastrad 	struct drm_print_iterator *iterator = p->arg;
    142  1.1  riastrad 	size_t len;
    143  1.1  riastrad 	char *buf;
    144  1.1  riastrad 
    145  1.1  riastrad 	if (!iterator->remain)
    146  1.1  riastrad 		return;
    147  1.1  riastrad 
    148  1.1  riastrad 	/* Figure out how big the string will be */
    149  1.1  riastrad 	len = snprintf(NULL, 0, "%pV", vaf);
    150  1.1  riastrad 
    151  1.1  riastrad 	/* This is the easiest path, we've already advanced beyond the offset */
    152  1.1  riastrad 	if (iterator->offset + len <= iterator->start) {
    153  1.1  riastrad 		iterator->offset += len;
    154  1.1  riastrad 		return;
    155  1.1  riastrad 	}
    156  1.1  riastrad 
    157  1.1  riastrad 	/* Then check if we can directly copy into the target buffer */
    158  1.1  riastrad 	if ((iterator->offset >= iterator->start) && (len < iterator->remain)) {
    159  1.1  riastrad 		ssize_t pos = iterator->offset - iterator->start;
    160  1.1  riastrad 
    161  1.1  riastrad 		snprintf(((char *) iterator->data) + pos,
    162  1.1  riastrad 			iterator->remain, "%pV", vaf);
    163  1.1  riastrad 
    164  1.1  riastrad 		iterator->offset += len;
    165  1.1  riastrad 		iterator->remain -= len;
    166  1.1  riastrad 
    167  1.1  riastrad 		return;
    168  1.1  riastrad 	}
    169  1.1  riastrad 
    170  1.1  riastrad 	/*
    171  1.1  riastrad 	 * Finally, hit the slow path and make a temporary string to copy over
    172  1.1  riastrad 	 * using _drm_puts_coredump
    173  1.1  riastrad 	 */
    174  1.1  riastrad 	buf = kmalloc(len + 1, GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY);
    175  1.1  riastrad 	if (!buf)
    176  1.1  riastrad 		return;
    177  1.1  riastrad 
    178  1.1  riastrad 	snprintf(buf, len + 1, "%pV", vaf);
    179  1.1  riastrad 	__drm_puts_coredump(p, (const char *) buf);
    180  1.1  riastrad 
    181  1.1  riastrad 	kfree(buf);
    182  1.1  riastrad }
    183  1.1  riastrad EXPORT_SYMBOL(__drm_printfn_coredump);
    184  1.1  riastrad 
    185  1.4  riastrad #ifndef __NetBSD__		/* XXX seq file */
    186  1.1  riastrad void __drm_puts_seq_file(struct drm_printer *p, const char *str)
    187  1.1  riastrad {
    188  1.1  riastrad 	seq_puts(p->arg, str);
    189  1.1  riastrad }
    190  1.1  riastrad EXPORT_SYMBOL(__drm_puts_seq_file);
    191  1.4  riastrad #endif
    192  1.1  riastrad 
    193  1.4  riastrad #ifndef __NetBSD__		/* XXX seq file */
    194  1.1  riastrad void __drm_printfn_seq_file(struct drm_printer *p, struct va_format *vaf)
    195  1.1  riastrad {
    196  1.1  riastrad 	seq_printf(p->arg, "%pV", vaf);
    197  1.1  riastrad }
    198  1.1  riastrad EXPORT_SYMBOL(__drm_printfn_seq_file);
    199  1.4  riastrad #endif
    200  1.1  riastrad 
    201  1.1  riastrad void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf)
    202  1.1  riastrad {
    203  1.9  riastrad #ifdef __NetBSD__
    204  1.9  riastrad 	dev_info(p->arg, "[" DRM_NAME "] ");
    205  1.9  riastrad 	vprintf(vaf->fmt, *vaf->va);	/* XXX */
    206  1.9  riastrad #else
    207  1.1  riastrad 	dev_info(p->arg, "[" DRM_NAME "] %pV", vaf);
    208  1.9  riastrad #endif
    209  1.1  riastrad }
    210  1.1  riastrad EXPORT_SYMBOL(__drm_printfn_info);
    211  1.1  riastrad 
    212  1.1  riastrad void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf)
    213  1.1  riastrad {
    214  1.9  riastrad #ifdef __NetBSD__
    215  1.9  riastrad 	pr_debug("%s ", p->prefix);
    216  1.9  riastrad 	vprintf(vaf->fmt, *vaf->va);	/* XXX */
    217  1.9  riastrad #else
    218  1.1  riastrad 	pr_debug("%s %pV", p->prefix, vaf);
    219  1.9  riastrad #endif
    220  1.1  riastrad }
    221  1.1  riastrad EXPORT_SYMBOL(__drm_printfn_debug);
    222  1.1  riastrad 
    223  1.1  riastrad void __drm_printfn_err(struct drm_printer *p, struct va_format *vaf)
    224  1.1  riastrad {
    225  1.9  riastrad #ifdef __NetBSD__
    226  1.9  riastrad 	pr_err("*ERROR* %s ", p->prefix);
    227  1.9  riastrad 	vprintf(vaf->fmt, *vaf->va);	/* XXX */
    228  1.9  riastrad #else
    229  1.1  riastrad 	pr_err("*ERROR* %s %pV", p->prefix, vaf);
    230  1.9  riastrad #endif
    231  1.1  riastrad }
    232  1.1  riastrad EXPORT_SYMBOL(__drm_printfn_err);
    233  1.1  riastrad 
    234  1.1  riastrad /**
    235  1.1  riastrad  * drm_puts - print a const string to a &drm_printer stream
    236  1.1  riastrad  * @p: the &drm printer
    237  1.1  riastrad  * @str: const string
    238  1.1  riastrad  *
    239  1.1  riastrad  * Allow &drm_printer types that have a constant string
    240  1.1  riastrad  * option to use it.
    241  1.1  riastrad  */
    242  1.1  riastrad void drm_puts(struct drm_printer *p, const char *str)
    243  1.1  riastrad {
    244  1.1  riastrad 	if (p->puts)
    245  1.1  riastrad 		p->puts(p, str);
    246  1.1  riastrad 	else
    247  1.1  riastrad 		drm_printf(p, "%s", str);
    248  1.1  riastrad }
    249  1.1  riastrad EXPORT_SYMBOL(drm_puts);
    250  1.1  riastrad 
    251  1.1  riastrad /**
    252  1.1  riastrad  * drm_printf - print to a &drm_printer stream
    253  1.1  riastrad  * @p: the &drm_printer
    254  1.1  riastrad  * @f: format string
    255  1.1  riastrad  */
    256  1.1  riastrad void drm_printf(struct drm_printer *p, const char *f, ...)
    257  1.1  riastrad {
    258  1.1  riastrad 	va_list args;
    259  1.1  riastrad 
    260  1.1  riastrad 	va_start(args, f);
    261  1.1  riastrad 	drm_vprintf(p, f, &args);
    262  1.1  riastrad 	va_end(args);
    263  1.1  riastrad }
    264  1.1  riastrad EXPORT_SYMBOL(drm_printf);
    265  1.1  riastrad 
    266  1.1  riastrad /**
    267  1.1  riastrad  * drm_print_bits - print bits to a &drm_printer stream
    268  1.1  riastrad  *
    269  1.1  riastrad  * Print bits (in flag fields for example) in human readable form.
    270  1.1  riastrad  *
    271  1.1  riastrad  * @p: the &drm_printer
    272  1.1  riastrad  * @value: field value.
    273  1.1  riastrad  * @bits: Array with bit names.
    274  1.1  riastrad  * @nbits: Size of bit names array.
    275  1.1  riastrad  */
    276  1.1  riastrad void drm_print_bits(struct drm_printer *p, unsigned long value,
    277  1.1  riastrad 		    const char * const bits[], unsigned int nbits)
    278  1.1  riastrad {
    279  1.1  riastrad 	bool first = true;
    280  1.1  riastrad 	unsigned int i;
    281  1.1  riastrad 
    282  1.1  riastrad 	if (WARN_ON_ONCE(nbits > BITS_PER_TYPE(value)))
    283  1.1  riastrad 		nbits = BITS_PER_TYPE(value);
    284  1.1  riastrad 
    285  1.1  riastrad 	for_each_set_bit(i, &value, nbits) {
    286  1.1  riastrad 		if (WARN_ON_ONCE(!bits[i]))
    287  1.1  riastrad 			continue;
    288  1.1  riastrad 		drm_printf(p, "%s%s", first ? "" : ",",
    289  1.1  riastrad 			   bits[i]);
    290  1.1  riastrad 		first = false;
    291  1.1  riastrad 	}
    292  1.1  riastrad 	if (first)
    293  1.1  riastrad 		drm_printf(p, "(none)");
    294  1.1  riastrad }
    295  1.1  riastrad EXPORT_SYMBOL(drm_print_bits);
    296  1.1  riastrad 
    297  1.1  riastrad void drm_dev_printk(const struct device *dev, const char *level,
    298  1.1  riastrad 		    const char *format, ...)
    299  1.1  riastrad {
    300  1.4  riastrad #ifdef __NetBSD__
    301  1.4  riastrad 	va_list va;
    302  1.9  riastrad 	char symbuf[128];
    303  1.9  riastrad 
    304  1.9  riastrad 	drm_symstr((vaddr_t)__builtin_return_address(0), symbuf, sizeof symbuf);
    305  1.9  riastrad 	if (dev)
    306  1.9  riastrad 		printf("%s [" DRM_NAME ":%s] ", device_xname(__UNCONST(dev)), symbuf);
    307  1.9  riastrad 	else
    308  1.9  riastrad 		printf("[" DRM_NAME ":%s] ", symbuf);
    309  1.4  riastrad 
    310  1.4  riastrad 	va_start(va, format);
    311  1.4  riastrad 	vprintf(format, va);
    312  1.4  riastrad 	va_end(va);
    313  1.4  riastrad #else
    314  1.1  riastrad 	struct va_format vaf;
    315  1.1  riastrad 	va_list args;
    316  1.1  riastrad 
    317  1.1  riastrad 	va_start(args, format);
    318  1.1  riastrad 	vaf.fmt = format;
    319  1.1  riastrad 	vaf.va = &args;
    320  1.1  riastrad 
    321  1.1  riastrad 	if (dev)
    322  1.1  riastrad 		dev_printk(level, dev, "[" DRM_NAME ":%ps] %pV",
    323  1.1  riastrad 			   __builtin_return_address(0), &vaf);
    324  1.1  riastrad 	else
    325  1.1  riastrad 		printk("%s" "[" DRM_NAME ":%ps] %pV",
    326  1.1  riastrad 		       level, __builtin_return_address(0), &vaf);
    327  1.1  riastrad 
    328  1.1  riastrad 	va_end(args);
    329  1.4  riastrad #endif
    330  1.1  riastrad }
    331  1.1  riastrad EXPORT_SYMBOL(drm_dev_printk);
    332  1.1  riastrad 
    333  1.1  riastrad void drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
    334  1.1  riastrad 		 const char *format, ...)
    335  1.1  riastrad {
    336  1.4  riastrad #ifdef __NetBSD__
    337  1.4  riastrad 	va_list va;
    338  1.9  riastrad 	char symbuf[128];
    339  1.4  riastrad 
    340  1.8  riastrad 	if (!(__drm_debug & category))
    341  1.4  riastrad 		return;
    342  1.4  riastrad 
    343  1.9  riastrad 	drm_symstr((vaddr_t)__builtin_return_address(0), symbuf, sizeof symbuf);
    344  1.9  riastrad 	if (dev)
    345  1.9  riastrad 		printf("%s [" DRM_NAME ":%s] ", device_xname(__UNCONST(dev)), symbuf);
    346  1.9  riastrad 	else
    347  1.9  riastrad 		printf("[" DRM_NAME ":%s] ", symbuf);
    348  1.9  riastrad 
    349  1.4  riastrad 	va_start(va, format);
    350  1.4  riastrad 	vprintf(format, va);
    351  1.4  riastrad 	va_end(va);
    352  1.4  riastrad #else
    353  1.1  riastrad 	struct va_format vaf;
    354  1.1  riastrad 	va_list args;
    355  1.1  riastrad 
    356  1.1  riastrad 	if (!drm_debug_enabled(category))
    357  1.1  riastrad 		return;
    358  1.1  riastrad 
    359  1.1  riastrad 	va_start(args, format);
    360  1.1  riastrad 	vaf.fmt = format;
    361  1.1  riastrad 	vaf.va = &args;
    362  1.1  riastrad 
    363  1.1  riastrad 	if (dev)
    364  1.1  riastrad 		dev_printk(KERN_DEBUG, dev, "[" DRM_NAME ":%ps] %pV",
    365  1.1  riastrad 			   __builtin_return_address(0), &vaf);
    366  1.1  riastrad 	else
    367  1.1  riastrad 		printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV",
    368  1.1  riastrad 		       __builtin_return_address(0), &vaf);
    369  1.1  riastrad 
    370  1.1  riastrad 	va_end(args);
    371  1.4  riastrad #endif
    372  1.1  riastrad }
    373  1.1  riastrad EXPORT_SYMBOL(drm_dev_dbg);
    374  1.1  riastrad 
    375  1.1  riastrad void __drm_dbg(enum drm_debug_category category, const char *format, ...)
    376  1.1  riastrad {
    377  1.4  riastrad #ifdef __NetBSD__
    378  1.9  riastrad 	char symbuf[128];
    379  1.4  riastrad 	va_list va;
    380  1.4  riastrad 
    381  1.8  riastrad 	if (!(__drm_debug & category))
    382  1.4  riastrad 		return;
    383  1.4  riastrad 
    384  1.9  riastrad 	drm_symstr((vaddr_t)__builtin_return_address(0), symbuf, sizeof symbuf);
    385  1.9  riastrad 	printf("[" DRM_NAME ":%s] ", symbuf);
    386  1.9  riastrad 
    387  1.4  riastrad 	va_start(va, format);
    388  1.4  riastrad 	vprintf(format, va);
    389  1.4  riastrad 	va_end(va);
    390  1.4  riastrad #else
    391  1.1  riastrad 	struct va_format vaf;
    392  1.1  riastrad 	va_list args;
    393  1.1  riastrad 
    394  1.1  riastrad 	if (!drm_debug_enabled(category))
    395  1.1  riastrad 		return;
    396  1.1  riastrad 
    397  1.1  riastrad 	va_start(args, format);
    398  1.1  riastrad 	vaf.fmt = format;
    399  1.1  riastrad 	vaf.va = &args;
    400  1.1  riastrad 
    401  1.1  riastrad 	printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV",
    402  1.1  riastrad 	       __builtin_return_address(0), &vaf);
    403  1.1  riastrad 
    404  1.1  riastrad 	va_end(args);
    405  1.4  riastrad #endif
    406  1.1  riastrad }
    407  1.1  riastrad EXPORT_SYMBOL(__drm_dbg);
    408  1.1  riastrad 
    409  1.1  riastrad void __drm_err(const char *format, ...)
    410  1.1  riastrad {
    411  1.9  riastrad #ifdef __NetBSD__
    412  1.9  riastrad 	char symbuf[128];
    413  1.9  riastrad 	va_list va;
    414  1.9  riastrad 
    415  1.9  riastrad 	drm_symstr((vaddr_t)__builtin_return_address(0), symbuf, sizeof symbuf);
    416  1.9  riastrad 	printf("[" DRM_NAME ":%s] *ERROR* ", symbuf);
    417  1.9  riastrad 
    418  1.9  riastrad 	va_start(va, format);
    419  1.9  riastrad 	vprintf(format, va);
    420  1.9  riastrad 	va_end(va);
    421  1.9  riastrad #else
    422  1.1  riastrad 	struct va_format vaf;
    423  1.1  riastrad 	va_list args;
    424  1.1  riastrad 
    425  1.1  riastrad 	va_start(args, format);
    426  1.1  riastrad 	vaf.fmt = format;
    427  1.1  riastrad 	vaf.va = &args;
    428  1.1  riastrad 
    429  1.1  riastrad 	printk(KERN_ERR "[" DRM_NAME ":%ps] *ERROR* %pV",
    430  1.1  riastrad 	       __builtin_return_address(0), &vaf);
    431  1.1  riastrad 
    432  1.1  riastrad 	va_end(args);
    433  1.9  riastrad #endif
    434  1.1  riastrad }
    435  1.1  riastrad EXPORT_SYMBOL(__drm_err);
    436  1.1  riastrad 
    437  1.5  riastrad #ifndef __NetBSD__
    438  1.1  riastrad /**
    439  1.1  riastrad  * drm_print_regset32 - print the contents of registers to a
    440  1.1  riastrad  * &drm_printer stream.
    441  1.1  riastrad  *
    442  1.1  riastrad  * @p: the &drm printer
    443  1.1  riastrad  * @regset: the list of registers to print.
    444  1.1  riastrad  *
    445  1.1  riastrad  * Often in driver debug, it's useful to be able to either capture the
    446  1.1  riastrad  * contents of registers in the steady state using debugfs or at
    447  1.1  riastrad  * specific points during operation.  This lets the driver have a
    448  1.1  riastrad  * single list of registers for both.
    449  1.1  riastrad  */
    450  1.1  riastrad void drm_print_regset32(struct drm_printer *p, struct debugfs_regset32 *regset)
    451  1.1  riastrad {
    452  1.1  riastrad 	int namelen = 0;
    453  1.1  riastrad 	int i;
    454  1.1  riastrad 
    455  1.1  riastrad 	for (i = 0; i < regset->nregs; i++)
    456  1.1  riastrad 		namelen = max(namelen, (int)strlen(regset->regs[i].name));
    457  1.1  riastrad 
    458  1.1  riastrad 	for (i = 0; i < regset->nregs; i++) {
    459  1.1  riastrad 		drm_printf(p, "%*s = 0x%08x\n",
    460  1.1  riastrad 			   namelen, regset->regs[i].name,
    461  1.1  riastrad 			   readl(regset->base + regset->regs[i].offset));
    462  1.1  riastrad 	}
    463  1.1  riastrad }
    464  1.1  riastrad EXPORT_SYMBOL(drm_print_regset32);
    465  1.5  riastrad #endif
    466