drivers/gpu/drm/msm/msm_fence.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/msm/msm_fence.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/msm/msm_fence.c- Extension
.c- Size
- 5001 bytes
- Lines
- 202
- 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
linux/dma-fence.hmsm_drv.hmsm_fence.hmsm_gpu.h
Detected Declarations
struct msm_fencefunction Copyrightfunction deadline_timerfunction deadline_workfunction msm_fence_context_allocfunction msm_fence_context_freefunction msm_fence_completedfunction msm_update_fencefunction msm_fence_signaledfunction msm_fence_set_deadlinefunction msm_fence_allocfunction msm_fence_init
Annotated Snippet
struct msm_fence {
struct dma_fence base;
struct msm_fence_context *fctx;
};
static inline struct msm_fence *to_msm_fence(struct dma_fence *fence)
{
return container_of(fence, struct msm_fence, base);
}
static const char *msm_fence_get_driver_name(struct dma_fence *fence)
{
return "msm";
}
static const char *msm_fence_get_timeline_name(struct dma_fence *fence)
{
struct msm_fence *f = to_msm_fence(fence);
return f->fctx->name;
}
static bool msm_fence_signaled(struct dma_fence *fence)
{
struct msm_fence *f = to_msm_fence(fence);
return msm_fence_completed(f->fctx, f->base.seqno);
}
static void msm_fence_set_deadline(struct dma_fence *fence, ktime_t deadline)
{
struct msm_fence *f = to_msm_fence(fence);
struct msm_fence_context *fctx = f->fctx;
unsigned long flags;
ktime_t now;
spin_lock_irqsave(&fctx->spinlock, flags);
now = ktime_get();
if (ktime_after(now, fctx->next_deadline) ||
ktime_before(deadline, fctx->next_deadline)) {
fctx->next_deadline = deadline;
fctx->next_deadline_fence =
max(fctx->next_deadline_fence, (uint32_t)fence->seqno);
/*
* Set timer to trigger boost 3ms before deadline, or
* if we are already less than 3ms before the deadline
* schedule boost work immediately.
*/
deadline = ktime_sub(deadline, ms_to_ktime(3));
if (ktime_after(now, deadline)) {
kthread_queue_work(fctx2gpu(fctx)->worker,
&fctx->deadline_work);
} else {
hrtimer_start(&fctx->deadline_timer, deadline,
HRTIMER_MODE_ABS);
}
}
spin_unlock_irqrestore(&fctx->spinlock, flags);
}
static const struct dma_fence_ops msm_fence_ops = {
.get_driver_name = msm_fence_get_driver_name,
.get_timeline_name = msm_fence_get_timeline_name,
.signaled = msm_fence_signaled,
.set_deadline = msm_fence_set_deadline,
};
struct dma_fence *
msm_fence_alloc(void)
{
struct msm_fence *f;
f = kzalloc_obj(*f);
if (!f)
return ERR_PTR(-ENOMEM);
return &f->base;
}
void
msm_fence_init(struct dma_fence *fence, struct msm_fence_context *fctx)
{
struct msm_fence *f = to_msm_fence(fence);
f->fctx = fctx;
/*
* Until this point, the fence was just some pre-allocated memory,
Annotation
- Immediate include surface: `linux/dma-fence.h`, `msm_drv.h`, `msm_fence.h`, `msm_gpu.h`.
- Detected declarations: `struct msm_fence`, `function Copyright`, `function deadline_timer`, `function deadline_work`, `function msm_fence_context_alloc`, `function msm_fence_context_free`, `function msm_fence_completed`, `function msm_update_fence`, `function msm_fence_signaled`, `function msm_fence_set_deadline`.
- 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.