drivers/gpu/drm/xe/xe_validation.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_validation.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_validation.c- Extension
.c- Size
- 7548 bytes
- Lines
- 278
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
drm/drm_exec.hdrm/drm_gem.hdrm/drm_gpuvm.hxe_assert.hxe_validation.h
Detected Declarations
function xe_validation_assert_execfunction xe_validation_lockfunction xe_validation_trylockfunction xe_validation_unlockfunction xe_validation_ctx_initfunction xe_validation_contention_injectedfunction xe_validation_contention_injectedfunction __xe_validation_should_retryfunction xe_validation_exec_lockfunction xe_validation_ctx_finifunction xe_validation_should_retry
Annotated Snippet
switch (PTR_ERR(exec)) {
case __XE_VAL_UNIMPLEMENTED:
break;
case __XE_VAL_UNSUPPORTED:
xe_assert(xe, !!obj->dma_buf);
break;
#if IS_ENABLED(CONFIG_KUNIT)
case __XE_VAL_OPT_OUT:
xe_assert(xe, current->kunit_test);
break;
#endif
default:
xe_assert(xe, false);
}
}
}
#endif
static int xe_validation_lock(struct xe_validation_ctx *ctx)
{
struct xe_validation_device *val = ctx->val;
int ret = 0;
if (ctx->val_flags.interruptible) {
if (ctx->request_exclusive)
ret = down_write_killable(&val->lock);
else
ret = down_read_interruptible(&val->lock);
} else {
if (ctx->request_exclusive)
down_write(&val->lock);
else
down_read(&val->lock);
}
if (!ret) {
ctx->lock_held = true;
ctx->lock_held_exclusive = ctx->request_exclusive;
}
return ret;
}
static int xe_validation_trylock(struct xe_validation_ctx *ctx)
{
struct xe_validation_device *val = ctx->val;
bool locked;
if (ctx->request_exclusive)
locked = down_write_trylock(&val->lock);
else
locked = down_read_trylock(&val->lock);
if (locked) {
ctx->lock_held = true;
ctx->lock_held_exclusive = ctx->request_exclusive;
}
return locked ? 0 : -EWOULDBLOCK;
}
static void xe_validation_unlock(struct xe_validation_ctx *ctx)
{
if (!ctx->lock_held)
return;
if (ctx->lock_held_exclusive)
up_write(&ctx->val->lock);
else
up_read(&ctx->val->lock);
ctx->lock_held = false;
}
/**
* xe_validation_ctx_init() - Initialize an xe_validation_ctx
* @ctx: The xe_validation_ctx to initialize.
* @val: The xe_validation_device representing the validation domain.
* @exec: The struct drm_exec to use for the transaction. May be NULL.
* @flags: The flags to use for initialization.
*
* Initialize and lock a an xe_validation transaction using the validation domain
* represented by @val. Also initialize the drm_exec object forwarding parts of
* @flags to the drm_exec initialization. The @flags.exclusive flag should
* typically be set to false to avoid locking out other validators from the
* domain until an OOM is hit. For testing- or final attempt purposes it can,
* however, be set to true.
*
* Return: %0 on success, %-EINTR if interruptible initial locking failed with a
* signal pending. If @flags.no_block is set to true, a failed trylock
Annotation
- Immediate include surface: `drm/drm_exec.h`, `drm/drm_gem.h`, `drm/drm_gpuvm.h`, `xe_assert.h`, `xe_validation.h`.
- Detected declarations: `function xe_validation_assert_exec`, `function xe_validation_lock`, `function xe_validation_trylock`, `function xe_validation_unlock`, `function xe_validation_ctx_init`, `function xe_validation_contention_injected`, `function xe_validation_contention_injected`, `function __xe_validation_should_retry`, `function xe_validation_exec_lock`, `function xe_validation_ctx_fini`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
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.