drivers/gpu/drm/drm_print.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_print.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_print.c- Extension
.c- Size
- 10969 bytes
- Lines
- 417
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/debugfs.hlinux/dynamic_debug.hlinux/export.hlinux/io.hlinux/moduleparam.hlinux/seq_file.hlinux/slab.hlinux/stdarg.hdrm/drm.hdrm/drm_drv.hdrm/drm_print.h
Detected Declarations
function __drm_puts_coredumpfunction __drm_printfn_coredumpfunction __drm_puts_seq_filefunction __drm_printfn_seq_filefunction __drm_dev_vprintkfunction __drm_printfn_infofunction __drm_printfn_dbgfunction __drm_printfn_errfunction __drm_printfn_linefunction drm_putsfunction drm_printffunction bitsfunction for_each_set_bitfunction drm_dev_printkfunction __drm_dev_dbgfunction __drm_errfunction drm_print_regset32function drm_print_hex_dumpexport __drm_debugexport __drm_puts_coredumpexport __drm_printfn_coredumpexport __drm_puts_seq_fileexport __drm_printfn_seq_fileexport __drm_printfn_infoexport __drm_printfn_dbgexport __drm_printfn_errexport __drm_printfn_lineexport drm_putsexport drm_printfexport drm_print_bitsexport drm_dev_printkexport __drm_dev_dbgexport __drm_errexport drm_print_regset32export drm_print_hex_dump
Annotated Snippet
if (iterator->offset + len <= iterator->start) {
iterator->offset += len;
return;
}
copy = len - (iterator->start - iterator->offset);
if (copy > iterator->remain)
copy = iterator->remain;
/* Copy out the bit of the string that we need */
if (iterator->data)
memcpy(iterator->data,
str + (iterator->start - iterator->offset), copy);
iterator->offset = iterator->start + copy;
iterator->remain -= copy;
} else {
ssize_t pos = iterator->offset - iterator->start;
len = min_t(ssize_t, strlen(str), iterator->remain);
if (iterator->data)
memcpy(iterator->data + pos, str, len);
iterator->offset += len;
iterator->remain -= len;
}
}
EXPORT_SYMBOL(__drm_puts_coredump);
void __drm_printfn_coredump(struct drm_printer *p, struct va_format *vaf)
{
struct drm_print_iterator *iterator = p->arg;
size_t len;
char *buf;
if (!iterator->remain)
return;
/* Figure out how big the string will be */
len = snprintf(NULL, 0, "%pV", vaf);
/* This is the easiest path, we've already advanced beyond the offset */
if (iterator->offset + len <= iterator->start) {
iterator->offset += len;
return;
}
/* Then check if we can directly copy into the target buffer */
if ((iterator->offset >= iterator->start) && (len < iterator->remain)) {
ssize_t pos = iterator->offset - iterator->start;
if (iterator->data)
snprintf(((char *) iterator->data) + pos,
iterator->remain, "%pV", vaf);
iterator->offset += len;
iterator->remain -= len;
return;
}
/*
* Finally, hit the slow path and make a temporary string to copy over
* using _drm_puts_coredump
*/
buf = kmalloc(len + 1, GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY);
if (!buf)
return;
snprintf(buf, len + 1, "%pV", vaf);
__drm_puts_coredump(p, (const char *) buf);
kfree(buf);
}
EXPORT_SYMBOL(__drm_printfn_coredump);
void __drm_puts_seq_file(struct drm_printer *p, const char *str)
{
seq_puts(p->arg, str);
}
EXPORT_SYMBOL(__drm_puts_seq_file);
void __drm_printfn_seq_file(struct drm_printer *p, struct va_format *vaf)
{
seq_printf(p->arg, "%pV", vaf);
}
EXPORT_SYMBOL(__drm_printfn_seq_file);
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/dynamic_debug.h`, `linux/export.h`, `linux/io.h`, `linux/moduleparam.h`, `linux/seq_file.h`, `linux/slab.h`, `linux/stdarg.h`.
- Detected declarations: `function __drm_puts_coredump`, `function __drm_printfn_coredump`, `function __drm_puts_seq_file`, `function __drm_printfn_seq_file`, `function __drm_dev_vprintk`, `function __drm_printfn_info`, `function __drm_printfn_dbg`, `function __drm_printfn_err`, `function __drm_printfn_line`, `function drm_puts`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.