drivers/gpu/drm/i915/i915_sw_fence.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/i915_sw_fence.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/i915_sw_fence.c- Extension
.c- Size
- 14283 bytes
- Lines
- 611
- 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/slab.hlinux/dma-fence.hlinux/irq_work.hlinux/dma-resv.hi915_sw_fence.hi915_selftest.hselftests/lib_sw_fence.cselftests/i915_sw_fence.c
Detected Declarations
struct i915_sw_dma_fence_cb_timerfunction debug_fence_initfunction debug_fence_init_onstackfunction debug_fence_activatefunction debug_fence_set_statefunction debug_fence_deactivatefunction debug_fence_destroyfunction debug_fence_freefunction debug_fence_assertfunction debug_fence_initfunction i915_sw_fence_finifunction __i915_sw_fence_wake_up_allfunction list_for_each_entry_safefunction list_for_each_entry_safefunction __i915_sw_fence_completefunction i915_sw_fence_completefunction i915_sw_fence_awaitfunction __i915_sw_fence_initfunction i915_sw_fence_reinitfunction i915_sw_fence_commitfunction i915_sw_fence_wakefunction __i915_sw_fence_check_if_afterfunction list_for_each_entryfunction __i915_sw_fence_clear_checked_bitfunction list_for_each_entryfunction i915_sw_fence_check_if_afterfunction i915_sw_fence_check_if_afterfunction __i915_sw_fence_await_sw_fencefunction i915_sw_fence_await_sw_fencefunction i915_sw_fence_await_sw_fence_gfpfunction dma_i915_sw_fence_wakefunction timer_i915_sw_fence_wakefunction dma_i915_sw_fence_wake_timerfunction irq_i915_sw_fence_workfunction i915_sw_fence_await_dma_fencefunction __dma_i915_sw_fence_wakefunction __i915_sw_fence_await_dma_fencefunction i915_sw_fence_await_reservation
Annotated Snippet
struct i915_sw_dma_fence_cb_timer {
struct i915_sw_dma_fence_cb base;
struct dma_fence *dma;
struct timer_list timer;
struct irq_work work;
struct rcu_head rcu;
};
static void dma_i915_sw_fence_wake(struct dma_fence *dma,
struct dma_fence_cb *data)
{
struct i915_sw_dma_fence_cb *cb = container_of(data, typeof(*cb), base);
i915_sw_fence_set_error_once(cb->fence, dma->error);
i915_sw_fence_complete(cb->fence);
kfree(cb);
}
static void timer_i915_sw_fence_wake(struct timer_list *t)
{
struct i915_sw_dma_fence_cb_timer *cb = timer_container_of(cb, t,
timer);
struct i915_sw_fence *fence;
const char __rcu *timeline;
const char __rcu *driver;
fence = xchg(&cb->base.fence, NULL);
if (!fence)
return;
rcu_read_lock();
driver = dma_fence_driver_name(cb->dma);
timeline = dma_fence_timeline_name(cb->dma);
pr_notice("Asynchronous wait on fence %s:%s:%llx timed out (hint:%ps)\n",
rcu_dereference(driver),
rcu_dereference(timeline),
cb->dma->seqno,
i915_sw_fence_debug_hint(fence));
rcu_read_unlock();
i915_sw_fence_set_error_once(fence, -ETIMEDOUT);
i915_sw_fence_complete(fence);
}
static void dma_i915_sw_fence_wake_timer(struct dma_fence *dma,
struct dma_fence_cb *data)
{
struct i915_sw_dma_fence_cb_timer *cb =
container_of(data, typeof(*cb), base.base);
struct i915_sw_fence *fence;
fence = xchg(&cb->base.fence, NULL);
if (fence) {
i915_sw_fence_set_error_once(fence, dma->error);
i915_sw_fence_complete(fence);
}
irq_work_queue(&cb->work);
}
static void irq_i915_sw_fence_work(struct irq_work *wrk)
{
struct i915_sw_dma_fence_cb_timer *cb =
container_of(wrk, typeof(*cb), work);
timer_shutdown_sync(&cb->timer);
dma_fence_put(cb->dma);
kfree_rcu(cb, rcu);
}
int i915_sw_fence_await_dma_fence(struct i915_sw_fence *fence,
struct dma_fence *dma,
unsigned long timeout,
gfp_t gfp)
{
struct i915_sw_dma_fence_cb *cb;
dma_fence_func_t func;
int ret;
debug_fence_assert(fence);
might_sleep_if(gfpflags_allow_blocking(gfp));
if (dma_fence_is_signaled(dma)) {
i915_sw_fence_set_error_once(fence, dma->error);
return 0;
}
cb = kmalloc(timeout ?
sizeof(struct i915_sw_dma_fence_cb_timer) :
Annotation
- Immediate include surface: `linux/slab.h`, `linux/dma-fence.h`, `linux/irq_work.h`, `linux/dma-resv.h`, `i915_sw_fence.h`, `i915_selftest.h`, `selftests/lib_sw_fence.c`, `selftests/i915_sw_fence.c`.
- Detected declarations: `struct i915_sw_dma_fence_cb_timer`, `function debug_fence_init`, `function debug_fence_init_onstack`, `function debug_fence_activate`, `function debug_fence_set_state`, `function debug_fence_deactivate`, `function debug_fence_destroy`, `function debug_fence_free`, `function debug_fence_assert`, `function debug_fence_init`.
- 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.