drivers/gpu/drm/i915/gem/i915_gem_wait.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gem/i915_gem_wait.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/gem/i915_gem_wait.c- Extension
.c- Size
- 8154 bytes
- Lines
- 297
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/dma-fence-array.hlinux/dma-fence-chain.hlinux/jiffies.hgt/intel_engine.hgt/intel_rps.hi915_gem_ioctls.hi915_gem_object.h
Detected Declarations
function i915_gem_object_wait_fencefunction i915_gem_object_boostfunction i915_gem_object_wait_reservationfunction fence_set_priorityfunction i915_gem_fence_wait_priorityfunction dma_fence_chain_for_eachfunction i915_gem_fence_wait_priority_displayfunction i915_gem_object_wait_priorityfunction i915_gem_object_waitfunction nsecs_to_jiffies_timeoutfunction to_wait_timeoutfunction i915_gem_wait_ioctlfunction i915_gem_object_wait_migration
Annotated Snippet
dma_fence_chain_for_each(iter, fence) {
fence_set_priority(to_dma_fence_chain(iter)->fence,
attr);
break;
}
dma_fence_put(iter);
} else {
fence_set_priority(fence, attr);
}
local_bh_enable(); /* kick the tasklets if queues were reprioritised */
}
void i915_gem_fence_wait_priority_display(struct dma_fence *fence)
{
struct i915_sched_attr attr = { .priority = I915_PRIORITY_DISPLAY };
i915_gem_fence_wait_priority(fence, &attr);
}
int
i915_gem_object_wait_priority(struct drm_i915_gem_object *obj,
unsigned int flags,
const struct i915_sched_attr *attr)
{
struct dma_resv_iter cursor;
struct dma_fence *fence;
dma_resv_iter_begin(&cursor, obj->base.resv,
dma_resv_usage_rw(flags & I915_WAIT_ALL));
dma_resv_for_each_fence_unlocked(&cursor, fence)
i915_gem_fence_wait_priority(fence, attr);
dma_resv_iter_end(&cursor);
return 0;
}
/**
* i915_gem_object_wait - Waits for rendering to the object to be completed
* @obj: i915 gem object
* @flags: how to wait (under a lock, for all rendering or just for writes etc)
* @timeout: how long to wait
*/
int
i915_gem_object_wait(struct drm_i915_gem_object *obj,
unsigned int flags,
long timeout)
{
might_sleep();
GEM_BUG_ON(timeout < 0);
timeout = i915_gem_object_wait_reservation(obj->base.resv,
flags, timeout);
if (timeout < 0)
return timeout;
return !timeout ? -ETIME : 0;
}
static inline unsigned long nsecs_to_jiffies_timeout(const u64 n)
{
/* nsecs_to_jiffies64() does not guard against overflow */
if ((NSEC_PER_SEC % HZ) != 0 &&
div_u64(n, NSEC_PER_SEC) >= MAX_JIFFY_OFFSET / HZ)
return MAX_JIFFY_OFFSET;
return min_t(u64, MAX_JIFFY_OFFSET, nsecs_to_jiffies64(n) + 1);
}
static unsigned long to_wait_timeout(s64 timeout_ns)
{
if (timeout_ns < 0)
return MAX_SCHEDULE_TIMEOUT;
if (timeout_ns == 0)
return 0;
return nsecs_to_jiffies_timeout(timeout_ns);
}
/**
* i915_gem_wait_ioctl - implements DRM_IOCTL_I915_GEM_WAIT
* @dev: drm device pointer
* @data: ioctl data blob
* @file: drm file pointer
*
* Returns 0 if successful, else an error is returned with the remaining time in
* the timeout parameter.
* -ETIME: object is still busy after timeout
* -ERESTARTSYS: signal interrupted the wait
Annotation
- Immediate include surface: `linux/dma-fence-array.h`, `linux/dma-fence-chain.h`, `linux/jiffies.h`, `gt/intel_engine.h`, `gt/intel_rps.h`, `i915_gem_ioctls.h`, `i915_gem_object.h`.
- Detected declarations: `function i915_gem_object_wait_fence`, `function i915_gem_object_boost`, `function i915_gem_object_wait_reservation`, `function fence_set_priority`, `function i915_gem_fence_wait_priority`, `function dma_fence_chain_for_each`, `function i915_gem_fence_wait_priority_display`, `function i915_gem_object_wait_priority`, `function i915_gem_object_wait`, `function nsecs_to_jiffies_timeout`.
- 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.