drivers/gpu/drm/drm_vblank_work.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_vblank_work.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_vblank_work.c- Extension
.c- Size
- 8905 bytes
- Lines
- 293
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
uapi/linux/sched/types.hlinux/export.hdrm/drm_print.hdrm/drm_vblank.hdrm/drm_vblank_work.hdrm/drm_crtc.hdrm_internal.h
Detected Declarations
function drm_handle_vblank_worksfunction list_for_each_entry_safefunction drm_vblank_cancel_pending_worksfunction list_for_each_entry_safefunction drm_vblank_work_schedulefunction drm_vblank_work_cancel_syncfunction drm_vblank_work_flushfunction drm_vblank_work_flush_allfunction drm_vblank_work_initfunction drm_vblank_worker_initexport drm_vblank_work_scheduleexport drm_vblank_work_cancel_syncexport drm_vblank_work_flushexport drm_vblank_work_flush_allexport drm_vblank_work_init
Annotated Snippet
if (rescheduling) {
list_del_init(&work->node);
wake = true;
}
} else {
if (!rescheduling)
list_add_tail(&work->node, &vblank->pending_work);
ret = true;
}
out:
spin_unlock_irqrestore(&dev->event_lock, irqflags);
if (wake)
wake_up_all(&vblank->work_wait_queue);
return ret;
}
EXPORT_SYMBOL(drm_vblank_work_schedule);
/**
* drm_vblank_work_cancel_sync - cancel a vblank work and wait for it to
* finish executing
* @work: vblank work to cancel
*
* Cancel an already scheduled vblank work and wait for its
* execution to finish.
*
* On return, @work is guaranteed to no longer be scheduled or running, even
* if it's self-arming.
*
* Returns:
* %True if the work was cancelled before it started to execute, %false
* otherwise.
*/
bool drm_vblank_work_cancel_sync(struct drm_vblank_work *work)
{
struct drm_vblank_crtc *vblank = work->vblank;
struct drm_device *dev = vblank->dev;
bool ret = false;
spin_lock_irq(&dev->event_lock);
if (!list_empty(&work->node)) {
list_del_init(&work->node);
drm_vblank_put(vblank->dev, vblank->pipe);
ret = true;
}
work->cancelling++;
spin_unlock_irq(&dev->event_lock);
wake_up_all(&vblank->work_wait_queue);
if (kthread_cancel_work_sync(&work->base))
ret = true;
spin_lock_irq(&dev->event_lock);
work->cancelling--;
spin_unlock_irq(&dev->event_lock);
return ret;
}
EXPORT_SYMBOL(drm_vblank_work_cancel_sync);
/**
* drm_vblank_work_flush - wait for a scheduled vblank work to finish
* executing
* @work: vblank work to flush
*
* Wait until @work has finished executing once.
*/
void drm_vblank_work_flush(struct drm_vblank_work *work)
{
struct drm_vblank_crtc *vblank = work->vblank;
struct drm_device *dev = vblank->dev;
spin_lock_irq(&dev->event_lock);
wait_event_lock_irq(vblank->work_wait_queue, list_empty(&work->node),
dev->event_lock);
spin_unlock_irq(&dev->event_lock);
kthread_flush_work(&work->base);
}
EXPORT_SYMBOL(drm_vblank_work_flush);
/**
* drm_vblank_work_flush_all - flush all currently pending vblank work on crtc.
* @crtc: crtc for which vblank work to flush
*
* Wait until all currently queued vblank work on @crtc
* has finished executing once.
*/
Annotation
- Immediate include surface: `uapi/linux/sched/types.h`, `linux/export.h`, `drm/drm_print.h`, `drm/drm_vblank.h`, `drm/drm_vblank_work.h`, `drm/drm_crtc.h`, `drm_internal.h`.
- Detected declarations: `function drm_handle_vblank_works`, `function list_for_each_entry_safe`, `function drm_vblank_cancel_pending_works`, `function list_for_each_entry_safe`, `function drm_vblank_work_schedule`, `function drm_vblank_work_cancel_sync`, `function drm_vblank_work_flush`, `function drm_vblank_work_flush_all`, `function drm_vblank_work_init`, `function drm_vblank_worker_init`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration 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.