drivers/gpu/drm/nouveau/nouveau_fence.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nouveau_fence.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nouveau_fence.c- Extension
.c- Size
- 13570 bytes
- Lines
- 542
- 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/ktime.hlinux/hrtimer.hlinux/sched/signal.htrace/events/dma_fence.hnvif/if0020.hnouveau_drv.hnouveau_dma.hnouveau_fence.h
Detected Declarations
function nouveau_fctxfunction nouveau_fence_signalfunction nouveau_local_fencefunction nouveau_fence_context_killfunction nouveau_fence_context_delfunction nouveau_fence_context_putfunction nouveau_fence_context_freefunction nouveau_fence_updatefunction list_for_each_entry_safefunction nouveau_fence_uevent_workfunction nouveau_fence_wait_uevent_handlerfunction nouveau_fence_context_newfunction nouveau_fence_emitfunction nouveau_fence_donefunction nouveau_fence_wait_legacyfunction nouveau_fence_wait_busyfunction nouveau_fence_waitfunction nouveau_fence_syncfunction dma_resv_for_each_fencefunction nouveau_fence_unreffunction nouveau_fence_createfunction nouveau_fence_newfunction nouveau_fence_is_signaledfunction nouveau_fence_no_signalingfunction nouveau_fence_releasefunction nouveau_fence_enable_signaling
Annotated Snippet
if (unlikely(fctx->killed)) {
spin_unlock_irq(&fctx->lock);
dma_fence_put(&fence->base);
return -ENODEV;
}
nouveau_fence_update(chan, fctx);
list_add_tail(&fence->head, &fctx->pending);
spin_unlock_irq(&fctx->lock);
}
return ret;
}
bool
nouveau_fence_done(struct nouveau_fence *fence)
{
struct nouveau_fence_chan *fctx = nouveau_fctx(fence);
struct nouveau_channel *chan;
unsigned long flags;
if (dma_fence_is_signaled(&fence->base))
return true;
spin_lock_irqsave(&fctx->lock, flags);
chan = rcu_dereference_protected(fence->channel, lockdep_is_held(&fctx->lock));
if (chan)
nouveau_fence_update(chan, fctx);
spin_unlock_irqrestore(&fctx->lock, flags);
return dma_fence_is_signaled(&fence->base);
}
static long
nouveau_fence_wait_legacy(struct dma_fence *f, bool intr, long wait)
{
struct nouveau_fence *fence = to_nouveau_fence(f);
unsigned long sleep_time = NSEC_PER_MSEC / 1000;
unsigned long t = jiffies, timeout = t + wait;
while (!nouveau_fence_done(fence)) {
ktime_t kt;
t = jiffies;
if (wait != MAX_SCHEDULE_TIMEOUT && time_after_eq(t, timeout)) {
__set_current_state(TASK_RUNNING);
return 0;
}
__set_current_state(intr ? TASK_INTERRUPTIBLE :
TASK_UNINTERRUPTIBLE);
kt = sleep_time;
schedule_hrtimeout(&kt, HRTIMER_MODE_REL);
sleep_time *= 2;
if (sleep_time > NSEC_PER_MSEC)
sleep_time = NSEC_PER_MSEC;
if (intr && signal_pending(current))
return -ERESTARTSYS;
}
__set_current_state(TASK_RUNNING);
return timeout - t;
}
static int
nouveau_fence_wait_busy(struct nouveau_fence *fence, bool intr)
{
int ret = 0;
while (!nouveau_fence_done(fence)) {
if (time_after_eq(jiffies, fence->timeout)) {
ret = -EBUSY;
break;
}
__set_current_state(intr ?
TASK_INTERRUPTIBLE :
TASK_UNINTERRUPTIBLE);
if (intr && signal_pending(current)) {
ret = -ERESTARTSYS;
break;
}
}
__set_current_state(TASK_RUNNING);
Annotation
- Immediate include surface: `linux/ktime.h`, `linux/hrtimer.h`, `linux/sched/signal.h`, `trace/events/dma_fence.h`, `nvif/if0020.h`, `nouveau_drv.h`, `nouveau_dma.h`, `nouveau_fence.h`.
- Detected declarations: `function nouveau_fctx`, `function nouveau_fence_signal`, `function nouveau_local_fence`, `function nouveau_fence_context_kill`, `function nouveau_fence_context_del`, `function nouveau_fence_context_put`, `function nouveau_fence_context_free`, `function nouveau_fence_update`, `function list_for_each_entry_safe`, `function nouveau_fence_uevent_work`.
- 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.