Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * Copyright (C) 2016 Red Hat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Permission is hereby granted, free of charge, to any person obtaining a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * copy of this software and associated documentation files (the "Software"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * to deal in the Software without restriction, including without limitation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * and/or sell copies of the Software, and to permit persons to whom the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * Software is furnished to do so, subject to the following conditions:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * The above copyright notice and this permission notice shall be included in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * all copies or substantial portions of the Software.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * OTHER DEALINGS IN THE SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * Authors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * Rob Clark <robdclark@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #define DEBUG /* for pr_debug() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include <stdarg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include <linux/moduleparam.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #include <drm/drm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #include <drm/drm_drv.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #include <drm/drm_print.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * __drm_debug: Enable debug output.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  * Bitmask of DRM_UT_x. See include/drm/drm_print.h for details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) unsigned int __drm_debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) EXPORT_SYMBOL(__drm_debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug category.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) "\t\tBit 0 (0x01)  will enable CORE messages (drm core code)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) "\t\tBit 1 (0x02)  will enable DRIVER messages (drm controller code)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) "\t\tBit 2 (0x04)  will enable KMS messages (modesetting code)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) "\t\tBit 3 (0x08)  will enable PRIME messages (prime code)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) "\t\tBit 4 (0x10)  will enable ATOMIC messages (atomic code)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) "\t\tBit 5 (0x20)  will enable VBL messages (vblank code)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) "\t\tBit 7 (0x80)  will enable LEASE messages (leasing code)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) "\t\tBit 8 (0x100) will enable DP messages (displayport code)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) module_param_named(debug, __drm_debug, int, 0600);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) void __drm_puts_coredump(struct drm_printer *p, const char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	struct drm_print_iterator *iterator = p->arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	ssize_t len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	if (!iterator->remain)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	if (iterator->offset < iterator->start) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		ssize_t copy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		len = strlen(str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		if (iterator->offset + len <= iterator->start) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 			iterator->offset += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		copy = len - (iterator->start - iterator->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		if (copy > iterator->remain)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 			copy = iterator->remain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		/* Copy out the bit of the string that we need */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		memcpy(iterator->data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			str + (iterator->start - iterator->offset), copy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		iterator->offset = iterator->start + copy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		iterator->remain -= copy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		ssize_t pos = iterator->offset - iterator->start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		len = min_t(ssize_t, strlen(str), iterator->remain);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		memcpy(iterator->data + pos, str, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		iterator->offset += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		iterator->remain -= len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) EXPORT_SYMBOL(__drm_puts_coredump);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) void __drm_printfn_coredump(struct drm_printer *p, struct va_format *vaf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	struct drm_print_iterator *iterator = p->arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	size_t len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	char *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	if (!iterator->remain)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	/* Figure out how big the string will be */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	len = snprintf(NULL, 0, "%pV", vaf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	/* This is the easiest path, we've already advanced beyond the offset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	if (iterator->offset + len <= iterator->start) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		iterator->offset += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	/* Then check if we can directly copy into the target buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	if ((iterator->offset >= iterator->start) && (len < iterator->remain)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		ssize_t pos = iterator->offset - iterator->start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		snprintf(((char *) iterator->data) + pos,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 			iterator->remain, "%pV", vaf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		iterator->offset += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		iterator->remain -= len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	 * Finally, hit the slow path and make a temporary string to copy over
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	 * using _drm_puts_coredump
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	buf = kmalloc(len + 1, GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	if (!buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	snprintf(buf, len + 1, "%pV", vaf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	__drm_puts_coredump(p, (const char *) buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) EXPORT_SYMBOL(__drm_printfn_coredump);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) void __drm_puts_seq_file(struct drm_printer *p, const char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	seq_puts(p->arg, str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) EXPORT_SYMBOL(__drm_puts_seq_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) void __drm_printfn_seq_file(struct drm_printer *p, struct va_format *vaf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	seq_printf(p->arg, "%pV", vaf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) EXPORT_SYMBOL(__drm_printfn_seq_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	dev_info(p->arg, "[" DRM_NAME "] %pV", vaf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) EXPORT_SYMBOL(__drm_printfn_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	pr_debug("%s %pV", p->prefix, vaf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) EXPORT_SYMBOL(__drm_printfn_debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) void __drm_printfn_err(struct drm_printer *p, struct va_format *vaf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	pr_err("*ERROR* %s %pV", p->prefix, vaf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) EXPORT_SYMBOL(__drm_printfn_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  * drm_puts - print a const string to a &drm_printer stream
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  * @p: the &drm printer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)  * @str: const string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)  * Allow &drm_printer types that have a constant string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)  * option to use it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) void drm_puts(struct drm_printer *p, const char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	if (p->puts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		p->puts(p, str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		drm_printf(p, "%s", str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) EXPORT_SYMBOL(drm_puts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)  * drm_printf - print to a &drm_printer stream
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)  * @p: the &drm_printer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)  * @f: format string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) void drm_printf(struct drm_printer *p, const char *f, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	va_list args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	va_start(args, f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	drm_vprintf(p, f, &args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	va_end(args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) EXPORT_SYMBOL(drm_printf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)  * drm_print_bits - print bits to a &drm_printer stream
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)  * Print bits (in flag fields for example) in human readable form.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)  * @p: the &drm_printer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)  * @value: field value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)  * @bits: Array with bit names.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)  * @nbits: Size of bit names array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) void drm_print_bits(struct drm_printer *p, unsigned long value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		    const char * const bits[], unsigned int nbits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	bool first = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	if (WARN_ON_ONCE(nbits > BITS_PER_TYPE(value)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		nbits = BITS_PER_TYPE(value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	for_each_set_bit(i, &value, nbits) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		if (WARN_ON_ONCE(!bits[i]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		drm_printf(p, "%s%s", first ? "" : ",",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 			   bits[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		first = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	if (first)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		drm_printf(p, "(none)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) EXPORT_SYMBOL(drm_print_bits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) void drm_dev_printk(const struct device *dev, const char *level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		    const char *format, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	struct va_format vaf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	va_list args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	va_start(args, format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	vaf.fmt = format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	vaf.va = &args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	if (dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		dev_printk(level, dev, "[" DRM_NAME ":%ps] %pV",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 			   __builtin_return_address(0), &vaf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		printk("%s" "[" DRM_NAME ":%ps] %pV",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		       level, __builtin_return_address(0), &vaf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	va_end(args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) EXPORT_SYMBOL(drm_dev_printk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) void drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		 const char *format, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	struct va_format vaf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	va_list args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	if (!drm_debug_enabled(category))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	va_start(args, format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	vaf.fmt = format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	vaf.va = &args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	if (dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		dev_printk(KERN_DEBUG, dev, "[" DRM_NAME ":%ps] %pV",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 			   __builtin_return_address(0), &vaf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 		printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 		       __builtin_return_address(0), &vaf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	va_end(args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) EXPORT_SYMBOL(drm_dev_dbg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) void __drm_dbg(enum drm_debug_category category, const char *format, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	struct va_format vaf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	va_list args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	if (!drm_debug_enabled(category))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	va_start(args, format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	vaf.fmt = format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	vaf.va = &args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	       __builtin_return_address(0), &vaf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	va_end(args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) EXPORT_SYMBOL(__drm_dbg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) void __drm_err(const char *format, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	struct va_format vaf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	va_list args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	va_start(args, format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	vaf.fmt = format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	vaf.va = &args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	printk(KERN_ERR "[" DRM_NAME ":%ps] *ERROR* %pV",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	       __builtin_return_address(0), &vaf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	va_end(args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) EXPORT_SYMBOL(__drm_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)  * drm_print_regset32 - print the contents of registers to a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)  * &drm_printer stream.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)  * @p: the &drm printer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)  * @regset: the list of registers to print.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)  * Often in driver debug, it's useful to be able to either capture the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)  * contents of registers in the steady state using debugfs or at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)  * specific points during operation.  This lets the driver have a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)  * single list of registers for both.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) void drm_print_regset32(struct drm_printer *p, struct debugfs_regset32 *regset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	int namelen = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	for (i = 0; i < regset->nregs; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 		namelen = max(namelen, (int)strlen(regset->regs[i].name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	for (i = 0; i < regset->nregs; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 		drm_printf(p, "%*s = 0x%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 			   namelen, regset->regs[i].name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 			   readl(regset->base + regset->regs[i].offset));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) EXPORT_SYMBOL(drm_print_regset32);