drivers/gpu/drm/nouveau/nvkm/core/event.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nvkm/core/event.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nvkm/core/event.c- Extension
.c- Size
- 5749 bytes
- Lines
- 215
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
core/event.hcore/subdev.h
Detected Declarations
function filesfunction nvkm_event_getfunction nvkm_event_ntfy_statefunction nvkm_event_ntfy_removefunction nvkm_event_ntfy_insertfunction nvkm_event_ntfy_block_function nvkm_event_ntfy_blockfunction nvkm_event_ntfy_allowfunction nvkm_event_ntfy_delfunction nvkm_event_ntfy_addfunction nvkm_event_ntfy_validfunction nvkm_event_ntfyfunction list_for_each_entry_safefunction nvkm_event_finifunction __nvkm_event_init
Annotated Snippet
if (--event->refs[index * event->types_nr + type] == 0) {
nvkm_trace(event->subdev, "event: blocking %d on %d\n", type, index);
if (event->func->fini)
event->func->fini(event, 1 << type, index);
}
}
}
static void
nvkm_event_get(struct nvkm_event *event, u32 types, int index)
{
assert_spin_locked(&event->refs_lock);
nvkm_trace(event->subdev, "event: incr %08x on %d\n", types, index);
while (types) {
int type = __ffs(types); types &= ~(1 << type);
if (++event->refs[index * event->types_nr + type] == 1) {
nvkm_trace(event->subdev, "event: allowing %d on %d\n", type, index);
if (event->func->init)
event->func->init(event, 1 << type, index);
}
}
}
static void
nvkm_event_ntfy_state(struct nvkm_event_ntfy *ntfy)
{
struct nvkm_event *event = ntfy->event;
unsigned long flags;
nvkm_trace(event->subdev, "event: ntfy state changed\n");
spin_lock_irqsave(&event->refs_lock, flags);
if (atomic_read(&ntfy->allowed) != ntfy->running) {
if (ntfy->running) {
nvkm_event_put(ntfy->event, ntfy->bits, ntfy->id);
ntfy->running = false;
} else {
nvkm_event_get(ntfy->event, ntfy->bits, ntfy->id);
ntfy->running = true;
}
}
spin_unlock_irqrestore(&event->refs_lock, flags);
}
static void
nvkm_event_ntfy_remove(struct nvkm_event_ntfy *ntfy)
{
write_lock_irq(&ntfy->event->list_lock);
list_del_init(&ntfy->head);
write_unlock_irq(&ntfy->event->list_lock);
}
static void
nvkm_event_ntfy_insert(struct nvkm_event_ntfy *ntfy)
{
write_lock_irq(&ntfy->event->list_lock);
list_add_tail(&ntfy->head, &ntfy->event->ntfy);
write_unlock_irq(&ntfy->event->list_lock);
}
static void
nvkm_event_ntfy_block_(struct nvkm_event_ntfy *ntfy, bool wait)
{
struct nvkm_subdev *subdev = ntfy->event->subdev;
nvkm_trace(subdev, "event: ntfy block %08x on %d wait:%d\n", ntfy->bits, ntfy->id, wait);
if (atomic_xchg(&ntfy->allowed, 0) == 1) {
nvkm_event_ntfy_state(ntfy);
if (wait)
nvkm_event_ntfy_remove(ntfy);
}
}
void
nvkm_event_ntfy_block(struct nvkm_event_ntfy *ntfy)
{
if (ntfy->event)
nvkm_event_ntfy_block_(ntfy, ntfy->wait);
}
void
nvkm_event_ntfy_allow(struct nvkm_event_ntfy *ntfy)
{
nvkm_trace(ntfy->event->subdev, "event: ntfy allow %08x on %d\n", ntfy->bits, ntfy->id);
if (atomic_xchg(&ntfy->allowed, 1) == 0) {
Annotation
- Immediate include surface: `core/event.h`, `core/subdev.h`.
- Detected declarations: `function files`, `function nvkm_event_get`, `function nvkm_event_ntfy_state`, `function nvkm_event_ntfy_remove`, `function nvkm_event_ntfy_insert`, `function nvkm_event_ntfy_block_`, `function nvkm_event_ntfy_block`, `function nvkm_event_ntfy_allow`, `function nvkm_event_ntfy_del`, `function nvkm_event_ntfy_add`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.