drivers/gpu/drm/drm_client_sysrq.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_client_sysrq.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_client_sysrq.c- Extension
.c- Size
- 1756 bytes
- Lines
- 66
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/sysrq.hdrm/drm_client_event.hdrm/drm_device.hdrm/drm_print.hdrm_internal.h
Detected Declarations
function drm_client_sysrq_restore_work_fnfunction list_for_each_entryfunction drm_client_sysrq_restore_handlerfunction drm_client_sysrq_registerfunction drm_client_sysrq_unregister
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0 or MIT
#include <linux/sysrq.h>
#include <drm/drm_client_event.h>
#include <drm/drm_device.h>
#include <drm/drm_print.h>
#include "drm_internal.h"
#ifdef CONFIG_MAGIC_SYSRQ
static LIST_HEAD(drm_client_sysrq_dev_list);
static DEFINE_MUTEX(drm_client_sysrq_dev_lock);
/* emergency restore, don't bother with error reporting */
static void drm_client_sysrq_restore_work_fn(struct work_struct *ignored)
{
struct drm_device *dev;
guard(mutex)(&drm_client_sysrq_dev_lock);
list_for_each_entry(dev, &drm_client_sysrq_dev_list, client_sysrq_list) {
if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
continue;
drm_client_dev_restore(dev, true);
}
}
static DECLARE_WORK(drm_client_sysrq_restore_work, drm_client_sysrq_restore_work_fn);
static void drm_client_sysrq_restore_handler(u8 ignored)
{
schedule_work(&drm_client_sysrq_restore_work);
}
static const struct sysrq_key_op drm_client_sysrq_restore_op = {
.handler = drm_client_sysrq_restore_handler,
.help_msg = "force-fb(v)",
.action_msg = "Restore framebuffer console",
};
void drm_client_sysrq_register(struct drm_device *dev)
{
guard(mutex)(&drm_client_sysrq_dev_lock);
if (list_empty(&drm_client_sysrq_dev_list))
register_sysrq_key('v', &drm_client_sysrq_restore_op);
list_add(&dev->client_sysrq_list, &drm_client_sysrq_dev_list);
}
void drm_client_sysrq_unregister(struct drm_device *dev)
{
guard(mutex)(&drm_client_sysrq_dev_lock);
/* remove device from global restore list */
if (!drm_WARN_ON(dev, list_empty(&dev->client_sysrq_list)))
list_del(&dev->client_sysrq_list);
/* no devices left; unregister key */
if (list_empty(&drm_client_sysrq_dev_list))
unregister_sysrq_key('v', &drm_client_sysrq_restore_op);
}
#endif
Annotation
- Immediate include surface: `linux/sysrq.h`, `drm/drm_client_event.h`, `drm/drm_device.h`, `drm/drm_print.h`, `drm_internal.h`.
- Detected declarations: `function drm_client_sysrq_restore_work_fn`, `function list_for_each_entry`, `function drm_client_sysrq_restore_handler`, `function drm_client_sysrq_register`, `function drm_client_sysrq_unregister`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source 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.